git-svn-id: svn://svn.code.sf.net/p/chibios/svn/branches/kernel_3_dev@6299 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
a86b48c578
commit
1a2e19d5d6
|
@ -22,7 +22,7 @@
|
|||
* Blue LED blinker thread, times are in milliseconds.
|
||||
*/
|
||||
static THD_WORKING_AREA(waThread1, 128);
|
||||
static msg_t Thread1(void *arg) {
|
||||
static THD_FUNCTION(Thread1, arg) {
|
||||
|
||||
(void)arg;
|
||||
chRegSetThreadName("blinker1");
|
||||
|
@ -38,7 +38,7 @@ static msg_t Thread1(void *arg) {
|
|||
* Green LED blinker thread, times are in milliseconds.
|
||||
*/
|
||||
static THD_WORKING_AREA(waThread2, 128);
|
||||
static msg_t Thread2(void *arg) {
|
||||
static THD_FUNCTION(Thread2, arg) {
|
||||
|
||||
(void)arg;
|
||||
chRegSetThreadName("blinker2");
|
||||
|
|
|
@ -18,12 +18,11 @@
|
|||
#include "hal.h"
|
||||
#include "test.h"
|
||||
|
||||
#if 0
|
||||
/*
|
||||
* This is a periodic thread that does absolutely nothing except flashing LEDs.
|
||||
* Flasher thread #1.
|
||||
*/
|
||||
static WORKING_AREA(waThread1, 128);
|
||||
static msg_t Thread1(void *arg) {
|
||||
static THD_WORKING_AREA(waThread1, 128);
|
||||
static THD_FUNCTION(Thread1, arg) {
|
||||
|
||||
(void)arg;
|
||||
chRegSetThreadName("blinker");
|
||||
|
@ -54,31 +53,40 @@ static msg_t Thread1(void *arg) {
|
|||
palClearPad(GPIOE, GPIOE_LED4_BLUE);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
static THD_WORKING_AREA(waThread1, 128);
|
||||
static msg_t Thread1(void *arg) {
|
||||
/*
|
||||
* Flasher thread #2.
|
||||
*/
|
||||
static THD_WORKING_AREA(waThread2, 128);
|
||||
static THD_FUNCTION(Thread2, arg) {
|
||||
|
||||
(void)arg;
|
||||
chRegSetThreadName("blinker1");
|
||||
chRegSetThreadName("blinker");
|
||||
while (true) {
|
||||
palSetPad(GPIOE, GPIOE_LED3_RED);
|
||||
chThdSleepMilliseconds(250);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED3_RED);
|
||||
chThdSleepMilliseconds(250);
|
||||
}
|
||||
}
|
||||
|
||||
static THD_WORKING_AREA(waThread2, 128);
|
||||
static msg_t Thread2(void *arg) {
|
||||
|
||||
(void)arg;
|
||||
chRegSetThreadName("blinker2");
|
||||
while (true) {
|
||||
palSetPad(GPIOE, GPIOE_LED5_ORANGE);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED5_ORANGE);
|
||||
palSetPad(GPIOE, GPIOE_LED7_GREEN);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED7_GREEN);
|
||||
palSetPad(GPIOE, GPIOE_LED9_BLUE);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED9_BLUE);
|
||||
palSetPad(GPIOE, GPIOE_LED10_RED);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED10_RED);
|
||||
palSetPad(GPIOE, GPIOE_LED8_ORANGE);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED8_ORANGE);
|
||||
palSetPad(GPIOE, GPIOE_LED6_GREEN);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED6_GREEN);
|
||||
palSetPad(GPIOE, GPIOE_LED4_BLUE);
|
||||
chThdSleepMilliseconds(500);
|
||||
chThdSleepMilliseconds(125);
|
||||
palClearPad(GPIOE, GPIOE_LED4_BLUE);
|
||||
chThdSleepMilliseconds(500);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -109,7 +117,7 @@ int main(void) {
|
|||
* Creates the example thread.
|
||||
*/
|
||||
chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO+1, Thread1, NULL);
|
||||
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO+2, Thread2, NULL);
|
||||
chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO+1, Thread2, NULL);
|
||||
|
||||
/*
|
||||
* Normal main() thread activity, in this demo it does nothing except
|
||||
|
|
|
@ -23,7 +23,7 @@
|
|||
* a LED.
|
||||
*/
|
||||
static THD_WORKING_AREA(waThread1, 128);
|
||||
static msg_t Thread1(void *arg) {
|
||||
static THD_FUNCTION(Thread1, arg) {
|
||||
|
||||
(void)arg;
|
||||
chRegSetThreadName("blinker");
|
||||
|
|
|
@ -72,7 +72,7 @@ typedef uint32_t ucnt_t; /**< Generic unsigned counter. */
|
|||
#define NOINLINE __attribute__((noinline))
|
||||
|
||||
/**
|
||||
* @brief Thread function declaration macro optimized for GCC.
|
||||
* @brief Optimized thread function declaration macro.
|
||||
*/
|
||||
#define PORT_THD_FUNCTION(tname, arg) \
|
||||
__attribute__((noreturn)) void tname(void *arg)
|
||||
|
|
|
@ -147,6 +147,17 @@ typedef msg_t (*tfunc_t)(void *);
|
|||
stkalign_t s[THD_WORKING_AREA_SIZE(n) / sizeof(stkalign_t)]
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Threads abstraction macros
|
||||
*/
|
||||
/**
|
||||
* @brief Thread declaration macro.
|
||||
* @note Thread declarations should be performed using this macro because
|
||||
* the port layer could define optimizations for thread functions.
|
||||
*/
|
||||
#define THD_FUNCTION(tname, arg) PORT_THD_FUNCTION(tname, arg)
|
||||
/** @} */
|
||||
|
||||
/**
|
||||
* @name Macro Functions
|
||||
* @{
|
||||
|
|
|
@ -79,6 +79,11 @@ typedef uint32_t ucnt_t; /**< Generic unsigned counter. */
|
|||
*/
|
||||
#define NOINLINE __attribute__((noinline))
|
||||
|
||||
/**
|
||||
* @brief Optimized thread function declaration macro.
|
||||
*/
|
||||
#define PORT_THD_FUNCTION(tname, arg) msg_t tname(void *arg)
|
||||
|
||||
#endif /* _CHTYPES_H_ */
|
||||
|
||||
/** @} */
|
||||
|
|
Loading…
Reference in New Issue