periph_cpu.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2025 Tom Hert <git@annsann.eu>
3  * SPDX-FileCopyrightText: 2025 HAW Hamburg
4  * SPDX-License-Identifier: LGPL-2.1-only
5  */
6 
7 #pragma once
8 
19 #include <stdbool.h>
20 #include <stdint.h>
21 
22 #include "RP2350.h"
23 #include "clock_conf.h"
24 #include "cpu.h"
25 #include "gpio_conf.h"
26 #include "helpers.h"
27 #include "uart_conf.h"
28 
30 #define HAVE_GPIO_T
31 typedef uint32_t gpio_t;
32 
33 /* Im currently copying the original rp2040 def but this causes the other port to not be addressable (I think)*/
34 #define GPIO_PIN(port, pin) (((port) & 0) | (pin))
35 
36 /* This is a define used throughout the pico sdk */
37 #define _u(x) ((uint32_t)(x))
38 
39 #include "periph/gpio.h"
40 
42 #define OSC_DEBUG_PIN_ID 15u
43 
45 #define RESET_PLL_SYS (1u << 14u)
46 
48 #define RESET_PADS_BANK0 (1u << 9u)
49 
51 #define RESET_UART0 (1u << 26u)
52 
54 #define RESET_UART1 (1u << 27u)
55 
57 #define RESET_IO_BANK0 (1u << 6u)
58 
60 #define PADS_BANK0_GPIO0_IE_BITS (1u << 6u)
61 
63 #define PADS_BANK0_ISO_BITS (1u << 8u)
64 
65 #ifdef __cplusplus
66 extern "C" {
67 #endif
68 
74 static inline uint32_t calculate_gpio_pad_register_addr(gpio_t pin) {
75  /* Each pin has a 4 byte register, so we can calculate the address
76  * by adding 4 bytes for each pin, starting at the base address of PADS_BANK0
77  * and adding 4 bytes to skip VOLTAGE_SELECT */
78  return PADS_BANK0_BASE + 4 * (pin + 1);
79 }
80 
86 static uint32_t calculate_gpio_io_status_register_addr(gpio_t pin) {
87  /* Each status register is followed by a ctrl register, */
88  return IO_BANK0_BASE + 8 * pin;
89 }
90 
97 static inline uint32_t calculate_gpio_io_ctrl_register_addr(gpio_t pin) {
98  /* Each pin has a 8 byte register (4 Bytes of Status, 4 Bytes of CTRL),
99  * so we can calculate the address by adding 8 bytes for each pin,
100  * starting at the base address of IO_BANK0 */
102 }
103 
104 #ifdef __cplusplus
105 }
106 #endif
107 
Clock configuration for the RP2350.
Low-level GPIO peripheral driver interface definitions.
GPIO configuration for the RP2350.
unsigned int gpio_t
GPIO type identifier.
Definition: gpio.h:91
Helper functions for atomic register operations.
static uint32_t calculate_gpio_io_status_register_addr(gpio_t pin)
Calculate the address of the GPIO IO status register for a given pin.
Definition: periph_cpu.h:86
static uint32_t calculate_gpio_pad_register_addr(gpio_t pin)
Calculate the address of the GPIO pad register for a given pin.
Definition: periph_cpu.h:74
static uint32_t calculate_gpio_io_ctrl_register_addr(gpio_t pin)
Calculate the address of the GPIO IO control register for a given pin.
Definition: periph_cpu.h:97
UART configuration for the RP2350.