Added yield to lower CPU usage when no characters are arriving.
This commit is contained in:
@@ -217,6 +217,9 @@ static void *dlmstp_master_fsm_task(void *pArg)
|
|||||||
if (MSTP_Port.ReceivedValidFrame == false &&
|
if (MSTP_Port.ReceivedValidFrame == false &&
|
||||||
MSTP_Port.ReceivedInvalidFrame == false) {
|
MSTP_Port.ReceivedInvalidFrame == false) {
|
||||||
RS485_Check_UART_Data(&MSTP_Port);
|
RS485_Check_UART_Data(&MSTP_Port);
|
||||||
|
if (MSTP_Port.DataAvailable == false) {
|
||||||
|
sched_yield();
|
||||||
|
}
|
||||||
MSTP_Receive_Frame_FSM(&MSTP_Port);
|
MSTP_Receive_Frame_FSM(&MSTP_Port);
|
||||||
}
|
}
|
||||||
if (MSTP_Port.ReceivedValidFrame || MSTP_Port.ReceivedInvalidFrame) {
|
if (MSTP_Port.ReceivedValidFrame || MSTP_Port.ReceivedInvalidFrame) {
|
||||||
@@ -241,9 +244,9 @@ static void *dlmstp_master_fsm_task(void *pArg)
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (run_master)
|
if (run_master) {
|
||||||
MSTP_Master_Node_FSM(&MSTP_Port);
|
MSTP_Master_Node_FSM(&MSTP_Port);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|||||||
@@ -258,7 +258,7 @@ void RS485_Check_UART_Data(volatile struct mstp_port_struct_t *mstp_port)
|
|||||||
if (mstp_port->DataAvailable == false) {
|
if (mstp_port->DataAvailable == false) {
|
||||||
/* check for data */
|
/* check for data */
|
||||||
pthread_mutex_lock(&Reader_Mutex);
|
pthread_mutex_lock(&Reader_Mutex);
|
||||||
if (FIFO_Count(&Rx_FIFO) > 0) {
|
if (FIFO_Count(&Rx_FIFO) > 0) {
|
||||||
mstp_port->DataRegister = FIFO_Get(&Rx_FIFO);
|
mstp_port->DataRegister = FIFO_Get(&Rx_FIFO);
|
||||||
mstp_port->DataAvailable = true;
|
mstp_port->DataAvailable = true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user