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 "multicore.h"
47
48#if !(defined(RP2350_USE_ARM) || defined(RP2350_USE_RISCV))
49# error "Either RP2350_USE_ARM or RP2350_USE_RISCV must be defined"
50#endif
51
52#if (defined(RP2350_USE_ARM) && defined(RP2350_USE_RISCV))
53# error "Only one of RP2350_USE_ARM or RP2350_USE_RISCV can be defined"
54#endif
55
56#ifdef __cplusplus
57extern "C" {
58#endif
59
61#define OSC_DEBUG_PIN_ID 15u
62
64#define RESET_PLL_SYS (1u << 14u)
65
67#define RESET_PADS_BANK0 (1u << 9u)
68
70#define RESET_UART0 (1u << 26u)
71
73#define RESET_UART1 (1u << 27u)
74
76#define RESET_IO_BANK0 (1u << 6u)
77
79#define PADS_BANK0_GPIO0_IE_BITS (1u << 6u)
80
82#define PADS_BANK0_ISO_BITS (1u << 8u)
83
88void rp2350_init(void);
89
95static inline uint32_t* calculate_gpio_pad_register_addr(gpio_t pin)
96{
97 /* Each pin has a 4 byte register, so we can calculate the address
98 * by adding 4 bytes for each pin, starting at the base address of PADS_BANK0
99 * and adding 4 bytes to skip VOLTAGE_SELECT */
100 return (uint32_t*) (PADS_BANK0_BASE + (4 * (pin + 1)));
101}
102
108static uint32_t calculate_gpio_io_status_register_addr(gpio_t pin) {
109 /* Each status register is followed by a ctrl register */
110 return IO_BANK0_BASE + (8 * pin);
111}
112
119static inline uint32_t* calculate_gpio_io_ctrl_register_addr(gpio_t pin) {
120 /* Each pin has a 8 byte register (4 Bytes of Status, 4 Bytes of CTRL),
121 * so we can calculate the address by adding 8 bytes for each pin,
122 * starting at the base address of IO_BANK0 */
123 return (uint32_t*) (calculate_gpio_io_status_register_addr(pin) + 4);
124}
125
126#ifdef __cplusplus
127}
128#endif
129
Clock configuration for the RP2350.
GPIO configuration for the RP2350.
Helper functions for atomic register operations.
Adds include for missing inttype definitions.
CPU 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:108
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:95
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:119
UART configuration for the RP2350.
xh3irq.h interrupt controller support