Skip to content
Snippets Groups Projects
Commit d654db22 authored by Cristian Maglie's avatar Cristian Maglie
Browse files

Cosmetic changes in WInterrupt.*

parent e2584897
No related branches found
No related tags found
No related merge requests found
......@@ -32,32 +32,23 @@ static void __initialize()
{
memset(callbacksInt, 0, sizeof(callbacksInt));
NVIC_DisableIRQ( EIC_IRQn ) ;
NVIC_ClearPendingIRQ( EIC_IRQn ) ;
NVIC_SetPriority( EIC_IRQn, 0 ) ;
NVIC_EnableIRQ( EIC_IRQn ) ;
NVIC_DisableIRQ(EIC_IRQn);
NVIC_ClearPendingIRQ(EIC_IRQn);
NVIC_SetPriority(EIC_IRQn, 0);
NVIC_EnableIRQ(EIC_IRQn);
// Enable GCLK for IEC (External Interrupt Controller)
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID( GCM_EIC )) ;
GCLK->CLKCTRL.reg = (uint16_t) (GCLK_CLKCTRL_CLKEN | GCLK_CLKCTRL_GEN_GCLK0 | GCLK_CLKCTRL_ID(GCM_EIC));
/* Shall we do that?
// Do a software reset on EIC
EIC->CTRL.SWRST.bit = 1 ;
while ( (EIC->CTRL.SWRST.bit == 1) && (EIC->STATUS.SYNCBUSY.bit == 1) )
{
// Waiting for synchronisation
}
while ((EIC->CTRL.SWRST.bit == 1) && (EIC->STATUS.SYNCBUSY.bit == 1)) { }
*/
// Enable EIC
EIC->CTRL.bit.ENABLE = 1 ;
while ( EIC->STATUS.bit.SYNCBUSY == 1 )
{
// Waiting for synchronisation
}
EIC->CTRL.bit.ENABLE = 1;
while (EIC->STATUS.bit.SYNCBUSY == 1) { }
}
/*
......@@ -138,22 +129,20 @@ void detachInterrupt(uint32_t pin)
/*
* External Interrupt Controller NVIC Interrupt Handler
*/
void EIC_Handler( void )
void EIC_Handler(void)
{
uint32_t ul ;
// Test the 16 normal interrupts
for ( ul = EXTERNAL_INT_0 ; ul <= EXTERNAL_INT_15 ; ul++ )
for (uint32_t i=EXTERNAL_INT_0; i<=EXTERNAL_INT_15; i++)
{
if ( (EIC->INTFLAG.reg & ( 1 << ul ) ) != 0 )
if ((EIC->INTFLAG.reg & (1 << i)) != 0)
{
// Call the callback function if assigned
if (callbacksInt[ul]) {
callbacksInt[ul]();
if (callbacksInt[i]) {
callbacksInt[i]();
}
// Clear the interrupt
EIC->INTFLAG.reg = 1 << ul ;
EIC->INTFLAG.reg = 1 << i;
}
}
}
......
/*
Copyright (c) 2014 Arduino. All right reserved.
Copyright (c) 2015 Arduino LLC. All right reserved.
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
......@@ -31,49 +31,24 @@ extern "C" {
#define FALLING 3
#define RISING 4
///*
//* Interrupt modes
//* The two first values are conflicting with the ones used by Digital API, so we use another name for each.
//*/
//typedef enum _EExt_IntMode
//{
//IM_LOW = 0,
//IM_HIGH = 1,
//CHANGE = 2,
//FALLING = 3,
//RISING = 4,
//IM_CHANGE = 2,
//IM_FALLING = 3,
//IM_RISING = 4,
//} EExt_IntMode ;
#define DEFAULT 1
#define EXTERNAL 0
typedef void (*voidFuncPtr)( void ) ;
typedef void (*voidFuncPtr)(void);
/*
* \brief Specifies a named Interrupt Service Routine (ISR) to call when an interrupt occurs.
* Replaces any previous function that was attached to the interrupt.
*/
//void attachInterrupt( uint32_t ulPin, void (*callback)(void), EExt_IntMode mode ) ;
//void attachInterrupt( uint32_t ulPin, voidFuncPtr callback, EExt_IntMode mode ) ;
void attachInterrupt( uint32_t ulPin, voidFuncPtr callback, uint32_t mode ) ;
void attachInterrupt(uint32_t pin, voidFuncPtr callback, uint32_t mode);
/*
* \brief Turns off the given interrupt.
*/
void detachInterrupt( uint32_t ulPin ) ;
void detachInterrupt(uint32_t pin);
#ifdef __cplusplus
}
#endif
//#ifdef __cplusplus
//inline operator ::EExt_IntMode( uint32_t ul )
//{
//return (EExt_IntMode)ul ;
//}
//#endif
#endif /* _WIRING_INTERRUPTS_ */
#endif
......@@ -111,25 +111,25 @@ typedef enum _EPortType
PORTC=2,
} EPortType ;
typedef enum _EExt_Interrupts
typedef enum
{
EXTERNAL_INT_0 = 0, // Available on pin 11
EXTERNAL_INT_1, // Available on pin 13
EXTERNAL_INT_2, // Available on pins 10, A0, A5
EXTERNAL_INT_3, // Available on pin 12
EXTERNAL_INT_4, // Available on pin 6, 8, A3
EXTERNAL_INT_5, // Available on pin 7, 9, A4
EXTERNAL_INT_6, // Available on pin 16
EXTERNAL_INT_7, // Available on pin 17
EXTERNAL_INT_8, // Available on pin A1
EXTERNAL_INT_9, // Available on pin 3, A2
EXTERNAL_INT_10, // Available on pin 0, 21
EXTERNAL_INT_11, // Available on pin 1, 20
EXTERNAL_INT_12, // Available on pin 18
EXTERNAL_INT_13, // Available on pin EDBG_GPIO0 (43)
EXTERNAL_INT_14, // Available on pin 4
EXTERNAL_INT_15, // Available on pin 5
EXTERNAL_INT_NMI, // Available on pin 2
EXTERNAL_INT_0 = 0,
EXTERNAL_INT_1,
EXTERNAL_INT_2,
EXTERNAL_INT_3,
EXTERNAL_INT_4,
EXTERNAL_INT_5,
EXTERNAL_INT_6,
EXTERNAL_INT_7,
EXTERNAL_INT_8,
EXTERNAL_INT_9,
EXTERNAL_INT_10,
EXTERNAL_INT_11,
EXTERNAL_INT_12,
EXTERNAL_INT_13,
EXTERNAL_INT_14,
EXTERNAL_INT_15,
EXTERNAL_INT_NMI,
EXTERNAL_NUM_INTERRUPTS,
NOT_AN_INTERRUPT = -1,
EXTERNAL_INT_NONE = NOT_AN_INTERRUPT,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment