Przeglądaj źródła

remove unwanted attributes

Dmitry Filimonchuk 6 lat temu
rodzic
commit
24cc51af4c

+ 8 - 3
src/usbd_stm32f429_otgfs.c

@@ -15,6 +15,7 @@
 
 #include <stdint.h>
 #include <stdbool.h>
+#include <string.h>
 #include "stm32.h"
 #include "usb.h"
 
@@ -329,14 +330,16 @@ int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) {
     for (unsigned i = 0; i < len; i +=4) {
         uint32_t _t = *fifo;
         if (blen >= 4) {
-            *(__attribute__((packed))uint32_t*)buf = _t;
+            /* Cortex M3, M4 supports unaligned access */
+            *(uint32_t*)buf = _t;
             blen -= 4;
             buf += 4;
         } else {
             while (blen){
-                *(uint8_t*)buf++ = 0xFF & _t;
+                *(uint8_t*)buf = 0xFF & _t;
                 _t >>= 8;
                 blen --;
+                buf++;
             }
         }
     }
@@ -358,7 +361,9 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) {
     epi->DIEPTSIZ = (1 << 19) + blen;
     _BMD(epi->DIEPCTL, USB_OTG_DIEPCTL_STALL, USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK);
     while (_len--) {
-        *_fifo = *(__attribute__((packed)) uint32_t*)buf;
+        /* Cortex M3, M4 supports unaligned access */
+        uint32_t _t = *(uint32_t*)buf;
+        *_fifo = _t;
         buf += 4;
     }
     return blen;

+ 5 - 2
src/usbd_stm32f429_otghs.c

@@ -331,7 +331,8 @@ static int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) {
     for (unsigned i = 0; i < len; i +=4) {
         uint32_t _t = *fifo;
         if (blen >= 4) {
-            *(__attribute__((packed))uint32_t*)buf = _t;
+            /* Cortex M3, M4 supports unaligned access */
+            *(uint32_t*)buf = _t;
             blen -= 4;
             buf += 4;
         } else {
@@ -362,7 +363,9 @@ static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) {
     _BMD(epi->DIEPCTL, USB_OTG_DIEPCTL_STALL, USB_OTG_DOEPCTL_CNAK);
     _BST(epi->DIEPCTL, USB_OTG_DOEPCTL_EPENA);
     while (_len--) {
-        *_fifo = *(__attribute__((packed)) uint32_t*)buf;
+        /* Cortex M3, M4 supports unaligned access */
+        uint32_t _t = *(uint32_t*)buf;
+        *_fifo = _t;
         buf += 4;
     }
     return blen;

+ 2 - 2
src/usbd_stm32l476_otgfs.c

@@ -354,7 +354,7 @@ int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) {
     for (unsigned i = 0; i < len; i +=4) {
         uint32_t _t = *fifo;
         if (blen >= 4) {
-            *(__attribute__((packed))uint32_t*)buf = _t;
+            *(uint32_t*)buf = _t;
             blen -= 4;
             buf += 4;
         } else {
@@ -384,7 +384,7 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) {
     epi->DIEPTSIZ = (1 << 19) + blen;
     _BMD(epi->DIEPCTL, USB_OTG_DIEPCTL_STALL, USB_OTG_DOEPCTL_EPENA | USB_OTG_DOEPCTL_CNAK);
     while (_len--) {
-        *_fifo = *(__attribute__((packed)) uint32_t*)buf;
+        *_fifo = *(uint32_t*)buf;
         buf += 4;
     }
     return blen;