更新:
1、数据发送统一换成DMA; 2、新增DMA接收与处理,使用宏定义对其进行封装; 3、新增“开始接收”、“接收完成”、“发送完成”时刻捕获,并对延迟时间进行了计算;
This commit is contained in:
parent
9bd6a9d702
commit
9ef099f074
|
@ -35,7 +35,8 @@
|
||||||
"key_functions.h": "c",
|
"key_functions.h": "c",
|
||||||
"sstream": "c",
|
"sstream": "c",
|
||||||
"modbus_485.h": "c",
|
"modbus_485.h": "c",
|
||||||
"hart.h": "c"
|
"hart.h": "c",
|
||||||
|
"string_view": "c"
|
||||||
},
|
},
|
||||||
"C_Cpp.errorSquiggles": "disabled",
|
"C_Cpp.errorSquiggles": "disabled",
|
||||||
"idf.pythonInstallPath": "F:\\Espressif\\tools\\idf-python\\3.11.2\\python.exe",
|
"idf.pythonInstallPath": "F:\\Espressif\\tools\\idf-python\\3.11.2\\python.exe",
|
||||||
|
|
|
@ -126,9 +126,12 @@ typedef enum
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
TRANS_NONE = 0, //无通讯
|
TRANS_NONE = 0, //无通讯
|
||||||
TRANS_HART, //HART透传
|
TRANS_HART_TO_PC, //HART设备->上位机
|
||||||
TRANS_BLUETOOTH, //蓝牙透传
|
TRANS_PC_TO_HART, //上位机->HART设备
|
||||||
TRANS_MODBUS //MODBUS
|
TRANS_BLE_TO_PC, //蓝牙设备->上位机
|
||||||
|
TRANS_PC_TO_BLE, //上位机->蓝牙设备
|
||||||
|
TRANS_MODBUS_PC_TO_SIG, //MODBUS,SIG作为从设备,上位机->SIG
|
||||||
|
TRANS_MODBUS_SIG_TO_SLAVE //MODBUS,SIG作为主设备,SIG->从设备
|
||||||
}SIG_TRANSMISSION;
|
}SIG_TRANSMISSION;
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
|
|
@ -832,6 +832,8 @@ void my_inits_gather(void)
|
||||||
{
|
{
|
||||||
//HART复位关闭
|
//HART复位关闭
|
||||||
HART_RESET(GPIO_PIN_SET);
|
HART_RESET(GPIO_PIN_SET);
|
||||||
|
//HART默认接收
|
||||||
|
HART_RTS(RTS_OFF);
|
||||||
|
|
||||||
//eeprom
|
//eeprom
|
||||||
eeprom_spi_init();
|
eeprom_spi_init();
|
||||||
|
|
|
@ -44,6 +44,10 @@ void transparent_bluetooth(st_scom *scom)
|
||||||
//清空缓存区,等待新的数据
|
//清空缓存区,等待新的数据
|
||||||
memset(scom->tx_buff, 0, sizeof(scom->tx_buff));
|
memset(scom->tx_buff, 0, sizeof(scom->tx_buff));
|
||||||
scom->tx_len = 0;
|
scom->tx_len = 0;
|
||||||
|
|
||||||
|
xTaskResumeFromISR(task_lcdHandle);
|
||||||
|
xTaskResumeFromISR(task_menuHandle);
|
||||||
|
screen_suspend_flag = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ void transparent_hart(st_scom *scom)
|
||||||
{
|
{
|
||||||
scom->tx_flag = FALSE;
|
scom->tx_flag = FALSE;
|
||||||
HART_RTS(RTS_ON);
|
HART_RTS(RTS_ON);
|
||||||
vTaskDelay(5);
|
vTaskDelay(15);
|
||||||
|
|
||||||
//将tx中的数据发送至HART设备
|
//将tx中的数据发送至HART设备
|
||||||
hart_send(&huart1, scom->tx_buff);
|
hart_send(&huart1, scom->tx_buff);
|
||||||
|
@ -95,6 +95,10 @@ void transparent_hart(st_scom *scom)
|
||||||
//清空缓存区,等待新的数据
|
//清空缓存区,等待新的数据
|
||||||
memset(scom->tx_buff, 0, sizeof(scom->tx_buff));
|
memset(scom->tx_buff, 0, sizeof(scom->tx_buff));
|
||||||
scom->tx_len = 0;
|
scom->tx_len = 0;
|
||||||
|
|
||||||
|
xTaskResumeFromISR(task_lcdHandle);
|
||||||
|
xTaskResumeFromISR(task_menuHandle);
|
||||||
|
screen_suspend_flag = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3,6 +3,13 @@
|
||||||
|
|
||||||
#include "apps_gather.h"
|
#include "apps_gather.h"
|
||||||
|
|
||||||
|
extern uint32_t tick_start;
|
||||||
|
extern uint32_t tick_middle;
|
||||||
|
extern uint32_t tick_end;
|
||||||
|
extern uint32_t trans_log_rx;
|
||||||
|
extern uint32_t trans_log_tx;
|
||||||
|
extern uint8_t st_flag;
|
||||||
|
|
||||||
void parse_scom_485(st_scom *scom);
|
void parse_scom_485(st_scom *scom);
|
||||||
|
|
||||||
//PC <---SIG---> HART/BLUETOOTH/MODBUS
|
//PC <---SIG---> HART/BLUETOOTH/MODBUS
|
||||||
|
@ -10,4 +17,23 @@ void parse_scom_485(st_scom *scom);
|
||||||
//HART:将接收完成的HART的数据发送至上位机,将来自上位机的HART数据装载至comhart_tx
|
//HART:将接收完成的HART的数据发送至上位机,将来自上位机的HART数据装载至comhart_tx
|
||||||
void transparent_485(st_scom *scom);
|
void transparent_485(st_scom *scom);
|
||||||
|
|
||||||
|
//透传,DMA发送,与发送回调组合使用
|
||||||
|
void transparent_tim(void);
|
||||||
|
|
||||||
|
void trans_hart2pc(void);
|
||||||
|
|
||||||
|
void trans_pc2hart(void);
|
||||||
|
|
||||||
|
void trans_ble2pc(void);
|
||||||
|
|
||||||
|
void trans_pc2ble(void);
|
||||||
|
|
||||||
|
void trans_modbus_pc2sig(void);
|
||||||
|
|
||||||
|
void trans_modbus_sig2slave(void);
|
||||||
|
|
||||||
|
//DMA接收只有半满中断、空闲中断和完成(溢出)中断,因此用以下函数尝试进行捕获
|
||||||
|
//该函数放置于TIM2的中断内,1ms为周期,尝试捕获前3帧
|
||||||
|
void trans_start_capture(void);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -1,5 +1,12 @@
|
||||||
#include "modbus_485.h"
|
#include "modbus_485.h"
|
||||||
|
|
||||||
|
uint32_t tick_start = 0;
|
||||||
|
uint32_t tick_middle = 0;
|
||||||
|
uint32_t tick_end = 0;
|
||||||
|
uint32_t trans_log_rx = 0;
|
||||||
|
uint32_t trans_log_tx = 0;
|
||||||
|
uint8_t st_flag = 0;
|
||||||
|
|
||||||
//static void scom_485_send(UART_HandleTypeDef *huart, char *str)
|
//static void scom_485_send(UART_HandleTypeDef *huart, char *str)
|
||||||
//{
|
//{
|
||||||
// RS485_RW(RS485_WR);
|
// RS485_RW(RS485_WR);
|
||||||
|
@ -36,44 +43,45 @@ void transparent_485(st_scom *scom)
|
||||||
{
|
{
|
||||||
scom->rx_flag = FALSE;
|
scom->rx_flag = FALSE;
|
||||||
|
|
||||||
switch (sig_trans)
|
// switch (sig_trans)
|
||||||
{
|
// {
|
||||||
case TRANS_HART:
|
// case TRANS_HART:
|
||||||
{
|
// {
|
||||||
if ((scom->rx_buff[0] == 0xff) && (scom->rx_buff[1] == 0xff) && (scom->rx_buff[scom->rx_len - 1] == 0xaa))
|
// if ((scom->rx_buff[0] == 0xff) && (scom->rx_buff[1] == 0xff) && (scom->rx_buff[scom->rx_len - 1] == 0xaa))
|
||||||
{
|
// {
|
||||||
//接收到的数据是否符合HART数据报,符合则写入HART的tx,准备发送至HART设备
|
// //接收到的数据是否符合HART数据报,符合则写入HART的tx,准备发送至HART设备
|
||||||
memcpy(scom1_hart.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
// memcpy(scom1_hart.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
||||||
scom1_hart.tx_flag = TRUE;
|
// scom1_hart.tx_flag = TRUE;
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case TRANS_BLUETOOTH:
|
// case TRANS_BLUETOOTH:
|
||||||
{
|
// {
|
||||||
//将接收到的数据存入BLE的tx,准备发送至蓝牙设备
|
// //将接收到的数据存入BLE的tx,准备发送至蓝牙设备
|
||||||
memcpy(scom6_ble.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
// memcpy(scom6_ble.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
||||||
scom6_ble.tx_flag = TRUE;
|
// scom6_ble.tx_flag = TRUE;
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case TRANS_MODBUS:
|
// case TRANS_MODBUS:
|
||||||
{
|
// {
|
||||||
modbus_process_rtu();
|
// modbus_process_rtu();
|
||||||
}
|
// }
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
case TRANS_NONE:
|
// case TRANS_NONE:
|
||||||
{}
|
// {}
|
||||||
break;
|
// break;
|
||||||
|
|
||||||
default:
|
// default:
|
||||||
break;
|
// break;
|
||||||
}
|
// }
|
||||||
|
|
||||||
//清空缓存区,等待新的数据
|
//清空缓存区,等待新的数据
|
||||||
memset(scom->rx_buff, 0, sizeof(scom->rx_buff));
|
memset(scom->rx_buff, 0, sizeof(scom->rx_buff));
|
||||||
scom->rx_len = 0;
|
scom->rx_len = 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//数据是否准备完成
|
//数据是否准备完成
|
||||||
|
@ -81,7 +89,8 @@ void transparent_485(st_scom *scom)
|
||||||
{
|
{
|
||||||
scom->tx_flag = FALSE;
|
scom->tx_flag = FALSE;
|
||||||
|
|
||||||
vTaskDelay(10);
|
//vTaskDelay(10);
|
||||||
|
wu_delay_us(1000);
|
||||||
|
|
||||||
//将数据发送至上位机
|
//将数据发送至上位机
|
||||||
HAL_UART_Transmit(&huart2, scom->tx_buff, scom->tx_len, 0xFFFF);
|
HAL_UART_Transmit(&huart2, scom->tx_buff, scom->tx_len, 0xFFFF);
|
||||||
|
@ -90,8 +99,253 @@ void transparent_485(st_scom *scom)
|
||||||
memset(scom->tx_buff, 0, sizeof(scom->tx_buff));
|
memset(scom->tx_buff, 0, sizeof(scom->tx_buff));
|
||||||
scom->tx_len = 0;
|
scom->tx_len = 0;
|
||||||
//HAL_UART_Transmit_IT(&huart2, scom->tx_buff, scom->tx_len);
|
//HAL_UART_Transmit_IT(&huart2, scom->tx_buff, scom->tx_len);
|
||||||
|
|
||||||
|
xTaskResumeFromISR(task_lcdHandle);
|
||||||
|
xTaskResumeFromISR(task_menuHandle);
|
||||||
|
screen_suspend_flag = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void transparent_tim(void)
|
||||||
|
{
|
||||||
|
switch (sig_trans)
|
||||||
|
{
|
||||||
|
case TRANS_NONE:
|
||||||
|
{}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRANS_HART_TO_PC:
|
||||||
|
{
|
||||||
|
trans_hart2pc();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRANS_PC_TO_HART:
|
||||||
|
{
|
||||||
|
trans_pc2hart();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRANS_BLE_TO_PC:
|
||||||
|
{
|
||||||
|
trans_ble2pc();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRANS_PC_TO_BLE:
|
||||||
|
{
|
||||||
|
trans_pc2ble();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRANS_MODBUS_PC_TO_SIG:
|
||||||
|
{
|
||||||
|
trans_modbus_pc2sig();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
case TRANS_MODBUS_SIG_TO_SLAVE:
|
||||||
|
{
|
||||||
|
trans_modbus_sig2slave();
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_hart2pc(void)
|
||||||
|
{
|
||||||
|
//来自HART设备的数据是否接收完成
|
||||||
|
if (scom1_hart.rx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom1_hart.rx_flag = FALSE;
|
||||||
|
|
||||||
|
//接收到的数据是否符合HART数据报,符合则写入485的tx,准备发送至上位机
|
||||||
|
if ((scom1_hart.rx_buff[0] == 0xff) && (scom1_hart.rx_buff[1] == 0xff) && (scom1_hart.rx_buff[scom1_hart.rx_len - 1] == 0xAA))
|
||||||
|
{
|
||||||
|
//SIG -> PC
|
||||||
|
memcpy(scom2_rs485.tx_buff, scom1_hart.rx_buff, sizeof(scom1_hart.rx_buff));
|
||||||
|
scom2_rs485.tx_len = scom1_hart.rx_len;
|
||||||
|
scom2_rs485.tx_flag = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(scom2_rs485.tx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom2_rs485.tx_flag = FALSE;
|
||||||
|
|
||||||
|
//wu_delay_us(500);
|
||||||
|
|
||||||
|
//将数据发送至上位机
|
||||||
|
//HAL_UART_Transmit(&huart2, scom2_rs485.tx_buff, scom2_rs485.tx_len, 0xFFFF);
|
||||||
|
HAL_UART_Transmit_DMA(&huart2, scom2_rs485.tx_buff, scom2_rs485.tx_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
//清空缓存区,等待新的数据
|
||||||
|
memset(scom1_hart.rx_buff, 0, sizeof(scom1_hart.rx_buff));
|
||||||
|
scom1_hart.rx_len = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_pc2hart(void)
|
||||||
|
{
|
||||||
|
if (scom2_rs485.rx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom2_rs485.rx_flag = FALSE;
|
||||||
|
|
||||||
|
if ((scom2_rs485.rx_buff[0] == 0xff) && (scom2_rs485.rx_buff[1] == 0xff) && (scom2_rs485.rx_buff[scom2_rs485.rx_len - 1] == 0xaa))
|
||||||
|
{
|
||||||
|
//接收到的数据是否符合HART数据报,符合则写入HART的tx,准备发送至HART设备
|
||||||
|
memcpy(scom1_hart.tx_buff, scom2_rs485.rx_buff, sizeof(scom2_rs485.rx_buff));
|
||||||
|
scom1_hart.tx_len = scom2_rs485.rx_len;
|
||||||
|
scom1_hart.tx_flag = TRUE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//来自上位机的数据是否准备完毕
|
||||||
|
if (scom1_hart.tx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom1_hart.tx_flag = FALSE;
|
||||||
|
HART_RTS(RTS_ON);
|
||||||
|
|
||||||
|
wu_delay_us(15000);
|
||||||
|
|
||||||
|
//将tx中的数据发送至HART设备
|
||||||
|
//hart_send(&huart1, scom1_hart.tx_buff);
|
||||||
|
//HAL_UART_Transmit(&huart1, scom1_hart.tx_buff, scom1_hart.tx_len , 0xFFFF);
|
||||||
|
HAL_UART_Transmit_DMA(&huart1, scom1_hart.tx_buff, scom1_hart.tx_len);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//清空缓存区,等待新的数据
|
||||||
|
memset(scom2_rs485.rx_buff, 0, sizeof(scom2_rs485.rx_buff));
|
||||||
|
scom2_rs485.rx_len = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_ble2pc(void)
|
||||||
|
{
|
||||||
|
if (scom6_ble.rx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom6_ble.rx_flag = FALSE;
|
||||||
|
|
||||||
|
//将接收到的数据存入485的tx,准备发送至上位机
|
||||||
|
memcpy(scom2_rs485.tx_buff, scom6_ble.rx_buff, sizeof(scom6_ble.rx_buff));
|
||||||
|
scom2_rs485.tx_len = scom6_ble.rx_len;
|
||||||
|
scom2_rs485.tx_flag = TRUE;
|
||||||
|
|
||||||
|
if(scom2_rs485.tx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom2_rs485.tx_flag = FALSE;
|
||||||
|
|
||||||
|
//wu_delay_us(500);
|
||||||
|
|
||||||
|
//将数据发送至上位机
|
||||||
|
//HAL_UART_Transmit(&huart2, scom2_rs485.tx_buff, scom2_rs485.tx_len, 0xFFFF);
|
||||||
|
HAL_UART_Transmit_DMA(&huart2, scom2_rs485.tx_buff, scom2_rs485.tx_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
//清空缓存区,等待新的数据
|
||||||
|
memset(scom6_ble.rx_buff, 0, sizeof(scom6_ble.rx_buff));
|
||||||
|
scom6_ble.rx_len = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_pc2ble(void)
|
||||||
|
{
|
||||||
|
if (scom2_rs485.rx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom2_rs485.rx_flag = FALSE;
|
||||||
|
|
||||||
|
//将接收到的数据存入BLE的tx,准备发送至蓝牙设备
|
||||||
|
memcpy(scom6_ble.tx_buff, scom2_rs485.rx_buff, sizeof(scom2_rs485.rx_buff));
|
||||||
|
scom6_ble.tx_len = scom2_rs485.rx_len;
|
||||||
|
scom6_ble.tx_flag = TRUE;
|
||||||
|
|
||||||
|
//来自上位机的数据是否准备完毕
|
||||||
|
if (scom6_ble.tx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom6_ble.tx_flag = FALSE;
|
||||||
|
|
||||||
|
//将tx中的数据发送至蓝牙设备
|
||||||
|
//ble_send(&huart6, scom6_ble.tx_buff);
|
||||||
|
//HAL_UART_Transmit(&huart6, scom6_ble.tx_buff, scom6_ble.tx_len, 0xFFFF);
|
||||||
|
HAL_UART_Transmit_DMA(&huart6, scom6_ble.tx_buff, scom6_ble.tx_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
//清空缓存区,等待新的数据
|
||||||
|
memset(scom2_rs485.rx_buff, 0, sizeof(scom2_rs485.rx_buff));
|
||||||
|
scom2_rs485.rx_len = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_modbus_pc2sig(void)
|
||||||
|
{
|
||||||
|
if (scom2_rs485.rx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom2_rs485.rx_flag = FALSE;
|
||||||
|
|
||||||
|
modbus_process_rtu();
|
||||||
|
|
||||||
|
if(scom2_rs485.tx_flag == TRUE)
|
||||||
|
{
|
||||||
|
scom2_rs485.tx_flag = FALSE;
|
||||||
|
|
||||||
|
//wu_delay_us(500);
|
||||||
|
|
||||||
|
//将数据发送至上位机
|
||||||
|
//HAL_UART_Transmit(&huart2, scom2_rs485.tx_buff, scom2_rs485.tx_len, 0xFFFF);
|
||||||
|
HAL_UART_Transmit_DMA(&huart2, scom2_rs485.tx_buff, scom2_rs485.tx_len);
|
||||||
|
}
|
||||||
|
|
||||||
|
//清空缓存区,等待新的数据
|
||||||
|
memset(scom2_rs485.rx_buff, 0, sizeof(scom2_rs485.rx_buff));
|
||||||
|
scom2_rs485.rx_len = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_modbus_sig2slave(void)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void trans_start_capture(void)
|
||||||
|
{
|
||||||
|
if( ( 1 <= (BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart1.hdmarx)) )&&( (BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart1.hdmarx)) <= 3) )
|
||||||
|
{
|
||||||
|
if(tabdata.hart_enable)
|
||||||
|
{
|
||||||
|
if (st_flag == 0)
|
||||||
|
{
|
||||||
|
st_flag = 1;
|
||||||
|
tick_start = xTaskGetTickCountFromISR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( 1 <= (BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart6.hdmarx)) )&&( (BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart6.hdmarx)) <= 3) )
|
||||||
|
{
|
||||||
|
if(tabdata.bluetooth_enable)
|
||||||
|
{
|
||||||
|
if (st_flag == 0)
|
||||||
|
{
|
||||||
|
st_flag = 1;
|
||||||
|
tick_start = xTaskGetTickCountFromISR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if( ( 1 <= (BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart2.hdmarx)) )&&( (BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart2.hdmarx)) <= 3) )
|
||||||
|
{
|
||||||
|
if(tabdata.hart_enable||tabdata.bluetooth_enable||tabdata.modbus_enable)
|
||||||
|
{
|
||||||
|
if (st_flag == 0)
|
||||||
|
{
|
||||||
|
st_flag = 1;
|
||||||
|
tick_start = xTaskGetTickCountFromISR();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -53,7 +53,10 @@ void BusFault_Handler(void);
|
||||||
void UsageFault_Handler(void);
|
void UsageFault_Handler(void);
|
||||||
void DebugMon_Handler(void);
|
void DebugMon_Handler(void);
|
||||||
void EXTI1_IRQHandler(void);
|
void EXTI1_IRQHandler(void);
|
||||||
|
void DMA1_Stream5_IRQHandler(void);
|
||||||
|
void DMA1_Stream6_IRQHandler(void);
|
||||||
void TIM1_UP_TIM10_IRQHandler(void);
|
void TIM1_UP_TIM10_IRQHandler(void);
|
||||||
|
void TIM2_IRQHandler(void);
|
||||||
void TIM3_IRQHandler(void);
|
void TIM3_IRQHandler(void);
|
||||||
void USART1_IRQHandler(void);
|
void USART1_IRQHandler(void);
|
||||||
void USART2_IRQHandler(void);
|
void USART2_IRQHandler(void);
|
||||||
|
@ -61,6 +64,10 @@ void USART3_IRQHandler(void);
|
||||||
void TIM6_DAC_IRQHandler(void);
|
void TIM6_DAC_IRQHandler(void);
|
||||||
void TIM7_IRQHandler(void);
|
void TIM7_IRQHandler(void);
|
||||||
void DMA2_Stream0_IRQHandler(void);
|
void DMA2_Stream0_IRQHandler(void);
|
||||||
|
void DMA2_Stream1_IRQHandler(void);
|
||||||
|
void DMA2_Stream2_IRQHandler(void);
|
||||||
|
void DMA2_Stream6_IRQHandler(void);
|
||||||
|
void DMA2_Stream7_IRQHandler(void);
|
||||||
void USART6_IRQHandler(void);
|
void USART6_IRQHandler(void);
|
||||||
/* USER CODE BEGIN EFP */
|
/* USER CODE BEGIN EFP */
|
||||||
|
|
||||||
|
|
|
@ -70,6 +70,8 @@ extern "C" {
|
||||||
|
|
||||||
extern TIM_HandleTypeDef htim1;
|
extern TIM_HandleTypeDef htim1;
|
||||||
|
|
||||||
|
extern TIM_HandleTypeDef htim2;
|
||||||
|
|
||||||
extern TIM_HandleTypeDef htim3;
|
extern TIM_HandleTypeDef htim3;
|
||||||
|
|
||||||
extern TIM_HandleTypeDef htim6;
|
extern TIM_HandleTypeDef htim6;
|
||||||
|
@ -79,6 +81,7 @@ extern TIM_HandleTypeDef htim6;
|
||||||
/* USER CODE END Private defines */
|
/* USER CODE END Private defines */
|
||||||
|
|
||||||
void MX_TIM1_Init(void);
|
void MX_TIM1_Init(void);
|
||||||
|
void MX_TIM2_Init(void);
|
||||||
void MX_TIM3_Init(void);
|
void MX_TIM3_Init(void);
|
||||||
void MX_TIM6_Init(void);
|
void MX_TIM6_Init(void);
|
||||||
|
|
||||||
|
|
|
@ -44,6 +44,8 @@ extern UART_HandleTypeDef huart6;
|
||||||
|
|
||||||
/* USER CODE BEGIN Private defines */
|
/* USER CODE BEGIN Private defines */
|
||||||
|
|
||||||
|
#define RX_DMA_ENABLE 1
|
||||||
|
|
||||||
#define BUFFER_SIZE 255
|
#define BUFFER_SIZE 255
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -78,6 +80,7 @@ void MX_USART6_UART_Init(void);
|
||||||
/* USER CODE BEGIN Prototypes */
|
/* USER CODE BEGIN Prototypes */
|
||||||
void usart_printf(UART_HandleTypeDef *huart, char *fmt, ...);
|
void usart_printf(UART_HandleTypeDef *huart, char *fmt, ...);
|
||||||
void proc_huart_it(UART_HandleTypeDef *huart);
|
void proc_huart_it(UART_HandleTypeDef *huart);
|
||||||
|
void proc_huart_it_dma(UART_HandleTypeDef *huart);
|
||||||
/* USER CODE END Prototypes */
|
/* USER CODE END Prototypes */
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -41,11 +41,30 @@ void MX_DMA_Init(void)
|
||||||
|
|
||||||
/* DMA controller clock enable */
|
/* DMA controller clock enable */
|
||||||
__HAL_RCC_DMA2_CLK_ENABLE();
|
__HAL_RCC_DMA2_CLK_ENABLE();
|
||||||
|
__HAL_RCC_DMA1_CLK_ENABLE();
|
||||||
|
|
||||||
/* DMA interrupt init */
|
/* DMA interrupt init */
|
||||||
|
/* DMA1_Stream5_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA1_Stream5_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA1_Stream5_IRQn);
|
||||||
|
/* DMA1_Stream6_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA1_Stream6_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA1_Stream6_IRQn);
|
||||||
/* DMA2_Stream0_IRQn interrupt configuration */
|
/* DMA2_Stream0_IRQn interrupt configuration */
|
||||||
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 5, 0);
|
||||||
HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
|
HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn);
|
||||||
|
/* DMA2_Stream1_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA2_Stream1_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA2_Stream1_IRQn);
|
||||||
|
/* DMA2_Stream2_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA2_Stream2_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA2_Stream2_IRQn);
|
||||||
|
/* DMA2_Stream6_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA2_Stream6_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA2_Stream6_IRQn);
|
||||||
|
/* DMA2_Stream7_IRQn interrupt configuration */
|
||||||
|
HAL_NVIC_SetPriority(DMA2_Stream7_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(DMA2_Stream7_IRQn);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -229,8 +229,8 @@ void start_task_hart(void const * argument)
|
||||||
hart_communicate(&scom1_hart);
|
hart_communicate(&scom1_hart);
|
||||||
}
|
}
|
||||||
|
|
||||||
sig_trans = TRANS_HART;
|
// sig_trans = TRANS_HART;
|
||||||
transparent_hart(&scom1_hart);
|
// transparent_hart(&scom1_hart);
|
||||||
}
|
}
|
||||||
|
|
||||||
osDelay(HART_TASK_PERIOD);
|
osDelay(HART_TASK_PERIOD);
|
||||||
|
@ -265,8 +265,8 @@ void start_task_ble(void const * argument)
|
||||||
ble_send(&huart6, scom6_ble.tx_buff);
|
ble_send(&huart6, scom6_ble.tx_buff);
|
||||||
}
|
}
|
||||||
|
|
||||||
sig_trans = TRANS_BLUETOOTH;
|
// sig_trans = TRANS_BLUETOOTH;
|
||||||
transparent_bluetooth(&scom6_ble);
|
// transparent_bluetooth(&scom6_ble);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,17 +288,17 @@ void start_rs485(void const * argument)
|
||||||
/* Infinite loop */
|
/* Infinite loop */
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if(tabdata.modbus_enable == 1)
|
// if(tabdata.modbus_enable == 1)
|
||||||
{
|
// {
|
||||||
sig_trans = TRANS_MODBUS;
|
// sig_trans = TRANS_MODBUS;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if( !(tabdata.bluetooth_enable||tabdata.hart_enable||tabdata.modbus_enable) )
|
if( !(tabdata.bluetooth_enable||tabdata.hart_enable||tabdata.modbus_enable) )
|
||||||
{
|
{
|
||||||
sig_trans = TRANS_NONE;
|
sig_trans = TRANS_NONE;
|
||||||
}
|
}
|
||||||
|
|
||||||
transparent_485(&scom2_rs485);
|
// transparent_485(&scom2_rs485);
|
||||||
|
|
||||||
osDelay(RS485_TASK_PERIOD);
|
osDelay(RS485_TASK_PERIOD);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,11 +110,19 @@ int main(void)
|
||||||
MX_TIM6_Init();
|
MX_TIM6_Init();
|
||||||
MX_USART3_UART_Init();
|
MX_USART3_UART_Init();
|
||||||
MX_I2C3_Init();
|
MX_I2C3_Init();
|
||||||
|
MX_TIM2_Init();
|
||||||
/* USER CODE BEGIN 2 */
|
/* USER CODE BEGIN 2 */
|
||||||
|
|
||||||
my_inits_gather();
|
my_inits_gather();
|
||||||
|
|
||||||
HAL_TIM_Base_Start_IT(&htim6);
|
HAL_TIM_Base_Start_IT(&htim6);
|
||||||
|
HAL_TIM_Base_Start_IT(&htim2);
|
||||||
|
|
||||||
|
#if RX_DMA_ENABLE
|
||||||
|
HAL_UART_Receive_DMA(&huart1, scom1_hart.rx_buff, BUFFER_SIZE);
|
||||||
|
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||||
|
HAL_UART_Receive_DMA(&huart6, scom6_ble.rx_buff, BUFFER_SIZE);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* USER CODE END 2 */
|
/* USER CODE END 2 */
|
||||||
|
|
||||||
|
@ -212,6 +220,26 @@ void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim)
|
||||||
duty_tim6();
|
duty_tim6();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (htim->Instance == TIM2)
|
||||||
|
{
|
||||||
|
//无通讯的情况下直接返回,或者对DMA的起始时刻尝试进行捕获
|
||||||
|
if(sig_trans == TRANS_NONE)
|
||||||
|
{
|
||||||
|
#if RX_DMA_ENABLE
|
||||||
|
trans_start_capture();
|
||||||
|
#endif
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
HAL_TIM_Base_Stop(&htim2);
|
||||||
|
|
||||||
|
//DMA发送
|
||||||
|
transparent_tim();
|
||||||
|
|
||||||
|
HAL_TIM_Base_Start(&htim2);
|
||||||
|
}
|
||||||
|
|
||||||
/* USER CODE END Callback 1 */
|
/* USER CODE END Callback 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -59,8 +59,15 @@
|
||||||
extern DMA_HandleTypeDef hdma_adc1;
|
extern DMA_HandleTypeDef hdma_adc1;
|
||||||
extern DAC_HandleTypeDef hdac;
|
extern DAC_HandleTypeDef hdac;
|
||||||
extern TIM_HandleTypeDef htim1;
|
extern TIM_HandleTypeDef htim1;
|
||||||
|
extern TIM_HandleTypeDef htim2;
|
||||||
extern TIM_HandleTypeDef htim3;
|
extern TIM_HandleTypeDef htim3;
|
||||||
extern TIM_HandleTypeDef htim6;
|
extern TIM_HandleTypeDef htim6;
|
||||||
|
extern DMA_HandleTypeDef hdma_usart1_tx;
|
||||||
|
extern DMA_HandleTypeDef hdma_usart1_rx;
|
||||||
|
extern DMA_HandleTypeDef hdma_usart2_tx;
|
||||||
|
extern DMA_HandleTypeDef hdma_usart2_rx;
|
||||||
|
extern DMA_HandleTypeDef hdma_usart6_tx;
|
||||||
|
extern DMA_HandleTypeDef hdma_usart6_rx;
|
||||||
extern UART_HandleTypeDef huart1;
|
extern UART_HandleTypeDef huart1;
|
||||||
extern UART_HandleTypeDef huart2;
|
extern UART_HandleTypeDef huart2;
|
||||||
extern UART_HandleTypeDef huart3;
|
extern UART_HandleTypeDef huart3;
|
||||||
|
@ -183,6 +190,34 @@ void EXTI1_IRQHandler(void)
|
||||||
/* USER CODE END EXTI1_IRQn 1 */
|
/* USER CODE END EXTI1_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles DMA1 stream5 global interrupt.
|
||||||
|
*/
|
||||||
|
void DMA1_Stream5_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DMA1_Stream5_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA1_Stream5_IRQn 0 */
|
||||||
|
HAL_DMA_IRQHandler(&hdma_usart2_rx);
|
||||||
|
/* USER CODE BEGIN DMA1_Stream5_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA1_Stream5_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles DMA1 stream6 global interrupt.
|
||||||
|
*/
|
||||||
|
void DMA1_Stream6_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DMA1_Stream6_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA1_Stream6_IRQn 0 */
|
||||||
|
HAL_DMA_IRQHandler(&hdma_usart2_tx);
|
||||||
|
/* USER CODE BEGIN DMA1_Stream6_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA1_Stream6_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
|
* @brief This function handles TIM1 update interrupt and TIM10 global interrupt.
|
||||||
*/
|
*/
|
||||||
|
@ -197,6 +232,20 @@ void TIM1_UP_TIM10_IRQHandler(void)
|
||||||
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
|
/* USER CODE END TIM1_UP_TIM10_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles TIM2 global interrupt.
|
||||||
|
*/
|
||||||
|
void TIM2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM2_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_IRQn 0 */
|
||||||
|
HAL_TIM_IRQHandler(&htim2);
|
||||||
|
/* USER CODE BEGIN TIM2_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles TIM3 global interrupt.
|
* @brief This function handles TIM3 global interrupt.
|
||||||
*/
|
*/
|
||||||
|
@ -221,7 +270,13 @@ void USART1_IRQHandler(void)
|
||||||
/* USER CODE END USART1_IRQn 0 */
|
/* USER CODE END USART1_IRQn 0 */
|
||||||
HAL_UART_IRQHandler(&huart1);
|
HAL_UART_IRQHandler(&huart1);
|
||||||
/* USER CODE BEGIN USART1_IRQn 1 */
|
/* USER CODE BEGIN USART1_IRQn 1 */
|
||||||
|
|
||||||
|
#if RX_DMA_ENABLE
|
||||||
|
proc_huart_it_dma(&huart1);
|
||||||
|
#else
|
||||||
proc_huart_it(&huart1);
|
proc_huart_it(&huart1);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* USER CODE END USART1_IRQn 1 */
|
/* USER CODE END USART1_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -235,7 +290,13 @@ void USART2_IRQHandler(void)
|
||||||
/* USER CODE END USART2_IRQn 0 */
|
/* USER CODE END USART2_IRQn 0 */
|
||||||
HAL_UART_IRQHandler(&huart2);
|
HAL_UART_IRQHandler(&huart2);
|
||||||
/* USER CODE BEGIN USART2_IRQn 1 */
|
/* USER CODE BEGIN USART2_IRQn 1 */
|
||||||
|
|
||||||
|
#if RX_DMA_ENABLE
|
||||||
|
proc_huart_it_dma(&huart2);
|
||||||
|
#else
|
||||||
proc_huart_it(&huart2);
|
proc_huart_it(&huart2);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* USER CODE END USART2_IRQn 1 */
|
/* USER CODE END USART2_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -296,6 +357,62 @@ void DMA2_Stream0_IRQHandler(void)
|
||||||
/* USER CODE END DMA2_Stream0_IRQn 1 */
|
/* USER CODE END DMA2_Stream0_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles DMA2 stream1 global interrupt.
|
||||||
|
*/
|
||||||
|
void DMA2_Stream1_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DMA2_Stream1_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream1_IRQn 0 */
|
||||||
|
HAL_DMA_IRQHandler(&hdma_usart6_rx);
|
||||||
|
/* USER CODE BEGIN DMA2_Stream1_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream1_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles DMA2 stream2 global interrupt.
|
||||||
|
*/
|
||||||
|
void DMA2_Stream2_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DMA2_Stream2_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream2_IRQn 0 */
|
||||||
|
HAL_DMA_IRQHandler(&hdma_usart1_rx);
|
||||||
|
/* USER CODE BEGIN DMA2_Stream2_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream2_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles DMA2 stream6 global interrupt.
|
||||||
|
*/
|
||||||
|
void DMA2_Stream6_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DMA2_Stream6_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream6_IRQn 0 */
|
||||||
|
HAL_DMA_IRQHandler(&hdma_usart6_tx);
|
||||||
|
/* USER CODE BEGIN DMA2_Stream6_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream6_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This function handles DMA2 stream7 global interrupt.
|
||||||
|
*/
|
||||||
|
void DMA2_Stream7_IRQHandler(void)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN DMA2_Stream7_IRQn 0 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream7_IRQn 0 */
|
||||||
|
HAL_DMA_IRQHandler(&hdma_usart1_tx);
|
||||||
|
/* USER CODE BEGIN DMA2_Stream7_IRQn 1 */
|
||||||
|
|
||||||
|
/* USER CODE END DMA2_Stream7_IRQn 1 */
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This function handles USART6 global interrupt.
|
* @brief This function handles USART6 global interrupt.
|
||||||
*/
|
*/
|
||||||
|
@ -306,30 +423,61 @@ void USART6_IRQHandler(void)
|
||||||
/* USER CODE END USART6_IRQn 0 */
|
/* USER CODE END USART6_IRQn 0 */
|
||||||
HAL_UART_IRQHandler(&huart6);
|
HAL_UART_IRQHandler(&huart6);
|
||||||
/* USER CODE BEGIN USART6_IRQn 1 */
|
/* USER CODE BEGIN USART6_IRQn 1 */
|
||||||
|
|
||||||
|
#if RX_DMA_ENABLE
|
||||||
|
proc_huart_it_dma(&huart6);
|
||||||
|
#else
|
||||||
proc_huart_it(&huart6);
|
proc_huart_it(&huart6);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* USER CODE END USART6_IRQn 1 */
|
/* USER CODE END USART6_IRQn 1 */
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE BEGIN 1 */
|
/* USER CODE BEGIN 1 */
|
||||||
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
||||||
{
|
{
|
||||||
// if( (huart == &huart1)||(huart == &huart2)||(huart == &huart6) )
|
//发送完成后将相关数组清零
|
||||||
// {
|
if(huart == &huart1)
|
||||||
// xTaskResumeFromISR(task_lcdHandle);
|
{
|
||||||
// xTaskResumeFromISR(task_menuHandle);
|
//HART重新使能接收
|
||||||
// screen_suspend_flag = 0;
|
HART_RTS(RTS_OFF);
|
||||||
// }
|
|
||||||
|
|
||||||
// st_scom *scom;
|
memset(scom1_hart.tx_buff, 0, sizeof(scom1_hart.tx_buff));
|
||||||
|
scom1_hart.tx_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// if (huart == &huart1) scom = &scom1_hart;
|
if(huart == &huart2)
|
||||||
// else if (huart == &huart2) scom = &scom2_rs485;
|
{
|
||||||
// else if (huart == &huart6) scom = &scom6_ble;
|
memset(scom2_rs485.tx_buff, 0, sizeof(scom2_rs485.tx_buff));
|
||||||
// if (!scom) return;
|
scom2_rs485.tx_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
// //清空缓存区,等待新的数据
|
if(huart == &huart6)
|
||||||
// memset(scom->tx_buff, 0, sizeof(scom->tx_buff));
|
{
|
||||||
// scom->tx_len = 0;
|
memset(scom6_ble.tx_buff, 0, sizeof(scom6_ble.tx_buff));
|
||||||
|
scom6_ble.tx_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//接收完成后通讯模式清空,等待下一次接收
|
||||||
|
sig_trans = TRANS_NONE;
|
||||||
|
|
||||||
|
//如果显示任务被挂起,则在此处释放(无DMA的情况)
|
||||||
|
if(screen_suspend_flag)
|
||||||
|
{
|
||||||
|
xTaskResumeFromISR(task_lcdHandle);
|
||||||
|
xTaskResumeFromISR(task_menuHandle);
|
||||||
|
screen_suspend_flag = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
//记录发送完成的时间点
|
||||||
|
st_flag = 3;
|
||||||
|
tick_end = xTaskGetTickCountFromISR();
|
||||||
|
|
||||||
|
//计算延迟,捕获失败时清零(速度过快,小于1ms)
|
||||||
|
trans_log_rx = tick_middle - tick_start;
|
||||||
|
trans_log_tx = tick_end - tick_middle;
|
||||||
|
if(trans_log_rx > 1000) trans_log_rx = 0;
|
||||||
|
if(trans_log_tx > 1000) trans_log_tx = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
/* USER CODE END 0 */
|
/* USER CODE END 0 */
|
||||||
|
|
||||||
TIM_HandleTypeDef htim1;
|
TIM_HandleTypeDef htim1;
|
||||||
|
TIM_HandleTypeDef htim2;
|
||||||
TIM_HandleTypeDef htim3;
|
TIM_HandleTypeDef htim3;
|
||||||
TIM_HandleTypeDef htim6;
|
TIM_HandleTypeDef htim6;
|
||||||
|
|
||||||
|
@ -101,6 +102,46 @@ void MX_TIM1_Init(void)
|
||||||
/* USER CODE END TIM1_Init 2 */
|
/* USER CODE END TIM1_Init 2 */
|
||||||
HAL_TIM_MspPostInit(&htim1);
|
HAL_TIM_MspPostInit(&htim1);
|
||||||
|
|
||||||
|
}
|
||||||
|
/* TIM2 init function */
|
||||||
|
void MX_TIM2_Init(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM2_Init 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_Init 0 */
|
||||||
|
|
||||||
|
TIM_ClockConfigTypeDef sClockSourceConfig = {0};
|
||||||
|
TIM_MasterConfigTypeDef sMasterConfig = {0};
|
||||||
|
|
||||||
|
/* USER CODE BEGIN TIM2_Init 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_Init 1 */
|
||||||
|
htim2.Instance = TIM2;
|
||||||
|
htim2.Init.Prescaler = 2-1;
|
||||||
|
htim2.Init.CounterMode = TIM_COUNTERMODE_UP;
|
||||||
|
htim2.Init.Period = 41472-1;
|
||||||
|
htim2.Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
|
||||||
|
htim2.Init.AutoReloadPreload = TIM_AUTORELOAD_PRELOAD_DISABLE;
|
||||||
|
if (HAL_TIM_Base_Init(&htim2) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sClockSourceConfig.ClockSource = TIM_CLOCKSOURCE_INTERNAL;
|
||||||
|
if (HAL_TIM_ConfigClockSource(&htim2, &sClockSourceConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
|
||||||
|
sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
|
||||||
|
if (HAL_TIMEx_MasterConfigSynchronization(&htim2, &sMasterConfig) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
/* USER CODE BEGIN TIM2_Init 2 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_Init 2 */
|
||||||
|
|
||||||
}
|
}
|
||||||
/* TIM3 init function */
|
/* TIM3 init function */
|
||||||
void MX_TIM3_Init(void)
|
void MX_TIM3_Init(void)
|
||||||
|
@ -208,6 +249,21 @@ void HAL_TIM_Base_MspInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
|
||||||
/* USER CODE END TIM1_MspInit 1 */
|
/* USER CODE END TIM1_MspInit 1 */
|
||||||
}
|
}
|
||||||
|
else if(tim_baseHandle->Instance==TIM2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM2_MspInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspInit 0 */
|
||||||
|
/* TIM2 clock enable */
|
||||||
|
__HAL_RCC_TIM2_CLK_ENABLE();
|
||||||
|
|
||||||
|
/* TIM2 interrupt Init */
|
||||||
|
HAL_NVIC_SetPriority(TIM2_IRQn, 5, 0);
|
||||||
|
HAL_NVIC_EnableIRQ(TIM2_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM2_MspInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspInit 1 */
|
||||||
|
}
|
||||||
else if(tim_baseHandle->Instance==TIM3)
|
else if(tim_baseHandle->Instance==TIM3)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM3_MspInit 0 */
|
/* USER CODE BEGIN TIM3_MspInit 0 */
|
||||||
|
@ -304,6 +360,20 @@ void HAL_TIM_Base_MspDeInit(TIM_HandleTypeDef* tim_baseHandle)
|
||||||
|
|
||||||
/* USER CODE END TIM1_MspDeInit 1 */
|
/* USER CODE END TIM1_MspDeInit 1 */
|
||||||
}
|
}
|
||||||
|
else if(tim_baseHandle->Instance==TIM2)
|
||||||
|
{
|
||||||
|
/* USER CODE BEGIN TIM2_MspDeInit 0 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspDeInit 0 */
|
||||||
|
/* Peripheral clock disable */
|
||||||
|
__HAL_RCC_TIM2_CLK_DISABLE();
|
||||||
|
|
||||||
|
/* TIM2 interrupt Deinit */
|
||||||
|
HAL_NVIC_DisableIRQ(TIM2_IRQn);
|
||||||
|
/* USER CODE BEGIN TIM2_MspDeInit 1 */
|
||||||
|
|
||||||
|
/* USER CODE END TIM2_MspDeInit 1 */
|
||||||
|
}
|
||||||
else if(tim_baseHandle->Instance==TIM3)
|
else if(tim_baseHandle->Instance==TIM3)
|
||||||
{
|
{
|
||||||
/* USER CODE BEGIN TIM3_MspDeInit 0 */
|
/* USER CODE BEGIN TIM3_MspDeInit 0 */
|
||||||
|
|
335
Core/Src/usart.c
335
Core/Src/usart.c
|
@ -44,6 +44,12 @@ UART_HandleTypeDef huart1;
|
||||||
UART_HandleTypeDef huart2;
|
UART_HandleTypeDef huart2;
|
||||||
UART_HandleTypeDef huart3;
|
UART_HandleTypeDef huart3;
|
||||||
UART_HandleTypeDef huart6;
|
UART_HandleTypeDef huart6;
|
||||||
|
DMA_HandleTypeDef hdma_usart1_tx;
|
||||||
|
DMA_HandleTypeDef hdma_usart1_rx;
|
||||||
|
DMA_HandleTypeDef hdma_usart2_tx;
|
||||||
|
DMA_HandleTypeDef hdma_usart2_rx;
|
||||||
|
DMA_HandleTypeDef hdma_usart6_tx;
|
||||||
|
DMA_HandleTypeDef hdma_usart6_rx;
|
||||||
|
|
||||||
/* USART1 init function */
|
/* USART1 init function */
|
||||||
|
|
||||||
|
@ -189,6 +195,43 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
|
GPIO_InitStruct.Alternate = GPIO_AF7_USART1;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USART1 DMA Init */
|
||||||
|
/* USART1_TX Init */
|
||||||
|
hdma_usart1_tx.Instance = DMA2_Stream7;
|
||||||
|
hdma_usart1_tx.Init.Channel = DMA_CHANNEL_4;
|
||||||
|
hdma_usart1_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||||
|
hdma_usart1_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
hdma_usart1_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
hdma_usart1_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
|
hdma_usart1_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
|
hdma_usart1_tx.Init.Mode = DMA_NORMAL;
|
||||||
|
hdma_usart1_tx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
|
hdma_usart1_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
if (HAL_DMA_Init(&hdma_usart1_tx) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart1_tx);
|
||||||
|
|
||||||
|
/* USART1_RX Init */
|
||||||
|
hdma_usart1_rx.Instance = DMA2_Stream2;
|
||||||
|
hdma_usart1_rx.Init.Channel = DMA_CHANNEL_4;
|
||||||
|
hdma_usart1_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||||
|
hdma_usart1_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
hdma_usart1_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
hdma_usart1_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
|
hdma_usart1_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
|
hdma_usart1_rx.Init.Mode = DMA_NORMAL;
|
||||||
|
hdma_usart1_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
|
hdma_usart1_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
if (HAL_DMA_Init(&hdma_usart1_rx) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart1_rx);
|
||||||
|
|
||||||
/* USART1 interrupt Init */
|
/* USART1 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(USART1_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(USART1_IRQn, 5, 0);
|
||||||
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
HAL_NVIC_EnableIRQ(USART1_IRQn);
|
||||||
|
@ -216,6 +259,43 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
GPIO_InitStruct.Alternate = GPIO_AF7_USART2;
|
||||||
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USART2 DMA Init */
|
||||||
|
/* USART2_TX Init */
|
||||||
|
hdma_usart2_tx.Instance = DMA1_Stream6;
|
||||||
|
hdma_usart2_tx.Init.Channel = DMA_CHANNEL_4;
|
||||||
|
hdma_usart2_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||||
|
hdma_usart2_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
hdma_usart2_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
hdma_usart2_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
|
hdma_usart2_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
|
hdma_usart2_tx.Init.Mode = DMA_NORMAL;
|
||||||
|
hdma_usart2_tx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
|
hdma_usart2_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
if (HAL_DMA_Init(&hdma_usart2_tx) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart2_tx);
|
||||||
|
|
||||||
|
/* USART2_RX Init */
|
||||||
|
hdma_usart2_rx.Instance = DMA1_Stream5;
|
||||||
|
hdma_usart2_rx.Init.Channel = DMA_CHANNEL_4;
|
||||||
|
hdma_usart2_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||||
|
hdma_usart2_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
hdma_usart2_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
hdma_usart2_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
|
hdma_usart2_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
|
hdma_usart2_rx.Init.Mode = DMA_NORMAL;
|
||||||
|
hdma_usart2_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
|
hdma_usart2_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
if (HAL_DMA_Init(&hdma_usart2_rx) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart2_rx);
|
||||||
|
|
||||||
/* USART2 interrupt Init */
|
/* USART2 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(USART2_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(USART2_IRQn, 5, 0);
|
||||||
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
HAL_NVIC_EnableIRQ(USART2_IRQn);
|
||||||
|
@ -270,6 +350,43 @@ void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle)
|
||||||
GPIO_InitStruct.Alternate = GPIO_AF8_USART6;
|
GPIO_InitStruct.Alternate = GPIO_AF8_USART6;
|
||||||
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
HAL_GPIO_Init(GPIOC, &GPIO_InitStruct);
|
||||||
|
|
||||||
|
/* USART6 DMA Init */
|
||||||
|
/* USART6_TX Init */
|
||||||
|
hdma_usart6_tx.Instance = DMA2_Stream6;
|
||||||
|
hdma_usart6_tx.Init.Channel = DMA_CHANNEL_5;
|
||||||
|
hdma_usart6_tx.Init.Direction = DMA_MEMORY_TO_PERIPH;
|
||||||
|
hdma_usart6_tx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
hdma_usart6_tx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
hdma_usart6_tx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
|
hdma_usart6_tx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
|
hdma_usart6_tx.Init.Mode = DMA_NORMAL;
|
||||||
|
hdma_usart6_tx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
|
hdma_usart6_tx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
if (HAL_DMA_Init(&hdma_usart6_tx) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_LINKDMA(uartHandle,hdmatx,hdma_usart6_tx);
|
||||||
|
|
||||||
|
/* USART6_RX Init */
|
||||||
|
hdma_usart6_rx.Instance = DMA2_Stream1;
|
||||||
|
hdma_usart6_rx.Init.Channel = DMA_CHANNEL_5;
|
||||||
|
hdma_usart6_rx.Init.Direction = DMA_PERIPH_TO_MEMORY;
|
||||||
|
hdma_usart6_rx.Init.PeriphInc = DMA_PINC_DISABLE;
|
||||||
|
hdma_usart6_rx.Init.MemInc = DMA_MINC_ENABLE;
|
||||||
|
hdma_usart6_rx.Init.PeriphDataAlignment = DMA_PDATAALIGN_BYTE;
|
||||||
|
hdma_usart6_rx.Init.MemDataAlignment = DMA_MDATAALIGN_BYTE;
|
||||||
|
hdma_usart6_rx.Init.Mode = DMA_NORMAL;
|
||||||
|
hdma_usart6_rx.Init.Priority = DMA_PRIORITY_LOW;
|
||||||
|
hdma_usart6_rx.Init.FIFOMode = DMA_FIFOMODE_DISABLE;
|
||||||
|
if (HAL_DMA_Init(&hdma_usart6_rx) != HAL_OK)
|
||||||
|
{
|
||||||
|
Error_Handler();
|
||||||
|
}
|
||||||
|
|
||||||
|
__HAL_LINKDMA(uartHandle,hdmarx,hdma_usart6_rx);
|
||||||
|
|
||||||
/* USART6 interrupt Init */
|
/* USART6 interrupt Init */
|
||||||
HAL_NVIC_SetPriority(USART6_IRQn, 5, 0);
|
HAL_NVIC_SetPriority(USART6_IRQn, 5, 0);
|
||||||
HAL_NVIC_EnableIRQ(USART6_IRQn);
|
HAL_NVIC_EnableIRQ(USART6_IRQn);
|
||||||
|
@ -296,6 +413,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOA, HART_TX_Pin|HART_RX_Pin);
|
HAL_GPIO_DeInit(GPIOA, HART_TX_Pin|HART_RX_Pin);
|
||||||
|
|
||||||
|
/* USART1 DMA DeInit */
|
||||||
|
HAL_DMA_DeInit(uartHandle->hdmatx);
|
||||||
|
HAL_DMA_DeInit(uartHandle->hdmarx);
|
||||||
|
|
||||||
/* USART1 interrupt Deinit */
|
/* USART1 interrupt Deinit */
|
||||||
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
HAL_NVIC_DisableIRQ(USART1_IRQn);
|
||||||
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
/* USER CODE BEGIN USART1_MspDeInit 1 */
|
||||||
|
@ -316,6 +437,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOA, RS485_TX_Pin|RS485_RX_Pin);
|
HAL_GPIO_DeInit(GPIOA, RS485_TX_Pin|RS485_RX_Pin);
|
||||||
|
|
||||||
|
/* USART2 DMA DeInit */
|
||||||
|
HAL_DMA_DeInit(uartHandle->hdmatx);
|
||||||
|
HAL_DMA_DeInit(uartHandle->hdmarx);
|
||||||
|
|
||||||
/* USART2 interrupt Deinit */
|
/* USART2 interrupt Deinit */
|
||||||
HAL_NVIC_DisableIRQ(USART2_IRQn);
|
HAL_NVIC_DisableIRQ(USART2_IRQn);
|
||||||
/* USER CODE BEGIN USART2_MspDeInit 1 */
|
/* USER CODE BEGIN USART2_MspDeInit 1 */
|
||||||
|
@ -356,6 +481,10 @@ void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle)
|
||||||
*/
|
*/
|
||||||
HAL_GPIO_DeInit(GPIOC, BLE_TX_Pin|BLE_RX_Pin);
|
HAL_GPIO_DeInit(GPIOC, BLE_TX_Pin|BLE_RX_Pin);
|
||||||
|
|
||||||
|
/* USART6 DMA DeInit */
|
||||||
|
HAL_DMA_DeInit(uartHandle->hdmatx);
|
||||||
|
HAL_DMA_DeInit(uartHandle->hdmarx);
|
||||||
|
|
||||||
/* USART6 interrupt Deinit */
|
/* USART6 interrupt Deinit */
|
||||||
HAL_NVIC_DisableIRQ(USART6_IRQn);
|
HAL_NVIC_DisableIRQ(USART6_IRQn);
|
||||||
/* USER CODE BEGIN USART6_MspDeInit 1 */
|
/* USER CODE BEGIN USART6_MspDeInit 1 */
|
||||||
|
@ -384,15 +513,28 @@ void usart_printf(UART_HandleTypeDef *huart, char *fmt, ...)
|
||||||
HAL_UART_Transmit(huart, (uint8_t *)tx_buff, length, 0xFFFF);
|
HAL_UART_Transmit(huart, (uint8_t *)tx_buff, length, 0xFFFF);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//不使用DMA,每接收到一帧都能产生中断,靠空闲中断判断接收结束
|
||||||
|
//未避免丢失空闲中断,接收到数据后需要将显示任务挂起
|
||||||
|
//该函数位于中断回调函数之后
|
||||||
void proc_huart_it(UART_HandleTypeDef *huart)
|
void proc_huart_it(UART_HandleTypeDef *huart)
|
||||||
{
|
{
|
||||||
|
//不对发送中断进行处理
|
||||||
|
if(st_flag == 3)
|
||||||
|
{
|
||||||
|
st_flag = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
st_scom *scom;
|
st_scom *scom;
|
||||||
|
|
||||||
|
//根据huart句柄和使能标志,判断即将进行的通讯方向
|
||||||
if(huart == &huart1)
|
if(huart == &huart1)
|
||||||
{
|
{
|
||||||
scom = &scom1_hart;
|
scom = &scom1_hart;
|
||||||
|
|
||||||
if(tabdata.hart_enable == 0)
|
if(tabdata.hart_enable == 0)
|
||||||
{
|
{
|
||||||
|
//HART未使能的情况下接收到数据,清空数组并返回
|
||||||
scom->rx_len = 0;
|
scom->rx_len = 0;
|
||||||
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
||||||
|
|
||||||
|
@ -401,28 +543,53 @@ void proc_huart_it(UART_HandleTypeDef *huart)
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
|
||||||
if (huart == &huart2)
|
|
||||||
{
|
{
|
||||||
scom = &scom2_rs485;
|
sig_trans = TRANS_HART_TO_PC;
|
||||||
if( !(tabdata.bluetooth_enable||tabdata.hart_enable||tabdata.modbus_enable) )
|
|
||||||
{
|
|
||||||
scom->rx_len = 0;
|
|
||||||
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
|
||||||
|
|
||||||
__HAL_UART_CLEAR_FLAG(huart, UART_FLAG_RXNE);
|
|
||||||
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(huart == &huart6)
|
if(huart == &huart6)
|
||||||
{
|
{
|
||||||
scom = &scom6_ble;
|
scom = &scom6_ble;
|
||||||
|
|
||||||
if(tabdata.bluetooth_enable == 0)
|
if(tabdata.bluetooth_enable == 0)
|
||||||
{
|
{
|
||||||
|
//蓝牙未使能的情况下接收到数据,清空数组并返回
|
||||||
|
scom->rx_len = 0;
|
||||||
|
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
||||||
|
|
||||||
|
__HAL_UART_CLEAR_FLAG(huart, UART_FLAG_RXNE);
|
||||||
|
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_BLE_TO_PC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(huart == &huart2)
|
||||||
|
{
|
||||||
|
scom = &scom2_rs485;
|
||||||
|
|
||||||
|
if(tabdata.hart_enable)
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_PC_TO_HART;
|
||||||
|
}
|
||||||
|
else if(tabdata.bluetooth_enable)
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_PC_TO_BLE;
|
||||||
|
}
|
||||||
|
else if(tabdata.modbus_enable)
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_MODBUS_PC_TO_SIG;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
//所有通讯均未使能的情况下接收到数据,清空数组并返回
|
||||||
|
sig_trans = TRANS_NONE;
|
||||||
scom->rx_len = 0;
|
scom->rx_len = 0;
|
||||||
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
||||||
|
|
||||||
|
@ -433,17 +600,26 @@ void proc_huart_it(UART_HandleTypeDef *huart)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!scom)
|
if (!scom) return;
|
||||||
return;
|
|
||||||
|
//进入此处说明接收到数据,并且对应通道使能
|
||||||
|
|
||||||
|
//显示任务挂起
|
||||||
|
screen_suspend_flag = 1;
|
||||||
|
|
||||||
|
//记录起始时刻
|
||||||
|
if(st_flag == 0)
|
||||||
|
{
|
||||||
|
st_flag = 1;
|
||||||
|
tick_start = xTaskGetTickCountFromISR();
|
||||||
|
}
|
||||||
|
|
||||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET)
|
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_RXNE) != RESET)
|
||||||
{
|
{
|
||||||
//接收数据时将显示任务挂起,但是vTaskSuspend无法在中断中调用
|
|
||||||
screen_suspend_flag = 1;
|
|
||||||
|
|
||||||
if (scom->rx_len >= BUFFER_SIZE - 1)
|
if (scom->rx_len >= BUFFER_SIZE - 1)
|
||||||
scom->rx_len = 0;
|
scom->rx_len = 0;
|
||||||
|
|
||||||
|
//将接收到的数据逐个存入数组
|
||||||
scom->rx_buff[scom->rx_len++] = (uint8_t)(huart->Instance->DR & 0xff);
|
scom->rx_buff[scom->rx_len++] = (uint8_t)(huart->Instance->DR & 0xff);
|
||||||
|
|
||||||
__HAL_UART_CLEAR_FLAG(huart, UART_FLAG_RXNE);
|
__HAL_UART_CLEAR_FLAG(huart, UART_FLAG_RXNE);
|
||||||
|
@ -451,15 +627,128 @@ void proc_huart_it(UART_HandleTypeDef *huart)
|
||||||
}
|
}
|
||||||
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) != RESET)
|
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) != RESET)
|
||||||
{
|
{
|
||||||
|
//接收结束
|
||||||
scom->rx_flag = TRUE;
|
scom->rx_flag = TRUE;
|
||||||
|
|
||||||
|
//记录中间时刻
|
||||||
|
st_flag = 2;
|
||||||
|
tick_middle = xTaskGetTickCountFromISR();
|
||||||
|
|
||||||
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||||
|
|
||||||
//数据接收结束,进入空闲后释放显示任务,中断中只能使用xTaskResumeFromISR
|
}
|
||||||
xTaskResumeFromISR(task_lcdHandle);
|
}
|
||||||
xTaskResumeFromISR(task_menuHandle);
|
|
||||||
screen_suspend_flag = 0;
|
//DMA接收
|
||||||
|
//DMA接收只有半满中断、空闲中断和完成(溢出)中断,能够使用的只有空闲中断,因此起始时刻在定时器tim2中尝试捕获
|
||||||
|
//DMA绕过CPU,因此可以不用挂起显示任务
|
||||||
|
void proc_huart_it_dma(UART_HandleTypeDef *huart)
|
||||||
|
{
|
||||||
|
if(st_flag == 3)
|
||||||
|
{
|
||||||
|
st_flag = 0;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
st_scom *scom;
|
||||||
|
|
||||||
|
if(huart == &huart1)
|
||||||
|
{
|
||||||
|
scom = &scom1_hart;
|
||||||
|
|
||||||
|
if(tabdata.hart_enable == 0)
|
||||||
|
{
|
||||||
|
scom->rx_len = 0;
|
||||||
|
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
||||||
|
|
||||||
|
sig_trans = TRANS_NONE;
|
||||||
|
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||||
|
HAL_UART_DMAStop(huart);
|
||||||
|
HAL_UART_Receive_DMA(huart, scom->rx_buff, BUFFER_SIZE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_HART_TO_PC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(huart == &huart6)
|
||||||
|
{
|
||||||
|
scom = &scom6_ble;
|
||||||
|
|
||||||
|
if(tabdata.bluetooth_enable == 0)
|
||||||
|
{
|
||||||
|
scom->rx_len = 0;
|
||||||
|
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
||||||
|
|
||||||
|
sig_trans = TRANS_NONE;
|
||||||
|
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||||
|
HAL_UART_DMAStop(huart);
|
||||||
|
HAL_UART_Receive_DMA(huart, scom->rx_buff, BUFFER_SIZE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_BLE_TO_PC;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if(huart == &huart2)
|
||||||
|
{
|
||||||
|
scom = &scom2_rs485;
|
||||||
|
|
||||||
|
if(tabdata.hart_enable)
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_PC_TO_HART;
|
||||||
|
}
|
||||||
|
else if(tabdata.bluetooth_enable)
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_PC_TO_BLE;
|
||||||
|
}
|
||||||
|
else if(tabdata.modbus_enable)
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_MODBUS_PC_TO_SIG;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sig_trans = TRANS_NONE;
|
||||||
|
scom->rx_len = 0;
|
||||||
|
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
||||||
|
|
||||||
|
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||||
|
HAL_UART_DMAStop(huart);
|
||||||
|
HAL_UART_Receive_DMA(huart, scom->rx_buff, BUFFER_SIZE);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!scom) return;
|
||||||
|
|
||||||
|
if (__HAL_UART_GET_FLAG(huart, UART_FLAG_IDLE) != RESET)
|
||||||
|
{
|
||||||
|
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||||
|
|
||||||
|
HAL_UART_DMAStop(huart);
|
||||||
|
|
||||||
|
//计算接收到的数据长度
|
||||||
|
scom->rx_len = BUFFER_SIZE - __HAL_DMA_GET_COUNTER(huart->hdmarx);
|
||||||
|
if( ( 0 < scom->rx_len )&&( scom->rx_len < BUFFER_SIZE ) )
|
||||||
|
{
|
||||||
|
scom->rx_flag = TRUE;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
memset(scom->rx_buff, 0, BUFFER_SIZE);
|
||||||
|
scom->rx_len = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
tick_middle = xTaskGetTickCountFromISR();
|
||||||
|
|
||||||
|
HAL_UART_Receive_DMA(huart, scom->rx_buff, BUFFER_SIZE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
/* USER CODE END 1 */
|
/* USER CODE END 1 */
|
||||||
|
|
|
@ -268,7 +268,17 @@
|
||||||
<Ww>
|
<Ww>
|
||||||
<count>22</count>
|
<count>22</count>
|
||||||
<WinNumber>1</WinNumber>
|
<WinNumber>1</WinNumber>
|
||||||
<ItemText>screen_suspend_flag</ItemText>
|
<ItemText>screen_suspend_flag,0x0A</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>23</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>trans_log_rx,0x0A</ItemText>
|
||||||
|
</Ww>
|
||||||
|
<Ww>
|
||||||
|
<count>24</count>
|
||||||
|
<WinNumber>1</WinNumber>
|
||||||
|
<ItemText>trans_log_tx,0x0A</ItemText>
|
||||||
</Ww>
|
</Ww>
|
||||||
</WatchWindow1>
|
</WatchWindow1>
|
||||||
<WatchWindow2>
|
<WatchWindow2>
|
||||||
|
@ -584,7 +594,7 @@
|
||||||
|
|
||||||
<Group>
|
<Group>
|
||||||
<GroupName>Application/User/App/MODBUS</GroupName>
|
<GroupName>Application/User/App/MODBUS</GroupName>
|
||||||
<tvExp>0</tvExp>
|
<tvExp>1</tvExp>
|
||||||
<tvExpOptDlg>0</tvExpOptDlg>
|
<tvExpOptDlg>0</tvExpOptDlg>
|
||||||
<cbSel>0</cbSel>
|
<cbSel>0</cbSel>
|
||||||
<RteFlg>0</RteFlg>
|
<RteFlg>0</RteFlg>
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -21,7 +21,73 @@ Dma.ADC1.0.PeriphInc=DMA_PINC_DISABLE
|
||||||
Dma.ADC1.0.Priority=DMA_PRIORITY_LOW
|
Dma.ADC1.0.Priority=DMA_PRIORITY_LOW
|
||||||
Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
Dma.ADC1.0.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||||
Dma.Request0=ADC1
|
Dma.Request0=ADC1
|
||||||
Dma.RequestsNb=1
|
Dma.Request1=USART1_TX
|
||||||
|
Dma.Request2=USART2_TX
|
||||||
|
Dma.Request3=USART6_TX
|
||||||
|
Dma.Request4=USART1_RX
|
||||||
|
Dma.Request5=USART2_RX
|
||||||
|
Dma.Request6=USART6_RX
|
||||||
|
Dma.RequestsNb=7
|
||||||
|
Dma.USART1_RX.4.Direction=DMA_PERIPH_TO_MEMORY
|
||||||
|
Dma.USART1_RX.4.FIFOMode=DMA_FIFOMODE_DISABLE
|
||||||
|
Dma.USART1_RX.4.Instance=DMA2_Stream2
|
||||||
|
Dma.USART1_RX.4.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||||
|
Dma.USART1_RX.4.MemInc=DMA_MINC_ENABLE
|
||||||
|
Dma.USART1_RX.4.Mode=DMA_NORMAL
|
||||||
|
Dma.USART1_RX.4.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||||
|
Dma.USART1_RX.4.PeriphInc=DMA_PINC_DISABLE
|
||||||
|
Dma.USART1_RX.4.Priority=DMA_PRIORITY_LOW
|
||||||
|
Dma.USART1_RX.4.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||||
|
Dma.USART1_TX.1.Direction=DMA_MEMORY_TO_PERIPH
|
||||||
|
Dma.USART1_TX.1.FIFOMode=DMA_FIFOMODE_DISABLE
|
||||||
|
Dma.USART1_TX.1.Instance=DMA2_Stream7
|
||||||
|
Dma.USART1_TX.1.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||||
|
Dma.USART1_TX.1.MemInc=DMA_MINC_ENABLE
|
||||||
|
Dma.USART1_TX.1.Mode=DMA_NORMAL
|
||||||
|
Dma.USART1_TX.1.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||||
|
Dma.USART1_TX.1.PeriphInc=DMA_PINC_DISABLE
|
||||||
|
Dma.USART1_TX.1.Priority=DMA_PRIORITY_LOW
|
||||||
|
Dma.USART1_TX.1.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||||
|
Dma.USART2_RX.5.Direction=DMA_PERIPH_TO_MEMORY
|
||||||
|
Dma.USART2_RX.5.FIFOMode=DMA_FIFOMODE_DISABLE
|
||||||
|
Dma.USART2_RX.5.Instance=DMA1_Stream5
|
||||||
|
Dma.USART2_RX.5.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||||
|
Dma.USART2_RX.5.MemInc=DMA_MINC_ENABLE
|
||||||
|
Dma.USART2_RX.5.Mode=DMA_NORMAL
|
||||||
|
Dma.USART2_RX.5.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||||
|
Dma.USART2_RX.5.PeriphInc=DMA_PINC_DISABLE
|
||||||
|
Dma.USART2_RX.5.Priority=DMA_PRIORITY_LOW
|
||||||
|
Dma.USART2_RX.5.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||||
|
Dma.USART2_TX.2.Direction=DMA_MEMORY_TO_PERIPH
|
||||||
|
Dma.USART2_TX.2.FIFOMode=DMA_FIFOMODE_DISABLE
|
||||||
|
Dma.USART2_TX.2.Instance=DMA1_Stream6
|
||||||
|
Dma.USART2_TX.2.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||||
|
Dma.USART2_TX.2.MemInc=DMA_MINC_ENABLE
|
||||||
|
Dma.USART2_TX.2.Mode=DMA_NORMAL
|
||||||
|
Dma.USART2_TX.2.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||||
|
Dma.USART2_TX.2.PeriphInc=DMA_PINC_DISABLE
|
||||||
|
Dma.USART2_TX.2.Priority=DMA_PRIORITY_LOW
|
||||||
|
Dma.USART2_TX.2.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||||
|
Dma.USART6_RX.6.Direction=DMA_PERIPH_TO_MEMORY
|
||||||
|
Dma.USART6_RX.6.FIFOMode=DMA_FIFOMODE_DISABLE
|
||||||
|
Dma.USART6_RX.6.Instance=DMA2_Stream1
|
||||||
|
Dma.USART6_RX.6.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||||
|
Dma.USART6_RX.6.MemInc=DMA_MINC_ENABLE
|
||||||
|
Dma.USART6_RX.6.Mode=DMA_NORMAL
|
||||||
|
Dma.USART6_RX.6.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||||
|
Dma.USART6_RX.6.PeriphInc=DMA_PINC_DISABLE
|
||||||
|
Dma.USART6_RX.6.Priority=DMA_PRIORITY_LOW
|
||||||
|
Dma.USART6_RX.6.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||||
|
Dma.USART6_TX.3.Direction=DMA_MEMORY_TO_PERIPH
|
||||||
|
Dma.USART6_TX.3.FIFOMode=DMA_FIFOMODE_DISABLE
|
||||||
|
Dma.USART6_TX.3.Instance=DMA2_Stream6
|
||||||
|
Dma.USART6_TX.3.MemDataAlignment=DMA_MDATAALIGN_BYTE
|
||||||
|
Dma.USART6_TX.3.MemInc=DMA_MINC_ENABLE
|
||||||
|
Dma.USART6_TX.3.Mode=DMA_NORMAL
|
||||||
|
Dma.USART6_TX.3.PeriphDataAlignment=DMA_PDATAALIGN_BYTE
|
||||||
|
Dma.USART6_TX.3.PeriphInc=DMA_PINC_DISABLE
|
||||||
|
Dma.USART6_TX.3.Priority=DMA_PRIORITY_LOW
|
||||||
|
Dma.USART6_TX.3.RequestParameters=Instance,Direction,PeriphInc,MemInc,PeriphDataAlignment,MemDataAlignment,Mode,Priority,FIFOMode
|
||||||
FREERTOS.FootprintOK=true
|
FREERTOS.FootprintOK=true
|
||||||
FREERTOS.INCLUDE_uxTaskGetStackHighWaterMark=1
|
FREERTOS.INCLUDE_uxTaskGetStackHighWaterMark=1
|
||||||
FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_TICKLESS_IDLE,configGENERATE_RUN_TIME_STATS,configTOTAL_HEAP_SIZE,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY,configUSE_IDLE_HOOK,INCLUDE_uxTaskGetStackHighWaterMark
|
FREERTOS.IPParameters=Tasks01,FootprintOK,configUSE_TICKLESS_IDLE,configGENERATE_RUN_TIME_STATS,configTOTAL_HEAP_SIZE,configUSE_STATS_FORMATTING_FUNCTIONS,configUSE_TRACE_FACILITY,configUSE_IDLE_HOOK,INCLUDE_uxTaskGetStackHighWaterMark
|
||||||
|
@ -44,12 +110,13 @@ Mcu.IP1=DAC
|
||||||
Mcu.IP10=SPI3
|
Mcu.IP10=SPI3
|
||||||
Mcu.IP11=SYS
|
Mcu.IP11=SYS
|
||||||
Mcu.IP12=TIM1
|
Mcu.IP12=TIM1
|
||||||
Mcu.IP13=TIM3
|
Mcu.IP13=TIM2
|
||||||
Mcu.IP14=TIM6
|
Mcu.IP14=TIM3
|
||||||
Mcu.IP15=USART1
|
Mcu.IP15=TIM6
|
||||||
Mcu.IP16=USART2
|
Mcu.IP16=USART1
|
||||||
Mcu.IP17=USART3
|
Mcu.IP17=USART2
|
||||||
Mcu.IP18=USART6
|
Mcu.IP18=USART3
|
||||||
|
Mcu.IP19=USART6
|
||||||
Mcu.IP2=DMA
|
Mcu.IP2=DMA
|
||||||
Mcu.IP3=FREERTOS
|
Mcu.IP3=FREERTOS
|
||||||
Mcu.IP4=I2C1
|
Mcu.IP4=I2C1
|
||||||
|
@ -58,7 +125,7 @@ Mcu.IP6=NVIC
|
||||||
Mcu.IP7=RCC
|
Mcu.IP7=RCC
|
||||||
Mcu.IP8=SPI1
|
Mcu.IP8=SPI1
|
||||||
Mcu.IP9=SPI2
|
Mcu.IP9=SPI2
|
||||||
Mcu.IPNb=19
|
Mcu.IPNb=20
|
||||||
Mcu.Name=STM32F407V(E-G)Tx
|
Mcu.Name=STM32F407V(E-G)Tx
|
||||||
Mcu.Package=LQFP100
|
Mcu.Package=LQFP100
|
||||||
Mcu.Pin0=PE2
|
Mcu.Pin0=PE2
|
||||||
|
@ -133,18 +200,25 @@ Mcu.Pin70=PB9
|
||||||
Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1
|
Mcu.Pin71=VP_FREERTOS_VS_CMSIS_V1
|
||||||
Mcu.Pin72=VP_SYS_VS_tim7
|
Mcu.Pin72=VP_SYS_VS_tim7
|
||||||
Mcu.Pin73=VP_TIM1_VS_ClockSourceINT
|
Mcu.Pin73=VP_TIM1_VS_ClockSourceINT
|
||||||
Mcu.Pin74=VP_TIM3_VS_ClockSourceINT
|
Mcu.Pin74=VP_TIM2_VS_ClockSourceINT
|
||||||
Mcu.Pin75=VP_TIM6_VS_ClockSourceINT
|
Mcu.Pin75=VP_TIM3_VS_ClockSourceINT
|
||||||
|
Mcu.Pin76=VP_TIM6_VS_ClockSourceINT
|
||||||
Mcu.Pin8=PC3
|
Mcu.Pin8=PC3
|
||||||
Mcu.Pin9=PA0-WKUP
|
Mcu.Pin9=PA0-WKUP
|
||||||
Mcu.PinsNb=76
|
Mcu.PinsNb=77
|
||||||
Mcu.ThirdPartyNb=0
|
Mcu.ThirdPartyNb=0
|
||||||
Mcu.UserConstants=xx,xx
|
Mcu.UserConstants=xx,xx
|
||||||
Mcu.UserName=STM32F407VGTx
|
Mcu.UserName=STM32F407VGTx
|
||||||
MxCube.Version=6.12.1
|
MxCube.Version=6.12.1
|
||||||
MxDb.Version=DB.6.0.121
|
MxDb.Version=DB.6.0.121
|
||||||
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
|
NVIC.DMA1_Stream5_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
|
NVIC.DMA1_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
NVIC.DMA2_Stream0_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
|
NVIC.DMA2_Stream1_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
|
NVIC.DMA2_Stream2_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
|
NVIC.DMA2_Stream6_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
|
NVIC.DMA2_Stream7_IRQn=true\:5\:0\:false\:false\:true\:true\:false\:true\:true
|
||||||
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
NVIC.DebugMonitor_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false\:false
|
||||||
NVIC.EXTI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.EXTI1_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.ForceEnableDMAVector=true
|
NVIC.ForceEnableDMAVector=true
|
||||||
|
@ -159,6 +233,7 @@ NVIC.SavedSvcallIrqHandlerGenerated=true
|
||||||
NVIC.SavedSystickIrqHandlerGenerated=true
|
NVIC.SavedSystickIrqHandlerGenerated=true
|
||||||
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true\:false
|
NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:false\:true\:false\:true\:false
|
||||||
NVIC.TIM1_UP_TIM10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.TIM1_UP_TIM10_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
|
NVIC.TIM2_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.TIM3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
NVIC.TIM3_IRQn=true\:5\:0\:false\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.TIM6_DAC_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
|
NVIC.TIM6_DAC_IRQn=true\:5\:0\:true\:false\:true\:true\:true\:true\:true
|
||||||
NVIC.TIM7_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true
|
NVIC.TIM7_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true
|
||||||
|
@ -510,7 +585,7 @@ ProjectManager.FreePins=false
|
||||||
ProjectManager.HalAssertFull=false
|
ProjectManager.HalAssertFull=false
|
||||||
ProjectManager.HeapSize=0x200
|
ProjectManager.HeapSize=0x200
|
||||||
ProjectManager.KeepUserCode=true
|
ProjectManager.KeepUserCode=true
|
||||||
ProjectManager.LastFirmware=true
|
ProjectManager.LastFirmware=false
|
||||||
ProjectManager.LibraryCopy=1
|
ProjectManager.LibraryCopy=1
|
||||||
ProjectManager.MainLocation=Core/Src
|
ProjectManager.MainLocation=Core/Src
|
||||||
ProjectManager.NoMain=false
|
ProjectManager.NoMain=false
|
||||||
|
@ -526,7 +601,7 @@ ProjectManager.ToolChainLocation=
|
||||||
ProjectManager.UAScriptAfterPath=
|
ProjectManager.UAScriptAfterPath=
|
||||||
ProjectManager.UAScriptBeforePath=
|
ProjectManager.UAScriptBeforePath=
|
||||||
ProjectManager.UnderRoot=false
|
ProjectManager.UnderRoot=false
|
||||||
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_USART6_UART_Init-USART6-false-HAL-true,7-MX_DAC_Init-DAC-false-HAL-true,8-MX_SPI3_Init-SPI3-false-HAL-true,9-MX_SPI2_Init-SPI2-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_I2C1_Init-I2C1-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_ADC1_Init-ADC1-false-HAL-true,15-MX_TIM6_Init-TIM6-false-HAL-true,16-MX_USART3_UART_Init-USART3-false-HAL-true,17-MX_I2C3_Init-I2C3-false-HAL-true
|
ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_USART1_UART_Init-USART1-false-HAL-true,5-MX_USART2_UART_Init-USART2-false-HAL-true,6-MX_USART6_UART_Init-USART6-false-HAL-true,7-MX_DAC_Init-DAC-false-HAL-true,8-MX_SPI3_Init-SPI3-false-HAL-true,9-MX_SPI2_Init-SPI2-false-HAL-true,10-MX_SPI1_Init-SPI1-false-HAL-true,11-MX_I2C1_Init-I2C1-false-HAL-true,12-MX_TIM1_Init-TIM1-false-HAL-true,13-MX_TIM3_Init-TIM3-false-HAL-true,14-MX_ADC1_Init-ADC1-false-HAL-true,15-MX_TIM6_Init-TIM6-false-HAL-true,16-MX_USART3_UART_Init-USART3-false-HAL-true,17-MX_I2C3_Init-I2C3-false-HAL-true,18-MX_TIM2_Init-TIM2-false-HAL-true
|
||||||
RCC.48MHZClocksFreq_Value=82944000
|
RCC.48MHZClocksFreq_Value=82944000
|
||||||
RCC.AHBCLKDivider=RCC_SYSCLK_DIV2
|
RCC.AHBCLKDivider=RCC_SYSCLK_DIV2
|
||||||
RCC.AHBFreq_Value=82944000
|
RCC.AHBFreq_Value=82944000
|
||||||
|
@ -607,6 +682,9 @@ TIM1.Period=55-1
|
||||||
TIM1.Prescaler=1500-1
|
TIM1.Prescaler=1500-1
|
||||||
TIM1.Pulse-PWM\ Generation2\ CH2N=28-1
|
TIM1.Pulse-PWM\ Generation2\ CH2N=28-1
|
||||||
TIM1.Pulse-PWM\ Generation3\ CH3=28-1
|
TIM1.Pulse-PWM\ Generation3\ CH3=28-1
|
||||||
|
TIM2.IPParameters=Prescaler,Period
|
||||||
|
TIM2.Period=41472-1
|
||||||
|
TIM2.Prescaler=2-1
|
||||||
TIM3.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
|
TIM3.AutoReloadPreload=TIM_AUTORELOAD_PRELOAD_ENABLE
|
||||||
TIM3.Channel-Input_Capture4_from_TI4=TIM_CHANNEL_4
|
TIM3.Channel-Input_Capture4_from_TI4=TIM_CHANNEL_4
|
||||||
TIM3.IPParameters=Channel-Input_Capture4_from_TI4,Prescaler,Period,AutoReloadPreload
|
TIM3.IPParameters=Channel-Input_Capture4_from_TI4,Prescaler,Period,AutoReloadPreload
|
||||||
|
@ -634,6 +712,8 @@ VP_SYS_VS_tim7.Mode=TIM7
|
||||||
VP_SYS_VS_tim7.Signal=SYS_VS_tim7
|
VP_SYS_VS_tim7.Signal=SYS_VS_tim7
|
||||||
VP_TIM1_VS_ClockSourceINT.Mode=Internal
|
VP_TIM1_VS_ClockSourceINT.Mode=Internal
|
||||||
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
|
VP_TIM1_VS_ClockSourceINT.Signal=TIM1_VS_ClockSourceINT
|
||||||
|
VP_TIM2_VS_ClockSourceINT.Mode=Internal
|
||||||
|
VP_TIM2_VS_ClockSourceINT.Signal=TIM2_VS_ClockSourceINT
|
||||||
VP_TIM3_VS_ClockSourceINT.Mode=Internal
|
VP_TIM3_VS_ClockSourceINT.Mode=Internal
|
||||||
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
|
VP_TIM3_VS_ClockSourceINT.Signal=TIM3_VS_ClockSourceINT
|
||||||
VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer
|
VP_TIM6_VS_ClockSourceINT.Mode=Enable_Timer
|
||||||
|
|
Loading…
Reference in New Issue