leakage
This commit is contained in:
145
calib_board/usr/app/app.c
Normal file
145
calib_board/usr/app/app.c
Normal file
@@ -0,0 +1,145 @@
|
||||
#include "app.h"
|
||||
#include "os_timer.h"
|
||||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
|
||||
#include "bsp_Uart.h"
|
||||
#include "bsp_Wdg.h"
|
||||
#include "bsp_Led.h"
|
||||
#include "bsp_74HC4067.h"
|
||||
#include "bsp_Flash.h"
|
||||
#include "tjc_usart_hmi.h"
|
||||
|
||||
#include "proto_modbus_master_tdlas.h"
|
||||
#include "proto_modbus_slave_ex.h"
|
||||
|
||||
const char *HwVersion = "V1.0";
|
||||
char SwVersion[24] = "V0.001.0";
|
||||
void TASK_Idle(void);
|
||||
void Task_10ms(void);
|
||||
void Task_50ms(void);
|
||||
void Task_100ms(void);
|
||||
void Task_200ms(void);
|
||||
void Task_500ms(void);
|
||||
void Task_1s(void);
|
||||
void Task_2s(void);
|
||||
|
||||
/******************************************
|
||||
* <20><><EFBFBD><EFBFBD>: AppInit
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>ʼ<EFBFBD><CABC>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
******************************************/
|
||||
void App_Init(void)
|
||||
{
|
||||
Usr_Flash.Init();
|
||||
|
||||
COM_Uart1.Init(&COM_Uart1);
|
||||
COM_Uart2.Init(&COM_Uart2);
|
||||
COM_Uart4.Init(&COM_Uart4);
|
||||
Led.Init();
|
||||
UartCH_Config.init();
|
||||
|
||||
|
||||
|
||||
tdlas.init();
|
||||
modbus_slave_ex.init();
|
||||
TJC_Init(&COM_Uart2);
|
||||
initRingBuffer();
|
||||
char init_msg[] = "ϵͳ<EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD>...\r\n";
|
||||
HAL_UART_Transmit(COM_Uart2.Uart, (uint8_t*)init_msg, strlen(init_msg), 100);
|
||||
//Wdg.Init();
|
||||
}
|
||||
|
||||
/******************************************
|
||||
* <20><><EFBFBD><EFBFBD>: App_Task
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>
|
||||
* <20><><EFBFBD><EFBFBD>: <20><>ѭ<EFBFBD><D1AD><EFBFBD>е<EFBFBD><D0B5><EFBFBD>
|
||||
******************************************/
|
||||
void App_Task(void)
|
||||
{
|
||||
if (TIME_TRUE == OsTimer_CheckTimeOut(OsTimeTick_10ms, osTime_MSecTick, 10))
|
||||
{
|
||||
OsTimeTick_10ms = osTime_MSecTick;
|
||||
Task_10ms();
|
||||
}
|
||||
if (TIME_TRUE == OsTimer_CheckTimeOut(OsTimeTick_50ms, osTime_MSecTick, 50))
|
||||
{
|
||||
OsTimeTick_50ms = osTime_MSecTick;
|
||||
Task_50ms();
|
||||
}
|
||||
if (TIME_TRUE == OsTimer_CheckTimeOut(OsTimeTick_100ms, osTime_MSecTick, 100))
|
||||
{
|
||||
OsTimeTick_100ms = osTime_MSecTick;
|
||||
Task_100ms();
|
||||
}
|
||||
if (TIME_TRUE == OsTimer_CheckTimeOut(OsTimeTick_200ms, osTime_MSecTick, 200))
|
||||
{
|
||||
OsTimeTick_200ms = osTime_MSecTick;
|
||||
Task_200ms();
|
||||
}
|
||||
if (TIME_TRUE == OsTimer_CheckTimeOut(OsTimeTick_500ms, osTime_MSecTick, 500))
|
||||
{
|
||||
OsTimeTick_500ms = osTime_MSecTick;
|
||||
Task_500ms();
|
||||
}
|
||||
if (TIME_TRUE == OsTimer_CheckTimeOut(OsTimeTick_1s, osTime_MSecTick, 1000))
|
||||
{
|
||||
OsTimeTick_1s = osTime_MSecTick;
|
||||
Task_1s();
|
||||
}
|
||||
if (TIME_TRUE == OsTimer_CheckTimeOut(OsTimeTick_2s, osTime_MSecTick, 2000))
|
||||
{
|
||||
OsTimeTick_2s = osTime_MSecTick;
|
||||
Task_2s();
|
||||
}
|
||||
TASK_Idle();
|
||||
}
|
||||
/*<2A><><EFBFBD><EFBFBD>ִ<EFBFBD>еĺ<D0B5><C4BA><EFBFBD>*/
|
||||
void TASK_Idle(void)
|
||||
{
|
||||
COM_Uart1.Rx_Task(&COM_Uart1);
|
||||
COM_Uart2.Rx_Task(&COM_Uart2);
|
||||
COM_Uart4.Rx_Task(&COM_Uart4);
|
||||
}
|
||||
|
||||
void Task_10ms(void)
|
||||
{
|
||||
}
|
||||
|
||||
void Task_50ms(void)
|
||||
{
|
||||
// tdlas.tx_task();
|
||||
}
|
||||
|
||||
void Task_100ms(void)
|
||||
{
|
||||
// tdlas.tx_task();
|
||||
}
|
||||
|
||||
void Task_200ms(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Task_500ms(void)
|
||||
{
|
||||
// UartCH_Config.ch_set(ch);
|
||||
// tdlas.tx_task();
|
||||
Led.Flash();
|
||||
}
|
||||
|
||||
|
||||
void Task_1s(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void Task_2s(void)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
10
calib_board/usr/app/app.h
Normal file
10
calib_board/usr/app/app.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef _APP_H_
|
||||
#define _APP_H_
|
||||
|
||||
extern const char *HwVersion;
|
||||
extern char SwVersion[24];
|
||||
|
||||
void App_Init(void);
|
||||
void App_Task(void);
|
||||
|
||||
#endif
|
||||
4
calib_board/usr/app/gas_data.c
Normal file
4
calib_board/usr/app/gas_data.c
Normal file
@@ -0,0 +1,4 @@
|
||||
#include "gas_data.h"
|
||||
|
||||
gas_data_t gas_data[SENSOR_NUM];
|
||||
|
||||
38
calib_board/usr/app/gas_data.h
Normal file
38
calib_board/usr/app/gas_data.h
Normal file
@@ -0,0 +1,38 @@
|
||||
#ifndef _GAS_DATA_H__
|
||||
#define _GAS_DATA_H__
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#define SENSOR_NUM 16
|
||||
|
||||
typedef struct
|
||||
{
|
||||
u8 ver[20]; /*<2A><><EFBFBD><EFBFBD><EFBFBD>汾<EFBFBD><E6B1BE>*/
|
||||
u8 sn[20]; /*SN<53><4E>*/
|
||||
u16 range; /*<2A><><EFBFBD><EFBFBD>*/
|
||||
s16 value; /*Ũ<><C5A8>*/
|
||||
u16 pp_ad; /*<2A><><EFBFBD><EFBFBD>ֵ*/
|
||||
u16 r_pp_ad; /*ԭʼ<D4AD><CABC><EFBFBD><EFBFBD>ֵ*/
|
||||
u16 pp_pix; /*<2A><><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>*/
|
||||
u16 light_ad; /*<2A><EFBFBD><E2B9A6>*/
|
||||
u16 tec_set_value; /*tec<65>趨ֵ*/
|
||||
u16 tec_temp; /*tec<65>¶<EFBFBD>*/
|
||||
s16 temp; /*<2A><><EFBFBD><EFBFBD><EFBFBD>¶<EFBFBD>*/
|
||||
u16 light_ad_max; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ*/
|
||||
u16 light_ad_min; /*<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сֵ*/
|
||||
u16 state_code; /*״̬<D7B4><CCAC>*/
|
||||
u16 dc_offset; /*ֱ<><D6B1>ƫ<EFBFBD><C6AB>*/
|
||||
//u16 ad_befor_multiple; /*ADǰ<44>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
u16 demod_multiple; /*<2A><><EFBFBD><EFBFBD><EFBFBD>Ŵ<EFBFBD><C5B4><EFBFBD><EFBFBD><EFBFBD>*/
|
||||
//u16 mode; /*ģʽ״̬*/
|
||||
s16 calib_temp; /*<2A>궨ʱ<EAB6A8><CAB1><EFBFBD>¶<EFBFBD>*/
|
||||
u16 calib_press; /*<2A>궨ʱ<EAB6A8><CAB1>ѹ<EFBFBD><D1B9>*/
|
||||
u16 calib_humidity; /*<2A>궨ʱ<EAB6A8><CAB1>ʪ<EFBFBD><CAAA>*/
|
||||
u16 fac_calib_code_h;
|
||||
u16 fac_calib_code_l; /*<2A><><EFBFBD>ұ궨ʱ<EAB6A8><CAB1>״̬<D7B4><CCAC>*/
|
||||
u16 reserve[1]; /*Ԥ<><D4A4>*/
|
||||
}gas_data_t;
|
||||
|
||||
extern gas_data_t gas_data[SENSOR_NUM];
|
||||
|
||||
#endif
|
||||
121
calib_board/usr/app/os_timer.c
Normal file
121
calib_board/usr/app/os_timer.c
Normal file
@@ -0,0 +1,121 @@
|
||||
#include "os_timer.h"
|
||||
|
||||
unsigned short osTime_MSecTick = 0; /*<2A>δ<EFBFBD>ʱ<EFBFBD><CAB1>*/
|
||||
unsigned short osTime_SecTick = 0;
|
||||
unsigned short osTime_10SecTick = 0; /*10s<30><73>һ<EFBFBD><D2BB> <20><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>¼*/
|
||||
|
||||
static unsigned short osTimer_MSec1 = 0;
|
||||
static unsigned short osTimer_MSec2 = 0;
|
||||
|
||||
unsigned short OsTimeTick_10ms;
|
||||
unsigned short OsTimeTick_50ms;
|
||||
unsigned short OsTimeTick_100ms;
|
||||
unsigned short OsTimeTick_200ms;
|
||||
unsigned short OsTimeTick_500ms;
|
||||
unsigned short OsTimeTick_1s;
|
||||
unsigned short OsTimeTick_2s;
|
||||
|
||||
/****************************************************************************
|
||||
* NAME: OsTimer_Init
|
||||
* CALLED BY: Application
|
||||
* PRECONDITIONS:
|
||||
* INPUT PARAMETERS: None
|
||||
* RETURN VALUES: None
|
||||
* DESCRIPTION: OsTimer initialization
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void OsTimer_Init(void)
|
||||
{
|
||||
osTimer_MSec1 = 0;
|
||||
osTimer_MSec2 = 0;
|
||||
osTime_SecTick = 0;
|
||||
osTime_MSecTick = 0;
|
||||
|
||||
OsTimeTick_10ms = osTime_MSecTick;
|
||||
OsTimeTick_50ms = osTime_MSecTick;
|
||||
OsTimeTick_100ms = osTime_MSecTick;
|
||||
OsTimeTick_200ms = osTime_MSecTick;
|
||||
OsTimeTick_500ms = osTime_MSecTick;
|
||||
OsTimeTick_1s = osTime_MSecTick;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* NAME: OsTimer_Increment
|
||||
* CALLED BY: ISR
|
||||
* PRECONDITIONS:
|
||||
* INPUT PARAMETERS: msec - millisecond to increase
|
||||
* RETURN VALUES: None
|
||||
* DESCRIPTION: Increase the Timer
|
||||
*
|
||||
****************************************************************************/
|
||||
void OsTimer_Increment(unsigned short msec)
|
||||
{
|
||||
osTime_MSecTick += msec;
|
||||
osTimer_MSec1 += msec;
|
||||
osTimer_MSec2 += msec;
|
||||
if (osTimer_MSec1 >= 1000U) /*1s*/
|
||||
{
|
||||
osTimer_MSec1 = 0U;
|
||||
osTime_SecTick++;
|
||||
}
|
||||
if (osTimer_MSec2 >= 10000U) /*10s*/
|
||||
{
|
||||
osTimer_MSec2 = 0U;
|
||||
osTime_10SecTick++;
|
||||
}
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* NAME: OsTimer_CheckTimeOut
|
||||
* CALLED BY: Application
|
||||
* PRECONDITIONS:
|
||||
* INPUT PARAMETERS: timeStart - start tick
|
||||
* timeNow - current tick
|
||||
* timeOut - expired tick
|
||||
* RETURN VALUES: whether timer is expired
|
||||
* DESCRIPTION: check if specified time is expired
|
||||
*
|
||||
****************************************************************************/
|
||||
unsigned char OsTimer_CheckTimeOut(unsigned short timeStart, unsigned short timeNow, unsigned short timeOut)
|
||||
{
|
||||
unsigned short timerActivateVal;
|
||||
timerActivateVal = timeOut + timeStart;
|
||||
|
||||
if (timerActivateVal > timeStart)
|
||||
{
|
||||
if ((timeNow >= timerActivateVal) || (timeNow < timeStart))
|
||||
{
|
||||
return TIME_TRUE;
|
||||
}
|
||||
}
|
||||
else if ((timeNow >= timerActivateVal) && (timeNow < timeStart))
|
||||
{
|
||||
return TIME_TRUE;
|
||||
}
|
||||
return TIME_FALSE;
|
||||
}
|
||||
|
||||
/*
|
||||
<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>л<EFBFBD><EFBFBD>ж<EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><EFBFBD> <20><><EFBFBD><EFBFBD>OsTimer_CheckTimeOut<75><74><EFBFBD><EFBFBD>ʹ<EFBFBD><CAB9>
|
||||
*/
|
||||
unsigned short OsTimer_CheckRunTime(unsigned short timeStart, unsigned short timeNow, unsigned short timeOut)
|
||||
{
|
||||
unsigned short timerActivateVal;
|
||||
timerActivateVal = timeOut + timeStart;
|
||||
|
||||
if (timerActivateVal > timeStart)
|
||||
{
|
||||
return (timerActivateVal - timeNow);
|
||||
}
|
||||
else
|
||||
{
|
||||
return (65535U - timeNow + timerActivateVal);
|
||||
}
|
||||
}
|
||||
|
||||
/*<2A><><EFBFBD><EFBFBD>ʽ<EFBFBD><CABD>ʱ*/
|
||||
void Delay_ms(unsigned short delay)
|
||||
{
|
||||
HAL_Delay(delay);
|
||||
}
|
||||
29
calib_board/usr/app/os_timer.h
Normal file
29
calib_board/usr/app/os_timer.h
Normal file
@@ -0,0 +1,29 @@
|
||||
#ifndef _OSTIMER_H_
|
||||
#define _OSTIMER_H_
|
||||
|
||||
#include "main.h"
|
||||
|
||||
#define TIME_TRUE 1U
|
||||
#define TIME_FALSE 0U
|
||||
|
||||
|
||||
extern unsigned short osTime_MSecTick;
|
||||
extern unsigned short osTime_SecTick;
|
||||
extern unsigned short osTime_10SecTick; // 10s<30><73>һ<EFBFBD><D2BB> <20><><EFBFBD><EFBFBD><EFBFBD>Զ<EFBFBD><D4B6><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>¼
|
||||
|
||||
extern unsigned short OsTimeTick_10ms;
|
||||
extern unsigned short OsTimeTick_50ms;
|
||||
extern unsigned short OsTimeTick_100ms;
|
||||
extern unsigned short OsTimeTick_200ms;
|
||||
extern unsigned short OsTimeTick_500ms;
|
||||
extern unsigned short OsTimeTick_1s;
|
||||
extern unsigned short OsTimeTick_2s;
|
||||
|
||||
void OsTimer_Init(void);
|
||||
void OsTimer_Increment(unsigned short msec);
|
||||
unsigned char OsTimer_CheckTimeOut(unsigned short timeStart, unsigned short timeNow, unsigned short timeOut);
|
||||
unsigned short OsTimer_CheckRunTime(unsigned short timeStart, unsigned short timeNow, unsigned short timeOut);
|
||||
|
||||
void Delay_ms(unsigned short delay);
|
||||
|
||||
#endif
|
||||
Reference in New Issue
Block a user