You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
#include "main.h"
|
|
|
|
usbMsgLen_t usbFunctionSetup(uchar data[8]) {
|
|
usbRequest_t *rq = (void *)data;
|
|
static uchar dataBuffer[4];
|
|
|
|
if(rq->bRequest == 1) {
|
|
dataBuffer[0] = (thermoData [0] & 0xff00)>>8;
|
|
dataBuffer[1] = thermoData [0] & 0x00ff;
|
|
dataBuffer[2] = (thermoData [1] & 0xff00)>>8;
|
|
dataBuffer[3] = thermoData [1] & 0x00ff;
|
|
usbMsgPtr = dataBuffer;
|
|
return 4;
|
|
} else if(rq->bRequest == 2) {
|
|
dataBuffer[0] = (thermoData [2] & 0xff00)>>8;
|
|
dataBuffer[1] = thermoData [2] & 0x00ff;
|
|
dataBuffer[2] = (thermoData [3] & 0xff00)>>8;
|
|
dataBuffer[3] = thermoData [3] & 0x00ff;
|
|
usbMsgPtr = dataBuffer;
|
|
return 4;
|
|
} else {
|
|
uint8_t opcode = (rq->bRequest & 0xff00)>>8;
|
|
uint8_t addr = (rq->wValue & 0xff00)>>8;
|
|
uint8_t valH = rq->wIndex & 0x00ff;
|
|
uint8_t valL = (rq->wIndex & 0xff00)>>8;
|
|
|
|
uint8_t send[] = {opcode, addr, valH, valL};
|
|
uint8_t recv[2];
|
|
spi_mst_write(4, data);
|
|
spi_mst_read(2, data)
|
|
|
|
dataBuffer[0] = recv[0];
|
|
dataBuffer[1] = recv[1];
|
|
dataBuffer[2] = 0x0000;
|
|
dataBuffer[3] = 0x0000;
|
|
usbMsgPtr = dataBuffer;
|
|
return 4;
|
|
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
|