12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697 |
- #include "ch.h"
- #include "hal.h"
- #include "chprintf.h"
- BaseSequentialStream* chp = (BaseSequentialStream*) &SD1;
- static int isrCpt;
- static void extcb(EXTDriver *extp, expchannel_t channel) {
- (void)extp;
- (void)channel;
- chSysLockFromISR();
- palTogglePad(IOPORT2, PORTB_LED1);
- isrCpt++;
- chSysUnlockFromISR();
- }
- static const EXTConfig extcfg = {
- {
- {EXT_CH_MODE_DISABLED , NULL},
- {EXT_CH_MODE_DISABLED , NULL},
- {EXT_CH_MODE_DISABLED , NULL},
- {EXT_CH_MODE_DISABLED , NULL},
- {EXT_CH_MODE_RISING_EDGE , extcb},
- {EXT_CH_MODE_DISABLED , NULL},
- }
- };
- int main(void) {
-
- halInit();
- chSysInit();
-
- palSetPadMode(IOPORT5, PE4, PAL_MODE_INPUT);
-
- sdStart(&SD1, NULL);
-
- extStart(&EXTD1, &extcfg);
- extChannelEnable(&EXTD1, INT4);
- palClearPad(IOPORT2, PORTB_LED1);
- chprintf(chp, "\n\r EXT hal test started...");
-
- while (TRUE) {
- chThdSleepMilliseconds(1000);
- chprintf(chp, "\n\r External Interrupt counter: %d", isrCpt);
- }
- }
|