12
CHAPTER 1
The example application OS_StartLEDBlink.c
1.3 The example application OS_StartLEDBlink.c
The following is a printout of the example application
OS_StartLEDBlink.c
. It is a good
starting point for your application. (Note that the file actually shipped with your port of
embOS may look slightly different from this one.)
What happens is easy to see:
After initialization of embOS; two tasks are created and started. The two tasks are activated
and execute until they run into the delay, then suspend for the specified time and continue
execution.
/*********************************************************************
* SEGGER Microcontroller GmbH *
* The Embedded Experts *
**********************************************************************
-------------------------- END-OF-HEADER -----------------------------
File : OS_StartLEDBlink.c
Purpose : embOS sample program running two simple tasks, each toggling
a LED of the target hardware (as configured in BSP.c).
*/
#include
"RTOS.h"
#include
"BSP.h"
static
OS_STACKPTR
int
StackHP[
128
], StackLP[
128
];
// Task stacks
static
OS_TASK TCBHP, TCBLP;
// Task control blocks
static
void
HPTask(
void
) {
while
(
1
) {
BSP_ToggleLED(
0
);
OS_TASK_Delay(
50
);
}
}
static
void
LPTask(
void
) {
while
(
1
) {
BSP_ToggleLED(
1
);
OS_TASK_Delay(
200
);
}
}
/*********************************************************************
*
* main()
*/
int
main(
void
) {
OS_Init();
// Initialize embOS
OS_InitHW();
// Initialize required hardware
BSP_Init();
// Initialize LED ports
OS_TASK_CREATE(&TCBHP,
"HP Task"
,
100
, HPTask, StackHP);
OS_TASK_CREATE(&TCBLP,
"LP Task"
,
50
, LPTask, StackLP);
OS_Start();
// Start embOS
return
0
;
}
/*************************** End of file ****************************/
embOS-MPU for Cortex-M and IAR
© 2010-2020 SEGGER Microcontroller GmbH