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

Header for interrupt module. More...

#include "stm32_def.h"
#include "pinmap.h"
#include <functional>

Macros

#define EXTI_IRQ_PRIO   3
 Default EXTI IRQ pre-emption priority (Cortex-M0/M0+)
 
#define EXTI_IRQ_SUBPRIO   0
 Default EXTI IRQ sub-priority.
 

Typedefs

typedef std::function< void(void)> callback_function_t
 

Functions

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.
 

Detailed Description

Header for interrupt module.

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

◆ 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).