189 lines
4.2 KiB
C
189 lines
4.2 KiB
C
|
#include "type.h"
|
|||
|
#include "UWater_uart_driver.h"
|
|||
|
#include "UWater_DebugPrint.h"
|
|||
|
#include "UWater_frame_app.h"
|
|||
|
|
|||
|
static u8 wait_for_print_buf[PRINT_BUF_SIZE]; //<2F><><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
static u8 print_nb_data_flag = FALSE;
|
|||
|
static u8 print_program_data_flag = FALSE;
|
|||
|
static PRINT_STRUCT printf_struct;
|
|||
|
static u8 print_data_state=PRINT_DATA_S0;
|
|||
|
static u8 print_temp_data;
|
|||
|
static u16 print_temp_save_len;
|
|||
|
//<2F><><EFBFBD><EFBFBD>NB<4E><42><EFBFBD>ݴ<EFBFBD>ӡ
|
|||
|
void OpenPrintNbDataSwitch(void)
|
|||
|
{
|
|||
|
FrameSetMsgApp(MsgOpenIr);
|
|||
|
print_nb_data_flag = TRUE;
|
|||
|
}
|
|||
|
|
|||
|
//<2F>ر<EFBFBD>NB<4E><42><EFBFBD>ݴ<EFBFBD>ӡ
|
|||
|
void ClosePrintNbDataSwitch(void)
|
|||
|
{
|
|||
|
print_nb_data_flag = FALSE;
|
|||
|
}
|
|||
|
u8 GetPrintNbDataSwitch(void)
|
|||
|
{
|
|||
|
return print_nb_data_flag;
|
|||
|
}
|
|||
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>ӡ
|
|||
|
void OpenPrintProgramDataSwitch(void)
|
|||
|
{
|
|||
|
print_program_data_flag = TRUE;
|
|||
|
}
|
|||
|
|
|||
|
//<2F>رճ<D8B1><D5B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ݴ<EFBFBD>ӡ
|
|||
|
void ClosePrintProgramDataSwitch(void)
|
|||
|
{
|
|||
|
print_program_data_flag = FALSE;
|
|||
|
}
|
|||
|
|
|||
|
/***********************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>********************************
|
|||
|
Function: void PrintNbData (u8 *data_src, u16 len)
|
|||
|
Description: <EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
Input: data_src <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դָ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>len <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
****************************************************************/
|
|||
|
void PrintNbData(u8 *data_src, u16 len)
|
|||
|
{
|
|||
|
if(print_nb_data_flag)
|
|||
|
{
|
|||
|
while(len--)
|
|||
|
{
|
|||
|
print_temp_save_len = printf_struct.saved_data_len;//<2F><>дָ<D0B4>뱣<EFBFBD><EBB1A3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
print_temp_save_len++;
|
|||
|
if (print_temp_save_len >= PRINT_BUF_SIZE)
|
|||
|
print_temp_save_len = 0;
|
|||
|
if (print_temp_save_len != printf_struct.printf_data_len)
|
|||
|
{
|
|||
|
wait_for_print_buf[printf_struct.saved_data_len] = *data_src++;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4><EFBFBD>ڴ滺<DAB4><E6BBBA><EFBFBD><EFBFBD>
|
|||
|
printf_struct.saved_data_len = print_temp_save_len;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
int Print_Get_Rx_Num(void)
|
|||
|
{
|
|||
|
if (printf_struct.saved_data_len >= printf_struct.printf_data_len)
|
|||
|
return (printf_struct.saved_data_len - printf_struct.printf_data_len);
|
|||
|
else
|
|||
|
return (printf_struct.saved_data_len + PRINT_BUF_SIZE - printf_struct.printf_data_len);
|
|||
|
}
|
|||
|
unsigned char Print_Get_Rx_Data(void)
|
|||
|
{
|
|||
|
unsigned char data;
|
|||
|
|
|||
|
data = wait_for_print_buf[printf_struct.printf_data_len];
|
|||
|
printf_struct.printf_data_len++;
|
|||
|
if (printf_struct.printf_data_len >= PRINT_BUF_SIZE)
|
|||
|
printf_struct.printf_data_len = 0;
|
|||
|
return data;
|
|||
|
}
|
|||
|
/***********************<2A><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>********************************
|
|||
|
Function: void PrintProgramData (u8 *data_src, u16 len)
|
|||
|
Description: <EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
Input: data_src <EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Դָ<EFBFBD><EFBFBD> <EFBFBD><EFBFBD>len <EFBFBD><EFBFBD><EFBFBD>ݳ<EFBFBD><EFBFBD><EFBFBD>
|
|||
|
****************************************************************/
|
|||
|
void PrintProgramData(u8 *data_src, u16 len)
|
|||
|
{
|
|||
|
if(print_program_data_flag)
|
|||
|
{
|
|||
|
u16 i;
|
|||
|
if(len < PRINT_BUF_SIZE)
|
|||
|
{
|
|||
|
for(i = 0; i < len; i++)
|
|||
|
{
|
|||
|
wait_for_print_buf[printf_struct.saved_data_len++] = *(data_src + i);
|
|||
|
printf_struct.saved_data_len = printf_struct.saved_data_len % PRINT_BUF_SIZE;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
//<2F><>ӡ״̬<D7B4><CCAC><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD>
|
|||
|
u8 PrintDataMachineIfIdle(void)
|
|||
|
{
|
|||
|
if(PRINT_DATA_S0 == print_data_state)
|
|||
|
{
|
|||
|
return TASK_IDLE;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
return TASK_BUSY;
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
/*******************************<2A><>ӡ<EFBFBD><D3A1><EFBFBD><EFBFBD>״̬<D7B4><CCAC>******************************
|
|||
|
Function: void PrintDataMachine(void)
|
|||
|
Description: <EFBFBD><EFBFBD>ӡ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<EFBFBD><EFBFBD>
|
|||
|
***************************************************************************/
|
|||
|
void PrintDataMachine(void)
|
|||
|
{
|
|||
|
switch(print_data_state)
|
|||
|
{
|
|||
|
case(PRINT_DATA_S0):
|
|||
|
{
|
|||
|
if(print_nb_data_flag)
|
|||
|
{
|
|||
|
if(Print_Get_Rx_Num()>0)
|
|||
|
{
|
|||
|
print_temp_data = Print_Get_Rx_Data();
|
|||
|
print_data_state = PRINT_DATA_S1;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
|
|||
|
case(PRINT_DATA_S1):
|
|||
|
{
|
|||
|
if(TASK_IDLE == UartIfIdle(IR_UART_COM))
|
|||
|
{
|
|||
|
UartSend(IR_UART_COM,1,&print_temp_data,&printf_struct.send_msg);
|
|||
|
print_data_state = PRINT_DATA_S2;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
case(PRINT_DATA_S2):
|
|||
|
{
|
|||
|
if(Print_Get_Rx_Num()>0)
|
|||
|
{
|
|||
|
print_temp_data = Print_Get_Rx_Data();
|
|||
|
print_data_state = PRINT_DATA_S1;
|
|||
|
}
|
|||
|
else
|
|||
|
{
|
|||
|
print_data_state = PRINT_DATA_S0;
|
|||
|
}
|
|||
|
}
|
|||
|
break;
|
|||
|
|
|||
|
case(PRINT_DATA_DEFAULT):
|
|||
|
{
|
|||
|
print_data_state = PRINT_DATA_S0;
|
|||
|
}
|
|||
|
break;
|
|||
|
default:
|
|||
|
{
|
|||
|
print_data_state = PRINT_DATA_S0;
|
|||
|
break;
|
|||
|
}
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|
|||
|
|