sakumisu 3 лет назад
Родитель
Сommit
b47fe8d958
2 измененных файлов с 11 добавлено и 11 удалено
  1. 7 7
      common/usb_mem.h
  2. 4 4
      core/usbd_core.c

+ 7 - 7
common/usb_mem.h

@@ -36,7 +36,7 @@
 #endif
 
 #define usb_malloc(size) malloc(size)
-#define usb_free(ptr) free(ptr)
+#define usb_free(ptr)    free(ptr)
 
 #ifdef CONFIG_USB_DCACHE_ENABLE
 static inline void *usb_iomalloc(size_t size)
@@ -60,14 +60,14 @@ static inline void *usb_iomalloc(size_t size)
     ptr = usb_malloc(align_size);
     if (ptr != NULL) {
         /* the allocated memory block is aligned */
-        if (((uint32_t)ptr & (align - 1)) == 0) {
-            align_ptr = (void *)((uint32_t)ptr + align);
+        if (((unsigned long)ptr & (align - 1)) == 0) {
+            align_ptr = (void *)((unsigned long)ptr + align);
         } else {
-            align_ptr = (void *)(((uint32_t)ptr + (align - 1)) & ~(align - 1));
+            align_ptr = (void *)(((unsigned long)ptr + (align - 1)) & ~(align - 1));
         }
 
         /* set the pointer before alignment pointer to the real pointer */
-        *((uint32_t *)((uint32_t)align_ptr - sizeof(void *))) = (uint32_t)ptr;
+        *((unsigned long *)((unsigned long)align_ptr - sizeof(void *))) = (unsigned long)ptr;
 
         ptr = align_ptr;
     }
@@ -79,12 +79,12 @@ static inline void usb_iofree(void *ptr)
 {
     void *real_ptr;
 
-    real_ptr = (void *)*(uint32_t *)((uint32_t)ptr - sizeof(void *));
+    real_ptr = (void *)*(unsigned long *)((unsigned long)ptr - sizeof(void *));
     usb_free(real_ptr);
 }
 #else
 #define usb_iomalloc(size) usb_malloc(size)
-#define usb_iofree(ptr) usb_free(ptr)
+#define usb_iofree(ptr)    usb_free(ptr)
 #endif
 
 #endif

+ 4 - 4
core/usbd_core.c

@@ -311,7 +311,7 @@ static bool usbd_get_descriptor(uint16_t type_index, uint8_t **data, uint32_t *l
         *data = p;
 
         /* get length from structure */
-        if ((type == USB_DESCRIPTOR_TYPE_CONFIGURATION)||((type == USB_DESCRIPTOR_TYPE_OTHER_SPEED))){
+        if ((type == USB_DESCRIPTOR_TYPE_CONFIGURATION) || ((type == USB_DESCRIPTOR_TYPE_OTHER_SPEED))) {
             /* configuration descriptor is an
              * exception, length is at offset
              * 2 and 3
@@ -1056,7 +1056,7 @@ static void usbd_ep0_setup_handler(void)
                                              setup->wLength);
 #ifdef CONFIG_USB_DCACHE_ENABLE
     /* check if the data buf addr uses usbd_core_cfg.req_data */
-    if (((uint32_t)usbd_core_cfg.ep0_data_buf) != ((uint32_t)usbd_core_cfg.req_data)) {
+    if (((unsigned long)usbd_core_cfg.ep0_data_buf) != ((unsigned long)usbd_core_cfg.req_data)) {
         /*copy data buf from misalign32 addr to align32 addr*/
         memcpy(usbd_core_cfg.req_data, usbd_core_cfg.ep0_data_buf, usbd_core_cfg.ep0_data_buf_residue);
         usbd_core_cfg.ep0_data_buf = usbd_core_cfg.req_data;
@@ -1251,11 +1251,11 @@ void usbd_event_notify_handler(uint8_t event, void *arg)
             break;
 
         case USBD_EVENT_EP_IN_NOTIFY:
-            usbd_ep_in_handler((uint8_t)arg);
+            usbd_ep_in_handler((uint8_t)(unsigned long)arg);
             break;
 
         case USBD_EVENT_EP_OUT_NOTIFY:
-            usbd_ep_out_handler((uint8_t)arg);
+            usbd_ep_out_handler((uint8_t)(unsigned long)arg);
             break;
 
         default: