📄 main.c
字号:
DataPack.Pic_Size = (uint32)rev_buf[9] + (((uint32)rev_buf[10]) << 8) + (((uint32)rev_buf[11]) << 16);
}
DataPack.Video_Order_Type = rev_buf[1];
DataPack.Video_ID = rev_buf[2];
OSMboxPost(VideoMbox, &DataPack);
}// if ((rev_buf[0] = UART0Getch()) == 0xaa)
break;
case 0x01:
rev_buf[0] = UART2Getch();
rev_buf[1] = UART2Getch();
rev_buf[2] = UART2Getch();
rev_buf[3] = UART2Getch();
pack_size = (uint16)rev_buf[2] + (((uint16)rev_buf[3]) << 8);
if (pack_size > PACK_SIZE)
break;
check_code = rev_buf[0] + rev_buf[1] + rev_buf[2] + rev_buf[3];
for (i = 0x0000; i < pack_size; i++){
pic_temp_buf[i] = UART2Getch();
check_code += pic_temp_buf[i];
}
rev_buf[4] = UART2Getch();
rev_buf[5] = UART2Getch();
if ((check_code == rev_buf[4]) && (rev_buf[5] == 0x00)){
pic_buf.pic_index = rev_buf[0];
pic_buf.pic_type = VIDEO_CH1;
pic_buf.pic_size = pack_size;
for (i = 0x0000; i < pack_size; i++)
pic_buf.pic_buf[i] = pic_temp_buf[i];
OSMboxPost(VideoMbox, &pic_buf);
}// if ((check_code == rev_buf[4]) && (rev_buf[4] == 0x00))
break;
default:
break;
}//switch(Pic_Rev_Flag)
}//for(; ;)
}
/*********************************************************************************************************/
void Uart3ReviceTask(void *pdata)
{
uint8 rev_buf[90], checkcode;
uint16 size, i;
REV_DATA DataPack;
for(; ;){
if (((rev_buf[0] = UART3Getch()) == '$')
&& ((rev_buf[1] = UART3Getch()) == 'G')
&& ((rev_buf[2] = UART3Getch()) == 'P')
&& ((rev_buf[3] = UART3Getch()) == 'R')
&& ((rev_buf[4] = UART3Getch()) == 'S')
&& ((rev_buf[5] = UART3Getch()) == 'C')
&& ((rev_buf[6] = UART3Getch()) == 'D')
&& ((rev_buf[7] = UART3Getch()) == 'M')
&& ((rev_buf[8] = UART3Getch()) == 'A')){
rev_buf[9] = UART3Getch();
if (rev_buf[9] == SYS_CONF_CODE){
rev_buf[10] = UART3Getch();
rev_buf[11] = UART3Getch();
size = (uint16)rev_buf[10] + (((uint16)rev_buf[11]) << 8);
for (i = 0x00; i < size; i++)
rev_buf[12 + i] = UART3Getch();
checkcode = UART3Getch();
if (CalCheckCode(rev_buf, checkcode, (uint8)(12 + size)) == SUCCESS){
if (Get_Config_Info(rev_buf) == SUCCESS){
DataPack.Data_Type = SYS_CONFIG_HANDEL;
OSQPost(Data_Rev_Queue, &DataPack);
}
}// if (CalCheckCode(rev_buf, checkcode, (uint8)(12 + size)) == SUCCESS)
}// if (rev_buf[9] == SYS_CONF_CODE)
}// if (((rev_buf[0] = UART0Getch()) == '$')
}// for(; ;)
}
/*********************************************************************************************************/
void TimerReviceTask(void *pdata)
{
REV_DATA LoginTimeData;
uint8 check_time_count = 0x00, login_time_count = 0x00, GPS_time_count = 0x00;
for(; ;){
OSTimeDly (OS_TICKS_PER_SEC );
check_time_count += 0x01;
if ((check_time_count & 0x01) == 0x00)
IO0CLR |= CHECK_OUTPUT; /* 设置P0.25输出为0*/
else IO0SET |= CHECK_OUTPUT; /* 设置P0.25输出为1*/
login_time_count += 0x01;
if (login_time_count >= 11){
login_time_count = 0x00;
LoginTimeData.Data_Type = LOGIN_DEAL_HANDEL;
OSQPost(Data_Rev_Queue, &LoginTimeData);
}// if (login_time_count >= 11)
GPS_time_count += 0x01;
if (GPS_time_count >= 5){
GPS_time_count = 0x00;
if (Rev_GPS_Data.Gps_Flag == 0x01){
OS_ENTER_CRITICAL();
History_GPS_Data[GPS_Data_Index] = Rev_GPS_Data;
OS_EXIT_CRITICAL();
if (GPS_Data_Index == (GPS_DATA_NUM -1))
GPS_Data_Index = 0x00;
else GPS_Data_Index += 0x01;
if (GPS_Data_Size < GPS_DATA_NUM )
GPS_Data_Size += 0x01;
}// if (Rev_GPS_Data.Gps_Flag == 0x01)
}// if (GPS_time_count >= 5)
}//for(; ;)
}
/*********************************************************************************************************/
void AlarmOutputTask(void *pdata)
{
uint8 count = 0x00;
for(; ;){
OSTimeDly (OS_TICKS_PER_SEC);
count += 0x01;
if (Alarm_flag == 0x00)
IOCLR = 0x80000000; /* 设置P0.31输出为0*/
else
{
if((count & 0x01) == 0x00)
IOCLR = 0x80000000; /* 设置P0.31输出为0*/
else IOSET = 0x80000000; /* 设置P0.31输出为1*/
}
}//for(; ;)
}
/*********************************************************************************************************/
void KeyInputTask(void *pdata)
{
uint8 mon_key_down = 0x00, mon_key_up = 0x00, mon_key_flag = 0x00;
uint8 alarm_key_down = 0x00, alarm_key_up = 0x00, alarm_key_flag = 0x00;
uint8 recode_key_down = 0x00, recode_key_up = 0x00, recode_key_flag = 0x00;
uint8 decode_key_down = 0x00, decode_key_up = 0x00, decode_key_flag = 0x00;
REV_DATA MonData, AlarmData, RecodeData, DecodeData;
for (;;)
{
OSTimeDly(OS_TICKS_PER_SEC / 50); // 延时20毫秒
if ((IO0PIN & KEY1) == NULL)
mon_key_down++;
else mon_key_up++;
if (mon_key_down == 0x02){
mon_key_up = 0x00;
mon_key_flag = 0x01;
}
if ((mon_key_flag == 0x01) && (mon_key_up == 0x02)){
mon_key_down = 0x00,
mon_key_up = 0x00,
mon_key_flag = 0x00;
MonData.Data_Type = PIC_DEAL_HANDEL;
OSQPost(Data_Rev_Queue, &MonData);
}
if ((IO1PIN & KEY2) == NULL)
alarm_key_down++;
else alarm_key_up++;
if (alarm_key_down == 0x02){
alarm_key_up = 0x00;
alarm_key_flag = 0x01;
}
if ((alarm_key_flag == 0x01) && (alarm_key_up == 0x02)){
alarm_key_down = 0x00,
alarm_key_up = 0x00,
alarm_key_flag = 0x00;
Alarm_Status = 0x01; // 系统处于报警状态
AlarmData.Data_Type = LOGIN_PIC_HANDEL;
OSQPost(Data_Rev_Queue, &AlarmData);
}
if ((IO1PIN & KEY3) == NULL)
recode_key_down++;
else recode_key_up++;
if (recode_key_down == 0x02){
recode_key_up = 0x00;
recode_key_flag = 0x01;
}
if ((recode_key_flag == 0x01) && (recode_key_up == 0x02)){
recode_key_down = 0x00,
recode_key_up = 0x00,
recode_key_flag = 0x00;
RecodeData.Data_Type = RECODE_HANDEL;
OSQPost(Data_Rev_Queue, &RecodeData);
}
if ((IO0PIN & KEY4) == NULL)
decode_key_down++;
else decode_key_up++;
if (decode_key_down == 0x02){
decode_key_up = 0x00;
decode_key_flag = 0x01;
}
if ((decode_key_flag == 0x01) && (decode_key_up == 0x02)){
decode_key_down = 0x00,
decode_key_up = 0x00,
decode_key_flag = 0x00;
DecodeData.Data_Type = PIC_DEAL_HANDEL;
//DecodeData.Data_Type = DECODE_HANDEL;
OSQPost(Data_Rev_Queue, &DecodeData);
}
}
}
/*********************************************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -