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 #include "periph/gpio.h"
34 
36 #define LED0_PIN_ID 25u
37 #define LED0_ON gpio_set(LED0_PIN_ID)
38 #define LED0_OFF gpio_clear(LED0_PIN_ID)
39 #define LED0_TOGGLE gpio_toggle(LED0_PIN_ID)
40 #define LED0_NAME "LED(Green)"
41 
43 #define OSC_DEBUG_PIN_ID 15u
44 
46 #define RESET_PLL_SYS (1u << 14u)
47 
49 #define RESET_PADS_BANK0 (1u << 9u)
50 
52 #define RESET_UART0 (1u << 26u)
53 
55 #define RESET_UART1 (1u << 27u)
56 
58 #define RESET_IO_BANK0 (1u << 6u)
59 
61 #define PADS_BANK0_GPIO0_IE_BITS (1u << 6u)
62 
64 #define PADS_BANK0_ISO_BITS (1u << 8u)
65 
66 #ifdef __cplusplus
67 extern "C" {
68 #endif
69 
75 static inline uint32_t calculate_gpio_pad_register_addr(gpio_t pin) {
76  /* Each pin has a 4 byte register, so we can calculate the address */
77  /* by adding 4 bytes for each pin, starting at the base address of PADS_BANK0
78  */
79  /* and adding 4 bytes to skip VOLTAGE_SELECT */
80  return PADS_BANK0_BASE + 4 * (pin + 1);
81 }
82 
88 static uint32_t calculate_gpio_io_status_register_addr(gpio_t pin) {
89  /* Each status register is followed by a ctrl register, */
90  return IO_BANK0_BASE + 8 * pin;
91 }
92 
99 static inline uint32_t calculate_gpio_io_ctrl_register_addr(gpio_t pin) {
100  /* Each pin has a 8 byte register (4 Bytes of Status, 4 Bytes of CTRL), */
101  /* so we can calculate the address by adding 8 bytes for each pin, */
102  /* starting at the base address of IO_BANK0 */
104 }
105 
106 #ifdef __cplusplus
107 }
108 #endif
109 
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:88
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:75
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:99
UART configuration for the RP2350.