aboutsummaryrefslogtreecommitdiffstats
path: root/src/stm32/usbfs.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/stm32/usbfs.c')
-rw-r--r--src/stm32/usbfs.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/src/stm32/usbfs.c b/src/stm32/usbfs.c
index ca66f513..b9152e62 100644
--- a/src/stm32/usbfs.c
+++ b/src/stm32/usbfs.c
@@ -21,22 +21,28 @@
* USB transfer memory
****************************************************************/
+#if CONFIG_MACH_STM32F103
+typedef volatile uint32_t epmword_t;
+#else
+typedef volatile uint16_t epmword_t;
+#endif
+
struct ep_desc {
- uint32_t addr_tx, count_tx, addr_rx, count_rx;
+ epmword_t addr_tx, count_tx, addr_rx, count_rx;
};
struct ep_mem {
struct ep_desc ep0, ep_acm, ep_bulk_out, ep_bulk_in;
- uint32_t ep0_tx[USB_CDC_EP0_SIZE / 2];
- uint32_t ep0_rx[USB_CDC_EP0_SIZE / 2 + 1];
- uint32_t ep_acm_tx[USB_CDC_EP_ACM_SIZE / 2];
- uint32_t ep_bulk_out_rx[USB_CDC_EP_BULK_OUT_SIZE / 2 + 1];
- uint32_t ep_bulk_in_tx[USB_CDC_EP_BULK_IN_SIZE / 2];
+ epmword_t ep0_tx[USB_CDC_EP0_SIZE / 2];
+ epmword_t ep0_rx[USB_CDC_EP0_SIZE / 2 + 1];
+ epmword_t ep_acm_tx[USB_CDC_EP_ACM_SIZE / 2];
+ epmword_t ep_bulk_out_rx[USB_CDC_EP_BULK_OUT_SIZE / 2 + 1];
+ epmword_t ep_bulk_in_tx[USB_CDC_EP_BULK_IN_SIZE / 2];
};
#define EPM ((struct ep_mem *)USB_PMAADDR)
-#define CALC_ADDR(p) (((void*)(p) - (void*)EPM) / 2)
+#define CALC_ADDR(p) (((epmword_t*)(p) - (epmword_t*)EPM) * 2)
#define CALC_SIZE(s) ((s) > 32 ? (DIV_ROUND_UP((s), 32) << 10) | 0x8000 \
: DIV_ROUND_UP((s), 2) << 10)
@@ -61,7 +67,7 @@ btable_configure(void)
// Read a packet stored in dedicated usb memory
static void
-btable_read_packet(uint8_t *dest, uint32_t *src, int count)
+btable_read_packet(uint8_t *dest, epmword_t *src, int count)
{
uint_fast8_t i;
for (i=0; i<(count/2); i++) {
@@ -75,7 +81,7 @@ btable_read_packet(uint8_t *dest, uint32_t *src, int count)
// Write a packet to dedicated usb memory
static void
-btable_write_packet(uint32_t *dest, const uint8_t *src, int count)
+btable_write_packet(epmword_t *dest, const uint8_t *src, int count)
{
int i;
for (i=0; i<(count/2); i++) {