Loading...
Searching...
No Matches
resets.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _HARDWARE_RESETS_H
8#define _HARDWARE_RESETS_H
9
10#include "pico.h"
11#include "hardware/structs/resets.h"
12
96
97// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_RESETS, Enable/disable assertions in the hardware_resets module, type=bool, default=0, group=hardware_adc
98#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_RESETS
99#ifdef PARAM_ASSERTIONS_ENABLED_RESET // backwards compatibility with SDK < 2.0.0
100#define PARAM_ASSERTIONS_ENABLED_HARDWARE_RESETS PARAM_ASSERTIONS_ENABLED_RESET
101#else
102#define PARAM_ASSERTIONS_ENABLED_HARDWARE_RESETS 0
103#endif
104#endif
105#ifdef __cplusplus
106extern "C" {
107#endif
108
109static_assert(RESET_COUNT == NUM_RESETS, "");
110
111static __force_inline void reset_block_reg_mask(io_rw_32 *reset, uint32_t mask) {
112 hw_set_bits(reset, mask);
113}
114
115static __force_inline void unreset_block_reg_mask(io_rw_32 *reset, uint32_t mask) {
116 hw_clear_bits(reset, mask);
117}
118
119static __force_inline void unreset_block_reg_mask_wait_blocking(io_rw_32 *reset, io_ro_32 *reset_done, uint32_t mask) {
120 hw_clear_bits(reset, mask);
121 while (~*reset_done & mask)
123}
124
126
132static __force_inline void reset_block_mask(uint32_t bits) {
133 reset_block_reg_mask(&resets_hw->reset, bits);
134}
135
141static __force_inline void unreset_block_mask(uint32_t bits) {
142 unreset_block_reg_mask(&resets_hw->reset, bits);
143}
144
151 unreset_block_reg_mask_wait_blocking(&resets_hw->reset, &resets_hw->reset_done, bits);
152}
153
155
156#ifndef HARDWARE_RESETS_ENABLE_SDK1XX_COMPATIBILITY
157#define HARDWARE_RESETS_ENABLE_SDK1XX_COMPATIBILITY 1
158#endif
159
160#if HARDWARE_RESETS_ENABLE_SDK1XX_COMPATIBILITY
161static __force_inline void reset_block(uint32_t bits) {
162 reset_block_mask(bits);
163}
164
165static __force_inline void unreset_block(uint32_t bits) {
166 unreset_block_mask(bits);
167}
168
169static __force_inline void unreset_block_wait(uint32_t bits) {
171}
172#endif
173
179static inline void reset_block_num(reset_num_t block_num) {
180 invalid_params_if(HARDWARE_RESETS, block_num >= RESET_COUNT);
181 reset_block_reg_mask(&resets_hw->reset, 1u << block_num);
182}
183
189static inline void unreset_block_num(reset_num_t block_num) {
190 invalid_params_if(HARDWARE_RESETS, block_num >= RESET_COUNT);
191 unreset_block_reg_mask(&resets_hw->reset, 1u << block_num);
192}
193
199static inline void unreset_block_num_wait_blocking(reset_num_t block_num) {
200 invalid_params_if(HARDWARE_RESETS, block_num >= RESET_COUNT);
201 unreset_block_reg_mask_wait_blocking(&resets_hw->reset, &resets_hw->reset_done, 1u << block_num);
202}
203
210 invalid_params_if(HARDWARE_RESETS, block_num >= RESET_COUNT);
211 reset_block_reg_mask(&resets_hw->reset, 1u << block_num);
212 unreset_block_reg_mask_wait_blocking(&resets_hw->reset, &resets_hw->reset_done, 1u << block_num);
213}
214
215#ifdef __cplusplus
216}
217#endif
218#endif
static __force_inline void hw_set_bits(io_rw_32 *addr, uint32_t mask)
Atomically set the specified bits to 1 in a HW register.
Definition address_mapped.h:135
static __force_inline void hw_clear_bits(io_rw_32 *addr, uint32_t mask)
Atomically clear the specified bits to 0 in a HW register.
Definition address_mapped.h:145
static void reset_block_num(reset_num_t block_num)
Reset the specified HW block.
Definition resets.h:179
static void unreset_block_num_wait_blocking(reset_num_t block_num)
Bring specified HW block out of reset and wait for completion.
Definition resets.h:199
static void unreset_block_num(reset_num_t block_num)
bring specified HW block out of reset
Definition resets.h:189
enum reset_num_rp2350 reset_num_t
Resettable component numbers on RP2350 (used as typedef reset_num_t).
static __force_inline void unreset_block_mask(uint32_t bits)
bring specified HW blocks out of reset
Definition resets.h:141
static void reset_unreset_block_num_wait_blocking(reset_num_t block_num)
Reset the specified HW block, and then bring at back out of reset and wait for completion.
Definition resets.h:209
static __force_inline void reset_block_mask(uint32_t bits)
Reset the specified HW blocks.
Definition resets.h:132
static __force_inline void unreset_block_mask_wait_blocking(uint32_t bits)
Bring specified HW blocks out of reset and wait for completion.
Definition resets.h:150
#define __force_inline
Attribute to force inlining of a function regardless of optimization level.
Definition compiler.h:128
static __force_inline void tight_loop_contents(void)
No-op function for the body of tight loops.
Definition common.h:79