Skip to content

Instantly share code, notes, and snippets.

@alexisrobert
Created February 21, 2013 17:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexisrobert/5006449 to your computer and use it in GitHub Desktop.
Save alexisrobert/5006449 to your computer and use it in GitHub Desktop.
EXTI et ChibiOS
#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