parent
7938f2317f
commit
53bd382658
|
@ -106,6 +106,9 @@ typedef struct
|
|||
SIG_FUNCTIONS_TYPE input_log_unit[60]; //输入记录,单位
|
||||
float32 output_log_value[60]; //输出记录,实际值
|
||||
SIG_FUNCTIONS_TYPE output_log_unit[60];//输出记录,单位
|
||||
uint8_t hart_enable;
|
||||
uint8_t bluetooth_enable;
|
||||
uint8_t modbus_enable;
|
||||
|
||||
//ITEMS_3
|
||||
uint8_t item3_page0_lightflag; //照明状态标志,0熄灭,1开启
|
||||
|
|
|
@ -106,15 +106,22 @@ typedef enum
|
|||
|
||||
typedef enum
|
||||
{
|
||||
OPENNING_ANIME, //播放开机动画
|
||||
OPENNING_ANIME = 0, //播放开机动画
|
||||
MAIN_FUNCTION, //主要功能:输入&输出、曲线显示等
|
||||
SET_ITEM_CHOOSE, //设置菜单:选项卡选择
|
||||
SET_CONTENT_CHOOSE, //设置菜单:内容选择
|
||||
SET_CONTENT_MODIFY, //设置菜单:内容修改
|
||||
SET_SHOW_LOG //设置菜单:查看记录
|
||||
|
||||
}OPERATIONS;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TRANS_NONE = 0,
|
||||
TRANS_HART,
|
||||
TRANS_BLUETOOTH,
|
||||
TRANS_MODBUS
|
||||
}SIG_TRANSMISSION;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16_t lvgl_stack_consume; //LVGL栈占用
|
||||
|
@ -128,7 +135,6 @@ typedef struct
|
|||
|
||||
}SYSTEM_STATUS_WATCH;
|
||||
|
||||
|
||||
#include "app_screen_main.h"
|
||||
#include "app_screen_setting.h"
|
||||
#include "scr_setting_item_text.h"
|
||||
|
@ -144,6 +150,7 @@ extern PHYSICAL_QUANTITY TC[8]; //热电偶,共8种
|
|||
extern PHYSICAL_QUANTITY RTD; //热电阻
|
||||
extern OPERATIONS current_operation; //当前操作
|
||||
extern SYSTEM_STATUS_WATCH system_sts; //系统状态监控
|
||||
extern SIG_TRANSMISSION sig_trans; //通讯模式
|
||||
|
||||
//绝对值计算
|
||||
#define MY_ABS(pa) ( ( (pa) >= 0 )?( (pa) ):( 0 - (pa) ) )
|
||||
|
|
|
@ -34,8 +34,7 @@ void tab_data_init(void)
|
|||
//ITEMS_1(部分内容位于EERPOM读取)
|
||||
|
||||
|
||||
//ITEMS_2(部分内容位于EERPOM读取)
|
||||
tabdata.item3_page0_saveflag = 0;
|
||||
//ITEMS_2(部分内容位于EERPOM读取)
|
||||
memset(tabdata.log_time, 0, sizeof(tabdata.log_time));
|
||||
memset(tabdata.input_log_value, 0, sizeof(tabdata.input_log_value));
|
||||
memset(tabdata.input_log_unit, 0, sizeof(tabdata.input_log_unit));
|
||||
|
@ -44,11 +43,15 @@ void tab_data_init(void)
|
|||
sprintf(tabdata.log_time[0], "00:00:00");
|
||||
tabdata.input_log_unit[0] = m5data.input_mode_type;
|
||||
tabdata.output_log_unit[0] = m5data.output_mode_type;
|
||||
tabdata.item3_page0_resetflag = 0;
|
||||
tabdata.hart_enable = 0;
|
||||
tabdata.bluetooth_enable = 0;
|
||||
tabdata.modbus_enable = 0;
|
||||
|
||||
//ITEMS_3(部分内容位于EERPOM读取)
|
||||
tabdata.item3_page0_lightflag = 0; //照明状态标志,0熄灭,1开启
|
||||
LIGHT_OFF;
|
||||
tabdata.item3_page0_saveflag = 0;
|
||||
tabdata.item3_page0_resetflag = 0;
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ PHYSICAL_QUANTITY FRE; //频率,KHz
|
|||
PHYSICAL_QUANTITY TC[8]; //热电偶,共8种
|
||||
PHYSICAL_QUANTITY RTD; //热电阻
|
||||
SYSTEM_STATUS_WATCH system_sts; //系统状态监控
|
||||
SIG_TRANSMISSION sig_trans = TRANS_NONE; //通讯模式
|
||||
|
||||
// 热电偶真值表,电压mV
|
||||
// 行:[0,7]->[K, S, N, B, E, J, R, T],列:[0,10]->[mV_Tmin,...,mV_Tmax](均分成10个间隔,11个端点)
|
||||
|
@ -829,6 +830,8 @@ float32 my_power(int a, int b)
|
|||
//初始化打包
|
||||
void my_inits_gather(void)
|
||||
{
|
||||
//HAL_UART_Receive_IT(&huart6, scom6_ble.rx_buff, 255);
|
||||
|
||||
//eeprom
|
||||
eeprom_spi_init();
|
||||
|
||||
|
|
|
@ -13,3 +13,36 @@ void ble_send(UART_HandleTypeDef *huart, uint8_t *data)
|
|||
{
|
||||
usart_printf(huart, (char *)data);
|
||||
}
|
||||
|
||||
void transparent_bluetooth(st_scom *scom)
|
||||
{
|
||||
if (scom != &scom6_ble) return;
|
||||
|
||||
if (scom->rx_flag == TRUE)
|
||||
{
|
||||
scom->rx_flag = FALSE;
|
||||
|
||||
memcpy(scom2_rs485.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
||||
scom2_rs485.tx_len = scom->rx_len;
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
}
|
||||
|
||||
if (scom->tx_flag == TRUE)
|
||||
{
|
||||
scom->tx_flag = FALSE;
|
||||
|
||||
ble_send(&huart6, scom6_ble.tx_buff);
|
||||
}
|
||||
}
|
||||
|
||||
int8_t write_ble_id(char *id)
|
||||
{
|
||||
if(!id) return -1;
|
||||
|
||||
char str_id[50] = {0};
|
||||
|
||||
sprintf(str_id,"AT+NAME=%s\r\n",id);
|
||||
usart_printf(&huart6, str_id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,8 +1,16 @@
|
|||
#ifndef __BLE_H
|
||||
#define __BLE_H
|
||||
|
||||
#include "usart.h"
|
||||
#include "data_type_def.h"
|
||||
#include "apps_gather.h"
|
||||
|
||||
void ble_send(UART_HandleTypeDef *huart, uint8_t *data);
|
||||
|
||||
//DEVICE <---SIG---> PC
|
||||
//将来自设备的BLUETOOTH数据装载至com485_tx,将comblue_tx的数据发送至设备
|
||||
void transparent_bluetooth(st_scom *scom);
|
||||
|
||||
int8_t write_ble_id(char *id);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -48,3 +48,42 @@ void hart_communicate(st_scom *scom)
|
|||
HART_RTS(RTS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
//DEVICE <---SIG---> PC
|
||||
//将来自设备的HART数据装载至com485_tx,将comhart_tx的HART数据发送至设备
|
||||
void transparent_hart(st_scom *scom)
|
||||
{
|
||||
if (scom != &scom1_hart) return;
|
||||
|
||||
HART_RTS(RTS_OFF);
|
||||
|
||||
//DEVICE -> SIG
|
||||
if (scom->rx_flag == TRUE)
|
||||
{
|
||||
scom->rx_flag = FALSE;
|
||||
|
||||
//中断内接收到的数据是否符合HART数据报,符合则写入com485_tx,准备发送至PC
|
||||
if ((scom->rx_buff[0] == 0xff) && (scom->rx_buff[1] == 0xff) && (scom->rx_buff[scom->rx_len - 1] == 0xAA))
|
||||
{
|
||||
//SIG -> PC
|
||||
memcpy(scom2_rs485.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
||||
scom2_rs485.tx_len = scom->rx_len;
|
||||
scom2_rs485.tx_flag = TRUE;
|
||||
}
|
||||
scom->rx_len = 0;
|
||||
}
|
||||
|
||||
//SIG -> DEVICE
|
||||
if (scom->tx_flag == TRUE)
|
||||
{
|
||||
scom->tx_flag = FALSE;
|
||||
HART_RTS(RTS_ON);
|
||||
vTaskDelay(5);
|
||||
|
||||
hart_send(&huart1, scom->tx_buff);
|
||||
|
||||
HART_RTS(RTS_OFF);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -8,4 +8,9 @@
|
|||
|
||||
void hart_send(UART_HandleTypeDef *huart, uint8_t *data);
|
||||
void hart_communicate(st_scom *scom);
|
||||
|
||||
//DEVICE <---SIG---> PC
|
||||
//将来自设备的HART数据装载至com485_tx,将comhart_tx的HART数据发送至设备
|
||||
void transparent_hart(st_scom *scom);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
#include "stdio.h"
|
||||
#include "modbus.h"
|
||||
#include "usart.h"
|
||||
#include "apps_gather.h"
|
||||
|
||||
//static void scom_485_send(UART_HandleTypeDef *huart, char *str)
|
||||
//{
|
||||
|
@ -39,3 +40,60 @@ void parse_scom_485(st_scom *scom)
|
|||
scom->rx_len = 0;
|
||||
}
|
||||
}
|
||||
|
||||
void transparent_485(st_scom *scom)
|
||||
{
|
||||
if(scom != &scom2_rs485) return;
|
||||
|
||||
//PC -> SIG
|
||||
if(scom->rx_flag == TRUE)
|
||||
{
|
||||
scom->rx_flag = FALSE;
|
||||
|
||||
switch (sig_trans)
|
||||
{
|
||||
case TRANS_HART:
|
||||
{
|
||||
if ((scom->rx_buff[0] == 0xff) && (scom->rx_buff[1] == 0xff) && (scom->rx_buff[scom->rx_len - 1] == 0xaa))
|
||||
{
|
||||
//SIG -> DEVICE
|
||||
memcpy(scom1_hart.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
||||
scom1_hart.tx_flag = TRUE;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case TRANS_BLUETOOTH:
|
||||
{
|
||||
memcpy(scom6_ble.tx_buff, scom->rx_buff, sizeof(scom->rx_buff));
|
||||
scom6_ble.tx_flag = TRUE;
|
||||
}
|
||||
break;
|
||||
|
||||
case TRANS_MODBUS:
|
||||
{}
|
||||
break;
|
||||
|
||||
case TRANS_NONE:
|
||||
{}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
scom->rx_len = 0;
|
||||
}
|
||||
|
||||
//SIG -> PC
|
||||
if(scom->tx_flag == TRUE)
|
||||
{
|
||||
scom->tx_flag = FALSE;
|
||||
|
||||
vTaskDelay(10);
|
||||
HAL_UART_Transmit(&huart2, scom->tx_buff, scom->tx_len, 0xFFFF);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5,4 +5,9 @@
|
|||
#include "usart.h"
|
||||
|
||||
void parse_scom_485(st_scom *scom);
|
||||
|
||||
//PC <---SIG---> HART/BLUETOOTH/MODBUS
|
||||
//HART:将com485_tx的数据发送至PC,将来自PC的HART数据装载至comhart_tx
|
||||
void transparent_485(st_scom *scom);
|
||||
|
||||
#endif
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
|
||||
/* Includes ------------------------------------------------------------------*/
|
||||
#include "FreeRTOS.h"
|
||||
#include "string.h"
|
||||
#include "task.h"
|
||||
#include "main.h"
|
||||
#include "cmsis_os.h"
|
||||
|
@ -206,8 +207,11 @@ void start_task_hart(void const * argument)
|
|||
/* Infinite loop */
|
||||
for (;;)
|
||||
{
|
||||
//驱动验证,DEVICE <--- HART ---> SIG
|
||||
//hart_communicate(&scom1_hart);
|
||||
|
||||
transparent_hart(&scom1_hart);
|
||||
|
||||
tm1650_read_key(&hi2c1, &kp_flag, COMMAND_READ_KEY_DATA, &key);
|
||||
|
||||
osDelay(10);
|
||||
|
@ -221,15 +225,41 @@ void start_task_hart(void const * argument)
|
|||
* @param argument: Not used
|
||||
* @retval None
|
||||
*/
|
||||
uint8_t ble_send_test = 0;
|
||||
/* USER CODE END Header_start_task_ble */
|
||||
void start_task_ble(void const * argument)
|
||||
{
|
||||
/* USER CODE BEGIN start_task_ble */
|
||||
/* Infinite loop */
|
||||
int count = 0;
|
||||
char lock = 0;
|
||||
char id[9];
|
||||
strcpy (id,"00000001");
|
||||
|
||||
for (;;)
|
||||
{
|
||||
// strcpy((char *)(scom6_ble.tx_buff), "hellow I am ble.\r\n");
|
||||
// ble_send(&huart6, scom6_ble.tx_buff);
|
||||
if((count++ > 5*10) &&(lock == 0))
|
||||
{
|
||||
lock = 1;
|
||||
write_ble_id(id);
|
||||
}
|
||||
|
||||
if(count < 10*10)
|
||||
{
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ble_send_test == 1)
|
||||
{
|
||||
ble_send_test = 0;
|
||||
|
||||
//驱动验证,DEVICE <--- BLUETOOTH ---> SIG
|
||||
strcpy((char *)(scom6_ble.tx_buff), "hellow I am ble.\r\n");
|
||||
ble_send(&huart6, scom6_ble.tx_buff);
|
||||
}
|
||||
|
||||
//transparent_bluetooth(&scom6_ble);
|
||||
}
|
||||
|
||||
osDelay(100);
|
||||
}
|
||||
|
@ -249,7 +279,11 @@ void start_rs485(void const * argument)
|
|||
/* Infinite loop */
|
||||
for (;;)
|
||||
{
|
||||
//驱动验证,PC <--- 485 ---> SIG
|
||||
//parse_scom_485(&scom2_rs485);
|
||||
|
||||
transparent_485(&scom2_rs485);
|
||||
|
||||
osDelay(10);
|
||||
}
|
||||
/* USER CODE END start_rs485 */
|
||||
|
|
|
@ -111,19 +111,11 @@ int main(void)
|
|||
MX_USART3_UART_Init();
|
||||
MX_I2C3_Init();
|
||||
/* USER CODE BEGIN 2 */
|
||||
// eeprom_spi_init();
|
||||
// tm1650_init(&hi2c1);
|
||||
// lcd_initial(); // LCD初始化,迁移至lv_port_disp_init()内部
|
||||
// lv_init(); // LVGL 初始化
|
||||
// lv_port_disp_init(); // 注册LVGL的显示任务初始化
|
||||
|
||||
my_inits_gather();
|
||||
|
||||
HAL_TIM_Base_Start_IT(&htim6);
|
||||
|
||||
// lv_demo_benchmark(); //lv_conf.h, line:761
|
||||
// setup_ui(&guider_ui); // 初始化UI,设置与加载初始界面
|
||||
// events_init(&guider_ui); // 初始化事件
|
||||
|
||||
/* USER CODE END 2 */
|
||||
|
||||
/* Call init function for freertos objects (in cmsis_os2.c) */
|
||||
|
|
|
@ -312,4 +312,13 @@ void USART6_IRQHandler(void)
|
|||
|
||||
/* USER CODE BEGIN 1 */
|
||||
|
||||
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart)
|
||||
{
|
||||
if( huart == &huart6 )
|
||||
{
|
||||
//HAL_UART_Receive_IT(&huart6, scom6_ble.rx_buff, 255);
|
||||
}
|
||||
}
|
||||
|
||||
/* USER CODE END 1 */
|
||||
|
|
|
@ -225,6 +225,16 @@
|
|||
<WinNumber>1</WinNumber>
|
||||
<ItemText>text_pack,0x0A</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>14</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>sig_trans</ItemText>
|
||||
</Ww>
|
||||
<Ww>
|
||||
<count>15</count>
|
||||
<WinNumber>1</WinNumber>
|
||||
<ItemText>ble_send_test</ItemText>
|
||||
</Ww>
|
||||
</WatchWindow1>
|
||||
<WatchWindow2>
|
||||
<Ww>
|
||||
|
@ -247,7 +257,7 @@
|
|||
<DebugFlag>
|
||||
<trace>0</trace>
|
||||
<periodic>1</periodic>
|
||||
<aLwin>1</aLwin>
|
||||
<aLwin>0</aLwin>
|
||||
<aCover>0</aCover>
|
||||
<aSer1>0</aSer1>
|
||||
<aSer2>0</aSer2>
|
||||
|
@ -519,7 +529,7 @@
|
|||
|
||||
<Group>
|
||||
<GroupName>Application/User/App/BLE</GroupName>
|
||||
<tvExp>0</tvExp>
|
||||
<tvExp>1</tvExp>
|
||||
<tvExpOptDlg>0</tvExpOptDlg>
|
||||
<cbSel>0</cbSel>
|
||||
<RteFlg>0</RteFlg>
|
||||
|
|
File diff suppressed because it is too large
Load Diff
Loading…
Reference in New Issue