diff options
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/stm32f10x_conf.h | 8 | ||||
-rw-r--r-- | src/lib/usb.c | 17 | ||||
-rw-r--r-- | src/lib/usb.h | 21 |
3 files changed, 38 insertions, 8 deletions
diff --git a/src/lib/stm32f10x_conf.h b/src/lib/stm32f10x_conf.h index d523f1a..ddd1833 100644 --- a/src/lib/stm32f10x_conf.h +++ b/src/lib/stm32f10x_conf.h @@ -29,10 +29,10 @@ /* Comment the line below to disable the specific peripheral inclusion */
/************************************* ADC ************************************/
-#define _ADC
-#define _ADC1
-#define _ADC2
-#define _ADC3
+//#define _ADC
+//#define _ADC1
+//#define _ADC2
+//#define _ADC3
//#define _BKP
//#define _CAN
//#define _CRC
diff --git a/src/lib/usb.c b/src/lib/usb.c index e83bf98..17c8c8d 100644 --- a/src/lib/usb.c +++ b/src/lib/usb.c @@ -1,6 +1,8 @@ #include <inttypes.h> #include "usb.h" +BootVectTable* bootVect = ((BootVectTable*) BOOTLOADER_VECT_TABLE); + void usb_lpIRQHandler(void) { typedef void (*funcPtr)(void); @@ -42,15 +44,24 @@ void usb_PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes) void usb_serialWriteStr(const char* outStr) { u8 offset=0; - while ((outStr[offset] != 0) + BootVectTable *bootVector = ((BootVectTable*)BOOTLOADER_VECT_TABLE); + + while ((outStr[offset] != '\0') && (offset < USB_SERIAL_BUF_SIZE)) { offset++; } - while (_GetEPTxCount(USB_SERIAL_ENDP_TX) > 0) {} + delay(offset*1); - usb_userToPMABufferCopy(outStr,USB_SERIAL_ENDP_TXADDR,offset); + bootVector->serial_count_in = (u32*) &offset; + usb_userToPMABufferCopy((u8*)outStr,USB_SERIAL_ENDP_TXADDR,offset); _SetEPTxCount(USB_SERIAL_ENDP_TX,offset); _SetEPTxValid(USB_SERIAL_ENDP_TX); + } +uint8_t usb_serialGetRecvLen() { + uint8_t count_out = _GetEPRxCount(USB_SERIAL_ENDP_RX); + _SetEPRxValid(USB_SERIAL_ENDP_RX); + return count_out; +} diff --git a/src/lib/usb.h b/src/lib/usb.h index d057b1d..3a7e92b 100644 --- a/src/lib/usb.h +++ b/src/lib/usb.h @@ -17,11 +17,30 @@ extern "C" { #define USB_SERIAL_ENDP_RX ((uint16_t) 0x3) #define USB_SERIAL_BUF_SIZE (0x40) +#define BOOTLOADER_VECT_TABLE ((uint32_t*)0x20000000) + +typedef void (*FuncPtr)(void); + +typedef struct { + FuncPtr serial_tx_cb; + FuncPtr serial_rx_cb; + FuncPtr serial_linecoding_cb; + uint32_t* serial_count_in; + uint32_t* serial_count_out; + uint8_t* serial_buffer_out; + void* linecoding; + uint8_t major_rev; + uint8_t minor_rev; + void* usb_device_ptr; +} BootVectTable; + +extern BootVectTable* bootVect; + void usb_lpIRQHandler(void); void usb_userToPMABufferCopy(u8 *pbUsrBuf,u16 wPMABufAddr,u16 wNBytes); void usb_PMAToUserBufferCopy(u8 *pbUsrBuf,u16 wPMABufAddr,u16 wNBytes); void usb_serialWriteStr(const char *outStr); - +uint8_t usb_serialGetRecvLen(); #ifdef __cplusplus } // extern "C" |