From 0f8ec31981f3c8a0b3099e2cada5680f9d5694e1 Mon Sep 17 00:00:00 2001 From: sakumisu <1203593632@qq.com> Date: Sat, 22 Jun 2024 18:46:02 +0800 Subject: update rst for malloc free --- docs/source/quick_start/other_chip.rst | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/docs/source/quick_start/other_chip.rst b/docs/source/quick_start/other_chip.rst index cb0832c7..ada557dc 100644 --- a/docs/source/quick_start/other_chip.rst +++ b/docs/source/quick_start/other_chip.rst @@ -1,7 +1,22 @@ 芯片通用移植指南 ========================= -本节主要介绍所有带 USB IP 的芯片,移植 CherryUSB 主从协议栈时的通用步骤和注意事项。在往下看之前,需要 **你准备好一个可以打印 helloworld 的基本工程** ,并且实现了 `printf` 、 `malloc`、 `free`。如果是主机,需要 **准备好可以打印 helloworld 的带 OS 的工程**。 +本节主要介绍所有带 USB IP 的芯片,移植 CherryUSB 主从协议栈时的通用步骤和注意事项。在往下看之前,需要 **你准备好一个可以打印 helloworld 的基本工程** ,并且实现了 `printf` 、 `malloc`、 `free`。如果是主机,需要 **准备好可以打印 helloworld 的带 OS 的工程**。通常来说, `printf` 大家都会实现, +`malloc`、 `free` 主要给主机使用, 默认 config 文件使用的就是 `malloc`、 `free`,推荐修改为 os 相关接口, 不推荐使用系统库,尤其是 keil 自带的这种。举例如下: + +.. code-block:: C + + // default config + #define usb_malloc(size) malloc(size) + #define usb_free(ptr) free(ptr) + + // freertos + #define usb_malloc(size) pvPortMalloc(size) + #define usb_free(ptr) vPortFree(ptr) + + //rtthread + #define usb_malloc(size) rt_malloc(size) + #define usb_free(ptr) rt_free(ptr) USB Device 移植要点 ----------------------- -- cgit v1.3.1