diff --git a/APP/inc/rtconfig.h b/APP/inc/rtconfig.h index 8cf88c3..03aaf38 100644 --- a/APP/inc/rtconfig.h +++ b/APP/inc/rtconfig.h @@ -25,7 +25,7 @@ #define RT_USING_HOOK /* Using Software Timer */ -/* #define RT_USING_TIMER_SOFT */ +#define RT_USING_TIMER_SOFT #define RT_TIMER_THREAD_PRIO 4 #define RT_TIMER_THREAD_STACK_SIZE 512 #define RT_TIMER_TICK_PER_SECOND 1000 diff --git a/FreeModbus/port/rtt/portserial.c b/FreeModbus/port/rtt/portserial.c index a97841f..6f8e71d 100644 --- a/FreeModbus/port/rtt/portserial.c +++ b/FreeModbus/port/rtt/portserial.c @@ -107,6 +107,7 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits, } /* software initialize */ + rt_event_init(&event_serial, "slave event", RT_IPC_FLAG_PRIO); rt_thread_init(&thread_serial_soft_trans_irq, "slave trans", serial_soft_trans_irq, @@ -115,7 +116,6 @@ BOOL xMBPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits, sizeof(serial_soft_trans_irq_stack), 10, 5); rt_thread_startup(&thread_serial_soft_trans_irq); - rt_event_init(&event_serial, "slave event", RT_IPC_FLAG_PRIO); return TRUE; } diff --git a/FreeModbus/port/rtt/portserial_m.c b/FreeModbus/port/rtt/portserial_m.c index 93a4af7..d19750c 100644 --- a/FreeModbus/port/rtt/portserial_m.c +++ b/FreeModbus/port/rtt/portserial_m.c @@ -108,6 +108,7 @@ BOOL xMBMasterPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits, } /* software initialize */ + rt_event_init(&event_serial, "master event", RT_IPC_FLAG_PRIO); rt_thread_init(&thread_serial_soft_trans_irq, "master trans", serial_soft_trans_irq, @@ -116,7 +117,6 @@ BOOL xMBMasterPortSerialInit(UCHAR ucPORT, ULONG ulBaudRate, UCHAR ucDataBits, sizeof(serial_soft_trans_irq_stack), 10, 5); rt_thread_startup(&thread_serial_soft_trans_irq); - rt_event_init(&event_serial, "master event", RT_IPC_FLAG_PRIO); return TRUE; } diff --git a/FreeModbus/port/rtt/porttimer.c b/FreeModbus/port/rtt/porttimer.c index 6f017d8..8c51ad0 100644 --- a/FreeModbus/port/rtt/porttimer.c +++ b/FreeModbus/port/rtt/porttimer.c @@ -37,7 +37,7 @@ BOOL xMBPortTimersInit(USHORT usTim1Timerout50us) rt_timer_init(&timer, "slave timer", timer_timeout_ind, /* bind timeout callback function */ RT_NULL, - (50*usTim1Timerout50us)/(1000*1000/RT_TICK_PER_SECOND), + (50 * usTim1Timerout50us) / (1000 * 1000 / RT_TICK_PER_SECOND) + 1, RT_TIMER_FLAG_ONE_SHOT); /* one shot */ return TRUE; } diff --git a/FreeModbus/port/rtt/porttimer_m.c b/FreeModbus/port/rtt/porttimer_m.c index 00441bf..ebf8000 100644 --- a/FreeModbus/port/rtt/porttimer_m.c +++ b/FreeModbus/port/rtt/porttimer_m.c @@ -46,7 +46,7 @@ BOOL xMBMasterPortTimersInit(USHORT usTimeOut50us) rt_timer_init(&timer, "master timer", timer_timeout_ind, /* bind timeout callback function */ RT_NULL, - (50 * usT35TimeOut50us) / (1000 * 1000 / RT_TICK_PER_SECOND), + (50 * usT35TimeOut50us) / (1000 * 1000 / RT_TICK_PER_SECOND) + 1, RT_TIMER_FLAG_ONE_SHOT); /* one shot */ return TRUE;