NavHAL 0.1.0
NAVRobotec's architecture-agnostic HAL for embedded systems.
Loading...
Searching...
No Matches
gpio_reg.h
Go to the documentation of this file.
1
20
21#ifndef CORTEX_M4_GPIO_REG_H
22#define CORTEX_M4_GPIO_REG_H
23
24#include "utils/types.h"
25#include <stdint.h>
26
43typedef struct {
44 __IO uint32_t MODER;
45 __IO uint32_t OTYPER;
46 __IO uint32_t OSPEEDR;
47 __IO uint32_t PUPDR;
48 __IO uint32_t IDR;
49 __IO uint32_t ODR;
50 __IO uint32_t BSRR;
51 __IO uint32_t LCKR;
52 __IO uint32_t AFRL;
53 __IO uint32_t AFRH;
55
57#define GPIOA_BASE_ADDR 0x40020000
58#define GPIOB_BASE_ADDR 0x40020400
59#define GPIOC_BASE_ADDR 0x40020800
60#define GPIOD_BASE_ADDR 0x40020C00
61#define GPIOE_BASE_ADDR 0x40021000
62#define GPIOH_BASE_ADDR 0x40021C00
63
65#define GPIO_GET_PORT_NUMBER(n) (n / 16 == 5 ? 7 : n / 16)
66
68#define GPIO_GET_PORT(n) \
69 ((GPIOx_Typedef *)(GPIOA_BASE_ADDR + ((GPIO_GET_PORT_NUMBER(n)) * 0x400)))
70
72#define GPIO_GET_PIN(n) (n % 16)
73
74#endif // !CORTEX_M4_GPIO_REG_H
#define __IO
Definition hal_types.h:20
GPIO port register structure.
Definition gpio_reg.h:43
__IO uint32_t OSPEEDR
Definition gpio_reg.h:46
__IO uint32_t MODER
Definition gpio_reg.h:44
__IO uint32_t IDR
Definition gpio_reg.h:48
__IO uint32_t LCKR
Definition gpio_reg.h:51
__IO uint32_t BSRR
Definition gpio_reg.h:50
__IO uint32_t PUPDR
Definition gpio_reg.h:47
__IO uint32_t ODR
Definition gpio_reg.h:49
__IO uint32_t AFRH
Definition gpio_reg.h:53
__IO uint32_t OTYPER
Definition gpio_reg.h:45
__IO uint32_t AFRL
Definition gpio_reg.h:52
Centralized type definitions include for NavHAL.