diff options
author | Perry Hung <iperry@alum.mit.edu> | 2010-03-30 22:58:47 -0400 |
---|---|---|
committer | Perry Hung <iperry@alum.mit.edu> | 2010-03-30 22:58:47 -0400 |
commit | 1be7df0937bee5127103e7dc8800c83e47415f3d (patch) | |
tree | 358e29df049ec0d664174f4d2fd88056d50172f4 /libmaple | |
parent | 869ed39e4c28ebb9813a8b28192d4ca92f72bf22 (diff) | |
download | librambutan-1be7df0937bee5127103e7dc8800c83e47415f3d.tar.gz librambutan-1be7df0937bee5127103e7dc8800c83e47415f3d.zip |
Removed remaining STM32 types and #defines.
Updated usb subsystem to use libmaple types, removed STM32 peripheral
library from the Makefile
Diffstat (limited to 'libmaple')
-rw-r--r-- | libmaple/usb.c | 46 | ||||
-rw-r--r-- | libmaple/usb.h | 21 | ||||
-rw-r--r-- | libmaple/usb_regs.h | 79 |
3 files changed, 71 insertions, 75 deletions
diff --git a/libmaple/usb.c b/libmaple/usb.c index 8c312f8..8826858 100644 --- a/libmaple/usb.c +++ b/libmaple/usb.c @@ -1,5 +1,7 @@ -#include <inttypes.h> +#include "libmaple.h" #include "usb.h" +#include "usb_regs.h" +#include "bootVect.h" void usb_lpIRQHandler(void) { @@ -10,38 +12,38 @@ void usb_lpIRQHandler(void) ptrToUsbISR(); } -void usb_userToPMABufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes) +void usb_userToPMABufferCopy(uint8 *pbUsrBuf, uint16 wPMABufAddr, uint16 wNBytes) { - u32 n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */ - u32 i, temp1, temp2; - u16 *pdwVal; - pdwVal = (u16 *)(wPMABufAddr * 2 + PMAAddr); + uint32 n = (wNBytes + 1) >> 1; /* n = (wNBytes + 1) / 2 */ + uint32 i, temp1, temp2; + uint16 *pdwVal; + pdwVal = (uint16 *)(wPMABufAddr * 2 + PMAAddr); for (i = n; i != 0; i--) { - temp1 = (u16) * pbUsrBuf; + temp1 = (uint16) * pbUsrBuf; pbUsrBuf++; - temp2 = temp1 | (u16) * pbUsrBuf << 8; + temp2 = temp1 | (uint16) * pbUsrBuf << 8; *pdwVal++ = temp2; pdwVal++; pbUsrBuf++; } } -void usb_PMAToUserBufferCopy(u8 *pbUsrBuf, u16 wPMABufAddr, u16 wNBytes) +void usb_PMAToUserBufferCopy(uint8 *pbUsrBuf, uint16 wPMABufAddr, uint16 wNBytes) { - u32 n = (wNBytes + 1) >> 1;/* /2*/ - u32 i; - u32 *pdwVal; - pdwVal = (u32 *)(wPMABufAddr * 2 + PMAAddr); + uint32 n = (wNBytes + 1) >> 1;/* /2*/ + uint32 i; + uint32 *pdwVal; + pdwVal = (uint32 *)(wPMABufAddr * 2 + PMAAddr); for (i = n; i != 0; i--) { - *(u16*)pbUsrBuf++ = *pdwVal++; + *(uint16*)pbUsrBuf++ = *pdwVal++; pbUsrBuf++; } } void usb_serialWriteStr(const char* outStr) { - u8 offset=0; + uint8 offset=0; BootVectTable *bootVector = ((BootVectTable*)BOOTLOADER_VECT_TABLE); while ((outStr[offset] != '\0') @@ -51,8 +53,8 @@ void usb_serialWriteStr(const char* outStr) { delay(offset*1); - bootVector->serial_count_in = (u32*) &offset; - usb_userToPMABufferCopy((u8*)outStr,USB_SERIAL_ENDP_TXADDR,offset); + bootVector->serial_count_in = (uint32*) &offset; + usb_userToPMABufferCopy((uint8*)outStr,USB_SERIAL_ENDP_TXADDR,offset); _SetEPTxCount(USB_SERIAL_ENDP_TX,offset); _SetEPTxValid(USB_SERIAL_ENDP_TX); @@ -64,20 +66,20 @@ void usb_serialWriteChar(unsigned char ch) { delay(1); *(bootVector->serial_count_in) = 1; - usb_userToPMABufferCopy((u8*)(&ch),USB_SERIAL_ENDP_TXADDR,1); + usb_userToPMABufferCopy((uint8*)(&ch),USB_SERIAL_ENDP_TXADDR,1); _SetEPTxCount(USB_SERIAL_ENDP_TX,1); _SetEPTxValid(USB_SERIAL_ENDP_TX); } -uint8_t usb_serialGetRecvLen() { - uint8_t count_out =_GetEPRxCount(USB_SERIAL_ENDP_RX); +uint8 usb_serialGetRecvLen() { + uint8 count_out =_GetEPRxCount(USB_SERIAL_ENDP_RX); return count_out; } -void usb_copyRecvBuffer(unsigned char* dest, uint8_t len) { +void usb_copyRecvBuffer(unsigned char* dest, uint8 len) { ASSERT(len < USB_SERIAL_BUF_SIZE); - usb_PMAToUserBufferCopy((u8*)(dest),USB_SERIAL_ENDP_RXADDR,len); + usb_PMAToUserBufferCopy((uint8*)(dest),USB_SERIAL_ENDP_RXADDR,len); _SetEPRxValid(USB_SERIAL_ENDP_RX); } diff --git a/libmaple/usb.h b/libmaple/usb.h index 960e1f4..fa40123 100644 --- a/libmaple/usb.h +++ b/libmaple/usb.h @@ -1,29 +1,24 @@ #ifndef _USB_H_ #define _USB_H_ -#include <inttypes.h> -#include "util.h" -#include "usb_regs.h" -#include "bootVect.h" - #define USB_ISR_ADDR (0x08000090) -#define USB_SERIAL_ENDP_TXADDR ((uint32_t) 0xC0) -#define USB_SERIAL_ENDP_RXADDR ((uint32_t) 0x110) -#define USB_SERIAL_ENDP_TX ((uint16_t) 0x1) -#define USB_SERIAL_ENDP_RX ((uint16_t) 0x3) +#define USB_SERIAL_ENDP_TXADDR ((uint32) 0xC0) +#define USB_SERIAL_ENDP_RXADDR ((uint32) 0x110) +#define USB_SERIAL_ENDP_TX ((uint16) 0x1) +#define USB_SERIAL_ENDP_RX ((uint16) 0x3) #define USB_SERIAL_BUF_SIZE (0x40) #ifdef __cplusplus extern "C" { #endif -void usb_lpIRQHandler(void); -void usb_userToPMABufferCopy(u8 *pbUsrBuf,u16 wPMABufAddr,u16 wNBytes); -void usb_PMAToUserBufferCopy(u8 *pbUsrBuf,u16 wPMABufAddr,u16 wNBytes); +void usb_lpIRQHandler(void); +void usb_userToPMABufferCopy(uint8 *pbUsrBuf,uint16 wPMABufAddr,uint16 wNBytes); +void usb_PMAToUserBufferCopy(uint8 *pbUsrBuf,uint16 wPMABufAddr,uint16 wNBytes); void usb_serialWriteStr(const char *outStr); void usb_serialWriteChar(unsigned char ch); uint8_t usb_serialGetRecvLen(); -void usb_copyRecvBuffer(unsigned char* dest, uint8_t len); +void usb_copyRecvBuffer(unsigned char* dest, uint8 len); #ifdef __cplusplus } // extern "C" diff --git a/libmaple/usb_regs.h b/libmaple/usb_regs.h index 135d645..bf5e10c 100644 --- a/libmaple/usb_regs.h +++ b/libmaple/usb_regs.h @@ -19,7 +19,6 @@ /* Includes ------------------------------------------------------------------*/
/* Exported types ------------------------------------------------------------*/
-#include "stm32f10x_type.h"
typedef enum _EP_DBUF_DIR
{
@@ -61,14 +60,14 @@ enum EP_BUF_NUM #define EP0REG ((volatile unsigned *)(RegBase)) /* endpoint 0 register address */
/* endpoints enumeration */
-#define ENDP0 ((u8)0)
-#define ENDP1 ((u8)1)
-#define ENDP2 ((u8)2)
-#define ENDP3 ((u8)3)
-#define ENDP4 ((u8)4)
-#define ENDP5 ((u8)5)
-#define ENDP6 ((u8)6)
-#define ENDP7 ((u8)7)
+#define ENDP0 ((uint8)0)
+#define ENDP1 ((uint8)1)
+#define ENDP2 ((uint8)2)
+#define ENDP3 ((uint8)3)
+#define ENDP4 ((uint8)4)
+#define ENDP5 ((uint8)5)
+#define ENDP6 ((uint8)6)
+#define ENDP7 ((uint8)7)
/******************************************************************************/
/* ISTR interrupt events */
/******************************************************************************/
@@ -175,38 +174,38 @@ enum EP_BUF_NUM #define EPRX_DTOGMASK (EPRX_STAT|EPREG_MASK)
/* Exported macro ------------------------------------------------------------*/
/* SetCNTR */
-#define _SetCNTR(wRegValue) (*CNTR = (u16)wRegValue)
+#define _SetCNTR(wRegValue) (*CNTR = (uint16)wRegValue)
/* SetISTR */
-#define _SetISTR(wRegValue) (*ISTR = (u16)wRegValue)
+#define _SetISTR(wRegValue) (*ISTR = (uint16)wRegValue)
/* SetDADDR */
-#define _SetDADDR(wRegValue) (*DADDR = (u16)wRegValue)
+#define _SetDADDR(wRegValue) (*DADDR = (uint16)wRegValue)
/* SetBTABLE */
-#define _SetBTABLE(wRegValue)(*BTABLE = (u16)(wRegValue & 0xFFF8))
+#define _SetBTABLE(wRegValue)(*BTABLE = (uint16)(wRegValue & 0xFFF8))
/* GetCNTR */
-#define _GetCNTR() ((u16) *CNTR)
+#define _GetCNTR() ((uint16) *CNTR)
/* GetISTR */
-#define _GetISTR() ((u16) *ISTR)
+#define _GetISTR() ((uint16) *ISTR)
/* GetFNR */
-#define _GetFNR() ((u16) *FNR)
+#define _GetFNR() ((uint16) *FNR)
/* GetDADDR */
-#define _GetDADDR() ((u16) *DADDR)
+#define _GetDADDR() ((uint16) *DADDR)
/* GetBTABLE */
-#define _GetBTABLE() ((u16) *BTABLE)
+#define _GetBTABLE() ((uint16) *BTABLE)
/* SetENDPOINT */
#define _SetENDPOINT(bEpNum,wRegValue) (*(EP0REG + bEpNum)= \
- (u16)wRegValue)
+ (uint16)wRegValue)
/* GetENDPOINT */
-#define _GetENDPOINT(bEpNum) ((u16)(*(EP0REG + bEpNum)))
+#define _GetENDPOINT(bEpNum) ((uint16)(*(EP0REG + bEpNum)))
/*******************************************************************************
* Macro Name : SetEPType
@@ -237,7 +236,7 @@ enum EP_BUF_NUM * Return : None.
*******************************************************************************/
#define _SetEPTxStatus(bEpNum,wState) {\
- register u16 _wRegVal; \
+ register uint16 _wRegVal; \
_wRegVal = _GetENDPOINT(bEpNum) & EPTX_DTOGMASK;\
/* toggle first bit ? */ \
if((EPTX_DTOG1 & wState)!= 0) \
@@ -257,7 +256,7 @@ enum EP_BUF_NUM * Return : None.
*******************************************************************************/
#define _SetEPRxStatus(bEpNum,wState) {\
- register u16 _wRegVal; \
+ register uint16 _wRegVal; \
\
_wRegVal = _GetENDPOINT(bEpNum) & EPRX_DTOGMASK;\
/* toggle first bit ? */ \
@@ -276,9 +275,9 @@ enum EP_BUF_NUM * Output : None.
* Return : status .
*******************************************************************************/
-#define _GetEPTxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPTX_STAT)
+#define _GetEPTxStatus(bEpNum) ((uint16)_GetENDPOINT(bEpNum) & EPTX_STAT)
-#define _GetEPRxStatus(bEpNum) ((u16)_GetENDPOINT(bEpNum) & EPRX_STAT)
+#define _GetEPRxStatus(bEpNum) ((uint16)_GetENDPOINT(bEpNum) & EPRX_STAT)
/*******************************************************************************
* Macro Name : SetEPTxValid / SetEPRxValid
@@ -388,12 +387,12 @@ enum EP_BUF_NUM * Output : None.
* Return : None.
*******************************************************************************/
-#define _GetEPAddress(bEpNum) ((u8)(_GetENDPOINT(bEpNum) & EPADDR_FIELD))
+#define _GetEPAddress(bEpNum) ((uint8)(_GetENDPOINT(bEpNum) & EPADDR_FIELD))
-#define _pEPTxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8 )*2 + PMAAddr))
-#define _pEPTxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+2)*2 + PMAAddr))
-#define _pEPRxAddr(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+4)*2 + PMAAddr))
-#define _pEPRxCount(bEpNum) ((u32 *)((_GetBTABLE()+bEpNum*8+6)*2 + PMAAddr))
+#define _pEPTxAddr(bEpNum) ((uint32 *)((_GetBTABLE()+bEpNum*8 )*2 + PMAAddr))
+#define _pEPTxCount(bEpNum) ((uint32 *)((_GetBTABLE()+bEpNum*8+2)*2 + PMAAddr))
+#define _pEPRxAddr(bEpNum) ((uint32 *)((_GetBTABLE()+bEpNum*8+4)*2 + PMAAddr))
+#define _pEPRxCount(bEpNum) ((uint32 *)((_GetBTABLE()+bEpNum*8+6)*2 + PMAAddr))
/*******************************************************************************
* Macro Name : SetEPTxAddr / SetEPRxAddr.
@@ -413,8 +412,8 @@ enum EP_BUF_NUM * Output : None.
* Return : address of the buffer.
*******************************************************************************/
-#define _GetEPTxAddr(bEpNum) ((u16)*_pEPTxAddr(bEpNum))
-#define _GetEPRxAddr(bEpNum) ((u16)*_pEPRxAddr(bEpNum))
+#define _GetEPTxAddr(bEpNum) ((uint16)*_pEPTxAddr(bEpNum))
+#define _GetEPRxAddr(bEpNum) ((uint16)*_pEPRxAddr(bEpNum))
/*******************************************************************************
* Macro Name : SetEPCountRxReg.
@@ -428,18 +427,18 @@ enum EP_BUF_NUM wNBlocks = wCount >> 5;\
if((wCount & 0x1f) == 0)\
wNBlocks--;\
- *pdwReg = (u32)((wNBlocks << 10) | 0x8000);\
+ *pdwReg = (uint32)((wNBlocks << 10) | 0x8000);\
}/* _BlocksOf32 */
#define _BlocksOf2(dwReg,wCount,wNBlocks) {\
wNBlocks = wCount >> 1;\
if((wCount & 0x1) != 0)\
wNBlocks++;\
- *pdwReg = (u32)(wNBlocks << 10);\
+ *pdwReg = (uint32)(wNBlocks << 10);\
}/* _BlocksOf2 */
#define _SetEPCountRxReg(dwReg,wCount) {\
- u16 wNBlocks;\
+ uint16 wNBlocks;\
if(wCount > 62){_BlocksOf32(dwReg,wCount,wNBlocks);}\
else {_BlocksOf2(dwReg,wCount,wNBlocks);}\
}/* _SetEPCountRxReg */
@@ -447,7 +446,7 @@ enum EP_BUF_NUM #define _SetEPRxDblBuf0Count(bEpNum,wCount) {\
- u32 *pdwReg = _pEPTxCount(bEpNum); \
+ uint32 *pdwReg = _pEPTxCount(bEpNum); \
_SetEPCountRxReg(pdwReg, wCount);\
}
/*******************************************************************************
@@ -460,7 +459,7 @@ enum EP_BUF_NUM *******************************************************************************/
#define _SetEPTxCount(bEpNum,wCount) (*_pEPTxCount(bEpNum) = wCount)
#define _SetEPRxCount(bEpNum,wCount) {\
- u32 *pdwReg = _pEPRxCount(bEpNum); \
+ uint32 *pdwReg = _pEPRxCount(bEpNum); \
_SetEPCountRxReg(pdwReg, wCount);\
}
/*******************************************************************************
@@ -470,8 +469,8 @@ enum EP_BUF_NUM * Output : None.
* Return : Counter value.
*******************************************************************************/
-#define _GetEPTxCount(bEpNum)((u16)(*_pEPTxCount(bEpNum)) & 0x3ff)
-#define _GetEPRxCount(bEpNum)((u16)(*_pEPRxCount(bEpNum)) & 0x3ff)
+#define _GetEPTxCount(bEpNum)((uint16)(*_pEPTxCount(bEpNum)) & 0x3ff)
+#define _GetEPRxCount(bEpNum)((uint16)(*_pEPRxCount(bEpNum)) & 0x3ff)
/*******************************************************************************
* Macro Name : SetEPDblBuf0Addr / SetEPDblBuf1Addr.
@@ -524,7 +523,7 @@ enum EP_BUF_NUM {_SetEPRxDblBuf0Count(bEpNum,wCount);} \
else if(bDir == EP_DBUF_IN)\
/* IN endpoint */ \
- *_pEPTxCount(bEpNum) = (u32)wCount; \
+ *_pEPTxCount(bEpNum) = (uint32)wCount; \
} /* SetEPDblBuf0Count*/
#define _SetEPDblBuf1Count(bEpNum, bDir, wCount) { \
@@ -533,7 +532,7 @@ enum EP_BUF_NUM {_SetEPRxCount(bEpNum,wCount);}\
else if(bDir == EP_DBUF_IN)\
/* IN endpoint */\
- *_pEPRxCount(bEpNum) = (u32)wCount; \
+ *_pEPRxCount(bEpNum) = (uint32)wCount; \
} /* SetEPDblBuf1Count */
#define _SetEPDblBuffCount(bEpNum, bDir, wCount) {\
|