From 6dfbd2419d40428c5e58c878e6049d5dcae23520 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Tue, 2 Feb 2021 21:11:31 +0100 Subject: [PATCH] Improved RX activation mechanism in rtx driver --- openrtx/src/rtx.c | 28 ++++++++++++++++------------ openrtx/src/threads.c | 30 +++++++++++++++--------------- 2 files changed, 31 insertions(+), 27 deletions(-) diff --git a/openrtx/src/rtx.c b/openrtx/src/rtx.c index 7e977dd7..369d2cb3 100644 --- a/openrtx/src/rtx.c +++ b/openrtx/src/rtx.c @@ -26,13 +26,13 @@ #include #include - OS_MUTEX *cfgMutex; /* Mutex for incoming config messages */ OS_Q cfgMailbox; /* Queue for incoming config messages */ rtxStatus_t rtxStatus; /* RTX driver status */ -bool sqlOpen; /* Flag for squlech open/close */ +bool sqlOpen; /* Flag for squelch open/close */ +bool enterRx; /* Flag for RX mode activation */ /* * These functions below provide a basic API for audio path management. They @@ -127,6 +127,7 @@ void rtx_init(OS_MUTEX *m) rtxStatus.txTone = 0; sqlOpen = false; + enterRx = false; /* * Initialise low-level platform-specific driver @@ -225,19 +226,12 @@ void rtx_taskFunc() radio_setVcoFrequency(rtxStatus.rxFrequency, false); radio_enableRx(); } + + /* TODO: temporarily force to RX mode if rtx is off. */ + if(rtxStatus.opStatus == OFF) enterRx = true; } } - /* TODO: temporarily force to RX mode if rtx is off. */ - if(rtxStatus.opStatus == OFF) - { - radio_disableRtx(); - - radio_setVcoFrequency(rtxStatus.rxFrequency, false); - radio_enableRx(); - rtxStatus.opStatus = RX; - } - /* RX logic */ if(rtxStatus.opStatus == RX) { @@ -259,6 +253,15 @@ void rtx_taskFunc() sqlOpen = false; } } + else if((rtxStatus.opMode == OFF) && enterRx) + { + radio_disableRtx(); + + radio_setVcoFrequency(rtxStatus.rxFrequency, false); + radio_enableRx(); + rtxStatus.opStatus = RX; + enterRx = false; + } /* TX logic */ if(platform_getPttStatus() && (rtxStatus.opStatus != TX)) @@ -278,6 +281,7 @@ void rtx_taskFunc() radio_disableRtx(); rtxStatus.opStatus = OFF; + enterRx = true; } /* Led control logic */ diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index 2684da71..cdb8d241 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -314,6 +314,21 @@ void create_threads() // State initialization, execute before starting all tasks state_init(); + // Create rtx radio thread + OSTaskCreate((OS_TCB *) &rtx_tcb, + (CPU_CHAR *) "RTX Task", + (OS_TASK_PTR ) rtx_task, + (void *) 0, + (OS_PRIO ) 5, + (CPU_STK *) &rtx_stk[0], + (CPU_STK ) 0, + (CPU_STK_SIZE) RTX_TASK_STKSIZE/sizeof(CPU_STK), + (OS_MSG_QTY ) 0, + (OS_TICK ) 0, + (void *) 0, + (OS_OPT ) (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), + (OS_ERR *) &os_err); + // Create UI thread OSTaskCreate((OS_TCB *) &ui_tcb, (CPU_CHAR *) "UI Task", @@ -358,19 +373,4 @@ void create_threads() (void *) 0, (OS_OPT ) (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR *) &os_err); - - // Create rtx radio thread - OSTaskCreate((OS_TCB *) &rtx_tcb, - (CPU_CHAR *) "RTX Task", - (OS_TASK_PTR ) rtx_task, - (void *) 0, - (OS_PRIO ) 5, - (CPU_STK *) &rtx_stk[0], - (CPU_STK ) 0, - (CPU_STK_SIZE) RTX_TASK_STKSIZE/sizeof(CPU_STK), - (OS_MSG_QTY ) 0, - (OS_TICK ) 0, - (void *) 0, - (OS_OPT ) (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), - (OS_ERR *) &os_err); }