mirror of https://github.com/Desuuuu/klipper.git
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>
This commit is contained in:
parent
c2881f7d15
commit
a46244057c
|
@ -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++) {
|
||||
|
|
Loading…
Reference in New Issue