Fix mstimer elapsed time (#58)
Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
This commit is contained in:
+1
-1
@@ -400,7 +400,7 @@ static void packet_statistics_clear(void)
|
||||
|
||||
static uint32_t Timer_Silence(void *pArg)
|
||||
{
|
||||
return mstimer_remaining(&Silence_Timer);
|
||||
return mstimer_elapsed(&Silence_Timer);
|
||||
}
|
||||
|
||||
static void Timer_Silence_Reset(void *pArg)
|
||||
|
||||
@@ -61,7 +61,7 @@ static struct mstimer Silence_Timer;
|
||||
bool rs485_silence_time_elapsed(
|
||||
uint16_t milliseconds)
|
||||
{
|
||||
return (mstimer_remaining(&Silence_Timer) > milliseconds);
|
||||
return (mstimer_elapsed(&Silence_Timer) > milliseconds);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
||||
@@ -62,12 +62,14 @@ static volatile struct mstp_port_struct_t MSTP_Port;
|
||||
/* buffers needed by mstp port struct */
|
||||
static uint8_t RxBuffer[MAX_MPDU];
|
||||
static uint8_t TxBuffer[MAX_MPDU];
|
||||
static struct mstimer Silence_Timer;
|
||||
|
||||
static uint32_t Timer_Silence(
|
||||
void *pArg)
|
||||
{
|
||||
uint32_t delta_time = 0;
|
||||
|
||||
delta_time = timer_milliseconds(TIMER_SILENCE);
|
||||
delta_time = mstimer_elapsed(&Silence_Timer);
|
||||
if (delta_time > 0xFFFF) {
|
||||
delta_time = 0xFFFF;
|
||||
}
|
||||
@@ -78,7 +80,7 @@ static uint32_t Timer_Silence(
|
||||
static void Timer_Silence_Reset(
|
||||
void *pArg)
|
||||
{
|
||||
timer_reset(TIMER_SILENCE);
|
||||
mstimer_set(&Silence_Timer, 0);
|
||||
}
|
||||
|
||||
/* functions used by the MS/TP state machine to put or get data */
|
||||
|
||||
@@ -76,7 +76,7 @@ void lse_init(
|
||||
while (1) {
|
||||
if (LSE_Delay < LSE_FAIL_FLAG) {
|
||||
mstimer_set(&Delay_Timer, 0);
|
||||
while (mstimer_remaining(&Delay_Timer) < 500) {
|
||||
while (mstimer_elapsed(&Delay_Timer) < 500) {
|
||||
/* do nothing */
|
||||
}
|
||||
/* check whether LSE is ready, with 4 seconds timeout */
|
||||
|
||||
@@ -72,7 +72,7 @@ void rs485_silence_reset(
|
||||
bool rs485_silence_elapsed(
|
||||
uint32_t interval)
|
||||
{
|
||||
return (mstimer_remaining(&Silence_Timer) > interval);
|
||||
return (mstimer_elapsed(&Silence_Timer) > interval);
|
||||
}
|
||||
|
||||
/*************************************************************************
|
||||
@@ -101,7 +101,7 @@ static uint16_t rs485_turnaround_time(
|
||||
bool rs485_turnaround_elapsed(
|
||||
void)
|
||||
{
|
||||
return (mstimer_remaining(&Silence_Timer) > rs485_turnaround_time());
|
||||
return (mstimer_elapsed(&Silence_Timer) > rs485_turnaround_time());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -72,7 +72,7 @@ static struct mstimer Silence_Timer;
|
||||
static uint32_t Timer_Silence(
|
||||
void *pArg)
|
||||
{
|
||||
return mstimer_remaining(&Silence_Timer);
|
||||
return mstimer_elapsed(&Silence_Timer);
|
||||
}
|
||||
|
||||
static void Timer_Silence_Reset(
|
||||
|
||||
@@ -90,7 +90,7 @@ void rs485_silence_reset(void)
|
||||
*/
|
||||
bool rs485_silence_elapsed(uint32_t interval)
|
||||
{
|
||||
return (mstimer_remaining(&Silence_Timer) > interval);
|
||||
return (mstimer_elapsed(&Silence_Timer) > interval);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +154,7 @@ static uint16_t rs485_turnaround_time(void)
|
||||
*/
|
||||
bool rs485_turnaround_elapsed(void)
|
||||
{
|
||||
return (mstimer_remaining(&Silence_Timer) > rs485_turnaround_time());
|
||||
return (mstimer_elapsed(&Silence_Timer) > rs485_turnaround_time());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -106,6 +106,21 @@ unsigned long mstimer_remaining(struct mstimer *t)
|
||||
return t->start + t->interval - mstimer_now();
|
||||
}
|
||||
|
||||
/**
|
||||
* The time elapsed since the timer started
|
||||
*
|
||||
* This function returns the time elapsed.
|
||||
*
|
||||
* @param t A pointer to the timer
|
||||
*
|
||||
* @return The time elapsed since the last start of the timer
|
||||
*
|
||||
*/
|
||||
unsigned long mstimer_elapsed(struct mstimer *t)
|
||||
{
|
||||
return mstimer_now() - t->start;
|
||||
}
|
||||
|
||||
/**
|
||||
* The value of the interval
|
||||
*
|
||||
|
||||
@@ -59,6 +59,8 @@ int mstimer_expired(struct mstimer *t);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned long mstimer_remaining(struct mstimer *t);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned long mstimer_elapsed(struct mstimer *t);
|
||||
BACNET_STACK_EXPORT
|
||||
unsigned long mstimer_interval(struct mstimer *t);
|
||||
/* HAL implementation */
|
||||
BACNET_STACK_EXPORT
|
||||
|
||||
Reference in New Issue
Block a user