فهرست منبع

move malloc,free,printf macro into config.h

sakimisu 3 سال پیش
والد
کامیت
66db88b7cd

+ 5 - 4
cherryusb_config_template.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 2 - 9
common/usb_log.h

@@ -14,10 +14,6 @@
 #define USB_DBG_INFO    2
 #define USB_DBG_LOG     3
 
-#ifndef CONFIG_USB_DBG_LEVEL
-#define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
-#endif
-
 #ifndef USB_DBG_TAG
 #define USB_DBG_TAG "USB"
 #endif
@@ -32,9 +28,6 @@
  * CYAN     36
  * WHITE    37
  */
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
 
 #ifdef  CONFIG_USB_PRINTF_COLOR_ENABLE
 #define _USB_DBG_COLOR(n) CONFIG_USB_PRINTF("\033[" #n "m")
@@ -80,7 +73,7 @@
 #define USB_LOG_ERR(...)
 #endif
 
-#define USB_LOG_RAW CONFIG_USB_PRINTF
+#define USB_LOG_RAW(...) CONFIG_USB_PRINTF(__VA_ARGS__)
 
 void usb_assert(const char *filename, int linenum);
 #define USB_ASSERT(f)                       \
@@ -89,4 +82,4 @@ void usb_assert(const char *filename, int linenum);
             usb_assert(__FILE__, __LINE__); \
     } while (0)
 
-#endif /* USB_LOG_H */
+#endif /* USB_LOG_H */

+ 0 - 19
common/usb_mem.h

@@ -6,25 +6,6 @@
 #ifndef USB_MEM_H
 #define USB_MEM_H
 
-#include "usb_config.h"
-
-#ifdef CONFIG_USBHOST_XHCI
-
-void *usb_hc_malloc(size_t size);
-void usb_hc_free();
-void *usb_hc_malloc_align(size_t align, size_t size);
-
-#define usb_malloc(size)                    usb_hc_malloc(size)
-#define usb_free(ptr)                       usb_hc_free(ptr)
-#define usb_align(align, size)              usb_hc_malloc_align(align, size)  
-
-#else
-
-#define usb_malloc(size) malloc(size)
-#define usb_free(ptr)    free(ptr)
-
-#endif
-
 #define USB_MEM_ALIGNX __attribute__((aligned(CONFIG_USB_ALIGN_SIZE)))
 
 #if (CONFIG_USB_ALIGN_SIZE > 4)

+ 5 - 4
demo/es32/usb_device/ES32F369x/Inc/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 5 - 4
demo/es32/usb_host/ES32F369x/Inc/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 5 - 4
demo/hpm/usb_device/src/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 5 - 6
demo/rp2040/cherryusb/usb_config.h

@@ -8,14 +8,13 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
-// #define CONFIG_USB_DBG_LEVEL USB_DBG_LOG
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
-// #define CONFIG_USB_DBG_LEVEL -1
-#endif
-
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
 #endif
 
 /* Enable print with color */

+ 5 - 4
demo/stm32/usb_device/stm32f103c8t6/Core/Inc/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 5 - 4
demo/stm32/usb_device/stm32f429igt6/Core/Inc/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 5 - 4
demo/stm32/usb_device/stm32h743vbt6/Core/Inc/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 5 - 4
demo/stm32/usb_host/stm32f429igt6/Core/Inc/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE
 

+ 5 - 4
demo/stm32/usb_host/stm32h743xih6/Core/Inc/usb_config.h

@@ -8,14 +8,15 @@
 
 /* ================ USB common Configuration ================ */
 
+#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__)
+
+#define usb_malloc(size) malloc(size)
+#define usb_free(ptr)    free(ptr)
+
 #ifndef CONFIG_USB_DBG_LEVEL
 #define CONFIG_USB_DBG_LEVEL USB_DBG_INFO
 #endif
 
-#ifndef CONFIG_USB_PRINTF
-#define CONFIG_USB_PRINTF printf
-#endif
-
 /* Enable print with color */
 #define CONFIG_USB_PRINTF_COLOR_ENABLE