Loading...
Searching...
No Matches
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
18
19#include <inttypes.h>
20
22#define HAVE_GPIO_T
23typedef uint32_t gpio_t;
24
30#define GPIO_PIN(port, pin) (((port) & 0) | (pin))
31
33#define _u(x) ((uint32_t)(x))
34
35#ifdef RP2350_USE_RISCV
36# include "periph_cpu_common.h"
37# include "xh3irq.h"
38#endif
39#include "cpu.h"
40#include "core_cm33.h" /* Trick RP2350 into believing the file exists on RISCV */
41#include "RP2350.h"
42#include "helpers.h"
43#include "gpio_conf.h"
44#include "clock_conf.h"
45#include "uart_conf.h"
46#include "timer_conf.h"
47#include "multicore.h"
48
49#if !(defined(RP2350_USE_ARM) || defined(RP2350_USE_RISCV))
50# error "Either RP2350_USE_ARM or RP2350_USE_RISCV must be defined"
51#endif
52
53#if (defined(RP2350_USE_ARM) && defined(RP2350_USE_RISCV))
54# error "Only one of RP2350_USE_ARM or RP2350_USE_RISCV can be defined"
55#endif
56
57#ifdef __cplusplus
58extern "C" {
59#endif
60
73#define RP2350_PM_SLEEP (0U)
74#define RP2350_PM_IDLE (1U)
75#define PM_NUM_MODES (2U)
77
79#define OSC_DEBUG_PIN_ID 15u
80
82#define RESET_PLL_SYS (1u << 14u)
83
85#define RESET_PADS_BANK0 (1u << 9u)
86
88#define RESET_UART0 (1u << 26u)
89
91#define RESET_UART1 (1u << 27u)
92
94#define RESET_IO_BANK0 (1u << 6u)
95
97#define PADS_BANK0_GPIO0_IE_BITS (1u << 6u)
98
100#define PADS_BANK0_ISO_BITS (1u << 8u)
101
106void rp2350_init(void);
107
113static inline uint32_t* calculate_gpio_pad_register_addr(gpio_t pin)
114{
115 /* Each pin has a 4 byte register, so we can calculate the address
116 * by adding 4 bytes for each pin, starting at the base address of PADS_BANK0
117 * and adding 4 bytes to skip VOLTAGE_SELECT */
118 return (uint32_t*) (PADS_BANK0_BASE + (4 * (pin + 1)));
119}
120
126static uint32_t calculate_gpio_io_status_register_addr(gpio_t pin) {
127 /* Each status register is followed by a ctrl register */
128 return IO_BANK0_BASE + (8 * pin);
129}
130
137static inline uint32_t* calculate_gpio_io_ctrl_register_addr(gpio_t pin) {
138 /* Each pin has a 8 byte register (4 Bytes of Status, 4 Bytes of CTRL),
139 * so we can calculate the address by adding 8 bytes for each pin,
140 * starting at the base address of IO_BANK0 */
141 return (uint32_t*) (calculate_gpio_io_status_register_addr(pin) + 4);
142}
143
144#ifdef __cplusplus
145}
146#endif
147
Clock configuration for the RP2350.
void rp2350_init(void)
Initialize RP2350 specific CPU peripherals that are not architecture specific.
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:126
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:113
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:137
GPIO configuration for the RP2350.
Helper functions for atomic register operations.
Adds include for missing inttype definitions.
CPU configuration for the RP2350.
Timer configuration for the RP2350.
UART configuration for the RP2350.
xh3irq.h interrupt controller support