/**************************************************************************** * DESCRIPTION: Waits on the SilenceTimer for 40 bits. * RETURN: none * ALGORITHM: none * NOTES: none *****************************************************************************/ void RS485_Turnaround_Delay( void) { uint16_t turnaround_time; // U8_T i; // uint16_t RS485_Baud; /* delay after reception before trasmitting - per MS/TP spec */ /* wait a minimum 40 bit times since reception */ /* at least 1 ms for errors: rounding, clock tick */ // if baud is 9600, turnaround_time is 4 // if baud if 19200, turnaround time is 2 // turnaround_time = 2 + ((Tturnaround * 1000UL) / RS485_Baud); if(modbus.com_config[0] == BAC_MSTP) { if(modbus.baudrate == 9600) { turnaround_time = 6; } else if(modbus.baudrate == 19200) { turnaround_time = 4; } else if(modbus.baudrate == 38400) { turnaround_time = 3; } else turnaround_time = 2; } while (Timer_Silence() < turnaround_time) { /* do nothing - wait for timer to increment */ }; }
/**************************************************************************** * DESCRIPTION: Waits on the SilenceTimer for 40 bits. * RETURN: none * ALGORITHM: none * NOTES: none *****************************************************************************/ void RS485_Turnaround_Delay( void) { uint16_t turnaround_time; /* delay after reception before trasmitting - per MS/TP spec */ /* wait a minimum 40 bit times since reception */ /* at least 1 ms for errors: rounding, clock tick */ turnaround_time = 1 + ((Tturnaround * 1000UL) / RS485_Baud); while (Timer_Silence() < turnaround_time) { /* do nothing - wait for timer to increment */ }; }