|
7 | 7 | #include "usb_dwc2_reg.h" |
8 | 8 | #include "usb_dwc2_param.h" |
9 | 9 |
|
10 | | -// clang-format off |
11 | | -#if defined ( __CC_ARM ) |
12 | | -#ifndef __UNALIGNED_UINT32_WRITE |
13 | | - #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) |
14 | | -#endif |
15 | | -#ifndef __UNALIGNED_UINT32_READ |
16 | | - #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) |
17 | | -#endif |
18 | | -#elif defined (__ICCARM__) |
19 | | -#ifndef __UNALIGNED_UINT32_WRITE |
20 | | - #define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val)) |
21 | | -#endif |
22 | | -#ifndef __UNALIGNED_UINT32_READ |
23 | | - #define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr))) |
24 | | -#endif |
25 | | -#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050) |
26 | | -#ifndef __UNALIGNED_UINT32_WRITE |
27 | | - #pragma clang diagnostic push |
28 | | - #pragma clang diagnostic ignored "-Wpacked" |
29 | | -/*lint -esym(9058, T_UINT32_WRITE)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_WRITE */ |
30 | | - __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; |
31 | | - #pragma clang diagnostic pop |
32 | | - #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) |
33 | | -#endif |
34 | | -#ifndef __UNALIGNED_UINT32_READ |
35 | | - #pragma clang diagnostic push |
36 | | - #pragma clang diagnostic ignored "-Wpacked" |
37 | | -/*lint -esym(9058, T_UINT32_READ)*/ /* disable MISRA 2012 Rule 2.4 for T_UINT32_READ */ |
38 | | - __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; |
39 | | - #pragma clang diagnostic pop |
40 | | - #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) |
41 | | -#endif |
42 | | -#elif defined ( __GNUC__ ) |
43 | | -#ifndef __UNALIGNED_UINT32_WRITE |
44 | | - #pragma GCC diagnostic push |
45 | | - #pragma GCC diagnostic ignored "-Wpacked" |
46 | | - #pragma GCC diagnostic ignored "-Wattributes" |
47 | | - __PACKED_STRUCT T_UINT32_WRITE { uint32_t v; }; |
48 | | - #pragma GCC diagnostic pop |
49 | | - #define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val)) |
50 | | -#endif |
51 | | -#ifndef __UNALIGNED_UINT32_READ |
52 | | - #pragma GCC diagnostic push |
53 | | - #pragma GCC diagnostic ignored "-Wpacked" |
54 | | - #pragma GCC diagnostic ignored "-Wattributes" |
55 | | - __PACKED_STRUCT T_UINT32_READ { uint32_t v; }; |
56 | | - #pragma GCC diagnostic pop |
57 | | - #define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v) |
58 | | -#endif |
59 | | -#endif |
60 | | -// clang-format on |
61 | | - |
62 | 10 | #define USBD_BASE (g_usbdev_bus[busid].reg_base) |
63 | 11 |
|
64 | 12 | #define USB_OTG_GLB ((DWC2_GlobalTypeDef *)(USBD_BASE)) |
@@ -351,25 +299,23 @@ static void dwc2_ep0_start_read_setup(uint8_t busid, uint8_t *psetup) |
351 | 299 |
|
352 | 300 | void dwc2_ep_write(uint8_t busid, uint8_t ep_idx, uint8_t *src, uint16_t len) |
353 | 301 | { |
354 | | - uint32_t *pSrc = (uint32_t *)src; |
| 302 | + uint32_t *psrc = (uint32_t *)src; |
355 | 303 | uint32_t count32b, i; |
356 | 304 |
|
357 | 305 | count32b = ((uint32_t)len + 3U) / 4U; |
358 | 306 | for (i = 0U; i < count32b; i++) { |
359 | | - USB_OTG_FIFO((uint32_t)ep_idx) = __UNALIGNED_UINT32_READ(pSrc); |
360 | | - pSrc++; |
| 307 | + USB_OTG_FIFO((uint32_t)ep_idx) = *psrc++; |
361 | 308 | } |
362 | 309 | } |
363 | 310 |
|
364 | 311 | void dwc2_ep_read(uint8_t busid, uint8_t *dest, uint16_t len) |
365 | 312 | { |
366 | | - uint32_t *pDest = (uint32_t *)dest; |
| 313 | + uint32_t *pdest = (uint32_t *)dest; |
367 | 314 | uint32_t i; |
368 | 315 | uint32_t count32b = ((uint32_t)len + 3U) / 4U; |
369 | 316 |
|
370 | 317 | for (i = 0U; i < count32b; i++) { |
371 | | - __UNALIGNED_UINT32_WRITE(pDest, USB_OTG_FIFO(0U)); |
372 | | - pDest++; |
| 318 | + *pdest++ = USB_OTG_FIFO(0U); |
373 | 319 | } |
374 | 320 | } |
375 | 321 |
|
@@ -1181,14 +1127,15 @@ void USBD_IRQHandler(uint8_t busid) |
1181 | 1127 | memset(g_dwc2_udc[busid].in_ep, 0, sizeof(struct dwc2_ep_state) * 16); |
1182 | 1128 | memset(g_dwc2_udc[busid].out_ep, 0, sizeof(struct dwc2_ep_state) * 16); |
1183 | 1129 | usbd_event_reset_handler(busid); |
1184 | | - /* Start reading setup */ |
1185 | | - dwc2_ep0_start_read_setup(busid, (uint8_t *)&g_dwc2_udc[busid].setup); |
1186 | 1130 | } |
1187 | 1131 | if (gint_status & USB_OTG_GINTSTS_ENUMDNE) { |
1188 | 1132 | USB_OTG_GLB->GINTSTS = USB_OTG_GINTSTS_ENUMDNE; |
1189 | 1133 | dwc2_set_turnaroundtime(busid, SystemCoreClock, dwc2_get_devspeed(busid)); |
1190 | 1134 |
|
1191 | 1135 | USB_OTG_DEV->DCTL |= USB_OTG_DCTL_CGINAK; |
| 1136 | + |
| 1137 | + /* Start reading setup */ |
| 1138 | + dwc2_ep0_start_read_setup(busid, (uint8_t *)&g_dwc2_udc[busid].setup); |
1192 | 1139 | } |
1193 | 1140 | if (gint_status & USB_OTG_GINTSTS_PXFR_INCOMPISOOUT) { |
1194 | 1141 | USB_OTG_GLB->GINTSTS = USB_OTG_GINTSTS_PXFR_INCOMPISOOUT; |
|
0 commit comments