PDL for FM4  Version1.2
Peripheral Driverl Library for FM4
External Interrupts (EXINT)

How to use External Interrupts. More...

Data Structures

struct  stc_exint_config
 EXINT configuration. More...
 
struct  stc_exint_nmi_config
 NMI configuration. More...
 
struct  stc_exint_intern_data
 Datatype for holding internal data needed for EXINT. More...
 
struct  stc_exint_nmi_intern_data
 Datatype for holding internal data needed for NMI. More...
 

Macros

#define PDL_EXINT_CHANNELS
 
#define EXINT0_BITPOS   0x00000001u
 
#define EXINT1_BITPOS   0x00000002u
 
#define EXINT2_BITPOS   0x00000004u
 
#define EXINT3_BITPOS   0x00000008u
 
#define EXINT4_BITPOS   0x00000010u
 
#define EXINT5_BITPOS   0x00000020u
 
#define EXINT6_BITPOS   0x00000040u
 
#define EXINT7_BITPOS   0x00000080u
 
#define EXINT8_BITPOS   0x00000100u
 
#define EXINT9_BITPOS   0x00000200u
 
#define EXINT10_BITPOS   0x00000400u
 
#define EXINT11_BITPOS   0x00000800u
 
#define EXINT12_BITPOS   0x00001000u
 
#define EXINT13_BITPOS   0x00002000u
 
#define EXINT14_BITPOS   0x00004000u
 
#define EXINT15_BITPOS   0x00008000u
 
#define EXINT16_BITPOS   0x00010000u
 
#define EXINT17_BITPOS   0x00020000u
 
#define EXINT18_BITPOS   0x00040000u
 
#define EXINT19_BITPOS   0x00080000u
 
#define EXINT20_BITPOS   0x00100000u
 
#define EXINT21_BITPOS   0x00200000u
 
#define EXINT22_BITPOS   0x00400000u
 
#define EXINT23_BITPOS   0x00800000u
 
#define EXINT24_BITPOS   0x01000000u
 
#define EXINT25_BITPOS   0x02000000u
 
#define EXINT26_BITPOS   0x04000000u
 
#define EXINT27_BITPOS   0x08000000u
 
#define EXINT28_BITPOS   0x10000000u
 
#define EXINT29_BITPOS   0x20000000u
 
#define EXINT30_BITPOS   0x40000000u
 
#define EXINT31_BITPOS   0x80000000u
 
#define EXINT0_BITMASK   0xFFFFFFFEu
 
#define EXINT1_BITMASK   0xFFFFFFFDu
 
#define EXINT2_BITMASK   0xFFFFFFFBu
 
#define EXINT3_BITMASK   0xFFFFFFF7u
 
#define EXINT4_BITMASK   0xFFFFFFEFu
 
#define EXINT5_BITMASK   0xFFFFFFDFu
 
#define EXINT6_BITMASK   0xFFFFFFBFu
 
#define EXINT7_BITMASK   0FFFFFFF7Fu
 
#define EXINT8_BITMASK   0xFFFFFEFFu
 
#define EXINT9_BITMASK   0xFFFFFDFFu
 
#define EXINT10_BITMASK   0xFFFFFBFFu
 
#define EXINT11_BITMASK   0xFFFFF7FFu
 
#define EXINT12_BITMASK   0xFFFFEFFFu
 
#define EXINT13_BITMASK   0xFFFFDFFFu
 
#define EXINT14_BITMASK   0xFFFFBFFFu
 
#define EXINT15_BITMASK   0xFFFF7FFFu
 
#define EXINT16_BITMASK   0xFFFEFFFFu
 
#define EXINT17_BITMASK   0xFFFDFFFFu
 
#define EXINT18_BITMASK   0xFFFBFFFFu
 
#define EXINT19_BITMASK   0xFFF7FFFFu
 
#define EXINT20_BITMASK   0xFFEFFFFFu
 
#define EXINT21_BITMASK   0xFFDFFFFFu
 
#define EXINT22_BITMASK   0xFFBFFFFFu
 
#define EXINT23_BITMASK   0xFF7FFFFFu
 
#define EXINT24_BITMASK   0xFEFFFFFFu
 
#define EXINT25_BITMASK   0xFDFFFFFFu
 
#define EXINT26_BITMASK   0xFBFFFFFFu
 
#define EXINT27_BITMASK   0xF7FFFFFFu
 
#define EXINT28_BITMASK   0xEFFFFFFFu
 
#define EXINT29_BITMASK   0xDFFFFFFFu
 
#define EXINT30_BITMASK   0xBFFFFFFFu
 
#define EXINT31_BITMASK   0x7FFFFFFFu
 

Typedefs

typedef enum en_exint_level en_exint_level_t
 
typedef struct stc_exint_config stc_exint_config_t
 EXINT configuration. More...
 
typedef struct stc_exint_nmi_config stc_exint_nmi_config_t
 NMI configuration. More...
 
typedef struct
stc_exint_intern_data 
stc_exint_intern_data_t
 Datatype for holding internal data needed for EXINT. More...
 
typedef struct
stc_exint_nmi_intern_data 
stc_exint_nmi_intern_data_t
 Datatype for holding internal data needed for NMI. More...
 

Enumerations

enum  en_exint_level {
  ExIntLowLevel = 0,
  ExIntHighLevel = 1,
  ExIntRisingEdge = 2,
  ExIntFallingEdge = 3
}
 

Functions

static uint8_t ExintGetInternDataIdx (uint8_t u8Channel)
 Return the internal reference index of an Exint channel. More...
 
void Exint_IrqHandler (uint8_t u8Channel)
 Interrupt handlers for External interrupts 0. More...
 
void ExintNMIrqHandler (void)
 Interrupt handler for None-Maskable Interrupt (NMI) More...
 
en_result_t Exint_Init (stc_exint_config_t *pstcConfig)
 Init External Interrupts. More...
 
en_result_t Exint_DeInit (void)
 Init External Interrupts. More...
 
en_result_t Exint_EnableChannel (uint8_t u8Channel)
 Enable a single External Interrupt. More...
 
en_result_t Exint_DisableChannel (uint8_t u8Channel)
 Disable a single External Interrupt. More...
 
en_result_t Exint_Nmi_Init (stc_exint_nmi_config_t *pstcConfig)
 Init Non-Maskable Interrupt (NMI) More...
 
en_result_t Exint_Nmi_DeInit (stc_exint_nmi_config_t *pstcConfig)
 De-Init Non-Maskable Interrupt (NMI) More...
 

Variables

stc_exint_intern_data_t stcExintInternData
 
stc_exint_nmi_intern_data_t stcExintNMIInternData
 
const uint8_t cau8ExintReferenceLut [(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT0==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT1==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT2==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT3==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT4==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT5==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT6==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT7==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT8==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT9==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT10==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT11==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT12==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT13==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT14==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT15==PDL_ON)+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT16_17_18_19==PDL_ON))+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT20_21_22_23==PDL_ON))+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT24_25_26_27==PDL_ON))+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT28_29_30_31==PDL_ON))+1]
 
stc_exint_intern_data_t stcExintInternData
 
stc_exint_nmi_intern_data_t stcExintNMIInternData
 

Detailed Description

How to use External Interrupts.

Provided functions of EXINT module:

With Exint_Init() the external interrupts are enabled as given in the configuration. Note, that both external interrupt groups (0-7 and 8-15) can be enabled individually.

If a single channel may be disabled and reenabled during runtime the functions Exint_DisableChannel() and Exint_EnableChannel() can be used.

The external interrupts are disabled globally by Exint_DeInit().

Each channel provides an individually callback function which is handled in the interrupt service routine.

Exint_Nmi_Init() "initializes" the None-Maskable Interrupt, which means that the callback function is set to the dedicated internal data.

Macro Definition Documentation

#define EXINT0_BITMASK   0xFFFFFFFEu

Definition at line 160 of file exint.h.

#define EXINT0_BITPOS   0x00000001u

Definition at line 127 of file exint.h.

#define EXINT10_BITMASK   0xFFFFFBFFu

Definition at line 170 of file exint.h.

#define EXINT10_BITPOS   0x00000400u

Definition at line 137 of file exint.h.

#define EXINT11_BITMASK   0xFFFFF7FFu

Definition at line 171 of file exint.h.

#define EXINT11_BITPOS   0x00000800u

Definition at line 138 of file exint.h.

#define EXINT12_BITMASK   0xFFFFEFFFu

Definition at line 172 of file exint.h.

#define EXINT12_BITPOS   0x00001000u

Definition at line 139 of file exint.h.

#define EXINT13_BITMASK   0xFFFFDFFFu

Definition at line 173 of file exint.h.

#define EXINT13_BITPOS   0x00002000u

Definition at line 140 of file exint.h.

#define EXINT14_BITMASK   0xFFFFBFFFu

Definition at line 174 of file exint.h.

#define EXINT14_BITPOS   0x00004000u

Definition at line 141 of file exint.h.

#define EXINT15_BITMASK   0xFFFF7FFFu

Definition at line 175 of file exint.h.

#define EXINT15_BITPOS   0x00008000u

Definition at line 142 of file exint.h.

#define EXINT16_BITMASK   0xFFFEFFFFu

Definition at line 176 of file exint.h.

#define EXINT16_BITPOS   0x00010000u

Definition at line 143 of file exint.h.

#define EXINT17_BITMASK   0xFFFDFFFFu

Definition at line 177 of file exint.h.

#define EXINT17_BITPOS   0x00020000u

Definition at line 144 of file exint.h.

#define EXINT18_BITMASK   0xFFFBFFFFu

Definition at line 178 of file exint.h.

#define EXINT18_BITPOS   0x00040000u

Definition at line 145 of file exint.h.

#define EXINT19_BITMASK   0xFFF7FFFFu

Definition at line 179 of file exint.h.

#define EXINT19_BITPOS   0x00080000u

Definition at line 146 of file exint.h.

#define EXINT1_BITMASK   0xFFFFFFFDu

Definition at line 161 of file exint.h.

#define EXINT1_BITPOS   0x00000002u

Definition at line 128 of file exint.h.

#define EXINT20_BITMASK   0xFFEFFFFFu

Definition at line 180 of file exint.h.

#define EXINT20_BITPOS   0x00100000u

Definition at line 147 of file exint.h.

#define EXINT21_BITMASK   0xFFDFFFFFu

Definition at line 181 of file exint.h.

#define EXINT21_BITPOS   0x00200000u

Definition at line 148 of file exint.h.

#define EXINT22_BITMASK   0xFFBFFFFFu

Definition at line 182 of file exint.h.

#define EXINT22_BITPOS   0x00400000u

Definition at line 149 of file exint.h.

#define EXINT23_BITMASK   0xFF7FFFFFu

Definition at line 183 of file exint.h.

#define EXINT23_BITPOS   0x00800000u

Definition at line 150 of file exint.h.

#define EXINT24_BITMASK   0xFEFFFFFFu

Definition at line 184 of file exint.h.

#define EXINT24_BITPOS   0x01000000u

Definition at line 151 of file exint.h.

#define EXINT25_BITMASK   0xFDFFFFFFu

Definition at line 185 of file exint.h.

#define EXINT25_BITPOS   0x02000000u

Definition at line 152 of file exint.h.

#define EXINT26_BITMASK   0xFBFFFFFFu

Definition at line 186 of file exint.h.

#define EXINT26_BITPOS   0x04000000u

Definition at line 153 of file exint.h.

#define EXINT27_BITMASK   0xF7FFFFFFu

Definition at line 187 of file exint.h.

#define EXINT27_BITPOS   0x08000000u

Definition at line 154 of file exint.h.

#define EXINT28_BITMASK   0xEFFFFFFFu

Definition at line 188 of file exint.h.

#define EXINT28_BITPOS   0x10000000u

Definition at line 155 of file exint.h.

#define EXINT29_BITMASK   0xDFFFFFFFu

Definition at line 189 of file exint.h.

#define EXINT29_BITPOS   0x20000000u

Definition at line 156 of file exint.h.

#define EXINT2_BITMASK   0xFFFFFFFBu

Definition at line 162 of file exint.h.

#define EXINT2_BITPOS   0x00000004u

Definition at line 129 of file exint.h.

#define EXINT30_BITMASK   0xBFFFFFFFu

Definition at line 190 of file exint.h.

#define EXINT30_BITPOS   0x40000000u

Definition at line 157 of file exint.h.

#define EXINT31_BITMASK   0x7FFFFFFFu

Definition at line 191 of file exint.h.

#define EXINT31_BITPOS   0x80000000u

Definition at line 158 of file exint.h.

#define EXINT3_BITMASK   0xFFFFFFF7u

Definition at line 163 of file exint.h.

#define EXINT3_BITPOS   0x00000008u

Definition at line 130 of file exint.h.

#define EXINT4_BITMASK   0xFFFFFFEFu

Definition at line 164 of file exint.h.

#define EXINT4_BITPOS   0x00000010u

Definition at line 131 of file exint.h.

#define EXINT5_BITMASK   0xFFFFFFDFu

Definition at line 165 of file exint.h.

#define EXINT5_BITPOS   0x00000020u

Definition at line 132 of file exint.h.

#define EXINT6_BITMASK   0xFFFFFFBFu

Definition at line 166 of file exint.h.

#define EXINT6_BITPOS   0x00000040u

Definition at line 133 of file exint.h.

#define EXINT7_BITMASK   0FFFFFFF7Fu

Definition at line 167 of file exint.h.

#define EXINT7_BITPOS   0x00000080u

Definition at line 134 of file exint.h.

#define EXINT8_BITMASK   0xFFFFFEFFu

Definition at line 168 of file exint.h.

#define EXINT8_BITPOS   0x00000100u

Definition at line 135 of file exint.h.

#define EXINT9_BITMASK   0xFFFFFDFFu

Definition at line 169 of file exint.h.

#define EXINT9_BITPOS   0x00000200u

Definition at line 136 of file exint.h.

#define PDL_EXINT_CHANNELS

Typedef Documentation

EXINT configuration.

External Interrupt configuration

The EXINT configuration

Datatype for holding internal data needed for EXINT.

NMI configuration.

The NMI configuration

Datatype for holding internal data needed for NMI.

Enumeration Type Documentation

Enumerator
ExIntLowLevel 

"L" level detection

ExIntHighLevel 

"H" level detection

ExIntRisingEdge 

Rising edge detection.

ExIntFallingEdge 

Falling edge detection.

Definition at line 197 of file exint.h.

Function Documentation

en_result_t Exint_DeInit ( void  )

Init External Interrupts.

This function de-initializes all external interrupts.

Return values
OkEXINT sucessful disabled

Definition at line 436 of file exint.c.

References Ok, PDL_DEFAULT_INTERRUPT_LEVEL, PDL_IRQ_LEVEL_EXINT16_17_18_19, PDL_IRQ_LEVEL_EXINT20_21_22_23, PDL_IRQ_LEVEL_EXINT24_25_26_27, and PDL_IRQ_LEVEL_EXINT28_29_30_31.

en_result_t Exint_DisableChannel ( uint8_t  u8Channel)

Disable a single External Interrupt.

This function disables a single External Interrupt.

Note
This function does not clear stc_exint_config_t::abEnable[u8Channel]!
Parameters
[in]u8ChannelExternal Interrupt channel number
Return values
OkChannel enabled
ErrorInvalidParameterInvalid channel number or channel

Definition at line 579 of file exint.c.

References ErrorInvalidParameter, and Ok.

en_result_t Exint_EnableChannel ( uint8_t  u8Channel)

Enable a single External Interrupt.

This function enables a single External Interrupt.

Note
This function does not set stc_exint_config_t::abEnable[u8Channel]!
Parameters
[in]u8ChannelExternal Interrupt channel number
Return values
OkChannel enabled
ErrorInvalidParameterInvalid channel number

Definition at line 551 of file exint.c.

References ErrorInvalidParameter, and Ok.

void Exint_IrqHandler ( uint8_t  u8Channel)

Interrupt handlers for External interrupts 0.

This function clears the cause bit and calls the callback function, if specified.

Definition at line 193 of file exint.c.

References stc_exint_intern_data::apfnExintCallback, and ExintGetInternDataIdx().

Here is the call graph for this function:

en_result_t Exint_Nmi_DeInit ( stc_exint_nmi_config_t *  pstcConfig)

De-Init Non-Maskable Interrupt (NMI)

This function de-initializes the NMI according to the given configuration.

Parameters
[in]pstcConfigNMI configuration parameters
Return values
OkNMI initialized
ErrorInvalidParameterpstcConfig == NULL
Note
NMI shares the interrupt vector with the Hardware Watchog. To avoid cross influence of initialization of the NVIC use stc_exint_nmi_config_t::bTouchNVIC to determine whether to touch the corresponding NVIC registers or not.

Definition at line 645 of file exint.c.

References stc_exint_nmi_config::bTouchNVIC, ErrorInvalidParameter, Ok, PDL_DEFAULT_INTERRUPT_LEVEL, stc_exint_nmi_config::pfnNMICallback, stc_exint_nmi_intern_data::pfnNMICallback, and TRUE.

en_result_t Exint_Nmi_Init ( stc_exint_nmi_config_t *  pstcConfig)

Init Non-Maskable Interrupt (NMI)

This function initializes the NMI according to the given configuration.

Parameters
[in]pstcConfigNMI configuration parameters
Return values
OkNMI initialized
ErrorInvalidParameterpstcConfig == NULL
Note
NMI shares the interrupt vector with the Hardware Watchog. To avoid cross influence of initialization of the NVIC use stc_exint_nmi_config_t::bTouchNVIC to determine whether to touch the corresponding NVIC registers or not.

Definition at line 608 of file exint.c.

References stc_exint_nmi_config::bTouchNVIC, ErrorInvalidParameter, Ok, PDL_IRQ_LEVEL_NMI, stc_exint_nmi_config::pfnNMICallback, stc_exint_nmi_intern_data::pfnNMICallback, and TRUE.

static uint8_t ExintGetInternDataIdx ( uint8_t  u8Channel)
static

Return the internal reference index of an Exint channel.

Parameters
u8ChannelExint channel number
Returns
uint8_t Reference index (255 if not found or u8Channel > 31)

Definition at line 158 of file exint.c.

References cau8ExintReferenceLut, and PDL_EXINT_CHANNELS.

Referenced by Exint_IrqHandler().

Here is the caller graph for this function:

void ExintNMIrqHandler ( void  )

Interrupt handler for None-Maskable Interrupt (NMI)

This function clears the cause bit and calls the NMI callback function, if specified.

Definition at line 214 of file exint.c.

References stc_exint_nmi_intern_data::pfnNMICallback.

Variable Documentation

const uint8_t cau8ExintReferenceLut[(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT0==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT1==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT2==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT3==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT4==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT5==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT6==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT7==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT8==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT9==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT10==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT11==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT12==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT13==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT14==PDL_ON)+(uint8_t)(PDL_INTERRUPT_ENABLE_EXINT15==PDL_ON)+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT16_17_18_19==PDL_ON))+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT20_21_22_23==PDL_ON))+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT24_25_26_27==PDL_ON))+(uint8_t)(4u *(PDL_INTERRUPT_ENABLE_EXINT28_29_30_31==PDL_ON))+1]

Definition at line 76 of file exint.c.

Referenced by Exint_Init(), and ExintGetInternDataIdx().

stc_exint_intern_data_t stcExintInternData

Definition at line 73 of file exint.c.

stc_exint_intern_data_t stcExintInternData

Definition at line 73 of file exint.c.

stc_exint_nmi_intern_data_t stcExintNMIInternData

Definition at line 74 of file exint.c.

stc_exint_nmi_intern_data_t stcExintNMIInternData

Definition at line 74 of file exint.c.