mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-29 18:52:13 +01:00
[sam] attachInterrupt() now works also on pins that belongs to PORTD
This commit is contained in:
parent
3f105bcd00
commit
5edc110f61
@ -16,6 +16,7 @@ ARDUINO 1.5.2 BETA - 2012.01.23
|
||||
* Extended command line build flags
|
||||
|
||||
[arduino core]
|
||||
* sam: attachInterrupt() now works also on pins that belongs to PORTD
|
||||
* sam: portOutputRegister() is now writeable.
|
||||
* sam: fixed issue on weak-symbol for some interrupt handlers
|
||||
* sam: fixed BSoD on some Windows machine (louismdavis)
|
||||
|
@ -23,6 +23,7 @@ typedef void (*interruptCB)(void);
|
||||
static interruptCB callbacksPioA[32];
|
||||
static interruptCB callbacksPioB[32];
|
||||
static interruptCB callbacksPioC[32];
|
||||
static interruptCB callbacksPioD[32];
|
||||
|
||||
/* Configure PIO interrupt sources */
|
||||
static void __initialize() {
|
||||
@ -31,6 +32,7 @@ static void __initialize() {
|
||||
callbacksPioA[i] = NULL;
|
||||
callbacksPioB[i] = NULL;
|
||||
callbacksPioC[i] = NULL;
|
||||
callbacksPioD[i] = NULL;
|
||||
}
|
||||
|
||||
pmc_enable_periph_clk(ID_PIOA);
|
||||
@ -50,6 +52,12 @@ static void __initialize() {
|
||||
NVIC_ClearPendingIRQ(PIOC_IRQn);
|
||||
NVIC_SetPriority(PIOC_IRQn, 0);
|
||||
NVIC_EnableIRQ(PIOC_IRQn);
|
||||
|
||||
pmc_enable_periph_clk(ID_PIOD);
|
||||
NVIC_DisableIRQ(PIOD_IRQn);
|
||||
NVIC_ClearPendingIRQ(PIOD_IRQn);
|
||||
NVIC_SetPriority(PIOD_IRQn, 0);
|
||||
NVIC_EnableIRQ(PIOD_IRQn);
|
||||
}
|
||||
|
||||
|
||||
@ -77,6 +85,8 @@ void attachInterrupt(uint32_t pin, void (*callback)(void), uint32_t mode)
|
||||
callbacksPioB[pos] = callback;
|
||||
if (pio == PIOC)
|
||||
callbacksPioC[pos] = callback;
|
||||
if (pio == PIOD)
|
||||
callbacksPioD[pos] = callback;
|
||||
|
||||
// Configure the interrupt mode
|
||||
if (mode == CHANGE) {
|
||||
@ -156,6 +166,17 @@ void PIOC_Handler(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void PIOD_Handler(void) {
|
||||
uint32_t isr = PIOD->PIO_ISR;
|
||||
uint32_t i;
|
||||
for (i=0; i<32; i++, isr>>=1) {
|
||||
if ((isr & 0x1) == 0)
|
||||
continue;
|
||||
if (callbacksPioD[i])
|
||||
callbacksPioD[i]();
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user