Data flow analysis begins with the interruption of the serial port
/* Receive one BYTE */@far @interrupt void uart2rx_interrupt (void)
{
U8 byte;
if (UART2->SR & Uart2_flag_rxne)
{
byte = uart2->sr;
byte = Uart2_receivedata8 ();
if (Uart_chn_rx_byte (byte))
{
Uart_rx_hook ();
}
}
}
The Uart_rx_hook () was triggered in the serial interrupt;
void Uart_rx_hook (void)
{
uart_file_infor[0].busy_rxing = Uart_char_max_delay;
Notify (Ev_rxchar);
}
Scan_uart_opt (void *args) triggered in the hook function of the serial interrupt
void scan_uart_opt (void *args)
{
struct Shs_frame *pframe;
Uint8 Idx,len;
IDX = Sys_uart_peek_data (g_frame_buffer, sizeof (G_frame_buffer));
Pframe = Get_smart_frame (G_FRAME_BUFFER,IDX);
if (NULL = = pframe) return;
IDX = (uint8 *) Pframe-g_frame_buffer;
Len = pframe->length+shs_frame_head+1;
Clear_uart (idx + len);
Memmove_my (&g_frame_buffer[0], &g_frame_buffer[idx], Len);
Pframe = (struct shs_frame *) G_frame_buffer;
Added 2-hour non-communication reset carrier chip function
Clear_rst_time (pframe);
Plc_machine_opt (pframe); Protocol handle (Buffer[i] is a complete frame data)
}
Don't understand ....
void plc_machine_opt (void *args)
{
struct Plc_state *pstate = plc_state.pstate;
Uint8 Init;
init = Plc_state.init;
if (init) plc_state.wait_t=0;
Plc_state.init = 0;
if (NULL! = pstate)
{
Pstate->action (init, args);//Where is the meaning of this sentence ....
}
}
void task_100ms (void *args)
{
notify (ev_state);//start state_machine
Uart_tick_ Hook ();
//learning_wave ();
Emitt_wave ();
} The function of
is primarily to solve the problem of timeouts
void Uart_tick_hook (void)
{
if (uart_file_infor[0].busy_ Rxing > 0x00)
{
uart_file_infor[0].busy_rxing--;
&NB Sp if (0x00 = = uart_file_infor[0].busy_rxing)
{
Empty_a_chn_slot (& (Uart_file_infor[0].rx_slot));
}
}
}