parent
5c2f009625
commit
10737c6231
|
@ -80,6 +80,13 @@ extern const lv_img_dsc_t * screen_main_ani_out_sign_imgs[4];
|
|||
#include "scr_setting_progam_out.h"
|
||||
#include "modbus_register_process.h"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
HAL_StatusTypeDef ust_RS485;
|
||||
HAL_StatusTypeDef ust_BLE;
|
||||
HAL_StatusTypeDef ust_HART;
|
||||
}UARTS_STATUS;
|
||||
|
||||
extern PHYSICAL_QUANTITY VOL[2]; //电压,VOL[0]-V, VOL[1]-mV
|
||||
extern PHYSICAL_QUANTITY CUR; //电流,mA
|
||||
extern PHYSICAL_QUANTITY RES; //电阻,Ω
|
||||
|
@ -89,6 +96,7 @@ extern PHYSICAL_QUANTITY RTD; //热电阻
|
|||
extern OPERATIONS current_operation; //当前操作
|
||||
extern SYSTEM_STATUS_WATCH system_sts; //系统状态监控
|
||||
extern SIG_TRANSMISSION sig_trans; //通讯模式
|
||||
extern UARTS_STATUS uarts_status;
|
||||
|
||||
//绝对值计算
|
||||
#define MY_ABS(pa) ( ( (pa) >= 0 )?( (pa) ):( 0 - (pa) ) )
|
||||
|
|
|
@ -1017,7 +1017,14 @@ void set_communication_modify(uint8_t con, int8_t step)
|
|||
case TEXT_HART:
|
||||
{
|
||||
tabdata.hart_enable += step;
|
||||
if(tabdata.hart_enable > 3) tabdata.hart_enable = 0;
|
||||
if(tabdata.hart_enable > 200)
|
||||
{
|
||||
tabdata.hart_enable = 3;
|
||||
}
|
||||
else if(tabdata.hart_enable > 3)
|
||||
{
|
||||
tabdata.hart_enable = 0;
|
||||
}
|
||||
|
||||
//通讯方式互斥
|
||||
if(tabdata.hart_enable)
|
||||
|
|
|
@ -10,6 +10,7 @@ PHYSICAL_QUANTITY TC[8]; //热电偶,共8种
|
|||
PHYSICAL_QUANTITY RTD; //热电阻
|
||||
SYSTEM_STATUS_WATCH system_sts; //系统状态监控
|
||||
SIG_TRANSMISSION sig_trans = TRANS_NONE; //通讯模式
|
||||
UARTS_STATUS uarts_status; //各个串口的状态
|
||||
|
||||
// 热电偶真值表,电压mV
|
||||
// 行:[0,7]->[K, S, N, B, E, J, R, T],列:[0,10]->[mV_Tmin,...,mV_Tmax](均分成10个间隔,11个端点)
|
||||
|
|
|
@ -102,7 +102,7 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
|||
scom1_hart.tx_len = 0;
|
||||
|
||||
//PC--->SIG--->HART,重新开启485的DMA
|
||||
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
else if(huart == &huart2)
|
||||
{
|
||||
|
@ -114,26 +114,26 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
|||
{
|
||||
case TRANS_HART_TO_PC:
|
||||
{
|
||||
HAL_UART_Receive_DMA(&huart1, scom1_hart.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_HART = HAL_UART_Receive_DMA(&huart1, scom1_hart.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
break;
|
||||
|
||||
case TRANS_BLE_TO_PC:
|
||||
{
|
||||
HAL_UART_Receive_DMA(&huart6, scom6_ble.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_BLE = HAL_UART_Receive_DMA(&huart6, scom6_ble.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
break;
|
||||
|
||||
case TRANS_MODBUS_PC_TO_SIG:
|
||||
{
|
||||
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
break;
|
||||
|
||||
case TRANS_MODBUS_SIG_TO_SLAVE:
|
||||
{
|
||||
mod_master.tx_flag = TX_OK;
|
||||
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
sig2slave_current_tick = 0;
|
||||
}
|
||||
break;
|
||||
|
@ -148,7 +148,7 @@ void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart)
|
|||
scom6_ble.tx_len = 0;
|
||||
|
||||
//PC--->SIG--->BLE,重新开启485的DMA
|
||||
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
//通讯模式清空,等待下一次接收
|
||||
|
|
|
@ -236,7 +236,7 @@ void trans_modbus_sig2slave(void)
|
|||
{
|
||||
//修改剩余buff长度,继续接收
|
||||
buffer_size_temp -= scom2_rs485.rx_len;
|
||||
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff + sig2slave_data_length_total, buffer_size_temp);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff + sig2slave_data_length_total, buffer_size_temp);
|
||||
}
|
||||
sig2slave_step++;
|
||||
}
|
||||
|
@ -258,7 +258,7 @@ void trans_modbus_sig2slave(void)
|
|||
{
|
||||
//继续接收
|
||||
buffer_size_temp -= sig2slave_data_length_temp;
|
||||
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff + sig2slave_data_length_total, buffer_size_temp);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff + sig2slave_data_length_total, buffer_size_temp);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -289,7 +289,7 @@ void trans_modbus_sig2slave(void)
|
|||
sig2slave_data_length_total = 0;
|
||||
buffer_size_temp = BUFFER_SIZE;
|
||||
|
||||
HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -232,6 +232,10 @@ void start_task_hart(void const * argument)
|
|||
fre_set_hart = 0;
|
||||
frequence_output(fre_set_hart, 50, PWM_HART);
|
||||
}
|
||||
|
||||
HART_24V_DISABLE;
|
||||
HART_VOUT_DISABLE;
|
||||
HART_250OHM_DISABLE;
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -331,10 +335,30 @@ void start_rs485(void const * argument)
|
|||
for (;;)
|
||||
{
|
||||
//当前通讯状态的更新
|
||||
if(sig_trans == TRANS_NONE)
|
||||
{
|
||||
if(uarts_status.ust_RS485 != HAL_OK)
|
||||
{
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
if(uarts_status.ust_HART != HAL_OK)
|
||||
{
|
||||
uarts_status.ust_HART = HAL_UART_Receive_DMA(&huart1, scom1_hart.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
|
||||
if(uarts_status.ust_BLE != HAL_OK)
|
||||
{
|
||||
uarts_status.ust_BLE = HAL_UART_Receive_DMA(&huart6, scom6_ble.rx_buff, BUFFER_SIZE);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if( !(tabdata.bluetooth_enable||tabdata.hart_enable||tabdata.modbus_enable) )
|
||||
{
|
||||
sig_trans = TRANS_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
//更新modbus的寄存器值
|
||||
//开机动画结束后再执行,否则会与数据初始化中的EEPROM读取产生冲突
|
||||
|
|
|
@ -121,9 +121,9 @@ int main(void)
|
|||
HAL_TIM_Base_Start_IT(&htim8);
|
||||
|
||||
#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);
|
||||
uarts_status.ust_HART = HAL_UART_Receive_DMA(&huart1, scom1_hart.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_RS485 = HAL_UART_Receive_DMA(&huart2, scom2_rs485.rx_buff, BUFFER_SIZE);
|
||||
uarts_status.ust_BLE = HAL_UART_Receive_DMA(&huart6, scom6_ble.rx_buff, BUFFER_SIZE);
|
||||
#endif
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
|
|
@ -540,8 +540,7 @@ void proc_huart_it(UART_HandleTypeDef *huart)
|
|||
|
||||
sig_trans = TRANS_NONE;
|
||||
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||
HAL_UART_DMAStop(huart);
|
||||
HAL_UART_Receive_DMA(huart, scom->rx_buff, BUFFER_SIZE);
|
||||
__HAL_UART_CLEAR_FLAG(huart, UART_FLAG_RXNE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
@ -597,9 +596,22 @@ void proc_huart_it_dma(UART_HandleTypeDef *huart)
|
|||
|
||||
//端口选择
|
||||
st_scom *scom;
|
||||
if(huart == &huart1) scom = &scom1_hart;
|
||||
if(huart == &huart6) scom = &scom6_ble;
|
||||
if(huart == &huart2) scom = &scom2_rs485;
|
||||
HAL_StatusTypeDef *scom_sts;
|
||||
if(huart == &huart1)
|
||||
{
|
||||
scom = &scom1_hart;
|
||||
scom_sts = &uarts_status.ust_HART;
|
||||
}
|
||||
else if(huart == &huart6)
|
||||
{
|
||||
scom = &scom6_ble;
|
||||
scom_sts = &uarts_status.ust_BLE;
|
||||
}
|
||||
else if(huart == &huart2)
|
||||
{
|
||||
scom = &scom2_rs485;
|
||||
scom_sts = &uarts_status.ust_RS485;
|
||||
}
|
||||
if( !scom ) return;
|
||||
|
||||
//对应功能是否使能
|
||||
|
@ -611,7 +623,7 @@ void proc_huart_it_dma(UART_HandleTypeDef *huart)
|
|||
sig_trans = TRANS_NONE;
|
||||
__HAL_UART_CLEAR_IDLEFLAG(huart);
|
||||
HAL_UART_DMAStop(huart);
|
||||
HAL_UART_Receive_DMA(huart, scom->rx_buff, BUFFER_SIZE);
|
||||
*scom_sts = HAL_UART_Receive_DMA(huart, scom->rx_buff, BUFFER_SIZE);
|
||||
|
||||
return;
|
||||
}
|
||||
|
|
|
@ -270,6 +270,11 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>cali_paras</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>23</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>uarts_status</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue