Loading...
Searching...
No Matches
compat_layer.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
20#include "periph_cpu.h"
21#include <stdint.h>
22
23#ifdef RP2350_USE_RISCV
24# include "xh3irq.h"
26# define __h3_block() __asm__("slt x0, x0, x0")
28# define __h3_unblock() __asm__("slt x0, x0, x1")
29#else
31 extern uint32_t _isr_vectors;
32#endif
33
34#ifdef __cplusplus
35extern "C" {
36#endif
37
42static inline void rp_irq_enable(uint32_t irq_no)
43{
44#ifdef RP2350_USE_RISCV
45 xh3irq_enable_irq(irq_no);
46#else
47 NVIC_EnableIRQ(irq_no);
48#endif
49}
50
55static inline void rp_irq_disable(uint32_t irq_no)
56{
57#ifdef RP2350_USE_RISCV
58 xh3irq_disable_irq(irq_no);
59#else
60 NVIC_DisableIRQ(irq_no);
61#endif
62}
63
67static inline void rp_end_isr(void)
68{
69#ifdef RP2350_USE_ARM
71#endif
72}
73
77static inline void rp_arch_init(void)
78{
79#ifdef RP2350_USE_RISCV
80 riscv_init();
81#else
83#endif
84}
85
89static inline void rp_block_core(void)
90{
91#ifdef RP2350_USE_RISCV
92 __h3_block();
93#else
94 __WFI();
95#endif
96}
97
101static inline void rp_unblock_core(void)
102{
103#ifdef RP2350_USE_RISCV
104 __h3_unblock();
105#else
106 __SEV();
107#endif
108}
109
114static inline uint32_t* rp_get_vector_poiner(void)
115{
116#ifdef RP2350_USE_RISCV
117 return (uint32_t*)vector_cpu;
118#else
119 return &_isr_vectors;
120#endif
121}
122
131static inline void io_reg_atomic_set(volatile uint32_t *reg, uint32_t mask)
132{
133 atomic_set(reg, mask);
134}
135
139static inline void io_reg_atomic_clear(volatile uint32_t *reg, uint32_t mask)
140{
141 atomic_clear(reg, mask);
142}
143
147static inline void periph_reset(uint32_t components)
148{
149 atomic_set(&RESETS->RESET, components);
150}
151
156static inline void periph_reset_done(uint32_t components)
157{
158 reset_component(components, components);
159}
160
161
162#ifdef __cplusplus
163}
164#endif
165
static void rp_arch_init(void)
Initialize the architecture-specific components.
static void rp_end_isr(void)
Called upon the end of an ISR.
static void io_reg_atomic_clear(volatile uint32_t *reg, uint32_t mask)
Atomically clear the bits of mask in the register reg.
uint32_t _isr_vectors
Defined in the linker script.
static void rp_block_core(void)
Wait For Interrupt abstraction.
static void rp_irq_disable(uint32_t irq_no)
Disable the given IRQ.
static uint32_t * rp_get_vector_poiner(void)
Get a pointer to the CPU specific interrupt vector table.
static void rp_irq_enable(uint32_t irq_no)
Enable the given IRQ.
static void rp_unblock_core(void)
Set Event abstraction.
static void io_reg_atomic_set(volatile uint32_t *reg, uint32_t mask)
Atomically set the bits of mask in the register reg.
static void periph_reset_done(uint32_t components)
Take the hardware components in components out of reset and wait until the reset is done.
static void periph_reset(uint32_t components)
Put the hardware components in components into reset.
Peripheral CPU definitions for the RP2350.
static void cortexm_isr_end(void)
Trigger a conditional context scheduler run / context switch.
Definition cpu.h:178
void cortexm_init(void)
Initialize Cortex-M specific core parts of the CPU.
static void reset_component(uint32_t reset_value, uint32_t reset_done_value)
Reset a component by clearing its reset bits and waiting for the reset to complete.
Definition helpers.h:66
static void atomic_clear(volatile uint32_t *reg, uint32_t val)
Clear bits in a register atomically.
Definition helpers.h:56
static void atomic_set(volatile uint32_t *reg, uint32_t val)
Set bits in a register atomically.
Definition helpers.h:46
void riscv_init(void)
Initialize rv32i specific core parts of the CPU.
xh3irq.h interrupt controller support
void xh3irq_enable_irq(uint32_t irq_no)
Enable the given IRQ number.
void xh3irq_disable_irq(uint32_t irq_no)
Disable the given IRQ number.
const void * vector_cpu[CPU_IRQ_NUMOF]
CPU specific interrupt vector table.