1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162 |
- #include "ch.h"
- #include "hal.h"
- #include "portab.h"
- static THD_WORKING_AREA(waThread1, 32);
- static THD_FUNCTION(Thread1, arg) {
- (void)arg;
- chRegSetThreadName("Blinker");
- while (true) {
- systime_t time = palReadLine(PORTAB_LINE_BUTTON) == PORTAB_BUTTON_PRESSED ? 1000 :50;
- palToggleLine(PORTAB_LINE_LED1);
- palToggleLine(PORTAB_LINE_LED2);
- chThdSleepMilliseconds(time);
- }
- }
- int main(void) {
-
- halInit();
- chSysInit();
- palSetPadMode(PAL_PORT(PORTAB_LINE_LED2),
- PAL_PAD(PORTAB_LINE_LED2),
- PAL_MODE_OUTPUT_PUSHPULL);
-
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
- while(TRUE) {
- chThdSleepMilliseconds(1000);
- }
- }
|