add XiUOS/stm32f103-nano board support, feat shell and docs stack-heap-optimize advice
|
@ -1,11 +1,11 @@
|
|||
ifeq ($(CONFIG_BOARD_CORTEX_M3_EVB),y)
|
||||
SRC_FILES := boot.c
|
||||
SRC_FILES := boot.c interrupt_vector_evb.S
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_BOARD_STM32F103_NANO),y)
|
||||
SRC_FILES := boot.S
|
||||
SRC_FILES := boot.S interrupt_vector_nano.S
|
||||
endif
|
||||
|
||||
SRC_FILES += interrupt.c interrupt_vector.S
|
||||
SRC_FILES += interrupt.c
|
||||
|
||||
include $(KERNEL_ROOT)/compiler.mk
|
||||
|
|
|
@ -15,12 +15,20 @@
|
|||
|
||||
#include <xs_base.h>
|
||||
|
||||
#ifdef BOARD_CORTEX_M3_EVB
|
||||
#define ARCH_MAX_IRQ_NUM (256)
|
||||
#endif
|
||||
|
||||
#ifdef BOARD_STM32F103_NANO
|
||||
#define ARCH_MAX_IRQ_NUM (64)
|
||||
#endif
|
||||
|
||||
#define ARCH_IRQ_NUM_OFFSET 0
|
||||
|
||||
#ifdef BOARD_CORTEX_M3_EVB
|
||||
#define SYSTICK_IRQN 15
|
||||
#define UART1_IRQn 21
|
||||
#endif
|
||||
|
||||
int32 ArchEnableHwIrq(uint32 irq_num);
|
||||
int32 ArchDisableHwIrq(uint32 irq_num);
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
//*****************************************************************************
|
||||
|
||||
/**
|
||||
* @file interrupt_vector.S
|
||||
* @file interrupt_vector_evb.S
|
||||
* @brief derived from Stellaris Firmware Development Package
|
||||
* @version 1.0
|
||||
* @author AIIT XUOS Lab
|
||||
|
@ -46,7 +46,7 @@
|
|||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: interrupt_vector.S
|
||||
File name: interrupt_vector_evb.S
|
||||
Description: vector table for a Cortex M3
|
||||
Others:
|
||||
History:
|
||||
|
@ -87,7 +87,7 @@ InterruptVectors:
|
|||
.word IsrEntry //DebugMon_Handler
|
||||
.word IsrEntry
|
||||
.word PendSV_Handler
|
||||
.word IsrEntry //systick
|
||||
.word SysTick_Handler //systick
|
||||
.word IsrEntry // GPIO Port A
|
||||
.word IsrEntry // GPIO Port B
|
||||
.word IsrEntry // GPIO Port C
|
|
@ -0,0 +1,130 @@
|
|||
/**
|
||||
*************** (C) COPYRIGHT 2017 STMicroelectronics ************************
|
||||
* @file startup_stm32f103xb.s
|
||||
* @author MCD Application Team
|
||||
* @brief STM32F103xB Devices vector table for Atollic toolchain.
|
||||
* This module performs:
|
||||
* - Set the initial SP
|
||||
* - Set the initial PC == Reset_Handler,
|
||||
* - Set the vector table entries with the exceptions ISR address
|
||||
* - Configure the clock system
|
||||
* - Branches to main in the C library (which eventually
|
||||
* calls main()).
|
||||
* After Reset the Cortex-M3 processor is in Thread mode,
|
||||
* priority is Privileged, and the Stack is set to Main.
|
||||
******************************************************************************
|
||||
* @attention
|
||||
*
|
||||
* <h2><center>© Copyright (c) 2017 STMicroelectronics.
|
||||
* All rights reserved.</center></h2>
|
||||
*
|
||||
* This software component is licensed by ST under BSD 3-Clause license,
|
||||
* the "License"; You may not use this file except in compliance with the
|
||||
* License. You may obtain a copy of the License at:
|
||||
* opensource.org/licenses/BSD-3-Clause
|
||||
*
|
||||
******************************************************************************
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file interrupt_vector_nano.S
|
||||
* @brief derived from Stellaris Firmware Development Package
|
||||
* @version 1.1
|
||||
* @author AIIT XUOS Lab
|
||||
* @date 2021-12-02
|
||||
*/
|
||||
|
||||
/*************************************************
|
||||
File name: interrupt_vector_nano.S
|
||||
Description: vector table for a stm32f103xb
|
||||
Others:
|
||||
History:
|
||||
1. Date: 2021-12-02
|
||||
Author: AIIT XUOS Lab
|
||||
Modification:
|
||||
1. take startup_stm32f103xb.s for XiUOS reference
|
||||
*************************************************/
|
||||
|
||||
|
||||
//*****************************************************************************
|
||||
//
|
||||
// The vector table. Note that the proper constructs must be placed on this to
|
||||
// ensure that it ends up at physical address 0x0000.0000.
|
||||
//
|
||||
//*****************************************************************************
|
||||
.globl InterruptVectors
|
||||
|
||||
/******************************************************************************
|
||||
*******************************************************************************/
|
||||
.section .isr_vector,"a",%progbits
|
||||
.type InterruptVectors, %object
|
||||
.size InterruptVectors, .-InterruptVectors
|
||||
|
||||
InterruptVectors:
|
||||
.word _sp
|
||||
.word Reset_Handler
|
||||
.word NMI_Handler
|
||||
.word HardFaultHandler
|
||||
.word MemFaultHandler
|
||||
.word BusFault_Handler
|
||||
.word UsageFault_Handler
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word 0
|
||||
.word PendSV_Handler
|
||||
.word SysTick_Handler
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word UartIsr1
|
||||
.word IsrEntry //UartIsr2
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word IsrEntry
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
||||
.word 0
|
|
@ -15,7 +15,9 @@
|
|||
#include <xs_assign.h>
|
||||
#include "svc_handle.h"
|
||||
#include <board.h>
|
||||
#ifdef TOOL_SHELL
|
||||
#include <shell.h>
|
||||
#endif
|
||||
|
||||
#if (defined ( __GNUC__ ) && defined ( __VFP_FP__ ) && !defined(__SOFTFP__))
|
||||
#define USE_FPU 1
|
||||
|
|
|
@ -129,20 +129,20 @@ CONFIG_SHELL_HELP_SHOW_PERMISSION=y
|
|||
# CONFIG_SHELL_HELP_LIST_USER is not set
|
||||
# CONFIG_SHELL_HELP_LIST_VAR is not set
|
||||
# CONFIG_SHELL_HELP_LIST_KEY is not set
|
||||
CONFIG_KERNEL_QUEUEMANAGE=y
|
||||
CONFIG_KERNEL_WORKQUEUE=y
|
||||
CONFIG_WORKQUEUE_KTASK_STACKSIZE=512
|
||||
CONFIG_WORKQUEUE_KTASK_PRIORITY=23
|
||||
CONFIG_KERNEL_WAITQUEUE=y
|
||||
CONFIG_KERNEL_DATAQUEUE=y
|
||||
# CONFIG_KERNEL_QUEUEMANAGE is not set
|
||||
# CONFIG_KERNEL_WORKQUEUE is not set
|
||||
# CONFIG_WORKQUEUE_KTASK_STACKSIZE is not set
|
||||
# CONFIG_WORKQUEUE_KTASK_PRIORITY is not set
|
||||
# CONFIG_KERNEL_WAITQUEUE is not set
|
||||
# CONFIG_KERNEL_DATAQUEUE is not set
|
||||
# CONFIG_KERNEL_CIRCULAR_AREA is not set
|
||||
# CONFIG_KERNEL_AVL_TREE is not set
|
||||
CONFIG_NAME_MAX=8
|
||||
CONFIG_ALIGN_SIZE=4
|
||||
CONFIG_KERNEL_COMPONENTS_INIT=y
|
||||
CONFIG_KERNEL_USER_MAIN=y
|
||||
CONFIG_MAIN_KTASK_STACK_SIZE=2048
|
||||
CONFIG_ENV_INIT_KTASK_STACK_SIZE=8192
|
||||
CONFIG_MAIN_KTASK_STACK_SIZE=256
|
||||
CONFIG_ENV_INIT_KTASK_STACK_SIZE=1024
|
||||
CONFIG_MAIN_KTASK_PRIORITY=10
|
||||
# CONFIG_USER_TEST is not set
|
||||
# CONFIG_TOOL_TEST_SEM is not set
|
||||
|
|
|
@ -122,29 +122,63 @@ XiUOS板级驱动当前支持使用GPIO、UART。
|
|||
### 编译工具链:`arm-none-eabi-gcc`
|
||||
使用`VScode`打开工程的方法有多种,本文介绍一种快捷键,在项目目录下将`code .`输入linux系统命令终端即可打开目标项目
|
||||
|
||||
修改`applications`文件夹下`main.c`
|
||||
在输出函数中写入 `Hello, world!!! \n Running on stm32f103-nano`完成代码编辑。
|
||||
修改`APP_Framework/Applications`文件夹下`main.c`
|
||||
在输出函数中写入 `Hello, world!`完成代码编辑。
|
||||
|
||||

|
||||
|
||||
编译步骤:
|
||||
|
||||
1.在VScode命令终端中执行以下命令,生成配置文件
|
||||
1.在VScode命令终端中执行以下命令,生成配置文件。
|
||||
|
||||
```c
|
||||
make BOARD=stm32f103-nano distclean
|
||||
make BOARD=stm32f103-nano menuconfig
|
||||
```
|
||||
|
||||
2.在menuconfig界面配置需要关闭和开启的功能,按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后保存并退出(本例旨在演示简单的输出例程,所以没有需要配置的选项,双击快捷键ESC退出配置)
|
||||
2.在menuconfig界面配置需要关闭和开启的功能,按回车键进入下级菜单,按Y键选中需要开启的功能,按N键选中需要关闭的功能,配置结束后保存并退出(本例旨在演示简单的输出例程,所以没有需要配置的选项,双击快捷键ESC退出配置)。
|
||||
|
||||

|
||||
|
||||
退出时选择`yes`保存上面所配置的内容,如下图所示:
|
||||
|
||||

|
||||

|
||||
|
||||
3.继续执行以下命令,进行编译
|
||||
3.需要注意的是,stm32f103-nano开发板中CPU RAM大小为20KB,需要调整XiUOS中堆栈相关配置的默认值,避免出现超出堆栈大小而无法正常启动。
|
||||
|
||||
(1)ID hash table配置,ID num配置为16,减少.bss段大小;
|
||||
|
||||

|
||||
|
||||
(2)IPC feature配置,保留信号量、互斥锁等必需的进程间通信,关闭队列等未用到的方式;
|
||||
|
||||

|
||||
|
||||
(3)ENV task配置,该线程栈大小配置为1024;
|
||||
|
||||

|
||||
|
||||
(4)MAIN task配置,该线程栈大小配置为256;
|
||||
|
||||

|
||||
|
||||
(5)大内存分配页对齐配置,页对齐配置为1KB,减少页对齐后优化的ram空间,增加可分配的堆大小;
|
||||
|
||||

|
||||
|
||||
(6)SHELL task配置,该线程栈大小配置为4096,建议无优化空间时再选择减少SHELL线程栈大小,避免出现SHELL工作异常的情况;
|
||||
|
||||

|
||||
|
||||
(7)WORKQUEUE配置,若未用到工作队列,可关闭该功能,减少堆栈空间申请;
|
||||
|
||||

|
||||
|
||||
(7)ZOMBIE RECYCLE task配置 ,僵尸线程回收线程栈大小同样在无优化空间时可选择减少。
|
||||
|
||||

|
||||
|
||||
4.继续执行以下命令,进行编译
|
||||
|
||||
```c
|
||||
make BOARD=stm32f103-nano
|
||||
|
@ -160,9 +194,7 @@ stm32f103-nano开发板内置板载st-link SWD下载接口,连接USB后便可
|
|||
|
||||
### 烧写工具
|
||||
|
||||
ARM:ST-LINK(ST-LINK V2实物如图,可在购物网站搜索关键字购买)
|
||||
|
||||

|
||||
ARM:ST-LINK, stm32f103-nano 板卡内置st-link SWD, 因此无需额外外接工具,只需安装st-flash相关依赖驱动即可。
|
||||
|
||||
下载并以下执行命令以下命令安装st-link工具(本文使用v1.5.1版本)。
|
||||
|
||||
|
@ -180,29 +212,7 @@ cd build/Release && make install DESTDIR=_install
|
|||
代码根目录下执行st-flash工具烧录
|
||||
|
||||
```
|
||||
sudo st-flash write build/XiUOS_stm32f103-nano.bin 0x8000000
|
||||
```
|
||||
|
||||
此外,推荐用户使用putty作为终端工具,安装命令如下:
|
||||
|
||||
```c
|
||||
sudo apt install putty
|
||||
```
|
||||
|
||||
打开putty配置串口信息
|
||||
|
||||
```c
|
||||
sudo puty
|
||||
```
|
||||
|
||||
选择ttyUSB0(这个端口号根据具体情况而定),配置波特率为115200。
|
||||
|
||||

|
||||
|
||||
注意:选择正确的终端端口号,最后可以执行以下命令,清除配置文件和编译生成的文件
|
||||
|
||||
```c
|
||||
make BOARD=stm32f103-nano distclean
|
||||
sudo st-flash write build/XiUOS_stm32f103-nano.bin 0x8000000
|
||||
```
|
||||
|
||||
### 3.1 运行结果
|
||||
|
|
|
@ -75,7 +75,7 @@ void SysTick_Handler(int irqn, void *arg)
|
|||
{
|
||||
TickAndTaskTimesliceUpdate();
|
||||
}
|
||||
DECLARE_HW_IRQ(SYSTICK_IRQN, SysTick_Handler, NONE);
|
||||
|
||||
|
||||
void InitBoardHardware()
|
||||
{
|
||||
|
|
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 25 KiB |
After Width: | Height: | Size: 12 KiB |
After Width: | Height: | Size: 14 KiB |
After Width: | Height: | Size: 18 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 13 KiB |
After Width: | Height: | Size: 90 KiB |
After Width: | Height: | Size: 35 KiB |
After Width: | Height: | Size: 21 KiB |
After Width: | Height: | Size: 1.2 MiB |
After Width: | Height: | Size: 20 KiB |
|
@ -11,7 +11,7 @@ MEMORY
|
|||
OUTPUT_ARCH(arm)
|
||||
|
||||
ENTRY(Reset_Handler)
|
||||
_system_stack_size = 0x1000;
|
||||
_system_stack_size = 0x200;
|
||||
|
||||
SECTIONS
|
||||
{
|
||||
|
|
|
@ -105,7 +105,6 @@ void UartIsr1(int vector, void *param)
|
|||
/* get serial bus 1 */
|
||||
UartHandler(&serial_bus_1, &serial_driver_1);
|
||||
}
|
||||
DECLARE_HW_IRQ(USART1_IRQn, UartIsr1, NONE);
|
||||
#endif
|
||||
|
||||
#ifdef BSP_USING_UART2
|
||||
|
@ -114,7 +113,6 @@ void UartIsr2(int vector, void *param)
|
|||
/* get serial bus 2 */
|
||||
UartHandler(&serial_bus_2, &serial_driver_2);
|
||||
}
|
||||
DECLARE_HW_IRQ(USART2_IRQn, UartIsr2, NONE);
|
||||
#endif
|
||||
|
||||
static uint32 SerialInit(struct SerialDriver *serial_drv, struct BusConfigureInfo *configure_info)
|
||||
|
|
|
@ -103,7 +103,7 @@ x_err_t _StartRun(TimerType timer)
|
|||
return EOK;
|
||||
}
|
||||
|
||||
// Just stop working, don't free memory
|
||||
// Just stop working, don't x_free memory
|
||||
x_err_t _QuitRun(TimerType timer)
|
||||
{
|
||||
x_base lock = 0;
|
||||
|
@ -246,7 +246,7 @@ static void TimerCBEnter(void *param)
|
|||
struct Timer *t = (struct Timer *)param;
|
||||
|
||||
t->func_callback(t->param);
|
||||
free(t->t_work);
|
||||
x_free(t->t_work);
|
||||
}
|
||||
|
||||
void timer_work_func(struct Work *work, void *work_data)
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
|
||||
menuconfig RESOURCES_SERIAL
|
||||
bool "Using SERIAL bus drivers"
|
||||
select KERNEL_WORKQUEUE
|
||||
default y
|
||||
|
||||
if RESOURCES_SERIAL
|
||||
|
|
|
@ -382,18 +382,18 @@ static uint32 SerialDevOpen(void *dev)
|
|||
|
||||
if (NONE == serial_dev->serial_fifo.serial_rx) {
|
||||
if (SIGN_OPER_INT_RX & serial_dev_param->serial_set_mode) {
|
||||
serial_dev->serial_fifo.serial_rx = (struct SerialRx *)malloc(sizeof(struct SerialRx));
|
||||
serial_dev->serial_fifo.serial_rx = (struct SerialRx *)x_malloc(sizeof(struct SerialRx));
|
||||
if (NONE == serial_dev->serial_fifo.serial_rx) {
|
||||
KPrintf("SerialDevOpen malloc serial_rx error\n");
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
KPrintf("SerialDevOpen x_malloc serial_rx error\n");
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)malloc(serial_cfg->data_cfg.serial_buffer_size);
|
||||
serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)x_malloc(serial_cfg->data_cfg.serial_buffer_size);
|
||||
if (NONE == serial_dev->serial_fifo.serial_rx->serial_rx_buffer) {
|
||||
KPrintf("SerialDevOpen malloc serial_rx_buffer error\n");
|
||||
free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
KPrintf("SerialDevOpen x_malloc serial_rx_buffer error\n");
|
||||
x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
@ -409,27 +409,27 @@ static uint32 SerialDevOpen(void *dev)
|
|||
#ifdef SERIAL_USING_DMA
|
||||
else if (SIGN_OPER_DMA_RX & serial_dev_param->serial_set_mode) {
|
||||
if (0 == serial_cfg->data_cfg.serial_buffer_size) {
|
||||
serial_dev->serial_fifo.serial_rx = (struct SerialRx *)malloc(sizeof(struct SerialRx));
|
||||
serial_dev->serial_fifo.serial_rx = (struct SerialRx *)x_malloc(sizeof(struct SerialRx));
|
||||
if (NONE == serial_dev->serial_fifo.serial_rx) {
|
||||
KPrintf("SerialDevOpen DMA buffer 0 malloc serial_rx error\n");
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
KPrintf("SerialDevOpen DMA buffer 0 x_malloc serial_rx error\n");
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
return ERROR;
|
||||
}
|
||||
serial_dev->serial_fifo.serial_rx->serial_dma_enable = RET_FALSE;
|
||||
serial_dev_param->serial_work_mode |= SIGN_OPER_DMA_RX;
|
||||
} else {
|
||||
serial_dev->serial_fifo.serial_rx = (struct SerialRx *)malloc(sizeof(struct SerialRx));
|
||||
serial_dev->serial_fifo.serial_rx = (struct SerialRx *)x_malloc(sizeof(struct SerialRx));
|
||||
if (NONE == serial_dev->serial_fifo.serial_rx) {
|
||||
KPrintf("SerialDevOpen DMA malloc serial_rx error\n");
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
KPrintf("SerialDevOpen DMA x_malloc serial_rx error\n");
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)malloc(serial_cfg->data_cfg.serial_buffer_size);
|
||||
serial_dev->serial_fifo.serial_rx->serial_rx_buffer = (uint8 *)x_malloc(serial_cfg->data_cfg.serial_buffer_size);
|
||||
if (NONE == serial_dev->serial_fifo.serial_rx->serial_rx_buffer) {
|
||||
KPrintf("SerialDevOpen DMA malloc serial_rx_buffer error\n");
|
||||
free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
KPrintf("SerialDevOpen DMA x_malloc serial_rx_buffer error\n");
|
||||
x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
@ -460,10 +460,10 @@ static uint32 SerialDevOpen(void *dev)
|
|||
|
||||
if (NONE == serial_dev->serial_fifo.serial_tx) {
|
||||
if (SIGN_OPER_INT_TX & serial_dev_param->serial_set_mode) {
|
||||
serial_dev->serial_fifo.serial_tx = (struct SerialTx *)malloc(sizeof(struct SerialTx));
|
||||
serial_dev->serial_fifo.serial_tx = (struct SerialTx *)x_malloc(sizeof(struct SerialTx));
|
||||
if (NONE == serial_dev->serial_fifo.serial_tx) {
|
||||
KPrintf("SerialDevOpen malloc serial_tx error\n");
|
||||
free(serial_dev->serial_fifo.serial_tx);
|
||||
KPrintf("SerialDevOpen x_malloc serial_tx error\n");
|
||||
x_free(serial_dev->serial_fifo.serial_tx);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
@ -475,10 +475,10 @@ static uint32 SerialDevOpen(void *dev)
|
|||
}
|
||||
#ifdef SERIAL_USING_DMA
|
||||
else if (SIGN_OPER_DMA_TX & serial_dev_param->serial_set_mode) {
|
||||
serial_dev->serial_fifo.serial_tx = (struct SerialTx *)malloc(sizeof(struct SerialTx));
|
||||
serial_dev->serial_fifo.serial_tx = (struct SerialTx *)x_malloc(sizeof(struct SerialTx));
|
||||
if (NONE == serial_dev->serial_fifo.serial_tx) {
|
||||
KPrintf("SerialDevOpen DMA malloc serial_tx error\n");
|
||||
free(serial_dev->serial_fifo.serial_tx);
|
||||
KPrintf("SerialDevOpen DMA x_malloc serial_tx error\n");
|
||||
x_free(serial_dev->serial_fifo.serial_tx);
|
||||
return ERROR;
|
||||
}
|
||||
|
||||
|
@ -511,13 +511,13 @@ static uint32 SerialDevOpen(void *dev)
|
|||
KPrintf("SerialDevOpen create sem failed .\n");
|
||||
|
||||
if (serial_dev->serial_fifo.serial_rx->serial_rx_buffer) {
|
||||
free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
}
|
||||
if (serial_dev->serial_fifo.serial_rx) {
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
}
|
||||
if (serial_dev->serial_fifo.serial_tx) {
|
||||
free(serial_dev->serial_fifo.serial_tx);
|
||||
x_free(serial_dev->serial_fifo.serial_tx);
|
||||
}
|
||||
|
||||
return ERROR;
|
||||
|
@ -540,8 +540,8 @@ static uint32 SerialDevClose(void *dev)
|
|||
if (SIGN_OPER_INT_RX & serial_dev_param->serial_work_mode) {
|
||||
NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx);
|
||||
free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
|
||||
serial_drv->drv_done->configure(serial_drv, serial_operation_cmd);
|
||||
}
|
||||
|
@ -550,12 +550,12 @@ static uint32 SerialDevClose(void *dev)
|
|||
if(0 == serial_cfg->data_cfg.serial_buffer_size)
|
||||
{
|
||||
NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx);
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
} else {
|
||||
NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_rx);
|
||||
free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
free(serial_dev->serial_fifo.serial_rx);
|
||||
x_free(serial_dev->serial_fifo.serial_rx->serial_rx_buffer);
|
||||
x_free(serial_dev->serial_fifo.serial_rx);
|
||||
}
|
||||
|
||||
serial_drv->drv_done->configure(serial_drv, serial_operation_cmd);
|
||||
|
@ -564,14 +564,14 @@ static uint32 SerialDevClose(void *dev)
|
|||
|
||||
if (SIGN_OPER_INT_TX & serial_dev_param->serial_work_mode) {
|
||||
NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_tx);
|
||||
free(serial_dev->serial_fifo.serial_tx);
|
||||
x_free(serial_dev->serial_fifo.serial_tx);
|
||||
|
||||
serial_drv->drv_done->configure(serial_drv, serial_operation_cmd);
|
||||
}
|
||||
#ifdef SERIAL_USING_DMA
|
||||
else if (SIGN_OPER_DMA_TX & serial_dev_param->serial_work_mode) {
|
||||
NULL_PARAM_CHECK(serial_dev->serial_fifo.serial_tx);
|
||||
free(serial_dev->serial_fifo.serial_tx);
|
||||
x_free(serial_dev->serial_fifo.serial_tx);
|
||||
|
||||
serial_drv->drv_done->configure(serial_drv, serial_operation_cmd);
|
||||
}
|
||||
|
|