Began integrating RTX driver with all the other code

replace/d25a84d8ac14683474e7c0b2c27e10825508f903
Silvano Seva 2020-12-13 11:43:58 +01:00
rodzic 4f0ffe8565
commit 0d5a703521
5 zmienionych plików z 49 dodań i 66 usunięć

Wyświetl plik

@ -30,8 +30,8 @@
*/ */
enum mode_t enum mode_t
{ {
FM = 0, /**< Analog FM mode */ FM = 0, /**< Analog FM mode */
DMR /**< DMR mode */ DMR = 1 /**< DMR mode */
}; };
/** /**
@ -41,9 +41,9 @@ enum mode_t
enum admit_t enum admit_t
{ {
ALWAYS = 0, /**< Always transmit when PTT is pressed */ ALWAYS = 0, /**< Always transmit when PTT is pressed */
FREE, /**< Transmit only if channel si free */ FREE = 1, /**< Transmit only if channel si free */
TONE, /**< Transmit on matching tone */ TONE = 2, /**< Transmit on matching tone */
COLOR /**< Transmit only if color code is not used yet */ COLOR = 3 /**< Transmit only if color code is not used yet */
}; };
/** /**
@ -52,8 +52,8 @@ enum admit_t
enum bw_t enum bw_t
{ {
BW_12_5 = 0, /**< Bandwidth is 12.5kHz */ BW_12_5 = 0, /**< Bandwidth is 12.5kHz */
BW_20, /**< Bandwidth is 20kHz */ BW_20 = 1, /**< Bandwidth is 20kHz */
BW_25 /**< Bandwidth is 25kHz */ BW_25 = 2 /**< Bandwidth is 25kHz */
}; };
/** /**

Wyświetl plik

@ -22,6 +22,7 @@
#define RTX_H #define RTX_H
#include <os.h> #include <os.h>
#include <cps.h>
#include <stdint.h> #include <stdint.h>
#include <datatypes.h> #include <datatypes.h>
@ -44,18 +45,18 @@ typedef struct
} }
rtxStatus_t; rtxStatus_t;
enum bandwidth // enum bandwidth
{ // {
BW_12_5 = 0, /**< 12.5kHz bandwidth */ // BW_12_5 = 0, /**< 12.5kHz bandwidth */
BW_20 = 1, /**< 20kHz bandwidth */ // BW_20 = 1, /**< 20kHz bandwidth */
BW_25 = 2 /**< 25kHz bandwidth */ // BW_25 = 2 /**< 25kHz bandwidth */
}; // };
//
enum opmode // enum opmode
{ // {
FM = 0, /**< Analog FM */ // FM = 0, /**< Analog FM */
DMR = 1 /**< DMR */ // DMR = 1 /**< DMR */
}; // };
enum opstatus enum opstatus
{ {

Wyświetl plik

@ -27,8 +27,7 @@
#include <platform.h> #include <platform.h>
#include <hwconfig.h> #include <hwconfig.h>
#include <event.h> #include <event.h>
#include <rtx.h>
#include <stdio.h>
/* Mutex for concurrent access to state variable */ /* Mutex for concurrent access to state variable */
static OS_MUTEX state_mutex; static OS_MUTEX state_mutex;
@ -36,6 +35,9 @@ static OS_MUTEX state_mutex;
/* Queue for sending and receiving ui update requests */ /* Queue for sending and receiving ui update requests */
static OS_Q ui_queue; static OS_Q ui_queue;
/* Mutex for concurrent access to RTX state variable */
static OS_MUTEX rtx_mutex;
/**************************** IMPORTANT NOTE *********************************** /**************************** IMPORTANT NOTE ***********************************
* * * *
* Rationale for "xx_TASK_STKSIZE/sizeof(CPU_STK)": uC/OS-III manages task * * 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 OS_TCB rtx_tcb;
static CPU_STK rtx_stk[RTX_TASK_STKSIZE/sizeof(CPU_STK)]; 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. * \internal Task function in charge of updating the UI.
*/ */
@ -189,28 +186,11 @@ static void rtx_task(void *arg)
(void) arg; (void) arg;
OS_ERR os_err; OS_ERR os_err;
while(1) rtx_init(&rtx_mutex);
{
// 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;
while(1) while(1)
{ {
// Execute dmr radio thread every 30ms to match DMR timeslot rtx_taskFunc();
//TODO: uncomment after dmr.h merge
//dmr_main();
OSTimeDlyHMSM(0u, 0u, 0u, 30u, OS_OPT_TIME_HMSM_STRICT, &os_err); OSTimeDlyHMSM(0u, 0u, 0u, 30u, OS_OPT_TIME_HMSM_STRICT, &os_err);
} }
} }
@ -233,6 +213,11 @@ void create_threads()
(OS_MSG_QTY ) 10, (OS_MSG_QTY ) 10,
(OS_ERR *) &os_err); (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 initialization, execute before starting all tasks
state_init(); state_init();
@ -295,19 +280,4 @@ void create_threads()
(void *) 0, (void *) 0,
(OS_OPT ) (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR), (OS_OPT ) (OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR),
(OS_ERR *) &os_err); (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);
} }

Wyświetl plik

@ -17,12 +17,13 @@
* along with this program; if not, see <http://www.gnu.org/licenses/> * * along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/ ***************************************************************************/
#include <platform.h>
#include <gpio.h> #include <gpio.h>
#include <nvmem.h>
#include <platform.h>
#include <hwconfig.h> #include <hwconfig.h>
#include <ADC1_MDx.h> #include <ADC1_MDx.h>
#include <calibInfo_MDx.h> #include <calibInfo_MDx.h>
#include <nvmem.h> #include <toneGenerator_MDx.h>
md3x0Calib_t calibration; md3x0Calib_t calibration;
@ -77,6 +78,11 @@ void platform_init()
*/ */
nvm_init(); nvm_init();
nvm_readCalibData(&calibration); nvm_readCalibData(&calibration);
/*
* Initialise tone generator
*/
toneGen_init();
} }
void platform_terminate() void platform_terminate()

Wyświetl plik

@ -17,12 +17,13 @@
* along with this program; if not, see <http://www.gnu.org/licenses/> * * along with this program; if not, see <http://www.gnu.org/licenses/> *
***************************************************************************/ ***************************************************************************/
#include <platform.h>
#include <gpio.h> #include <gpio.h>
#include <nvmem.h>
#include <platform.h>
#include <hwconfig.h> #include <hwconfig.h>
#include <ADC1_MDx.h> #include <ADC1_MDx.h>
#include <calibInfo_MDx.h> #include <calibInfo_MDx.h>
#include <nvmem.h> #include <toneGenerator_MDx.h>
md3x0Calib_t calibration; md3x0Calib_t calibration;
@ -77,6 +78,11 @@ void platform_init()
*/ */
nvm_init(); nvm_init();
nvm_readCalibData(&calibration); nvm_readCalibData(&calibration);
/*
* Initialise tone generator
*/
toneGen_init();
} }
void platform_terminate() void platform_terminate()