队列+中断发送完成
This commit is contained in:
parent
303494d1e4
commit
5142a3d77d
|
@ -256,7 +256,7 @@
|
|||
<tool id="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash.1801165667" name="GNU RISC-V Cross Create Flash Image" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.tool.createflash">
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection.1097396305" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.textsection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection.2034511797" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.datasection" useByScannerDiscovery="false" value="false" valueType="boolean"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.1726268709" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihex" valueType="enumerated"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.1726268709" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice" useByScannerDiscovery="false" value="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.choice.ihexAndbinary" valueType="enumerated"/>
|
||||
<option IS_BUILTIN_EMPTY="false" IS_VALUE_EMPTY="false" id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection.1890795928" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.othersection" useByScannerDiscovery="false" valueType="stringList"/>
|
||||
<option id="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other.788974495" superClass="ilg.gnumcueclipse.managedbuild.cross.riscv.option.createflash.other" useByScannerDiscovery="false" value="" valueType="string"/>
|
||||
</tool>
|
||||
|
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef APP_BUS_IDLE_DETECTION_H_
|
||||
#define APP_BUS_IDLE_DETECTION_H_
|
||||
|
||||
#include "uart_dev.h"
|
||||
|
||||
#include "FreeRTOS.h"
|
||||
#include "event_groups.h"
|
||||
|
||||
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
void J1_485_IN_IDLE(void);
|
||||
void J2_485_IN_IDLE(void);
|
||||
void J3_485_IN_IDLE(void);
|
||||
void J4_485_IN_IDLE(void);
|
||||
void J5_0_485_IN_IDLE(void);
|
||||
|
||||
void J1_485_IN_RXNE(void);
|
||||
void J2_485_IN_RXNE(void);
|
||||
void J3_485_IN_RXNE(void);
|
||||
void J4_485_IN_RXNE(void);
|
||||
void J5_0_485_IN_RXNE(void);
|
||||
#endif
|
||||
|
||||
uint8_t getRs485State(device_handle device);
|
||||
uint8_t getUartState(device_handle device);
|
||||
|
||||
|
||||
#endif
|
|
@ -0,0 +1,32 @@
|
|||
#ifndef APP_QUEUE_UART_H_
|
||||
#define APP_QUEUE_UART_H_
|
||||
|
||||
#include "pDebug.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "queue.h"
|
||||
|
||||
/* 存入队列中的数据格式 */
|
||||
typedef struct _queueUartSendInfo{
|
||||
uint32_t length; //数据长度
|
||||
uint8_t *data; //数据
|
||||
} queueUartSendInfo;
|
||||
|
||||
/* 分时复用485存入队列中的数据格式 */
|
||||
typedef struct _queueTimeShareSendInfo{
|
||||
uint8_t connectPort; //发送的端口
|
||||
uint32_t length; //数据长度
|
||||
uint8_t *data; //数据
|
||||
} queueTimeShareSendInfo;
|
||||
|
||||
extern QueueHandle_t J1_485_Queue;
|
||||
extern QueueHandle_t J2_485_Queue;
|
||||
extern QueueHandle_t J3_485_Queue;
|
||||
extern QueueHandle_t J4_485_Queue;
|
||||
extern QueueHandle_t J5_0_485_Queue;
|
||||
extern QueueHandle_t upward_uart_Queue;
|
||||
extern QueueSetHandle_t uart_Queue;
|
||||
|
||||
void uartQueueInit(void);
|
||||
void uartQueueSend(void);
|
||||
|
||||
#endif
|
|
@ -0,0 +1,220 @@
|
|||
#include "busIdleDetection.h"
|
||||
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
#include "uart_dev.h"
|
||||
|
||||
/* 通过软件定时器的方式来完成 */
|
||||
static TimerHandle_t J1_485_Swtmr = NULL;
|
||||
static TimerHandle_t J2_485_Swtmr = NULL;
|
||||
static TimerHandle_t J3_485_Swtmr = NULL;
|
||||
static TimerHandle_t J4_485_Swtmr = NULL;
|
||||
static TimerHandle_t J5_0_485_Swtmr = NULL;
|
||||
|
||||
static void J1_485_tmrCallback(void* parameter);
|
||||
static void J2_485_tmrCallback(void* parameter);
|
||||
static void J3_485_tmrCallback(void* parameter);
|
||||
static void J4_485_tmrCallback(void* parameter);
|
||||
static void J5_0_485_tmrCallback(void* parameter);
|
||||
|
||||
#define softwareDelay (30 / (1000 / configTICK_RATE_HZ))
|
||||
|
||||
/*
|
||||
* @brief 初始化所有的软件定时器
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void softwareTimeInit(void)
|
||||
{
|
||||
J1_485_Swtmr = xTimerCreate((const char*)"J1Timer",
|
||||
softwareDelay, //延时
|
||||
(UBaseType_t )pdFALSE, //单次模式
|
||||
(void *)1, //为每个计时器分配一个索引的唯一ID
|
||||
(TimerCallbackFunction_t)J1_485_tmrCallback); //回调函数
|
||||
|
||||
J2_485_Swtmr = xTimerCreate((const char*)"J2Timer",
|
||||
softwareDelay,
|
||||
(UBaseType_t )pdFALSE,
|
||||
(void *)2,
|
||||
(TimerCallbackFunction_t)J2_485_tmrCallback);
|
||||
|
||||
J3_485_Swtmr = xTimerCreate((const char*)"J3Timer",
|
||||
softwareDelay,
|
||||
(UBaseType_t )pdFALSE,
|
||||
(void *)3,
|
||||
(TimerCallbackFunction_t)J3_485_tmrCallback);
|
||||
|
||||
J4_485_Swtmr = xTimerCreate((const char*)"J4Timer",
|
||||
softwareDelay,
|
||||
(UBaseType_t )pdFALSE,
|
||||
(void *)4,
|
||||
(TimerCallbackFunction_t)J4_485_tmrCallback);
|
||||
|
||||
J5_0_485_Swtmr = xTimerCreate((const char*)"J5_0Timer",
|
||||
softwareDelay,
|
||||
(UBaseType_t )pdFALSE,
|
||||
(void *)5,
|
||||
(TimerCallbackFunction_t)J5_0_485_tmrCallback);
|
||||
}
|
||||
|
||||
void J1_485_tmrCallback(void* parameter)
|
||||
{
|
||||
setBUSIDLEFlag(g_J1_uart6_handle, 0);
|
||||
}
|
||||
|
||||
void J2_485_tmrCallback(void* parameter)
|
||||
{
|
||||
setBUSIDLEFlag(g_J2_uart7_handle, 0);
|
||||
}
|
||||
|
||||
void J3_485_tmrCallback(void* parameter)
|
||||
{
|
||||
setBUSIDLEFlag(g_J3_usart2_handle, 0);
|
||||
}
|
||||
|
||||
void J4_485_tmrCallback(void* parameter)
|
||||
{
|
||||
setBUSIDLEFlag(g_J4_uart8_handle, 0);
|
||||
}
|
||||
|
||||
void J5_0_485_tmrCallback(void* parameter)
|
||||
{
|
||||
setBUSIDLEFlag(g_J5_0_usart3_handle, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J1_485空闲中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J1_485_IN_IDLE(void)
|
||||
{
|
||||
xTimerStartFromISR(J1_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J2_485空闲中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J2_485_IN_IDLE(void)
|
||||
{
|
||||
xTimerStartFromISR(J2_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J3_485空闲中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J3_485_IN_IDLE(void)
|
||||
{
|
||||
xTimerStartFromISR(J3_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J4_485空闲中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J4_485_IN_IDLE(void)
|
||||
{
|
||||
xTimerStartFromISR(J4_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J5_0_485空闲中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J5_0_485_IN_IDLE(void)
|
||||
{
|
||||
xTimerStartFromISR(J5_0_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J1_485空闲中断后,第一次进入接收中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J1_485_IN_RXNE(void)
|
||||
{
|
||||
xTimerStopFromISR(J1_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J2_485空闲中断后,第一次进入接收中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J2_485_IN_RXNE(void)
|
||||
{
|
||||
xTimerStopFromISR(J2_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J3_485空闲中断后,第一次进入接收中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J3_485_IN_RXNE(void)
|
||||
{
|
||||
xTimerStopFromISR(J3_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J4_485空闲中断后,第一次进入接收中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J4_485_IN_RXNE(void)
|
||||
{
|
||||
xTimerStopFromISR(J4_485_Swtmr, 0);
|
||||
}
|
||||
|
||||
/*
|
||||
* @brief J5_0_485空闲中断后,第一次进入接收中断内容
|
||||
* @param
|
||||
* @retval
|
||||
*
|
||||
*/
|
||||
void J5_0_485_IN_RXNE(void)
|
||||
{
|
||||
xTimerStopFromISR(J5_0_485_Swtmr, 0);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*
|
||||
* @brief 得到串口能否发送
|
||||
* @param
|
||||
* @retval 0 能发送
|
||||
1 不能发送
|
||||
0xFF 错误
|
||||
*/
|
||||
uint8_t getRs485State(device_handle device)
|
||||
{
|
||||
#ifdef RS485BUSIDLE1
|
||||
#ifdef UARTINTERRUPTSEND
|
||||
return (getUartSendState(device) || getBUSIDLEFlag(device));
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
uint8_t getUartState(device_handle device)
|
||||
{
|
||||
#ifdef UARTINTERRUPTSEND
|
||||
return getUartSendState(device);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
@ -1,31 +1,60 @@
|
|||
|
||||
#include "freerotsTask.h"
|
||||
|
||||
|
||||
#include "uart_dev.h"
|
||||
#include "HD_UART.h"
|
||||
#include "FM_GPIO.h"
|
||||
#include "FM_ADC.h"
|
||||
#include "queueUart.h"
|
||||
|
||||
#define TASK1_TASK_PRIO 5
|
||||
#define TASK1_STK_SIZE 256
|
||||
#include "stdio.h"
|
||||
|
||||
TaskHandle_t Task1Task_Handler;
|
||||
#define Common_TASK_PRIO 5
|
||||
#define Common_STK_SIZE 256
|
||||
|
||||
#define Transmit_TASK_PRIO 5
|
||||
#define Transmit_STK_SIZE 256
|
||||
|
||||
TaskHandle_t CommonTask_Handler;
|
||||
TaskHandle_t TransmitTask_Handler;
|
||||
uint8_t data[20] = "hello world\n";
|
||||
|
||||
void task1_task(void *pvParameters)
|
||||
void common_Task(void *pvParameters)
|
||||
{
|
||||
writePwrCtrlState(Android_PwrCtrl, PwrCtrlOpen);
|
||||
proportionalInt();
|
||||
while(1) {
|
||||
// printf("task1 entry\r\n");
|
||||
printf_adc_data();
|
||||
USART_ITConfig(UART5, USART_IT_TXE, ENABLE);
|
||||
uartInterruptSend(g_Upward_uart5_handle, data, 12);
|
||||
// writePwrCtrlState(Android_PwrCtrl, PwrCtrlOpen);
|
||||
// proportionalInt();
|
||||
// while(1) {
|
||||
// // printf("task1 entry\r\n");
|
||||
// printf_adc_data();
|
||||
// USART_ITConfig(UART5, USART_IT_TXE, ENABLE);
|
||||
// uartInterruptSend(g_Upward_uart5_handle, data, 12);
|
||||
// vTaskDelay(1000);
|
||||
// }
|
||||
|
||||
while (1) {
|
||||
uint8_t *Buff = (uint8_t *)pvPortMalloc(200);
|
||||
if (Buff == NULL) {
|
||||
log_error("Memory allocation failed\n");
|
||||
return;
|
||||
}
|
||||
|
||||
queueUartSendInfo *sendBuff = (queueUartSendInfo *)Buff;
|
||||
sendBuff->length = sizeof("hello world\n");
|
||||
sendBuff->data = Buff + sizeof(queueUartSendInfo);
|
||||
strlcpy((char *)sendBuff->data, "hello world\n", sizeof("hello world\n"));
|
||||
|
||||
xQueueSend(upward_uart_Queue, &Buff, 10);
|
||||
vTaskDelay(1000);
|
||||
}
|
||||
}
|
||||
|
||||
void transmit_Task(void *pvParameters)
|
||||
{
|
||||
while (1) {
|
||||
uartQueueSend();
|
||||
/* ÑÓʱÈý¸öϵͳ½ÚÅÄ */
|
||||
vTaskDelay(3);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Æô¶¯
|
||||
|
@ -38,13 +67,24 @@ void startApp(void)
|
|||
FM_GPIO_Init();
|
||||
FM_ADC_Init();
|
||||
|
||||
|
||||
uartQueueInit();
|
||||
|
||||
/* create task */
|
||||
xTaskCreate((TaskFunction_t )task1_task,
|
||||
(const char* )"task1",
|
||||
(uint16_t )TASK1_STK_SIZE,
|
||||
xTaskCreate((TaskFunction_t )common_Task,
|
||||
(const char* )"commonTask",
|
||||
(uint16_t )Common_STK_SIZE,
|
||||
(void* )NULL,
|
||||
(UBaseType_t )TASK1_TASK_PRIO,
|
||||
(TaskHandle_t* )&Task1Task_Handler);
|
||||
(UBaseType_t )Common_TASK_PRIO,
|
||||
(TaskHandle_t* )&CommonTask_Handler);
|
||||
|
||||
xTaskCreate((TaskFunction_t )transmit_Task,
|
||||
(const char* )"transmitTask",
|
||||
(uint16_t )Transmit_STK_SIZE,
|
||||
(void* )NULL,
|
||||
(UBaseType_t )Transmit_TASK_PRIO,
|
||||
(TaskHandle_t* )&TransmitTask_Handler);
|
||||
|
||||
vTaskStartScheduler();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,192 @@
|
|||
|
||||
#include "queueUart.h"
|
||||
#include "uart_dev.h"
|
||||
#include "busIdleDetection.h"
|
||||
|
||||
/* 队列中每个消息的大小 */
|
||||
#define QUEUE_SIZE 4
|
||||
|
||||
/* 各个通讯口的队列 */
|
||||
QueueHandle_t J1_485_Queue = NULL;
|
||||
QueueHandle_t J2_485_Queue = NULL;
|
||||
QueueHandle_t J3_485_Queue = NULL;
|
||||
QueueHandle_t J4_485_Queue = NULL;
|
||||
QueueHandle_t J5_0_485_Queue = NULL;
|
||||
QueueHandle_t upward_uart_Queue = NULL;
|
||||
|
||||
/* 队列集 */
|
||||
QueueSetHandle_t uart_Queue = NULL;
|
||||
|
||||
/* 查看队列集中是否有数据 */
|
||||
QueueSetMemberHandle_t xActivatedMember;
|
||||
|
||||
/* 通过该结构体接收对应的数据用来发送,结束后通过该结构体,释放数据的内存 */
|
||||
typedef struct _queueRecvDataInfo {
|
||||
queueUartSendInfo *J1_485_data;
|
||||
queueUartSendInfo *J2_485_data;
|
||||
queueUartSendInfo *J3_485_data;
|
||||
queueUartSendInfo *J4_485_data;
|
||||
queueUartSendInfo *upward_uart_data;
|
||||
queueTimeShareSendInfo *J5_0_485_data;
|
||||
} queueRecvDataInfo;
|
||||
static queueRecvDataInfo queueRecvData;
|
||||
|
||||
/**
|
||||
* @brief 初始化串口发送的队列
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void uartQueueInit(void)
|
||||
{
|
||||
/* 初始化队列 */
|
||||
J1_485_Queue = xQueueCreate(5, QUEUE_SIZE);
|
||||
// if (NULL == J1_485_Queue) {
|
||||
// log_error("creat J1_485_Queue error\n");
|
||||
// }
|
||||
|
||||
J2_485_Queue = xQueueCreate(5, QUEUE_SIZE);
|
||||
// if (NULL == J2_485_Queue) {
|
||||
// log_error("creat J2_485_Queue error\n");
|
||||
// }
|
||||
|
||||
J3_485_Queue = xQueueCreate(5, QUEUE_SIZE);
|
||||
// if (NULL == J3_485_Queue) {
|
||||
// log_error("creat J3_485_Queue error\n");
|
||||
// }
|
||||
|
||||
J4_485_Queue = xQueueCreate(5, QUEUE_SIZE);
|
||||
// if (NULL == J4_485_Queue) {
|
||||
// log_error("creat J4_485_Queue error\n");
|
||||
// }
|
||||
|
||||
J5_0_485_Queue = xQueueCreate(5, QUEUE_SIZE);
|
||||
// if (NULL == J5_0_485_Queue) {
|
||||
// log_error("creat J5_0_485_Queue error\n");
|
||||
// }
|
||||
|
||||
upward_uart_Queue = xQueueCreate(10, QUEUE_SIZE);
|
||||
// if (NULL == upward_uart_Queue) {
|
||||
// log_error("creat upward_uart_Queue error\n");
|
||||
// }
|
||||
|
||||
|
||||
/* 将队列都放入队列集中 */
|
||||
uart_Queue = xQueueCreateSet(6);
|
||||
xQueueAddToSet(J1_485_Queue, uart_Queue);
|
||||
xQueueAddToSet(J2_485_Queue, uart_Queue);
|
||||
xQueueAddToSet(J3_485_Queue, uart_Queue);
|
||||
xQueueAddToSet(J4_485_Queue, uart_Queue);
|
||||
xQueueAddToSet(J5_0_485_Queue, uart_Queue);
|
||||
xQueueAddToSet(upward_uart_Queue, uart_Queue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 从队列中取出数据,发送函数
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void uartQueueSend(void)
|
||||
{
|
||||
/* 查看队列集中是否有数据 */
|
||||
xActivatedMember = xQueueSelectFromSet(uart_Queue, portMAX_DELAY);
|
||||
|
||||
/* 查看Upward_uart5中有无数据 */
|
||||
if (!getUartState(g_Upward_uart5_handle)) {
|
||||
/* 处理接收到的数据 */
|
||||
if (xQueueReceive(upward_uart_Queue, &queueRecvData.upward_uart_data, 0) == pdTRUE) {
|
||||
uartInterruptSend(g_Upward_uart5_handle, queueRecvData.upward_uart_data->data
|
||||
, queueRecvData.upward_uart_data->length);
|
||||
}
|
||||
}
|
||||
|
||||
/* 查看J1_485中有无数据 */
|
||||
if (!getRs485State(g_J1_uart6_handle)) {
|
||||
/* 处理接收到的数据 */
|
||||
if (xQueueReceive(J1_485_Queue, &queueRecvData.J1_485_data, 0) == pdTRUE) {
|
||||
uartInterruptSend(g_J1_uart6_handle, queueRecvData.J1_485_data->data
|
||||
, queueRecvData.J1_485_data->length);
|
||||
}
|
||||
}
|
||||
|
||||
/* 查看J2_485中有无数据 */
|
||||
if (!getRs485State(g_J2_uart7_handle)) {
|
||||
/* 处理接收到的数据 */
|
||||
if (xQueueReceive(J2_485_Queue, &queueRecvData.J2_485_data, 0) == pdTRUE) {
|
||||
uartInterruptSend(g_J2_uart7_handle, queueRecvData.J2_485_data->data
|
||||
, queueRecvData.J2_485_data->length);
|
||||
}
|
||||
}
|
||||
|
||||
/* 查看J3_485中有无数据 */
|
||||
if (!getRs485State(g_J3_usart2_handle)) {
|
||||
/* 处理接收到的数据 */
|
||||
if (xQueueReceive(J3_485_Queue, &queueRecvData.J3_485_data, 0) == pdTRUE) {
|
||||
uartInterruptSend(g_J3_usart2_handle, queueRecvData.J3_485_data->data
|
||||
, queueRecvData.J3_485_data->length);
|
||||
}
|
||||
}
|
||||
|
||||
/* 查看J4_485中有无数据 */
|
||||
if (!getRs485State(g_J4_uart8_handle)) {
|
||||
/* 处理接收到的数据 */
|
||||
if (xQueueReceive(J4_485_Queue, &queueRecvData.J4_485_data, 0) == pdTRUE) {
|
||||
uartInterruptSend(g_J4_uart8_handle, queueRecvData.J3_485_data->data
|
||||
, queueRecvData.J4_485_data->length);
|
||||
}
|
||||
}
|
||||
|
||||
/* 查看J5_0_485中有无数据 */
|
||||
if (!getRs485State(g_J5_0_usart3_handle)) {
|
||||
/* 处理接收到的数据 */
|
||||
if (xQueueReceive(J5_0_485_Queue, &queueRecvData.J5_0_485_data, 0) == pdTRUE) {
|
||||
setConnectPort(queueRecvData.J5_0_485_data->connectPort);
|
||||
uartInterruptSend(g_J4_uart8_handle, queueRecvData.J5_0_485_data->data
|
||||
, queueRecvData.J5_0_485_data->length);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
#ifdef UARTINTERRUPTSEND
|
||||
/**
|
||||
* @brief 数据发送完成后用于清除
|
||||
* @param
|
||||
* @retval
|
||||
*/
|
||||
void J1_485_IN_TXE(void)
|
||||
{
|
||||
vPortFree(queueRecvData.J1_485_data);
|
||||
}
|
||||
|
||||
|
||||
void J2_485_IN_TXE(void)
|
||||
{
|
||||
vPortFree(queueRecvData.J2_485_data);
|
||||
}
|
||||
|
||||
|
||||
void J3_485_IN_TXE(void)
|
||||
{
|
||||
vPortFree(queueRecvData.J3_485_data);
|
||||
}
|
||||
|
||||
|
||||
void J4_485_IN_TXE(void)
|
||||
{
|
||||
vPortFree(queueRecvData.J4_485_data);
|
||||
}
|
||||
|
||||
|
||||
void J5_0_485_IN_TXE(void)
|
||||
{
|
||||
vPortFree(queueRecvData.J5_0_485_data);
|
||||
}
|
||||
|
||||
|
||||
void Upward_USART_IN_TXE(void)
|
||||
{
|
||||
vPortFree(queueRecvData.upward_uart_data);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -9,6 +9,9 @@
|
|||
/* 是否使用中断发送,后期可能改为DMA发送 */
|
||||
#define UARTINTERRUPTSEND
|
||||
|
||||
/* 是否使用空闲中断,后期可以改为其他方式判断总线空闲中断 */
|
||||
#define RS485BUSIDLE1
|
||||
|
||||
#define ASCII_CHAR_BACKSPACE 0x08 /* '\b' */
|
||||
#define ASCII_CHAR_CHARACTER_TABULATION 0x09 /* '\t' */
|
||||
#define ASCII_CHAR_LINE_FEED 0x0A /* '\n' */
|
||||
|
@ -59,8 +62,48 @@ void Init_J4_485(uint32_t baud);
|
|||
void Init_J5_0_485(uint32_t baud);
|
||||
void Init_Upward_uart(uint32_t baud);
|
||||
|
||||
uint8_t getUartSendState(device_handle device);
|
||||
|
||||
#ifdef UARTINTERRUPTSEND
|
||||
extern void J1_485_IN_TXE(void);
|
||||
extern void J2_485_IN_TXE(void);
|
||||
extern void J3_485_IN_TXE(void);
|
||||
extern void J4_485_IN_TXE(void);
|
||||
extern void J5_0_485_IN_TXE(void);
|
||||
extern void Upward_USART_IN_TXE(void);
|
||||
uint8_t uartInterruptSend(device_handle device, uint8_t *data, uint16_t len);
|
||||
#endif
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
extern void J1_485_IN_IDLE(void);
|
||||
extern void J2_485_IN_IDLE(void);
|
||||
extern void J3_485_IN_IDLE(void);
|
||||
extern void J4_485_IN_IDLE(void);
|
||||
extern void J5_0_485_IN_IDLE(void);
|
||||
|
||||
extern void J1_485_IN_RXNE(void);
|
||||
extern void J2_485_IN_RXNE(void);
|
||||
extern void J3_485_IN_RXNE(void);
|
||||
extern void J4_485_IN_RXNE(void);
|
||||
extern void J5_0_485_IN_RXNE(void);
|
||||
|
||||
uint8_t getBUSIDLEFlag(device_handle device);
|
||||
// uint8_t getSoftwareIDLEFlag(device_handle device);
|
||||
void setBUSIDLEFlag(device_handle device, uint8_t state);
|
||||
// void setSoftwareIDLEFlag(device_handle device, uint8_t state);
|
||||
#endif
|
||||
|
||||
/* J5_0连接到哪个端口 */
|
||||
typedef enum _connectPortEnum {
|
||||
connectJ0 = 1,
|
||||
connectJ5,
|
||||
connectJ6,
|
||||
connectJ7,
|
||||
connectJ8,
|
||||
connectJ9,
|
||||
} connectPortEnum;
|
||||
void setConnectPort(uint8_t port);
|
||||
uint8_t getConnectPort(void);
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
@ -52,6 +52,22 @@ static void setJ5_0_485_SendState(uint8_t state);
|
|||
static void setUpward_uart_SendState(uint8_t state);
|
||||
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
/* 用于总线空闲标志位 */
|
||||
//该位为0时表示总线空闲
|
||||
#define BUS_IDLE 0x01
|
||||
// //该位为0时表示进入了空闲中断
|
||||
// #define softwareTimeFlag 0x02
|
||||
static uint8_t J1_485_IDLE_Flag = 0;
|
||||
static uint8_t J2_485_IDLE_Flag = 0;
|
||||
static uint8_t J3_485_IDLE_Flag = 0;
|
||||
static uint8_t J4_485_IDLE_Flag = 0;
|
||||
static uint8_t J5_0_485_IDLE_Flag = 0;
|
||||
#endif
|
||||
|
||||
/* J5_0_485当前连接到的端口 */
|
||||
static uint8_t connectPort = connectJ0;
|
||||
|
||||
/**
|
||||
* @brief 串口信息初始化,串口号及波特率.
|
||||
* @param uart_index 对应的硬件串口号
|
||||
|
@ -211,7 +227,7 @@ void Init_Upward_uart(uint32_t baud)
|
|||
/**
|
||||
* @brief 得到串口的发送状态
|
||||
* @param device 设备
|
||||
* @retval 0:发生完成 1:发送中 0xFF:错误
|
||||
* @retval 0:发送完成 1:发送中 0xFF:错误
|
||||
*/
|
||||
uint8_t getUartSendState(device_handle device)
|
||||
{
|
||||
|
@ -451,6 +467,12 @@ void J3_Interrupt()
|
|||
{
|
||||
/* 数据接收中断 */
|
||||
if (USART_GetITStatus(J3_USART, USART_IT_RXNE) != RESET) {
|
||||
#ifdef RS485BUSIDLE1
|
||||
if (J3_485_IDLE_Flag == 0) {
|
||||
J3_485_IDLE_Flag = 1;
|
||||
J3_485_IN_RXNE();
|
||||
}
|
||||
#endif
|
||||
J3_Rbuffer[0] = USART_ReceiveData(J3_USART); //接收数据
|
||||
uart_device_info *dev = (uart_device_info *)g_J3_usart2_handle;
|
||||
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
|
@ -464,17 +486,31 @@ void J3_Interrupt()
|
|||
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||
USART_ITConfig(J3_USART, USART_IT_TXE, DISABLE);
|
||||
setJ3_485_SendState(0);
|
||||
J3_485_IN_TXE();
|
||||
return;
|
||||
}
|
||||
USART_SendData(J3_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
/* 空闲中断 */
|
||||
if (USART_GetITStatus(J3_USART, USART_IT_IDLE) != RESET) {
|
||||
J3_485_IN_IDLE();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void J5_0_Interrupt()
|
||||
{
|
||||
/* 数据接收中断 */
|
||||
if (USART_GetITStatus(J5_0_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||
#ifdef RS485BUSIDLE1
|
||||
if (J5_0_485_IDLE_Flag == 0) {
|
||||
J5_0_485_IDLE_Flag = 1;
|
||||
J5_0_485_IN_RXNE();
|
||||
}
|
||||
#endif
|
||||
J5_0_Rbuffer[0] = USART_ReceiveData(J5_0_USART); //接收数据
|
||||
uart_device_info *dev = (uart_device_info *)g_J5_0_usart3_handle;
|
||||
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
|
@ -488,11 +524,19 @@ void J5_0_Interrupt()
|
|||
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||
USART_ITConfig(J5_0_USART, USART_IT_TXE, DISABLE);
|
||||
setJ5_0_485_SendState(0);
|
||||
J5_0_485_IN_TXE();
|
||||
return;
|
||||
}
|
||||
USART_SendData(J5_0_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
/* 空闲中断 */
|
||||
if (USART_GetITStatus(J5_0_USART, USART_IT_IDLE) != RESET) {
|
||||
J5_0_485_IN_IDLE();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void Upward_Interrupt()
|
||||
|
@ -513,6 +557,7 @@ void Upward_Interrupt()
|
|||
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||
USART_ITConfig(Upward_USART, USART_IT_TXE, DISABLE);
|
||||
setUpward_uart_SendState(0);
|
||||
Upward_USART_IN_TXE();
|
||||
return;
|
||||
}
|
||||
USART_SendData(Upward_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||
|
@ -524,6 +569,12 @@ void J1_Interrupt()
|
|||
{
|
||||
/* 数据接收中断 */
|
||||
if (USART_GetITStatus(J1_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||
#ifdef RS485BUSIDLE1
|
||||
if (J1_485_IDLE_Flag == 0) {
|
||||
J1_485_IDLE_Flag = 1;
|
||||
J1_485_IN_RXNE();
|
||||
}
|
||||
#endif
|
||||
J1_Rbuffer[0] = USART_ReceiveData(J1_USART); //接收数据
|
||||
uart_device_info *dev = (uart_device_info *)g_J1_uart6_handle;
|
||||
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
|
@ -537,17 +588,31 @@ void J1_Interrupt()
|
|||
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||
USART_ITConfig(J1_USART, USART_IT_TXE, DISABLE);
|
||||
setJ1_485_SendState(0);
|
||||
J1_485_IN_TXE();
|
||||
return;
|
||||
}
|
||||
USART_SendData(J1_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
/* 空闲中断 */
|
||||
if (USART_GetITStatus(J1_USART, USART_IT_IDLE) != RESET) {
|
||||
J1_485_IN_IDLE();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void J2_Interrupt()
|
||||
{
|
||||
/* 数据接收中断 */
|
||||
if (USART_GetITStatus(J2_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||
#ifdef RS485BUSIDLE1
|
||||
if (J2_485_IDLE_Flag == 0) {
|
||||
J2_485_IDLE_Flag = 1;
|
||||
J2_485_IN_RXNE();
|
||||
}
|
||||
#endif
|
||||
J2_Rbuffer[0] = USART_ReceiveData(J2_USART); //接收数据
|
||||
uart_device_info *dev = (uart_device_info *)g_J2_uart7_handle;
|
||||
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
|
@ -561,17 +626,31 @@ void J2_Interrupt()
|
|||
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||
USART_ITConfig(J2_USART, USART_IT_TXE, DISABLE);
|
||||
setJ2_485_SendState(0);
|
||||
J2_485_IN_TXE();
|
||||
return;
|
||||
}
|
||||
USART_SendData(J2_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
/* 空闲中断 */
|
||||
if (USART_GetITStatus(J2_USART, USART_IT_IDLE) != RESET) {
|
||||
J2_485_IN_IDLE();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void J4_Interrupt()
|
||||
{
|
||||
/* 数据接收中断 */
|
||||
if (USART_GetITStatus(J4_USART, USART_IT_RXNE) != RESET) { //中断产生
|
||||
#ifdef RS485BUSIDLE1
|
||||
if (J4_485_IDLE_Flag == 0) {
|
||||
J4_485_IDLE_Flag = 1;
|
||||
J4_485_IN_RXNE();
|
||||
}
|
||||
#endif
|
||||
J4_Rbuffer[0] = USART_ReceiveData(J4_USART); //接收数据
|
||||
uart_device_info *dev = (uart_device_info *)g_J4_uart8_handle;
|
||||
if(!RingQueueFull(&dev->uart_ring_queue))
|
||||
|
@ -585,11 +664,19 @@ void J4_Interrupt()
|
|||
if (dev->uart_send_data.count >= dev->uart_send_data.len) {
|
||||
USART_ITConfig(J4_USART, USART_IT_TXE, DISABLE);
|
||||
setJ4_485_SendState(0);
|
||||
J4_485_IN_TXE();
|
||||
return;
|
||||
}
|
||||
USART_SendData(J4_USART, dev->uart_send_data.data[dev->uart_send_data.count++]);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
/* 空闲中断 */
|
||||
if (USART_GetITStatus(J4_USART, USART_IT_IDLE) != RESET) {
|
||||
J4_485_IN_IDLE();
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef UARTINTERRUPTSEND
|
||||
|
@ -644,3 +731,179 @@ uint8_t uartInterruptSend(device_handle device,uint8_t *data, uint16_t len)
|
|||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef RS485BUSIDLE1
|
||||
/**
|
||||
* @brief 得到总线的空闲状态
|
||||
* @param device 设备
|
||||
* @retval 0 空闲
|
||||
1 不空闲
|
||||
0xFF 异常
|
||||
*/
|
||||
uint8_t getBUSIDLEFlag(device_handle device)
|
||||
{
|
||||
if (device == g_J1_uart6_handle) {
|
||||
return (J1_485_IDLE_Flag & BUS_IDLE);
|
||||
} else if (device == g_J2_uart7_handle) {
|
||||
return (J2_485_IDLE_Flag & BUS_IDLE);
|
||||
} else if (device == g_J3_usart2_handle) {
|
||||
return (J3_485_IDLE_Flag & BUS_IDLE);
|
||||
} else if (device == g_J4_uart8_handle) {
|
||||
return (J4_485_IDLE_Flag & BUS_IDLE);
|
||||
} else if (device == g_J5_0_usart3_handle) {
|
||||
return (J5_0_485_IDLE_Flag & BUS_IDLE);
|
||||
}
|
||||
return 0xFF;
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @brief 得到总线的空闲状态
|
||||
// * @param device 设备
|
||||
// * @retval 0 空闲
|
||||
// 1 不空闲
|
||||
// 0xFF 异常
|
||||
// */
|
||||
// uint8_t getSoftwareIDLEFlag(device_handle device)
|
||||
// {
|
||||
// if (device == g_J1_uart6_handle) {
|
||||
// return (J1_485_IDLE_Flag & softwareTimeFlag);
|
||||
// } else if (device == g_J2_uart7_handle) {
|
||||
// return (J2_485_IDLE_Flag & softwareTimeFlag);
|
||||
// } else if (device == g_J3_usart2_handle) {
|
||||
// return (J3_485_IDLE_Flag & softwareTimeFlag);
|
||||
// } else if (device == g_J4_uart8_handle) {
|
||||
// return (J4_485_IDLE_Flag & softwareTimeFlag);
|
||||
// } else if (device == g_J5_0_usart3_handle) {
|
||||
// return (J5_0_485_IDLE_Flag & softwareTimeFlag);
|
||||
// }
|
||||
// return 0xFF;
|
||||
// }
|
||||
|
||||
// /**
|
||||
// * @brief 设置总线对应的串口进入空闲状态(空闲中断获得)
|
||||
// * @param device 设备
|
||||
// state 状态 0 空闲
|
||||
// 1 不空闲
|
||||
// * @retval
|
||||
// */
|
||||
// void setSoftwareIDLEFlag(device_handle device, uint8_t state)
|
||||
// {
|
||||
// if (state == 0) {
|
||||
// if (device == g_J1_uart6_handle) {
|
||||
// J1_485_IDLE_Flag &= (~softwareTimeFlag);
|
||||
// } else if (device == g_J2_uart7_handle) {
|
||||
// J2_485_IDLE_Flag &= (~softwareTimeFlag);
|
||||
// } else if (device == g_J3_usart2_handle) {
|
||||
// J3_485_IDLE_Flag &= (~softwareTimeFlag);
|
||||
// } else if (device == g_J4_uart8_handle) {
|
||||
// J4_485_IDLE_Flag &= (~softwareTimeFlag);
|
||||
// } else if (device == g_J5_0_usart3_handle) {
|
||||
// J5_0_485_IDLE_Flag &= (~softwareTimeFlag);
|
||||
// }
|
||||
// }
|
||||
// else if (state == 1) {
|
||||
// if (device == g_J1_uart6_handle) {
|
||||
// J1_485_IDLE_Flag &= (softwareTimeFlag);
|
||||
// } else if (device == g_J2_uart7_handle) {
|
||||
// J2_485_IDLE_Flag &= (softwareTimeFlag);
|
||||
// } else if (device == g_J3_usart2_handle) {
|
||||
// J3_485_IDLE_Flag &= (softwareTimeFlag);
|
||||
// } else if (device == g_J4_uart8_handle) {
|
||||
// J4_485_IDLE_Flag &= (softwareTimeFlag);
|
||||
// } else if (device == g_J5_0_usart3_handle) {
|
||||
// J5_0_485_IDLE_Flag &= (softwareTimeFlag);
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/**
|
||||
* @brief 设置总线空闲状态
|
||||
* @param device 设备
|
||||
state 状态 0 空闲
|
||||
1 不空闲
|
||||
* @retval
|
||||
*/
|
||||
void setBUSIDLEFlag(device_handle device, uint8_t state)
|
||||
{
|
||||
// if (state == 0) {
|
||||
// if (device == g_J1_uart6_handle) {
|
||||
// J1_485_IDLE_Flag &= (~BUS_IDLE);
|
||||
// } else if (device == g_J2_uart7_handle) {
|
||||
// J2_485_IDLE_Flag &= (~BUS_IDLE);
|
||||
// } else if (device == g_J3_usart2_handle) {
|
||||
// J3_485_IDLE_Flag &= (~BUS_IDLE);
|
||||
// } else if (device == g_J4_uart8_handle) {
|
||||
// J4_485_IDLE_Flag &= (~BUS_IDLE);
|
||||
// } else if (device == g_J5_0_usart3_handle) {
|
||||
// J5_0_485_IDLE_Flag &= (~BUS_IDLE);
|
||||
// }
|
||||
// }
|
||||
// else if (state == 1) {
|
||||
// if (device == g_J1_uart6_handle) {
|
||||
// J1_485_IDLE_Flag &= (BUS_IDLE);
|
||||
// } else if (device == g_J2_uart7_handle) {
|
||||
// J2_485_IDLE_Flag &= (BUS_IDLE);
|
||||
// } else if (device == g_J3_usart2_handle) {
|
||||
// J3_485_IDLE_Flag &= (BUS_IDLE);
|
||||
// } else if (device == g_J4_uart8_handle) {
|
||||
// J4_485_IDLE_Flag &= (BUS_IDLE);
|
||||
// } else if (device == g_J5_0_usart3_handle) {
|
||||
// J5_0_485_IDLE_Flag &= (BUS_IDLE);
|
||||
// }
|
||||
// }
|
||||
|
||||
if (state != 0 || state != 1) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (device == g_J1_uart6_handle) {
|
||||
J1_485_IDLE_Flag = state;
|
||||
} else if (device == g_J2_uart7_handle) {
|
||||
J2_485_IDLE_Flag = state;
|
||||
} else if (device == g_J3_usart2_handle) {
|
||||
J3_485_IDLE_Flag = state;
|
||||
} else if (device == g_J4_uart8_handle) {
|
||||
J4_485_IDLE_Flag = state;
|
||||
} else if (device == g_J5_0_usart3_handle) {
|
||||
J5_0_485_IDLE_Flag = state;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief 设置总线空闲状态
|
||||
* @param port 要连接的端口
|
||||
* @retval
|
||||
*/
|
||||
void setConnectPort(uint8_t port)
|
||||
{
|
||||
if (port == connectJ0) {
|
||||
connectPort = connectJ0;
|
||||
USART_CONNET_J0();
|
||||
} else if (port == connectJ5) {
|
||||
connectPort = connectJ5;
|
||||
USART_CONNET_J5();
|
||||
} else if (port == connectJ6) {
|
||||
connectPort = connectJ6;
|
||||
USART_CONNET_J6();
|
||||
} else if (port == connectJ7) {
|
||||
connectPort = connectJ7;
|
||||
USART_CONNET_J7();
|
||||
} else if (port == connectJ8) {
|
||||
connectPort = connectJ8;
|
||||
USART_CONNET_J8();
|
||||
} else if (port == connectJ9) {
|
||||
connectPort = connectJ9;
|
||||
USART_CONNET_J9();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief 设置总线空闲状态
|
||||
* @param
|
||||
* @retval 连接的端口
|
||||
*/
|
||||
uint8_t getConnectPort(void)
|
||||
{
|
||||
return connectPort;
|
||||
}
|
||||
|
|
|
@ -62,6 +62,7 @@ void J1_485_Init(uint32_t baud)
|
|||
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||
|
||||
USART_ITConfig(UART6, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(UART6, USART_IT_IDLE, ENABLE);
|
||||
|
||||
USART_Cmd(UART6,ENABLE);
|
||||
}
|
||||
|
@ -115,6 +116,7 @@ void J2_485_Init(uint32_t baud)
|
|||
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||
|
||||
USART_ITConfig(UART7, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(UART7, USART_IT_IDLE, ENABLE);
|
||||
|
||||
USART_Cmd(UART7,ENABLE);
|
||||
}
|
||||
|
@ -167,6 +169,7 @@ void J3_485_Init(uint32_t baud)
|
|||
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||
|
||||
USART_ITConfig(USART2, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(USART2, USART_IT_IDLE, ENABLE);
|
||||
|
||||
USART_Cmd(USART2,ENABLE);
|
||||
}
|
||||
|
@ -219,6 +222,7 @@ void J4_485_Init(uint32_t baud)
|
|||
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||
|
||||
USART_ITConfig(UART8, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(UART8, USART_IT_IDLE, ENABLE);
|
||||
|
||||
USART_Cmd(UART8,ENABLE);
|
||||
}
|
||||
|
@ -278,6 +282,7 @@ void J5_0_485_Init(uint32_t baud)
|
|||
NVIC_Init(&NVIC_InitStructure); //中断优先级初始化
|
||||
|
||||
USART_ITConfig(USART3, USART_IT_RXNE, ENABLE);
|
||||
USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
|
||||
// USART_ITConfig(USART3, USART_IT_IDLE, ENABLE);
|
||||
|
||||
USART_Cmd(USART3,ENABLE);
|
||||
|
|
|
@ -304,7 +304,7 @@
|
|||
},
|
||||
"createFlash": {
|
||||
"enabled": true,
|
||||
"outputFileFormat": "ihex",
|
||||
"outputFileFormat": "ihexAndbinary",
|
||||
"copy_only_section_text": false,
|
||||
"copy_only_section_data": false,
|
||||
"copy_only_sections": [],
|
||||
|
|
|
@ -72,6 +72,10 @@
|
|||
#define FREERTOS_CONFIG_H
|
||||
#include "debug.h"
|
||||
|
||||
/* user */
|
||||
#define configUSE_QUEUE_SETS 1
|
||||
|
||||
|
||||
/*-----------------------------------------------------------
|
||||
* Application specific definitions.
|
||||
*
|
||||
|
@ -97,7 +101,8 @@
|
|||
#define configTICK_RATE_HZ ( ( TickType_t ) 500 )
|
||||
#define configMAX_PRIORITIES ( 15 )
|
||||
#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 ) /* Can be as low as 60 but some of the demo tasks that use this constant require it to be higher. */
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 12 * 1024 ) )
|
||||
// #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 12 * 1024 ) )
|
||||
#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 24 * 1024 ) )
|
||||
#define configMAX_TASK_NAME_LEN ( 16 )
|
||||
#define configUSE_TRACE_FACILITY 0
|
||||
#define configUSE_16_BIT_TICKS 0
|
||||
|
|
Binary file not shown.
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
@ -45,6 +45,7 @@ endif
|
|||
|
||||
# Add inputs and outputs from these tool invocations to the build variables
|
||||
SECONDARY_FLASH += \
|
||||
CH32V303-FreeRTOS.bin \
|
||||
CH32V303-FreeRTOS.hex \
|
||||
|
||||
SECONDARY_LIST += \
|
||||
|
@ -63,6 +64,8 @@ main-build: CH32V303-FreeRTOS.elf secondary-outputs
|
|||
# Tool invocations
|
||||
CH32V303-FreeRTOS.elf: $(OBJS) $(USER_OBJS)
|
||||
@ riscv-none-embed-gcc -march=rv32imacxw -mabi=ilp32 -msmall-data-limit=8 -msave-restore -fmax-errors=20 -Os -fmessage-length=0 -fsigned-char -ffunction-sections -fdata-sections -fno-common -Wunused -Wuninitialized -g -T "d:/psx/su806/2.software/mcu_git/CH32V303-FreeRTOS/Ld/Link.ld" -nostartfiles -Xlinker --gc-sections -Wl,-Map,"CH32V303-FreeRTOS.map" --specs=nano.specs --specs=nosys.specs -o "CH32V303-FreeRTOS.elf" $(OBJS) $(USER_OBJS) $(LIBS)
|
||||
CH32V303-FreeRTOS.bin: CH32V303-FreeRTOS.elf
|
||||
@ riscv-none-embed-objcopy -O binary "CH32V303-FreeRTOS.elf" "CH32V303-FreeRTOS.bin"
|
||||
CH32V303-FreeRTOS.hex: CH32V303-FreeRTOS.elf
|
||||
@ riscv-none-embed-objcopy -O ihex "CH32V303-FreeRTOS.elf" "CH32V303-FreeRTOS.hex"
|
||||
CH32V303-FreeRTOS.lst: CH32V303-FreeRTOS.elf
|
||||
|
|
Loading…
Reference in New Issue