STM32 core 3.0.1-dev
Arduino core for STM32 based boards: API reference
← STM32duino documentation
Loading...
Searching...
No Matches
interrupt.cpp File Reference

provide an interface to enable/disable interruptions More...

#include "interrupt.h"
#include "lock_resource.h"
#include "stm32yyxx_ll_exti.h"
#include "stm32yyxx_ll_gpio.h"

Classes

struct  gpio_irq_conf_str
 

Macros

#define NB_EXTI   (16)
 

Functions

static uint8_t get_pin_id (uint16_t pin)
 Return the ID of a GPIO pin, i.e.
 
void stm32_interrupt_enable (PinName pn, callback_function_t callback, uint32_t mode)
 Enable the EXTI interrupt on a pin and register its callback.
 
void stm32_interrupt_disable (GPIO_TypeDef *port, uint16_t pin)
 Disable the EXTI interrupt on a pin and clear its callback.
 
void HAL_GPIO_EXTI_Callback (uint16_t GPIO_Pin)
 Callback called by the HAL when a valid EXTI interrupt is detected.
 
void EXTI0_IRQHandler (void)
 This function handles external line 0 interrupt request.
 
void EXTI1_IRQHandler (void)
 This function handles external line 1 interrupt request.
 
void EXTI2_IRQHandler (void)
 This function handles external line 2 interrupt request.
 
void EXTI3_IRQHandler (void)
 This function handles external line 3 interrupt request.
 
void EXTI4_IRQHandler (void)
 This function handles external line 4 interrupt request.
 
void EXTI9_5_IRQHandler (void)
 This function handles external line 5 to 9 interrupt request.
 
void EXTI15_10_IRQHandler (void)
 This function handles external line 10 to 15 interrupt request.
 

Variables

static gpio_irq_conf_str gpio_irq_conf [NB_EXTI]
 
static const uint32_t ll_exti_lines [NB_EXTI]
 

Detailed Description

provide an interface to enable/disable interruptions

Author
WI6LABS
Version
V1.0.0
Date
01-August-2016
Attention

© COPYRIGHT(c) 2016 STMicroelectronics

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

  1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
  3. Neither the name of STMicroelectronics nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

Function Documentation

◆ get_pin_id()

static uint8_t get_pin_id ( uint16_t  pin)
static

Return the ID of a GPIO pin, i.e.

its bit index in the port.

Parameters
pinOne of the GPIO pins.
Returns
The bit index of the pin.

◆ HAL_GPIO_EXTI_Callback()

void HAL_GPIO_EXTI_Callback ( uint16_t  GPIO_Pin)

Callback called by the HAL when a valid EXTI interrupt is detected.

Parameters
GPIO_PinGPIO pin that triggered the interrupt.

◆ stm32_interrupt_disable()

void stm32_interrupt_disable ( GPIO_TypeDef *  port,
uint16_t  pin 
)

Disable the EXTI interrupt on a pin and clear its callback.

Parameters
portGPIO port of the pin (only used on STM32WB0x and STM32WL3x, where the GPIO IRQ is shared by all the pins of a port).
pinGPIO pin mask (e.g. GPIO_PIN_0) to disable.

◆ stm32_interrupt_enable()

void stm32_interrupt_enable ( PinName  pn,
callback_function_t  callback,
uint32_t  mode 
)

Enable the EXTI interrupt on a pin and register its callback.

The pin is configured as an interrupt input, keeping its current pull configuration, and the EXTI IRQ is enabled with EXTI_IRQ_PRIO / EXTI_IRQ_SUBPRIO priorities.

Parameters
pnPin name (e.g. PA_0) to attach the interrupt to.
callbackFunction called when the interrupt fires.
modeTrigger mode, e.g. GPIO_MODE_IT_RISING, GPIO_MODE_IT_FALLING or GPIO_MODE_IT_RISING_FALLING (hal_exti_trigger_t when USE_HALV2_DRIVER).

Variable Documentation

◆ ll_exti_lines

const uint32_t ll_exti_lines[NB_EXTI]
static
Initial value:
= {
LL_EXTI_LINE_0, LL_EXTI_LINE_1, LL_EXTI_LINE_2, LL_EXTI_LINE_3,
LL_EXTI_LINE_4, LL_EXTI_LINE_5, LL_EXTI_LINE_6, LL_EXTI_LINE_7,
LL_EXTI_LINE_8, LL_EXTI_LINE_9, LL_EXTI_LINE_10, LL_EXTI_LINE_11,
LL_EXTI_LINE_12, LL_EXTI_LINE_13, LL_EXTI_LINE_14, LL_EXTI_LINE_15
}