XDK110 BCDS
© Bosch Connected Devices and Solutions GmbH reserves all rights even in the event of industrial property rights. We reserve all rights of disposal such as
copying and passing on to third parties. BOSCH and the symbol are registered trademarks of Robert Bosch GmbH, Germany.
Note: Specifications within this document are subject to change without notice.
2.2 Hello World Timer Task
An other type of tasks beside the operating tasks are the timer tasks. These have the advantage to run an
application periodically without manual implementations of any infinite loops. How to use them will be shown
in the implementation code 3 of the hello world application with timer tasks:
Code 6: Hello World Timer Task Application File - application.c
/* system header files */
#include <stdio.h>
#include <BCDS_Basics.h>
/* additional interface header files */
#include "FreeRTOS.h"
#include "timers.h"
#include "BCDS_CmdProcessor.h"
#include "BCDS_Assert.h"
/* Macro used to define blocktime of a timer */
#define TIMERBLOCKTIME UINT32_C(0xffff)
#define TIMER_AUTORELOAD_ON pdTRUE
#define SECONDS(x) ((portTickType) (x * 1000) / portTICK_RATE_MS)
/* Print string "Hello World" on the console */
void printHelloWorld(xTimerHandle pxTimer)
{
BCDS_UNUSED(pxTimer);
printf("Hello world\r\n");
}
/* Application to print "hello world" on serial console. */
void applicationInit(void){
xTimerHandle applicationTimer;
/* create timer task to print Hello World in the output console every three
seconds */
/* Validated for portMAX_DELAY to assist the task to wait Infinitely
(without timing out) and ticks cannot be 0 in FreeRTOS timer. So ticks is
assigned to 1 */
applicationTimer = xTimerCreate(
(char * const) "Test Application to print Hello World",!
SECONDS(3),
TIMER_AUTORELOAD_ON,!
NULL,
printHelloWorld);
/*start the timer*/
xTimerStart(applicationTimer, TIMERBLOCKTIME);
}
/* This is a template function where the user can write his/her custom
application */
void appInitSystem(void * CmdProcessorHandle, uint32_t param2){
if (CmdProcessorHandle == NULL){
printf("Command processor handle is null \n\r");
assert(false);
}
BCDS_UNUSED(param2);
applicationInit();
}