1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798 |
- #include "ch.h"
- #include "hal.h"
- static void gpt4cb(GPTDriver *gptp) {
- (void)gptp;
- palSetPad(GPIOD, GPIOD_LED5);
- chSysLockFromISR();
- gptStartOneShotI(&GPTD3, 1000);
- chSysUnlockFromISR();
- }
- static void gpt3cb(GPTDriver *gptp) {
- (void)gptp;
- palClearPad(GPIOD, GPIOD_LED5);
- }
- static const GPTConfig gpt4cfg = {
- 10000,
- gpt4cb,
- 0,
- 0
- };
- static const GPTConfig gpt3cfg = {
- 10000,
- gpt3cb,
- 0,
- 0
- };
- int main(void) {
-
- halInit();
- chSysInit();
-
- gptStart(&GPTD4, &gpt4cfg);
- gptPolledDelay(&GPTD4, 10);
- gptStart(&GPTD3, &gpt3cfg);
- gptPolledDelay(&GPTD3, 10);
-
- while (true) {
- palSetPad(GPIOD, GPIOD_LED4);
- gptStartContinuous(&GPTD4, 5000);
- chThdSleepMilliseconds(5000);
- gptStopTimer(&GPTD4);
- palClearPad(GPIOD, GPIOD_LED4);
- gptStartContinuous(&GPTD4, 2500);
- chThdSleepMilliseconds(5000);
- gptStopTimer(&GPTD4);
- }
- }
|