Skip to content

Commit 45c1128

Browse files
committed
Modified fwk initialisation and FreeRTOS' Scheduler starting point
> rkh_fwk_enter() now starts the FreeRTOS' Scheluder. > The RKH Timer Tick is generated through a FreeRTOS' Software Timer. > Removed rkh_startupTask().
1 parent 9b413bf commit 45c1128

File tree

5 files changed

+60
-39
lines changed

5 files changed

+60
-39
lines changed

demo/cross/shared/build/arm-cortex/freertos/ciaa-nxp/mcuxpresso/FreeRTOSConfig.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ extern int DbgConsole_Printf( const char *fmt_s, ... );
8282
#define configMAX_CO_ROUTINE_PRIORITIES ( 2 )
8383

8484
/* Software timer definitions. */
85-
#define configUSE_TIMERS 0
85+
#define configUSE_TIMERS 1
8686
#define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 3 )
8787
#define configTIMER_QUEUE_LENGTH 10
8888
#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE * 4 )
@@ -132,7 +132,6 @@ extern int DbgConsole_Printf( const char *fmt_s, ... );
132132
configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY + 1)
133133

134134
/* RKH definitions for FreeRTOS integration */
135-
#define RKH_STARTUP_STACK_SIZE 512
136135
#define RKH_TASK_PRIORITY (configMAX_PRIORITIES - 1)
137136

138137
/* Normal assert() semantics without relying on the provision of an assert.h

demo/cross/shared/build/arm-cortex/freertos/ciaa-nxp/mcuxpresso/FreeRTOSHooks.c

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,32 @@ static StackType_t uxIdleTaskStack[ configMINIMAL_STACK_SIZE ];
8282
*pulIdleTaskStackSize = configMINIMAL_STACK_SIZE;
8383
}
8484

85+
/* configSUPPORT_STATIC_ALLOCATION and configUSE_TIMERS are both set to 1, so the
86+
application must provide an implementation of vApplicationGetTimerTaskMemory()
87+
to provide the memory that is used by the Timer service task. */
88+
void vApplicationGetTimerTaskMemory( StaticTask_t **ppxTimerTaskTCBBuffer,
89+
StackType_t **ppxTimerTaskStackBuffer,
90+
uint32_t *pulTimerTaskStackSize )
91+
{
92+
/* If the buffers to be provided to the Timer task are declared inside this
93+
function then they must be declared static – otherwise they will be allocated on
94+
the stack and so not exists after this function exits. */
95+
static StaticTask_t xTimerTaskTCB;
96+
static StackType_t uxTimerTaskStack[ configTIMER_TASK_STACK_DEPTH ];
97+
98+
/* Pass out a pointer to the StaticTask_t structure in which the Timer
99+
task’s state will be stored. */
100+
*ppxTimerTaskTCBBuffer = &xTimerTaskTCB;
101+
102+
/* Pass out the array that will be used as the Timer task’s stack. */
103+
*ppxTimerTaskStackBuffer = uxTimerTaskStack;
104+
105+
/* Pass out the size of the array pointed to by *ppxTimerTaskStackBuffer.
106+
Note that, as the array is necessarily of type StackType_t,
107+
configTIMER_TASK_STACK_DEPTH is specified in words, not bytes. */
108+
*pulTimerTaskStackSize = configTIMER_TASK_STACK_DEPTH;
109+
}
110+
85111
/* Delay for the specified number of milliSeconds */
86112
void
87113
FreeRTOSDelay(uint32_t ms)

demo/cross/shared/main.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -67,12 +67,10 @@ main(int argc, char *argv[])
6767
RKH_SMA_ACTIVATE(CLI(cn), cli_qsto[cn], QSTO_SIZE, cli_stk[cn],
6868
CLI_STK_SIZE);
6969
}
70-
#ifdef __FREERTOS_V10_03_00__
71-
vTaskStartScheduler();
72-
#else
70+
7371
rkh_fwk_enter();
7472
RKH_TRC_CLOSE();
75-
#endif
73+
7674
return 0;
7775
}
7876

demo/libbsp/platform/arm-cortex/arm_cm4f/ciaa-nxp/bsp_shared.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@ bsp_init(int argc, char *argv[])
150150
RKH_FILTER_OFF_SIGNAL( REQ );
151151
RKH_FILTER_OFF_SIGNAL( START );
152152

153-
RKH_TRC_OPEN();
154153
}
155154

156155
void
@@ -383,16 +382,5 @@ rkh_hook_exit( void )
383382
RKH_TRC_FLUSH();
384383
}
385384

386-
void
387-
rkh_startupTask(void *pvParameter)
388-
{
389-
/* Trace already open on bsp_init */
390-
/* RKH_TRC_OPEN(); */
391-
392-
rkh_fwk_enter();
393-
394-
vTaskDelete(NULL);
395-
}
396-
397385
/* ------------------------------ File footer ------------------------------ */
398386
/* Use file_footer.txt file */

source/portable/freertos/v10.3.0/rkhport.c

Lines changed: 31 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@
5454
#include "rkhfwk_dynevt.h"
5555
#include "FreeRTOSConfig.h"
5656
#include "FreeRTOS.h"
57+
#include "timers.h"
5758

5859
/* ----------------------------- Local macros ------------------------------ */
5960
/* ------------------------------- Constants ------------------------------- */
@@ -69,10 +70,9 @@ static rui8_t l_isr_tick;
6970
#endif
7071
static rui8_t running;
7172

72-
static StaticQueue_t QueueBuff[RKH_CFG_FWK_MAX_SMA];
73+
StaticTimer_t xTimerBuffers[ 1 ];
7374

74-
static StaticTask_t startupTask;
75-
static StackType_t startupTaskStack[RKH_STARTUP_STACK_SIZE];
75+
static StaticQueue_t QueueBuff[RKH_CFG_FWK_MAX_SMA];
7676

7777
/* ----------------------- Local function prototypes ----------------------- */
7878
static void thread_function(void *arg);
@@ -101,6 +101,13 @@ thread_function(void *arg)
101101
vTaskDelete(NULL);
102102
}
103103

104+
void
105+
tick_timerCallback(TimerHandle_t xTimer)
106+
{
107+
(void) xTimer;
108+
RKH_TIM_TICK(&l_isr_tick);
109+
}
110+
104111
/* ---------------------------- Global functions --------------------------- */
105112
const
106113
char *
@@ -129,36 +136,39 @@ rkh_startupTask(void *pvParameter)
129136
void
130137
rkh_fwk_init(void)
131138
{
132-
TaskHandle_t TaskHandle = NULL;
139+
RKH_TRC_OPEN();
140+
141+
#if defined(RKH_USE_TRC_SENDER)
142+
RKH_TR_FWK_OBJ(&l_isr_tick);
143+
#endif
144+
145+
TimerHandle_t tick_TimerHandle = NULL;
146+
147+
tick_TimerHandle = xTimerCreateStatic( "isr_Timer",
148+
configTICK_RATE_HZ /* wait for the tick interval */
149+
/ RKH_CFG_FWK_TICK_RATE_HZ,
150+
pdTRUE,
151+
( void * ) 0,
152+
tick_timerCallback,
153+
&( xTimerBuffers[0] )
154+
);
155+
156+
RKH_ASSERT(tick_TimerHandle);
157+
158+
xTimerStart( tick_TimerHandle, (TickType_t) NULL );
133159

134-
TaskHandle = xTaskCreateStatic(rkh_startupTask,
135-
"rkh_startupTask",
136-
RKH_STARTUP_STACK_SIZE,
137-
NULL,
138-
RKH_TASK_PRIORITY,
139-
startupTaskStack,
140-
&startupTask);
141-
RKH_ASSERT(TaskHandle);
142160
}
143161

144162
void
145163
rkh_fwk_enter(void)
146164
{
147165
RKH_SR_ALLOC();
148166

149-
running = (rui8_t)1;
150-
151167
RKH_HOOK_START(); /* start-up callback */
152168
RKH_TR_FWK_EN();
153169

154-
RKH_TR_FWK_OBJ(&l_isr_tick);
170+
vTaskStartScheduler();
155171

156-
while (running)
157-
{
158-
vTaskDelay(configTICK_RATE_HZ /* wait for the tick interval */
159-
/ RKH_CFG_FWK_TICK_RATE_HZ);
160-
RKH_TIM_TICK(&l_isr_tick); /* tick handler */
161-
}
162172
RKH_HOOK_EXIT(); /* cleanup callback */
163173
RKH_TRC_CLOSE(); /* cleanup the trace session */
164174

0 commit comments

Comments
 (0)