123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100 |
- #include "ch.h"
- #include "hal.h"
- #include "rt_test_root.h"
- #include "oslib_test_root.h"
- #define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2))
- static THD_WORKING_AREA(waThread1, 128);
- static THD_FUNCTION(Thread1, arg) {
- (void)arg;
- chRegSetThreadName("blinker1");
- while (true) {
- palClearPort(IOPORT1, PAL_PORT_BIT(PA_LED2));
- chThdSleepMilliseconds(200);
- palSetPort(IOPORT1, PAL_PORT_BIT(PA_LED1) | PAL_PORT_BIT(PA_LED2));
- chThdSleepMilliseconds(800);
- palClearPort(IOPORT1, PAL_PORT_BIT(PA_LED1));
- chThdSleepMilliseconds(200);
- palSetPort(IOPORT1, PAL_PORT_BIT(PA_LED1) | PAL_PORT_BIT(PA_LED2));
- chThdSleepMilliseconds(800);
- }
- }
- static THD_WORKING_AREA(waThread2, 128);
- static THD_FUNCTION(Thread2, arg) {
- (void)arg;
- chRegSetThreadName("blinker2");
- while (true) {
- palClearPad(IOPORT1, PA_LEDUSB);
- chThdSleepMilliseconds(200);
- palSetPad(IOPORT1, PA_LEDUSB);
- chThdSleepMilliseconds(300);
- }
- }
- int main(void) {
-
- halInit();
- chSysInit();
-
- sdStart(&SD1, NULL);
-
- chThdCreateStatic(waThread1, sizeof(waThread1), NORMALPRIO, Thread1, NULL);
- chThdCreateStatic(waThread2, sizeof(waThread2), NORMALPRIO, Thread2, NULL);
-
- while (true) {
- if (!palReadPad(IOPORT1, PA_BUTTON1))
- sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14);
- if (!palReadPad(IOPORT1, PA_BUTTON2)) {
- test_execute((BaseSequentialStream *)&SD1, &rt_test_suite);
- test_execute((BaseSequentialStream *)&SD1, &oslib_test_suite);
- }
- chThdSleepMilliseconds(500);
- }
- return 0;
- }
|