From d0020aac149a971e2cde6ceb1568eda7c0707ead Mon Sep 17 00:00:00 2001 From: Dario Ernst Date: Fri, 10 Dec 2010 23:39:00 +0100 Subject: [PATCH] fixed doc a bit, trying to add usb->spi interface --- documentation/SPI-Proto | 4 ++-- firmware/masterchip/usb.c | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 6 deletions(-) diff --git a/documentation/SPI-Proto b/documentation/SPI-Proto index cd16977..5f36039 100644 --- a/documentation/SPI-Proto +++ b/documentation/SPI-Proto @@ -6,7 +6,7 @@ Where following values are Valid: |--------------------------------------------------------------------------------------------------------------------------| -| Binary Hex Name Address ValueL ValueH Reply Description| +| Decimal Hex Name Address ValueL ValueH Reply Description| |--------------------------------------------------------------------------------------------------------------------------| | 0000001 0x01 Read-Temp Number of zeroes/Rand zeroes/Rand A 16Bit Value Reads the | | Thermometer Representing Temperature| @@ -24,7 +24,7 @@ Where following values are Valid: | 0000005 0x05 Write-Var16 Number of the Value of Var Value of Var zeroes/Rand Writes 16 | | var-DEFINE to write (HIGH) to write (LOW) Bit Var | |--------------------------------------------------------------------------------------------------------------------------| -| 0000006 0x07 Call-Func Number of the zeroes/Rand zeroes/Rand zeroes/Rand Calls a | +| 0000006 0x06 Call-Func Number of the zeroes/Rand zeroes/Rand zeroes/Rand Calls a | | func-DEFINE remote | function | |--------------------------------------------------------------------------------------------------------------------------| diff --git a/firmware/masterchip/usb.c b/firmware/masterchip/usb.c index cbbd7b7..e1b646d 100644 --- a/firmware/masterchip/usb.c +++ b/firmware/masterchip/usb.c @@ -4,22 +4,34 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) { usbRequest_t *rq = (void *)data; static uchar dataBuffer[4]; - if(rq->bRequest == 1){ + 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; - } - - if(rq->bRequest == 2){ + } 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; + + // uint16_t reply = do_spi_stuff(opcode, addr, valH, valL); + dataBuffer[0] = (reply & 0xff00)>>8; + dataBuffer[1] = reply & 0x00ff; + dataBuffer[2] = 0x0000; + dataBuffer[3] = 0x0000; + usbMsgPtr = dataBuffer; + return 4; + } return 0;