Here is example for
- creating thread
- IO pin toggle
board.h considers
Code: Select all
...
/*
* Port C setup.
* Everything input with pull-up except:
* PC8 - Push-pull output (LED4), initially low state.
* PC9 - Push-pull output (LED3), initially low state.
*/
#define VAL_GPIOCCRL 0x88888888 /* PC7...PC0 */
#define VAL_GPIOCCRH 0x88888833 /* PC15...PC8 */
#define VAL_GPIOCODR 0xFFFFFCFF
...
main.c
Code: Select all
#include <ch.h>
#include <hal.h>
#include <stm32f10x.h>
#include <chtypes.h>
#include <chmsg.h>
static WORKING_AREA(wa_blinker, 128);
static msg_t blinker(void *arg) {
(void)arg;
chRegSetThreadName("blinker");
while (!chThdShouldTerminate()) {
palTogglePad(GPIOC, GPIOC_LED3);
chThdSleepMilliseconds(500);
}
return 0;
}
int main(void) {
halInit();
chSysInit();
chThdCreateStatic(wa_blinker, sizeof(wa_blinker), NORMALPRIO, blinker, NULL);
while (!chThdShouldTerminate()) {
chThdSleepMilliseconds(500);
}
return 0;
}