/* * Executed as an event handler at 500mS intervals. */ static void TimerHandler(eventid_t id) { (void)id; if (palReadPad(GPIOA, GPIOA_BUTTON)) { TesterThread tester; tester.Wait(); }; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); System::init(); // Initializes a serial-over-USB CDC driver. sduObjectInit(&SDU1); sduStart(&SDU1, &serusbcfg); /* * Activates the USB driver and then the USB bus pull-up on D+. * Note, a delay is inserted in order to not have to disconnect the cable * after a reset. */ usbDisconnectBus(serusbcfg.usbp); chThdSleepMilliseconds(1500); usbStart(serusbcfg.usbp, &usbcfg); usbConnectBus(serusbcfg.usbp); /* * Activates the serial driver 1 using the driver default configuration. */ // sdStart(&SD1, NULL); /* * Starts several instances of the SequencerThread class, each one operating * on a different LED. */ blinker1.start(NORMALPRIO + 10); /* * Serves timer events. */ while (true) { if (palReadPad(GPIOA, GPIOA_BUTTON)) { #if TESTER tester.start(NORMALPRIO); tester.wait(); #endif }; BaseThread::sleep(MS2ST(500)); } return 0; }
/* * Application entry point. */ int main(void) { /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); System::init(); fs.mount(); fs.unmount(); /* * Activates the serial driver 2 using the driver default configuration. * PA2(TX) and PA3(RX) are routed to USART2. */ sdStart(&SD2, NULL); palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); /* * Starts several instances of the SequencerThread class, each one operating * on a different LED. */ blinker1.start(NORMALPRIO + 10); blinker2.start(NORMALPRIO + 10); blinker3.start(NORMALPRIO + 10); blinker4.start(NORMALPRIO + 10); /* * Serves timer events. */ while (true) { if (palReadPad(GPIOA, GPIOA_BUTTON)) { tester.start(NORMALPRIO); tester.wait(); }; BaseThread::sleep(MS2ST(500)); } return 0; }
/* * Application entry point. */ int main(void) { uint8_t buf; /* * System initializations. * - HAL initialization, this also initializes the configured device drivers * and performs the board-specific initializations. * - Kernel initialization, the main() function becomes a thread and the * RTOS is active. */ halInit(); System::init(); Motor m1(&PWMD3, 2, 800, 800, 2, {GPIOC, 1}, {GPIOC, 2}); // TIM3_CH3 on PB0 //Motor m2(&PWMD4, 3, 2000, 2000, 2); // TIM3_CH3 on PB8 //Motor m3(&PWMD9, 8, 2000, 2000, 0); // TIM9_CH1 on PA2 m1.enable(); m1.goToPos(50); usb_cdc_init(); //sduObjectInit(&SDU1); //sduStart(&SDU1, &serUsbCfg); /* * Activates the serial driver 2 using the driver default configuration. * PA2(TX) and PA3(RX) are routed to USART2. */ sdStart(&SD2, NULL); palSetPadMode(GPIOA, 2, PAL_MODE_ALTERNATE(7)); palSetPadMode(GPIOA, 3, PAL_MODE_ALTERNATE(7)); /* * Starts several instances of the SequencerThread class, each one operating * on a different LED. */ blinker1.start(NORMALPRIO + 10); blinker2.start(NORMALPRIO + 10); blinker3.start(NORMALPRIO + 10); blinker4.start(NORMALPRIO + 10); /* * Serves timer events. */ while (true) { if (palReadPad(GPIOA, GPIOA_BUTTON)) { tester.start(NORMALPRIO); tester.wait(); }; BaseThread::sleep(MS2ST(500)); if(usb_cdc_read(&buf, 1, TIME_IMMEDIATE)){ usb_cdc_write(&buf, 1); } } return 0; }