diff options
author | ajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123> | 2009-12-19 15:14:29 +0000 |
---|---|---|
committer | ajmeyer@mit.edu <ajmeyer@mit.edu@749a229e-a60e-11de-b98f-4500b42dc123> | 2009-12-19 15:14:29 +0000 |
commit | 6a0091418a8cdad33f7cb9b2a576e91c6960e07a (patch) | |
tree | 8d85cf4b3b008686b26b062025c366876c84ee9f | |
parent | acf59b1abb346998c492b93fee4a680a32f538d5 (diff) | |
download | librambutan-6a0091418a8cdad33f7cb9b2a576e91c6960e07a.tar.gz librambutan-6a0091418a8cdad33f7cb9b2a576e91c6960e07a.zip |
added a usb.h and usb.c to cover some of the low level access functions that we can use to build the usb serial port. my sandbox widgets are in main.cpp, look at it then throw it out. I adjusted the stm32f10x_conf.h file to properly NOT include certain st lib files that werent being used, and modified the NVIC init to cope with the bootloader
git-svn-id: https://leaflabs.googlecode.com/svn/trunk/library@76 749a229e-a60e-11de-b98f-4500b42dc123
-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 | ||||
-rw-r--r-- | src/wiring/wiring.c | 2 |
4 files changed, 40 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" diff --git a/src/wiring/wiring.c b/src/wiring/wiring.c index 9d77a5b..cecca20 100644 --- a/src/wiring/wiring.c +++ b/src/wiring/wiring.c @@ -59,8 +59,10 @@ void init(void) { void NVIC_Configuration(void) { #ifdef VECT_TAB_ROM NVIC_SetVectorTable(USER_ADDR_ROM, 0x0); +#warning writing to ROM #elif defined VECT_TAB_RAM NVIC_SetVectorTable(USER_ADDR_RAM, 0x0); +#warning writing to RAM #else // VECT_TAB_BASE /* Set the Vector Table base location at 0x08000000 */ NVIC_SetVectorTable(NVIC_VectTab_FLASH, 0x0); |