aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/usb.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmaple/usb.c')
-rw-r--r--libmaple/usb.c46
1 files changed, 24 insertions, 22 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);
}