Created
February 21, 2013 17:22
-
-
Save alexisrobert/5006449 to your computer and use it in GitHub Desktop.
EXTI et ChibiOS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "ch.h" | |
#include "hal.h" | |
static void extcb1(EXTDriver *extp, expchannel_t channel) { | |
chSysLockFromIsr(); | |
palTogglePad(GPIOD, GPIOD_LED4); | |
chSysUnlockFromIsr(); | |
} | |
int main(void) { | |
halInit(); // Initialise la HAL | |
chSysInit(); // Initialise ChibiOS | |
palSetPadMode(GPIOD, GPIOD_LED4, PAL_MODE_OUTPUT_PUSHPULL); // Règle la GPIO LED en output push/pull | |
/* Configure EXTI */ | |
static const EXTConfig extcfg = { | |
{ | |
{EXT_CH_MODE_BOTH_EDGES | EXT_MODE_GPIOA, extcb1}, | |
{EXT_CH_MODE_DISABLED, NULL}, | |
}, | |
}; | |
extInit(); // Initialise le driver EXTI | |
extStart(&EXTD1, &extcfg); // Règle les registres EXTI | |
extChannelEnable(&EXTD1, 0); // Démarre EXTI | |
while(1) {} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment