From 66db88b7cd7aa7eac522d2c0e940947d2cbf391d Mon Sep 17 00:00:00 2001 From: sakimisu <1203593632@qq.com> Date: Sun, 6 Nov 2022 16:31:34 +0800 Subject: [PATCH] move malloc,free,printf macro into config.h --- cherryusb_config_template.h | 9 +++++---- common/usb_log.h | 11 ++--------- common/usb_mem.h | 19 ------------------- .../usb_device/ES32F369x/Inc/usb_config.h | 9 +++++---- demo/es32/usb_host/ES32F369x/Inc/usb_config.h | 9 +++++---- demo/hpm/usb_device/src/usb_config.h | 9 +++++---- demo/rp2040/cherryusb/usb_config.h | 13 ++++++------- .../stm32f103c8t6/Core/Inc/usb_config.h | 9 +++++---- .../stm32f429igt6/Core/Inc/usb_config.h | 9 +++++---- .../stm32h743vbt6/Core/Inc/usb_config.h | 9 +++++---- .../stm32f429igt6/Core/Inc/usb_config.h | 9 +++++---- .../stm32h743xih6/Core/Inc/usb_config.h | 9 +++++---- 12 files changed, 53 insertions(+), 71 deletions(-) diff --git a/cherryusb_config_template.h b/cherryusb_config_template.h index 0b30f64b..589937a1 100644 --- a/cherryusb_config_template.h +++ b/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 diff --git a/common/usb_log.h b/common/usb_log.h index 45ad9e17..4d1eff84 100644 --- a/common/usb_log.h +++ b/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 */ \ No newline at end of file diff --git a/common/usb_mem.h b/common/usb_mem.h index 17b8c950..77a82bb8 100644 --- a/common/usb_mem.h +++ b/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) diff --git a/demo/es32/usb_device/ES32F369x/Inc/usb_config.h b/demo/es32/usb_device/ES32F369x/Inc/usb_config.h index d7fc7270..f36817b6 100644 --- a/demo/es32/usb_device/ES32F369x/Inc/usb_config.h +++ b/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 diff --git a/demo/es32/usb_host/ES32F369x/Inc/usb_config.h b/demo/es32/usb_host/ES32F369x/Inc/usb_config.h index 078010e6..dc85de3b 100644 --- a/demo/es32/usb_host/ES32F369x/Inc/usb_config.h +++ b/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 diff --git a/demo/hpm/usb_device/src/usb_config.h b/demo/hpm/usb_device/src/usb_config.h index ff2ec878..824bb5dd 100644 --- a/demo/hpm/usb_device/src/usb_config.h +++ b/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 diff --git a/demo/rp2040/cherryusb/usb_config.h b/demo/rp2040/cherryusb/usb_config.h index 34fb3409..545fa1bd 100644 --- a/demo/rp2040/cherryusb/usb_config.h +++ b/demo/rp2040/cherryusb/usb_config.h @@ -8,14 +8,13 @@ /* ================ USB common Configuration ================ */ -#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 +#define CONFIG_USB_PRINTF(...) printf(__VA_ARGS__) -#ifndef CONFIG_USB_PRINTF -#define CONFIG_USB_PRINTF printf +#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 /* Enable print with color */ diff --git a/demo/stm32/usb_device/stm32f103c8t6/Core/Inc/usb_config.h b/demo/stm32/usb_device/stm32f103c8t6/Core/Inc/usb_config.h index d7fc7270..f36817b6 100644 --- a/demo/stm32/usb_device/stm32f103c8t6/Core/Inc/usb_config.h +++ b/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 diff --git a/demo/stm32/usb_device/stm32f429igt6/Core/Inc/usb_config.h b/demo/stm32/usb_device/stm32f429igt6/Core/Inc/usb_config.h index d7fc7270..f36817b6 100644 --- a/demo/stm32/usb_device/stm32f429igt6/Core/Inc/usb_config.h +++ b/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 diff --git a/demo/stm32/usb_device/stm32h743vbt6/Core/Inc/usb_config.h b/demo/stm32/usb_device/stm32h743vbt6/Core/Inc/usb_config.h index d7fc7270..f36817b6 100644 --- a/demo/stm32/usb_device/stm32h743vbt6/Core/Inc/usb_config.h +++ b/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 diff --git a/demo/stm32/usb_host/stm32f429igt6/Core/Inc/usb_config.h b/demo/stm32/usb_host/stm32f429igt6/Core/Inc/usb_config.h index 796311dd..67488137 100644 --- a/demo/stm32/usb_host/stm32f429igt6/Core/Inc/usb_config.h +++ b/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 diff --git a/demo/stm32/usb_host/stm32h743xih6/Core/Inc/usb_config.h b/demo/stm32/usb_host/stm32h743xih6/Core/Inc/usb_config.h index 796311dd..67488137 100644 --- a/demo/stm32/usb_host/stm32h743xih6/Core/Inc/usb_config.h +++ b/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