From 0d5a70352191c3eefde43300a56d680ecd2ad5a2 Mon Sep 17 00:00:00 2001 From: Silvano Seva Date: Sun, 13 Dec 2020 11:43:58 +0100 Subject: [PATCH] Began integrating RTX driver with all the other code --- openrtx/include/cps.h | 14 ++++---- openrtx/include/interfaces/rtx.h | 25 ++++++------- openrtx/src/threads.c | 56 +++++++----------------------- platform/targets/MD-380/platform.c | 10 ++++-- platform/targets/MD-390/platform.c | 10 ++++-- 5 files changed, 49 insertions(+), 66 deletions(-) diff --git a/openrtx/include/cps.h b/openrtx/include/cps.h index 2859a988..e833257e 100644 --- a/openrtx/include/cps.h +++ b/openrtx/include/cps.h @@ -30,8 +30,8 @@ */ enum mode_t { - FM = 0, /**< Analog FM mode */ - DMR /**< DMR mode */ + FM = 0, /**< Analog FM mode */ + DMR = 1 /**< DMR mode */ }; /** @@ -41,9 +41,9 @@ enum mode_t enum admit_t { ALWAYS = 0, /**< Always transmit when PTT is pressed */ - FREE, /**< Transmit only if channel si free */ - TONE, /**< Transmit on matching tone */ - COLOR /**< Transmit only if color code is not used yet */ + FREE = 1, /**< Transmit only if channel si free */ + TONE = 2, /**< Transmit on matching tone */ + COLOR = 3 /**< Transmit only if color code is not used yet */ }; /** @@ -52,8 +52,8 @@ enum admit_t enum bw_t { BW_12_5 = 0, /**< Bandwidth is 12.5kHz */ - BW_20, /**< Bandwidth is 20kHz */ - BW_25 /**< Bandwidth is 25kHz */ + BW_20 = 1, /**< Bandwidth is 20kHz */ + BW_25 = 2 /**< Bandwidth is 25kHz */ }; /** diff --git a/openrtx/include/interfaces/rtx.h b/openrtx/include/interfaces/rtx.h index 6be9715e..0e3d6ba1 100644 --- a/openrtx/include/interfaces/rtx.h +++ b/openrtx/include/interfaces/rtx.h @@ -22,6 +22,7 @@ #define RTX_H #include +#include #include #include @@ -44,18 +45,18 @@ typedef struct } rtxStatus_t; -enum bandwidth -{ - BW_12_5 = 0, /**< 12.5kHz bandwidth */ - BW_20 = 1, /**< 20kHz bandwidth */ - BW_25 = 2 /**< 25kHz bandwidth */ -}; - -enum opmode -{ - FM = 0, /**< Analog FM */ - DMR = 1 /**< DMR */ -}; +// enum bandwidth +// { +// BW_12_5 = 0, /**< 12.5kHz bandwidth */ +// BW_20 = 1, /**< 20kHz bandwidth */ +// BW_25 = 2 /**< 25kHz bandwidth */ +// }; +// +// enum opmode +// { +// FM = 0, /**< Analog FM */ +// DMR = 1 /**< DMR */ +// }; enum opstatus { diff --git a/openrtx/src/threads.c b/openrtx/src/threads.c index 17f499dd..7a4a2458 100644 --- a/openrtx/src/threads.c +++ b/openrtx/src/threads.c @@ -27,8 +27,7 @@ #include #include #include - -#include +#include /* Mutex for concurrent access to state variable */ static OS_MUTEX state_mutex; @@ -36,6 +35,9 @@ static OS_MUTEX state_mutex; /* Queue for sending and receiving ui update requests */ static OS_Q ui_queue; +/* Mutex for concurrent access to RTX state variable */ +static OS_MUTEX rtx_mutex; + /**************************** IMPORTANT NOTE *********************************** * * * Rationale for "xx_TASK_STKSIZE/sizeof(CPU_STK)": uC/OS-III manages task * @@ -65,11 +67,6 @@ static CPU_STK dev_stk[DEV_TASK_STKSIZE/sizeof(CPU_STK)]; static OS_TCB rtx_tcb; static CPU_STK rtx_stk[RTX_TASK_STKSIZE/sizeof(CPU_STK)]; -/* DMR task control block and stack */ -static OS_TCB dmr_tcb; -static CPU_STK dmr_stk[DMR_TASK_STKSIZE/sizeof(CPU_STK)]; - - /** * \internal Task function in charge of updating the UI. */ @@ -189,28 +186,11 @@ static void rtx_task(void *arg) (void) arg; OS_ERR os_err; - while(1) - { - // Execute rtx radio thread every 30ms to match DMR task - //TODO: uncomment after rtx.h merge - //rtx_main(); - OSTimeDlyHMSM(0u, 0u, 0u, 30u, OS_OPT_TIME_HMSM_STRICT, &os_err); - } -} - -/** - * \internal Task function for DMR management. - */ -static void dmr_task(void *arg) -{ - (void) arg; - OS_ERR os_err; + rtx_init(&rtx_mutex); while(1) { - // Execute dmr radio thread every 30ms to match DMR timeslot - //TODO: uncomment after dmr.h merge - //dmr_main(); + rtx_taskFunc(); OSTimeDlyHMSM(0u, 0u, 0u, 30u, OS_OPT_TIME_HMSM_STRICT, &os_err); } } @@ -232,7 +212,12 @@ void create_threads() (CPU_CHAR *) "UI event queue", (OS_MSG_QTY ) 10, (OS_ERR *) &os_err); - + + // Create RTX state mutex + OSMutexCreate((OS_MUTEX *) &rtx_mutex, + (CPU_CHAR *) "RTX Mutex", + (OS_ERR *) &os_err); + // State initialization, execute before starting all tasks state_init(); @@ -265,7 +250,7 @@ void create_threads() (void *) 0, (OS_OPT ) (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR *) &os_err); - + // Create state thread OSTaskCreate((OS_TCB *) &dev_tcb, (CPU_CHAR *) "Device Task", @@ -295,19 +280,4 @@ void create_threads() (void *) 0, (OS_OPT ) (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_ERR *) &os_err); - - // Create dmr radio thread - OSTaskCreate((OS_TCB *) &dmr_tcb, - (CPU_CHAR *) "DMR Task", - (OS_TASK_PTR ) dmr_task, - (void *) 0, - (OS_PRIO ) 3, - (CPU_STK *) &dmr_stk[0], - (CPU_STK ) 0, - (CPU_STK_SIZE) DMR_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); } diff --git a/platform/targets/MD-380/platform.c b/platform/targets/MD-380/platform.c index 4e3f8be9..4adc5d9b 100644 --- a/platform/targets/MD-380/platform.c +++ b/platform/targets/MD-380/platform.c @@ -17,12 +17,13 @@ * along with this program; if not, see * ***************************************************************************/ -#include #include +#include +#include #include #include #include -#include +#include md3x0Calib_t calibration; @@ -77,6 +78,11 @@ void platform_init() */ nvm_init(); nvm_readCalibData(&calibration); + + /* + * Initialise tone generator + */ + toneGen_init(); } void platform_terminate() diff --git a/platform/targets/MD-390/platform.c b/platform/targets/MD-390/platform.c index 4e3f8be9..4adc5d9b 100644 --- a/platform/targets/MD-390/platform.c +++ b/platform/targets/MD-390/platform.c @@ -17,12 +17,13 @@ * along with this program; if not, see * ***************************************************************************/ -#include #include +#include +#include #include #include #include -#include +#include md3x0Calib_t calibration; @@ -77,6 +78,11 @@ void platform_init() */ nvm_init(); nvm_readCalibData(&calibration); + + /* + * Initialise tone generator + */ + toneGen_init(); } void platform_terminate()