@web-font-path: "roboto-debian.css";
Loading...
Searching...
No Matches
flash.h
Go to the documentation of this file.
1/*
2 * Copyright (c) 2023 Raspberry Pi (Trading) Ltd.
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6
7#ifndef _PICO_FLASH_H
8#define _PICO_FLASH_H
9
10#include "pico.h"
11
12#include "hardware/flash.h"
13#include "pico/time.h"
14
55#ifdef __cplusplus
56extern "C" {
57#endif
58
67
74
90int flash_safe_execute(void (*func)(void *), void *param, uint32_t enter_exit_timeout_ms);
91
92// PICO_CONFIG: PICO_FLASH_ASSERT_ON_UNSAFE, Assert in debug mode rather than returning an error if flash_safe_execute cannot guarantee safety to catch bugs early, type=bool, default=1, group=pico_flash
93#ifndef PICO_FLASH_ASSERT_ON_UNSAFE
94#define PICO_FLASH_ASSERT_ON_UNSAFE 1
95#endif
96
97// PICO_CONFIG: PICO_FLASH_ASSUME_CORE0_SAFE, Assume that core 0 will never be accessing flash and so doesn't need to be considered during flash_safe_execute, type=bool, default=0, group=pico_flash
98#ifndef PICO_FLASH_ASSUME_CORE0_SAFE
99#define PICO_FLASH_ASSUME_CORE0_SAFE 0
100#endif
101
102// PICO_CONFIG: PICO_FLASH_ASSUME_CORE1_SAFE, Assume that core 1 will never be accessing flash and so doesn't need to be considered during flash_safe_execute, type=bool, default=0, group=pico_flash
103#ifndef PICO_FLASH_ASSUME_CORE1_SAFE
104#define PICO_FLASH_ASSUME_CORE1_SAFE 0
105#endif
106
107// PICO_CONFIG: PICO_FLASH_SAFE_EXECUTE_SUPPORT_FREERTOS_SMP, Support using FreeRTOS SMP to make the other core safe during flash_safe_execute, type=bool, default=1 when using FreeRTOS SMP, group=pico_flash
108#ifndef PICO_FLASH_SAFE_EXECUTE_SUPPORT_FREERTOS_SMP
109#if LIB_FREERTOS_KERNEL && FREE_RTOS_KERNEL_SMP // set by RP2040 SMP port
110#define PICO_FLASH_SAFE_EXECUTE_SUPPORT_FREERTOS_SMP 1
111#endif
112#endif
113
114// PICO_CONFIG: PICO_FLASH_SAFE_EXECUTE_PICO_SUPPORT_MULTICORE_LOCKOUT, Support using multicore_lockout functions to make the other core safe during flash_safe_execute, type=bool, default=1 when using pico_multicore, group=pico_flash
115#ifndef PICO_FLASH_SAFE_EXECUTE_PICO_SUPPORT_MULTICORE_LOCKOUT
116#if LIB_PICO_MULTICORE
117#define PICO_FLASH_SAFE_EXECUTE_PICO_SUPPORT_MULTICORE_LOCKOUT 1
118#endif
119#endif
120
121typedef struct {
122 bool (*core_init_deinit)(bool init);
123 int (*enter_safe_zone_timeout_ms)(uint32_t timeout_ms);
124 int (*exit_safe_zone_timeout_ms)(uint32_t timeout_ms);
126
137
138#ifdef __cplusplus
139}
140#endif
141
142#endif
bool flash_safe_execute_core_init(void)
Definition flash.c:65
int flash_safe_execute(void(*func)(void *), void *param, uint32_t enter_exit_timeout_ms)
Definition flash.c:75
bool flash_safe_execute_core_deinit(void)
Definition flash.c:70
flash_safety_helper_t * get_flash_safety_helper(void)
Definition flash.c:61
Definition flash.h:121