重写BSP
This commit is contained in:
parent
957efa64ab
commit
d963759f90
@ -1,131 +1,26 @@
|
|||||||
#ifndef __BOARD_H__
|
#ifndef __BOARD_H__
|
||||||
#define __BOARD_H__
|
#define __BOARD_H__
|
||||||
|
|
||||||
|
/* MCU INCLUDE */
|
||||||
#include <stm32f10x.h>
|
#include <stm32f10x.h>
|
||||||
|
|
||||||
#define VERSION "v1.0.0"
|
/* PERIPH INCLUDE */
|
||||||
|
#include "Gpio.h"
|
||||||
/* **********NVIC中断向量控制器组别********** */
|
#include "Usart.h"
|
||||||
#define NVIC_GROUP_LEVEL NVIC_PriorityGroup_2
|
#include "Interrupt.h"
|
||||||
/* **********END********** */
|
#include "Flash.h"
|
||||||
|
|
||||||
/* 使用OS,ThreadX */
|
|
||||||
#define USE_THREADX
|
|
||||||
|
|
||||||
/* **********SystemClock相关********** */
|
|
||||||
// GPIO
|
|
||||||
#define GPIO_ENABLE
|
|
||||||
#define USE_GPIOA
|
|
||||||
#define USE_GPIOB
|
|
||||||
#define USE_GPIOC
|
|
||||||
#define USE_GPIOD
|
|
||||||
#define USE_GPIOE
|
|
||||||
#define USE_GPIOF
|
|
||||||
#define USE_GPIOG
|
|
||||||
// USART
|
|
||||||
#define USART_ENABLE
|
|
||||||
#define USE_USART1
|
|
||||||
#undef USE_USART2
|
|
||||||
#undef USE_USART3
|
|
||||||
#undef USE_USART4
|
|
||||||
#undef USE_USART5
|
|
||||||
#undef USE_USART6
|
|
||||||
/* **********END********** */
|
|
||||||
|
|
||||||
/* **********GPIO DO DI相关********** */
|
|
||||||
// 数字输出
|
|
||||||
#undef USE_DIGITAL_OUTPUT
|
|
||||||
#ifdef USE_DIGITAL_OUTPUT
|
|
||||||
#define DO_NUM 2
|
|
||||||
#define DO1 0
|
|
||||||
#define DO2 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// 数字输入
|
|
||||||
#undef USE_DIGITAL_INPUT
|
|
||||||
#ifdef USE_DIGITAL_INPUT
|
|
||||||
#define DI_NUM 2
|
|
||||||
#define DI1 0
|
|
||||||
#define DI2 1
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// LED灯
|
|
||||||
#define USE_LED
|
|
||||||
#ifdef USE_LED
|
|
||||||
#define LED_NUM 3
|
|
||||||
#define LED0 0
|
|
||||||
#define LED1 1
|
|
||||||
#define LED2 2
|
|
||||||
#endif
|
|
||||||
/* **********END********** */
|
|
||||||
|
|
||||||
/* **********串口相关********** */
|
|
||||||
#ifdef USE_USART1
|
|
||||||
#define COM0 USART1_BASE
|
|
||||||
#define COM0_IRQN USART1_IRQn
|
|
||||||
#define COM0_TX_PORT GPIOA
|
|
||||||
#define COM0_RX_PORT GPIOA
|
|
||||||
#define COM0_TX_PIN GPIO_Pin_9
|
|
||||||
#define COM0_RX_PIN GPIO_Pin_10
|
|
||||||
#endif
|
|
||||||
#ifdef USE_USART2
|
|
||||||
#define COM1 USART2_BASE
|
|
||||||
#define COM1_IRQN USART2_IRQn
|
|
||||||
#define COM1_TX_PORT GPIOA
|
|
||||||
#define COM1_RX_PORT GPIOA
|
|
||||||
#define COM1_TX_PIN GPIO_Pin_2
|
|
||||||
#define COM1_RX_PIN GPIO_Pin_3
|
|
||||||
#endif
|
|
||||||
#ifdef USE_USART3
|
|
||||||
#define COM2 USART3_BASE
|
|
||||||
#define COM2_IRQN USART3_IRQn
|
|
||||||
#define COM2_TX_PORT GPIOB
|
|
||||||
#define COM2_RX_PORT GPIOB
|
|
||||||
#define COM2_TX_PIN GPIO_Pin_10
|
|
||||||
#define COM2_RX_PIN GPIO_Pin_11
|
|
||||||
#endif
|
|
||||||
#ifdef USE_USART4
|
|
||||||
#define COM3 UART4_BASE
|
|
||||||
#define COM3_IRQN UART4_IRQn
|
|
||||||
#define COM3_TX_PORT GPIOC
|
|
||||||
#define COM3_RX_PORT GPIOC
|
|
||||||
#define COM3_TX_PIN GPIO_Pin_10
|
|
||||||
#define COM3_RX_PIN GPIO_Pin_11
|
|
||||||
#endif
|
|
||||||
#ifdef USE_USART5
|
|
||||||
#define COM4 UART5_BASE
|
|
||||||
#define COM4_IRQN UART5_IRQn
|
|
||||||
#define COM4_TX_PORT GPIOB
|
|
||||||
#define COM4_RX_PORT GPIOD
|
|
||||||
#define COM4_TX_PIN GPIO_Pin_12
|
|
||||||
#define COM4_RX_PIN GPIO_Pin_2
|
|
||||||
#endif
|
|
||||||
/* LetterShell */
|
|
||||||
#define USE_SHELL
|
|
||||||
#ifdef USE_SHELL
|
|
||||||
#define TTY_COM COM0
|
|
||||||
#define TTY_COM_IRQN COM0_IRQN
|
|
||||||
#endif
|
|
||||||
/* **********END********** */
|
|
||||||
|
|
||||||
#define USE_ANALOG_INPUT
|
|
||||||
#define USE_ANALOG_OUTPUT
|
|
||||||
|
|
||||||
|
|
||||||
/* 自定义Flash布局相关 */
|
/* VERSION INFO */
|
||||||
#define BOOT_SIZE_16 /* 16Kb的Bootloader大小 不带网络*/
|
#define HARDWARE_VERSION "v1.0.0"
|
||||||
//#define BOOT_SIZE_32 /* 32Kb的Bootloader大小 带网络*/
|
#define SOFTWARE_VERSION "v1.0.0"
|
||||||
|
|
||||||
#define FLASH_BASE_ADDR 0x08000000 //Flash基地址
|
/* RTOS */
|
||||||
#define BOOT_ADDR 0x08000000 //引导程序地址
|
#define USE_RTOS
|
||||||
//BOOT程序大小
|
#ifdef USE_RTOS
|
||||||
#ifdef BOOT_SIZE_16
|
#undef USE_FREERTOS
|
||||||
#define BOOT_ROM 0x4000
|
#undef USE_UCOS
|
||||||
|
#define USE_THREADX
|
||||||
#endif
|
#endif
|
||||||
#ifdef BOOT_SIZE_32
|
|
||||||
#define BOOT_ROM 0x8000
|
|
||||||
#endif
|
|
||||||
#define USER_PARAM_ADDR (FLASH_BASE_ADDR + BOOT_ROM) //用户参数分区
|
|
||||||
#define APPLICATION_ADDR 0x08010000 //从128K的位置开始是应用程序
|
|
||||||
/* **********END********** */
|
|
||||||
#endif
|
#endif
|
||||||
|
20
App/Board/Flash.h
Normal file
20
App/Board/Flash.h
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
#ifndef __FLASH_H__
|
||||||
|
#define __FLASH_H__
|
||||||
|
|
||||||
|
///* 自定义Flash布局相关 */
|
||||||
|
//#define BOOT_SIZE_16 /* 16Kb的Bootloader大小 不带网络*/
|
||||||
|
////#define BOOT_SIZE_32 /* 32Kb的Bootloader大小 带网络*/
|
||||||
|
|
||||||
|
//#define FLASH_BASE_ADDR 0x08000000 //Flash基地址
|
||||||
|
//#define BOOT_ADDR 0x08000000 //引导程序地址
|
||||||
|
////BOOT程序大小
|
||||||
|
//#ifdef BOOT_SIZE_16
|
||||||
|
// #define BOOT_ROM 0x4000
|
||||||
|
//#endif
|
||||||
|
//#ifdef BOOT_SIZE_32
|
||||||
|
// #define BOOT_ROM 0x8000
|
||||||
|
//#endif
|
||||||
|
//#define USER_PARAM_ADDR (FLASH_BASE_ADDR + BOOT_ROM) //用户参数分区
|
||||||
|
//#define APPLICATION_ADDR 0x08010000 //从128K的位置开始是应用程序
|
||||||
|
|
||||||
|
#endif
|
62
App/Board/Gpio.h
Normal file
62
App/Board/Gpio.h
Normal file
@ -0,0 +1,62 @@
|
|||||||
|
#ifndef __GPIO_H__
|
||||||
|
#define __GPIO_H__
|
||||||
|
|
||||||
|
/* MCU_GPIO_INFO */
|
||||||
|
#define GPIO_PORT_NUM 7 //共7组GPIO
|
||||||
|
#define GPIO_PIN_NUM 16 //每组16个Pin
|
||||||
|
|
||||||
|
//数组信号输出开关
|
||||||
|
#define DO_ON 0
|
||||||
|
#define DO_OFF 1
|
||||||
|
|
||||||
|
//LED灯开关
|
||||||
|
#define LED_ON 0
|
||||||
|
#define LED_OFF 1
|
||||||
|
|
||||||
|
//GPIO结构体
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
GPIO_TypeDef* GpioPort;
|
||||||
|
unsigned short GpioPin;
|
||||||
|
uint8_t DefaultStatus;
|
||||||
|
}GPIO_ST, *GPIO_ST_PTR;
|
||||||
|
|
||||||
|
/* **********SystemClock相关********** */
|
||||||
|
// GPIO
|
||||||
|
#define GPIO_ENABLE
|
||||||
|
#ifdef GPIO_ENABLE
|
||||||
|
#define USE_GPIOA
|
||||||
|
#define USE_GPIOB
|
||||||
|
#define USE_GPIOC
|
||||||
|
#define USE_GPIOD
|
||||||
|
#define USE_GPIOE
|
||||||
|
#define USE_GPIOF
|
||||||
|
#define USE_GPIOG
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* **********GPIO DO DI相关********** */
|
||||||
|
// 数字输出
|
||||||
|
#undef USE_DIGITAL_OUTPUT
|
||||||
|
#ifdef USE_DIGITAL_OUTPUT
|
||||||
|
#define DO_NUM 2
|
||||||
|
#define DO1 0
|
||||||
|
#define DO2 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// 数字输入
|
||||||
|
#undef USE_DIGITAL_INPUT
|
||||||
|
#ifdef USE_DIGITAL_INPUT
|
||||||
|
#define DI_NUM 2
|
||||||
|
#define DI1 0
|
||||||
|
#define DI2 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// LED灯
|
||||||
|
#define USE_LED
|
||||||
|
#ifdef USE_LED
|
||||||
|
#define LED_NUM 2
|
||||||
|
#define LED0 0
|
||||||
|
#define LED1 1
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
69
App/Board/Interrupt.h
Normal file
69
App/Board/Interrupt.h
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
#ifndef __INTERRUPT_H__
|
||||||
|
#define __INTERRUPT_H__
|
||||||
|
|
||||||
|
/* **********NVIC中断向量控制器组别********** */
|
||||||
|
#define NVIC_GROUP_LEVEL NVIC_PriorityGroup_2
|
||||||
|
/* **********END********** */
|
||||||
|
|
||||||
|
/* Control System Interrupt Sw */
|
||||||
|
#define DISABLE_INTERRUPT __set_PRIMASK(1);
|
||||||
|
#define ENABLE_INTERRUPT __set_PRIMASK(0);
|
||||||
|
|
||||||
|
#define INTERRUPT_NUM 300 //System Interrupt Num
|
||||||
|
|
||||||
|
#ifdef INTERRUPT_NUM
|
||||||
|
/* INTERRUPT_DESC_ST STRUCT */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
void(*CallBack)(unsigned int); //回调函数
|
||||||
|
unsigned int IntId; //触发中断的外设id
|
||||||
|
} INTERRUPT_DESC_ST;
|
||||||
|
|
||||||
|
/* INTERRUPT_ST STRUCT */
|
||||||
|
typedef struct
|
||||||
|
{
|
||||||
|
INTERRUPT_DESC_ST Adc_1_2;
|
||||||
|
INTERRUPT_DESC_ST Usb_Hp_Can1_Tx;
|
||||||
|
INTERRUPT_DESC_ST Usb_Hp_Can1_Rx0;
|
||||||
|
INTERRUPT_DESC_ST Can1_Rx1;
|
||||||
|
INTERRUPT_DESC_ST Can1_Sce;
|
||||||
|
INTERRUPT_DESC_ST Exti_9_5;
|
||||||
|
INTERRUPT_DESC_ST Tim_1_Brk;
|
||||||
|
INTERRUPT_DESC_ST Tim_1_Up;
|
||||||
|
INTERRUPT_DESC_ST Tim_1_Trg_Com;
|
||||||
|
INTERRUPT_DESC_ST Tim_1_Cc;
|
||||||
|
INTERRUPT_DESC_ST Tim_2;
|
||||||
|
INTERRUPT_DESC_ST Tim_3;
|
||||||
|
INTERRUPT_DESC_ST Tim_4;
|
||||||
|
INTERRUPT_DESC_ST I2c_1_Ev;
|
||||||
|
INTERRUPT_DESC_ST I2c_1_ER;
|
||||||
|
INTERRUPT_DESC_ST I2c_2_Ev;
|
||||||
|
INTERRUPT_DESC_ST I2c_2_ER;
|
||||||
|
INTERRUPT_DESC_ST Spi_1;
|
||||||
|
INTERRUPT_DESC_ST Spi_2;
|
||||||
|
INTERRUPT_DESC_ST Usart1;
|
||||||
|
INTERRUPT_DESC_ST Usart2;
|
||||||
|
INTERRUPT_DESC_ST Usart3;
|
||||||
|
INTERRUPT_DESC_ST Exti_15_10;
|
||||||
|
INTERRUPT_DESC_ST Rtc_Alarm;
|
||||||
|
INTERRUPT_DESC_ST Usb_WackUp;
|
||||||
|
INTERRUPT_DESC_ST Tim_8_Brk;
|
||||||
|
INTERRUPT_DESC_ST Tim_8_Up;
|
||||||
|
INTERRUPT_DESC_ST Tim_8_Trg_Com;
|
||||||
|
INTERRUPT_DESC_ST Tim_8_Cc;
|
||||||
|
INTERRUPT_DESC_ST Adc_3;
|
||||||
|
INTERRUPT_DESC_ST Fsmc;
|
||||||
|
INTERRUPT_DESC_ST Sdio;
|
||||||
|
INTERRUPT_DESC_ST Tim_5;
|
||||||
|
INTERRUPT_DESC_ST Spi_3;
|
||||||
|
INTERRUPT_DESC_ST Uart4;
|
||||||
|
INTERRUPT_DESC_ST Uart5;
|
||||||
|
INTERRUPT_DESC_ST Tim_6;
|
||||||
|
INTERRUPT_DESC_ST Tim_7;
|
||||||
|
INTERRUPT_DESC_ST Dma_2_Chnl_1;
|
||||||
|
INTERRUPT_DESC_ST Dma_2_Chnl_2;
|
||||||
|
INTERRUPT_DESC_ST Dma_2_Chnl_3;
|
||||||
|
INTERRUPT_DESC_ST Dma_2_Chnl_4;
|
||||||
|
} INTERRUPT_ST, *INTERRUPT_ST_PTR;
|
||||||
|
#endif
|
||||||
|
#endif
|
112
App/Board/Usart.h
Normal file
112
App/Board/Usart.h
Normal file
@ -0,0 +1,112 @@
|
|||||||
|
#ifndef __USART_H__
|
||||||
|
#define __USART_H__
|
||||||
|
|
||||||
|
//数据位
|
||||||
|
#define USART_DATA_BIT_8 USART_WordLength_8b //数据位8
|
||||||
|
#define USART_DATA_BIT_9 USART_WordLength_9b //数据位9
|
||||||
|
|
||||||
|
//停止位
|
||||||
|
#define USART_STOP_BIT_1 USART_StopBits_1 //停止位1
|
||||||
|
#define USART_STOP_BIT_0_5 USART_StopBits_0_5 //停止位0.5
|
||||||
|
#define USART_STOP_BIT_2 USART_StopBits_2 //停止位2
|
||||||
|
#define USART_STOP_BIT_1_5 USART_StopBits_1_5 //停止位1.5
|
||||||
|
|
||||||
|
//校验位
|
||||||
|
#define USART_PARITY_NO USART_Parity_No //无校验
|
||||||
|
#define USART_PRAITY_EVEN USART_Parity_Even //偶校验
|
||||||
|
#define USART_PRAITY_ODD USART_Parity_Odd //奇校验
|
||||||
|
|
||||||
|
//USART
|
||||||
|
#define USART_ENABLE
|
||||||
|
#ifdef USART_ENABLE
|
||||||
|
#define USE_USART1
|
||||||
|
#undef USE_USART2
|
||||||
|
#undef USE_USART3
|
||||||
|
#undef USE_USART4
|
||||||
|
#undef USE_USART5
|
||||||
|
#undef USE_USART6
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* **********串口相关********** */
|
||||||
|
#ifdef USE_USART1
|
||||||
|
#define COM0 USART1_BASE
|
||||||
|
#define COM0_IRQN USART1_IRQn
|
||||||
|
#define COM0_TX_PORT GPIOA
|
||||||
|
#define COM0_RX_PORT GPIOA
|
||||||
|
#define COM0_TX_PIN GPIO_Pin_9
|
||||||
|
#define COM0_RX_PIN GPIO_Pin_10
|
||||||
|
#endif
|
||||||
|
#ifdef USE_USART2
|
||||||
|
#define COM1 USART2_BASE
|
||||||
|
#define COM1_IRQN USART2_IRQn
|
||||||
|
#define COM1_TX_PORT GPIOA
|
||||||
|
#define COM1_RX_PORT GPIOA
|
||||||
|
#define COM1_TX_PIN GPIO_Pin_2
|
||||||
|
#define COM1_RX_PIN GPIO_Pin_3
|
||||||
|
#endif
|
||||||
|
#ifdef USE_USART3
|
||||||
|
#define COM2 USART3_BASE
|
||||||
|
#define COM2_IRQN USART3_IRQn
|
||||||
|
#define COM2_TX_PORT GPIOB
|
||||||
|
#define COM2_RX_PORT GPIOB
|
||||||
|
#define COM2_TX_PIN GPIO_Pin_10
|
||||||
|
#define COM2_RX_PIN GPIO_Pin_11
|
||||||
|
#endif
|
||||||
|
#ifdef USE_USART4
|
||||||
|
#define COM3 UART4_BASE
|
||||||
|
#define COM3_IRQN UART4_IRQn
|
||||||
|
#define COM3_TX_PORT GPIOC
|
||||||
|
#define COM3_RX_PORT GPIOC
|
||||||
|
#define COM3_TX_PIN GPIO_Pin_10
|
||||||
|
#define COM3_RX_PIN GPIO_Pin_11
|
||||||
|
#endif
|
||||||
|
#ifdef USE_USART5
|
||||||
|
#define COM4 UART5_BASE
|
||||||
|
#define COM4_IRQN UART5_IRQn
|
||||||
|
#define COM4_TX_PORT GPIOB
|
||||||
|
#define COM4_RX_PORT GPIOD
|
||||||
|
#define COM4_TX_PIN GPIO_Pin_12
|
||||||
|
#define COM4_RX_PIN GPIO_Pin_2
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* LetterShell */
|
||||||
|
#define USE_SHELL
|
||||||
|
#ifdef USE_SHELL
|
||||||
|
#define TTY_COM COM0
|
||||||
|
#define TTY_COM_IRQN COM0_IRQN
|
||||||
|
#endif
|
||||||
|
|
||||||
|
/* 此BSP规定最多4路RS485 */
|
||||||
|
#undef USE_RS4851
|
||||||
|
#ifdef USE_RS4851
|
||||||
|
#define RS4851_TRANS_PORT GPIOx
|
||||||
|
#define RS4851_TRANS_PIN GPIO_Pin_x
|
||||||
|
#define RS4851_TRANS_TX RESET
|
||||||
|
#define RS4851_TRANS_RX SET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef USE_RS4852
|
||||||
|
#ifdef USE_RS4852
|
||||||
|
#define RS4852_TRANS_PORT GPIOx
|
||||||
|
#define RS4852_TRANS_PIN GPIO_Pin_x
|
||||||
|
#define RS4852_TRANS_TX RESET
|
||||||
|
#define RS4852_TRANS_RX SET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef USE_RS4853
|
||||||
|
#ifdef USE_RS4853
|
||||||
|
#define RS4853_TRANS_PORT GPIOx
|
||||||
|
#define RS4853_TRANS_PIN GPIO_Pin_x
|
||||||
|
#define RS4853_TRANS_TX RESET
|
||||||
|
#define RS4853_TRANS_RX SET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#undef USE_RS4854
|
||||||
|
#ifdef USE_RS4854
|
||||||
|
#define RS4854_TRANS_PORT GPIOx
|
||||||
|
#define RS4854_TRANS_PIN GPIO_Pin_x
|
||||||
|
#define RS4854_TRANS_TX RESET
|
||||||
|
#define RS4854_TRANS_RX SET
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#endif
|
@ -22,7 +22,7 @@ void LedCtlTaskInit(uint8_t Level,uint8_t Preemption)
|
|||||||
"LedCtlTask", /* 任务名称 */
|
"LedCtlTask", /* 任务名称 */
|
||||||
LedCtlTask, /* 任务入口函数 */
|
LedCtlTask, /* 任务入口函数 */
|
||||||
0, /* 任务参数 */
|
0, /* 任务参数 */
|
||||||
&TaskStack[0], /* ¦昢梬お宎華硊 */
|
TaskStack, /* ¦昢梬お宎華硊 */
|
||||||
TASK_STACK_SIZE, /* 任务堆栈大小 */
|
TASK_STACK_SIZE, /* 任务堆栈大小 */
|
||||||
Level, /* 优先级 */
|
Level, /* 优先级 */
|
||||||
Preemption, /* 抢占阈值 */
|
Preemption, /* 抢占阈值 */
|
||||||
@ -42,9 +42,8 @@ void LedCtlTask(ULONG ThreadXInput)
|
|||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
IoCtlLedToggle(LED0);
|
LedToggle(LED0);
|
||||||
IoCtlLedToggle(LED1);
|
LedToggle(LED1);
|
||||||
IoCtlLedToggle(LED2);
|
|
||||||
tx_thread_sleep(100);
|
tx_thread_sleep(100);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
/* 1. 创建shell对象,开辟shell缓冲区 */
|
/* 1. 创建shell对象,开辟shell缓冲区 */
|
||||||
Shell Host; //Shell实例化
|
Shell Host; //Shell实例化
|
||||||
char HostBuffer[WR_BUFFER_SIZE]; //读写缓冲区
|
char HostBuffer[WR_BUFFER_SIZE]; //读写缓冲区
|
||||||
uint32_t HostId; //串口号
|
uint32_t TtyComId; //串口号
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Shell写函数
|
* @brief Shell写函数
|
||||||
@ -17,7 +17,7 @@ uint32_t HostId; //串口号
|
|||||||
*/
|
*/
|
||||||
signed short ShellWrite(char* ch, unsigned short Len)
|
signed short ShellWrite(char* ch, unsigned short Len)
|
||||||
{
|
{
|
||||||
UsartSendStr(HostId, (uint8_t* )ch,Len);
|
UsartSendStr(TtyComId, (uint8_t* )ch,Len);
|
||||||
return Len;
|
return Len;
|
||||||
}
|
}
|
||||||
/**
|
/**
|
||||||
@ -45,14 +45,14 @@ void LetterShellIrqFunc(uint32_t Vector)
|
|||||||
*/
|
*/
|
||||||
void LetterShellInit(uint32_t ComId, uint32_t baud)
|
void LetterShellInit(uint32_t ComId, uint32_t baud)
|
||||||
{
|
{
|
||||||
HostId = ComId;
|
TtyComId = ComId;
|
||||||
|
|
||||||
//初始化串口
|
//初始化串口
|
||||||
UsartStdConfig(ComId, baud);
|
UsartStdConfig(ComId, baud);
|
||||||
//设置串口回调函数
|
//设置串口回调函数
|
||||||
IntCbReg(TTY_COM_IRQN, LetterShellIrqFunc);
|
InterruptRegist(TTY_COM_IRQN, LetterShellIrqFunc);
|
||||||
//设置中断等级
|
//设置中断等级
|
||||||
IntSetLevel(TTY_COM_IRQN,1,1);
|
InterruptSetLevel(TTY_COM_IRQN,3,3);
|
||||||
//注册写函数
|
//注册写函数
|
||||||
Host.write = ShellWrite;
|
Host.write = ShellWrite;
|
||||||
|
|
||||||
@ -68,36 +68,10 @@ void LetterShellInit(uint32_t ComId, uint32_t baud)
|
|||||||
*/
|
*/
|
||||||
int version(void)
|
int version(void)
|
||||||
{
|
{
|
||||||
printf("%s\r\n",VERSION);
|
printf("硬件版本:%s\r\n",HARDWARE_VERSION);
|
||||||
|
printf("软件版本:%s\r\n",SOFTWARE_VERSION);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief DO控制
|
|
||||||
* @param chnl 通道号 val状态值
|
|
||||||
* @retval void
|
|
||||||
* @note void
|
|
||||||
* @example void
|
|
||||||
*/
|
|
||||||
void doSet(uint8_t chnl, uint8_t val)
|
|
||||||
{
|
|
||||||
IoCtl(IO_TYPE_DO, chnl, val);
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
* @brief DO控制反转
|
|
||||||
* @param chnl 通道号
|
|
||||||
* @retval void
|
|
||||||
* @note void
|
|
||||||
* @example void
|
|
||||||
*/
|
|
||||||
void doToggle(uint8_t chnl)
|
|
||||||
{
|
|
||||||
IoCtlToggleDo(chnl);
|
|
||||||
}
|
|
||||||
|
|
||||||
//打印版本号
|
//打印版本号
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), version, version, version);
|
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), version, version, version);
|
||||||
//控制DO
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), doSet, doSet, doSet);
|
|
||||||
//反转DO
|
|
||||||
SHELL_EXPORT_CMD(SHELL_CMD_PERMISSION(0)|SHELL_CMD_TYPE(SHELL_TYPE_CMD_FUNC), doToggle, doToggle, doToggle);
|
|
||||||
|
@ -2,8 +2,6 @@
|
|||||||
#include "stm32f10x.h"
|
#include "stm32f10x.h"
|
||||||
/* BSP INCLUDE */
|
/* BSP INCLUDE */
|
||||||
#include "Bsp.h"
|
#include "Bsp.h"
|
||||||
/* OPEN_SOURCE_LIB INCLUDE */
|
|
||||||
#include "LetterShell.h"
|
|
||||||
/* APP INLCUDE */
|
/* APP INLCUDE */
|
||||||
#include "LedTest.h"
|
#include "LedTest.h"
|
||||||
|
|
||||||
@ -31,9 +29,6 @@ int main(void)
|
|||||||
{
|
{
|
||||||
//bsp初始化
|
//bsp初始化
|
||||||
BspConfigInit();
|
BspConfigInit();
|
||||||
|
|
||||||
//LetterShell初始化
|
|
||||||
LetterShellInit(TTY_COM,115200);
|
|
||||||
|
|
||||||
/* Start ThreadX */
|
/* Start ThreadX */
|
||||||
tx_kernel_enter();
|
tx_kernel_enter();
|
||||||
|
@ -315,7 +315,7 @@
|
|||||||
</ArmAdsMisc>
|
</ArmAdsMisc>
|
||||||
<Cads>
|
<Cads>
|
||||||
<interw>1</interw>
|
<interw>1</interw>
|
||||||
<Optim>2</Optim>
|
<Optim>1</Optim>
|
||||||
<oTime>0</oTime>
|
<oTime>0</oTime>
|
||||||
<SplitLS>0</SplitLS>
|
<SplitLS>0</SplitLS>
|
||||||
<OneElfS>1</OneElfS>
|
<OneElfS>1</OneElfS>
|
||||||
@ -338,10 +338,10 @@
|
|||||||
<v6WtE>0</v6WtE>
|
<v6WtE>0</v6WtE>
|
||||||
<v6Rtti>0</v6Rtti>
|
<v6Rtti>0</v6Rtti>
|
||||||
<VariousControls>
|
<VariousControls>
|
||||||
<MiscControls></MiscControls>
|
<MiscControls>--no-multibyte-chars</MiscControls>
|
||||||
<Define>USE_STDPERIPH_DRIVER,STM32F10X_HD,DEBUG,</Define>
|
<Define>USE_STDPERIPH_DRIVER,STM32F10X_HD,DEBUG,</Define>
|
||||||
<Undefine></Undefine>
|
<Undefine></Undefine>
|
||||||
<IncludePath>..\..\..\Bsp\Inc;..\..\..\System;..\..\..\System\CMSIS;..\..\..\ThirdLib\LetterShell\Inc;..\..\..\StdLib\Inc;..\App\Inc;..\..\..\ThirdLib\ThreadX\common\inc;..\..\..\ThirdLib\ThreadX\ports\cortex_m3\keil\inc</IncludePath>
|
<IncludePath>..\..\..\Bsp\Inc;..\..\..\System;..\..\..\System\CMSIS;..\..\..\ThirdLib\LetterShell\Inc;..\..\..\StdLib\Inc;..\App\Inc;..\..\..\ThirdLib\ThreadX\common\inc;..\..\..\ThirdLib\ThreadX\ports\cortex_m3\keil\inc;..\App\Board</IncludePath>
|
||||||
</VariousControls>
|
</VariousControls>
|
||||||
</Cads>
|
</Cads>
|
||||||
<Aads>
|
<Aads>
|
||||||
@ -386,9 +386,9 @@
|
|||||||
<GroupName>App</GroupName>
|
<GroupName>App</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
<File>
|
||||||
<FileName>LetterShell.c</FileName>
|
<FileName>Main.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\App\Src\LetterShell.c</FilePath>
|
<FilePath>..\App\Src\Main.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>LedTest.c</FileName>
|
<FileName>LedTest.c</FileName>
|
||||||
@ -396,9 +396,9 @@
|
|||||||
<FilePath>..\App\Src\LedTest.c</FilePath>
|
<FilePath>..\App\Src\LedTest.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>Main.c</FileName>
|
<FileName>LetterShell.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\App\Src\Main.c</FilePath>
|
<FilePath>..\App\Src\LetterShell.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
@ -1962,9 +1962,9 @@
|
|||||||
<GroupName>App</GroupName>
|
<GroupName>App</GroupName>
|
||||||
<Files>
|
<Files>
|
||||||
<File>
|
<File>
|
||||||
<FileName>LetterShell.c</FileName>
|
<FileName>Main.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\App\Src\LetterShell.c</FilePath>
|
<FilePath>..\App\Src\Main.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>LedTest.c</FileName>
|
<FileName>LedTest.c</FileName>
|
||||||
@ -1972,9 +1972,9 @@
|
|||||||
<FilePath>..\App\Src\LedTest.c</FilePath>
|
<FilePath>..\App\Src\LedTest.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
<File>
|
<File>
|
||||||
<FileName>Main.c</FileName>
|
<FileName>LetterShell.c</FileName>
|
||||||
<FileType>1</FileType>
|
<FileType>1</FileType>
|
||||||
<FilePath>..\App\Src\Main.c</FilePath>
|
<FilePath>..\App\Src\LetterShell.c</FilePath>
|
||||||
</File>
|
</File>
|
||||||
</Files>
|
</Files>
|
||||||
</Group>
|
</Group>
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
IMPORT _tx_thread_system_stack_ptr
|
|
||||||
IMPORT _tx_initialize_unused_memory
|
|
||||||
IMPORT _tx_timer_interrupt
|
|
||||||
IMPORT __main
|
|
||||||
IMPORT __initial_sp
|
|
||||||
IMPORT __Vectors
|
|
||||||
|
|
||||||
SYSTEM_CLOCK EQU 72000000
|
|
||||||
SYSTICK_CYCLES EQU ((SYSTEM_CLOCK / 1000) -1)
|
|
||||||
|
|
||||||
AREA ||.text||, CODE, READONLY
|
|
||||||
|
|
||||||
;VOID _tx_initialize_low_level(VOID)
|
|
||||||
;{
|
|
||||||
EXPORT _tx_initialize_low_level
|
|
||||||
_tx_initialize_low_level
|
|
||||||
;
|
|
||||||
; /* Disable interrupts during ThreadX initialization. */
|
|
||||||
;
|
|
||||||
CPSID i
|
|
||||||
;
|
|
||||||
; /* Set base of available memory to end of non-initialised RAM area. */
|
|
||||||
;
|
|
||||||
LDR r0, =_tx_initialize_unused_memory ; Build address of unused memory pointer
|
|
||||||
LDR r1, =__initial_sp ; Build first free address
|
|
||||||
ADD r1, r1, #4 ;
|
|
||||||
STR r1, [r0] ; Setup first unused memory pointer
|
|
||||||
;
|
|
||||||
; /* Setup Vector Table Offset Register. */
|
|
||||||
;
|
|
||||||
MOV r0, #0xE000E000 ; Build address of NVIC registers
|
|
||||||
LDR r1, =__Vectors ; Pickup address of vector table
|
|
||||||
STR r1, [r0, #0xD08] ; Set vector table address
|
|
||||||
;
|
|
||||||
; /* Enable the cycle count register. */
|
|
||||||
;
|
|
||||||
; LDR r0, =0xE0001000 ; Build address of DWT register
|
|
||||||
; LDR r1, [r0] ; Pickup the current value
|
|
||||||
; ORR r1, r1, #1 ; Set the CYCCNTENA bit
|
|
||||||
; STR r1, [r0] ; Enable the cycle count register
|
|
||||||
;
|
|
||||||
; /* Set system stack pointer from vector value. */
|
|
||||||
;
|
|
||||||
LDR r0, =_tx_thread_system_stack_ptr ; Build address of system stack pointer
|
|
||||||
LDR r1, =__Vectors ; Pickup address of vector table
|
|
||||||
LDR r1, [r1] ; Pickup reset stack pointer
|
|
||||||
STR r1, [r0] ; Save system stack pointer
|
|
||||||
;
|
|
||||||
; /* Configure SysTick for 100Hz clock, or 16384 cycles if no reference. */
|
|
||||||
;
|
|
||||||
MOV r0, #0xE000E000 ; Build address of NVIC registers
|
|
||||||
LDR r1, =SYSTICK_CYCLES
|
|
||||||
STR r1, [r0, #0x14] ; Setup SysTick Reload Value
|
|
||||||
MOV r1, #0x7 ; Build SysTick Control Enable Value
|
|
||||||
STR r1, [r0, #0x10] ; Setup SysTick Control
|
|
||||||
;
|
|
||||||
; /* Configure handler priorities. */
|
|
||||||
;
|
|
||||||
LDR r1, =0x00000000 ; Rsrv, UsgF, BusF, MemM
|
|
||||||
STR r1, [r0, #0xD18] ; Setup System Handlers 4-7 Priority Registers
|
|
||||||
|
|
||||||
LDR r1, =0xFF000000 ; SVCl, Rsrv, Rsrv, Rsrv
|
|
||||||
STR r1, [r0, #0xD1C] ; Setup System Handlers 8-11 Priority Registers
|
|
||||||
; Note: SVC must be lowest priority, which is 0xFF
|
|
||||||
|
|
||||||
LDR r1, =0x40FF0000 ; SysT, PnSV, Rsrv, DbgM
|
|
||||||
STR r1, [r0, #0xD20] ; Setup System Handlers 12-15 Priority Registers
|
|
||||||
; Note: PnSV must be lowest priority, which is 0xFF
|
|
||||||
;
|
|
||||||
; /* Return to caller. */
|
|
||||||
;
|
|
||||||
BX lr
|
|
||||||
;}
|
|
||||||
;/* Define shells for each of the unused vectors. */
|
|
||||||
;
|
|
||||||
EXPORT __tx_BadHandler
|
|
||||||
__tx_BadHandler
|
|
||||||
B __tx_BadHandler
|
|
||||||
|
|
||||||
|
|
||||||
EXPORT __tx_SVCallHandler
|
|
||||||
__tx_SVCallHandler
|
|
||||||
B __tx_SVCallHandler
|
|
||||||
|
|
||||||
|
|
||||||
EXPORT __tx_IntHandler
|
|
||||||
__tx_IntHandler
|
|
||||||
; VOID InterruptHandler (VOID)
|
|
||||||
; {
|
|
||||||
PUSH {r0, lr}
|
|
||||||
|
|
||||||
; /* Do interrupt handler work here */
|
|
||||||
; /* .... */
|
|
||||||
|
|
||||||
POP {r0, lr}
|
|
||||||
BX LR
|
|
||||||
; }
|
|
||||||
|
|
||||||
EXPORT __tx_SysTickHandler
|
|
||||||
EXPORT SysTick_Handler
|
|
||||||
__tx_SysTickHandler
|
|
||||||
SysTick_Handler
|
|
||||||
; VOID TimerInterruptHandler (VOID)
|
|
||||||
; {
|
|
||||||
;
|
|
||||||
PUSH {r0, lr}
|
|
||||||
BL _tx_timer_interrupt
|
|
||||||
POP {r0, lr}
|
|
||||||
BX LR
|
|
||||||
; }
|
|
||||||
|
|
||||||
EXPORT __tx_NMIHandler
|
|
||||||
__tx_NMIHandler
|
|
||||||
B __tx_NMIHandler
|
|
||||||
|
|
||||||
EXPORT __tx_DBGHandler
|
|
||||||
__tx_DBGHandler
|
|
||||||
B __tx_DBGHandler
|
|
||||||
ALIGN
|
|
||||||
LTORG
|
|
||||||
END
|
|
Loading…
x
Reference in New Issue
Block a user