diff options
author | Kevin O'Connor <kevin@koconnor.net> | 2019-10-13 20:34:06 -0400 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2019-10-23 21:16:35 -0400 |
commit | a46244057cb02ad88e7e5fd2871afb85774974f4 (patch) | |
tree | 228bf555732ca24e8c4c2f3820ca5b3de99698fc /src/stm32/usbfs.c | |
parent | c2881f7d150f46590d489665e53f38ee8b032877 (diff) | |
download | kutter-a46244057cb02ad88e7e5fd2871afb85774974f4.tar.gz kutter-a46244057cb02ad88e7e5fd2871afb85774974f4.tar.xz kutter-a46244057cb02ad88e7e5fd2871afb85774974f4.zip |
stm32: Support 16bit packet memory access on usbfs controller
The stm32f0 line uses 16bit packet memory reads/writes (as opposed to
the goofy 32bit accesses required on the stm32f103).
Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
Diffstat (limited to 'src/stm32/usbfs.c')
-rw-r--r-- | src/stm32/usbfs.c | 24 |
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++) { |