GPS Device
Loading...
Searching...
No Matches
GPIO Internal Helpers

Functions

static void gpio_set_pclk (GPIO_REGDEF_ts const *gpio_port, EN_STATUS_te en_status)
 Enables or disables the peripheral clock for a GPIO port.
static PORT_CODES_ts get_syscfg_code (GPIO_REGDEF_ts const *gpio_port)
 Returns the SYSCFG port code for a GPIO port instance.
static uint8_t get_exti_position (GPIO_CFG_ts const *gpio_cfg)
 Returns the IRQ number for the EXTI line corresponding to a GPIO pin.

Detailed Description

Function Documentation

◆ gpio_set_pclk()

void gpio_set_pclk ( GPIO_REGDEF_ts const * gpio_port,
EN_STATUS_te en_status )
static

Enables or disables the peripheral clock for a GPIO port.

Calls the appropriate RCC AHB1 clock enable/disable function based on the port pointer. Called by gpio_init and gpio_deinit.

Parameters
[in]gpio_portPointer to the GPIO port instance.
[in]en_statusENABLE to enable the clock, DISABLE to disable it.

Definition at line 188 of file stm32f401re_gpio.c.

188 {
189 if(gpio_port == GPIOA) {
191 }
192 else if(gpio_port == GPIOB) {
194 }
195 else if(gpio_port == GPIOC) {
197 }
198 else if(gpio_port == GPIOD) {
200 }
201 else if(gpio_port == GPIOE) {
203 }
204 else if(gpio_port == GPIOH) {
206 }
207}
void rcc_set_pclk_ahb1(RCC_AHB1ENR_te periph_position, EN_STATUS_te en_status)
Enables or disables the peripheral clock for an AHB1 peripheral.
#define GPIOC
#define GPIOB
#define GPIOD
#define GPIOA
#define GPIOH
#define GPIOE
@ RCC_AHB1ENR_GPIOAEN
@ RCC_AHB1ENR_GPIOCEN
@ RCC_AHB1ENR_GPIOHEN
@ RCC_AHB1ENR_GPIOBEN
@ RCC_AHB1ENR_GPIOEEN
@ RCC_AHB1ENR_GPIODEN
Here is the call graph for this function:
Here is the caller graph for this function:

◆ get_syscfg_code()

PORT_CODES_ts get_syscfg_code ( GPIO_REGDEF_ts const * gpio_port)
static

Returns the SYSCFG port code for a GPIO port instance.

The SYSCFG_EXTICRx registers use a 4-bit code to select which port is routed to a given EXTI line. This function maps port pointers to their corresponding PORT_CODES_ts values.

Parameters
[in]gpio_portPointer to the GPIO port instance.
Returns
The PORT_CODES_ts code for the given port.

Definition at line 221 of file stm32f401re_gpio.c.

221 {
222 if(gpio_port == GPIOA) return PA;
223 else if(gpio_port == GPIOB) return PB;
224 else if(gpio_port == GPIOC) return PC;
225 else if(gpio_port == GPIOD) return PD;
226 else if(gpio_port == GPIOE) return PE;
227 return PH;
228}
@ PH
@ PE
@ PB
@ PC
@ PA
@ PD
Here is the caller graph for this function:

◆ get_exti_position()

uint8_t get_exti_position ( GPIO_CFG_ts const * gpio_cfg)
static

Returns the IRQ number for the EXTI line corresponding to a GPIO pin.

Maps GPIO pin numbers to NVIC IRQ numbers as defined by the STM32F401RE vector table:

  • Pins 0–4 have individual EXTI IRQs (EXTI0–EXTI4).
  • Pins 5–9 share EXTI9_5_IRQn.
  • Pins 10–15 share EXTI15_10_IRQn.
Parameters
[in]gpio_cfgPointer to the GPIO configuration structure.
Returns
The IRQn_te IRQ number for the pin's EXTI line.

Definition at line 244 of file stm32f401re_gpio.c.

244 {
245 if(gpio_cfg->pin == 0) return EXTI0_IRQn;
246 else if(gpio_cfg->pin == 1) return EXTI1_IRQn;
247 else if(gpio_cfg->pin == 2) return EXTI2_IRQn;
248 else if(gpio_cfg->pin == 3) return EXTI3_IRQn;
249 else if(gpio_cfg->pin == 4) return EXTI4_IRQn;
250 else if(gpio_cfg->pin < 10 && gpio_cfg->pin > 4) return EXTI9_5_IRQn;
251 return EXTI15_10_IRQn;
252}
@ EXTI2_IRQn
@ EXTI15_10_IRQn
@ EXTI9_5_IRQn
@ EXTI0_IRQn
@ EXTI4_IRQn
@ EXTI3_IRQn
@ EXTI1_IRQn
Here is the caller graph for this function: