@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
flash.h
Go to the documentation of this file.
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _HARDWARE_FLASH_H
#define _HARDWARE_FLASH_H
#include "pico.h"
// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH, Enable/disable assertions in the hardware_flash module, type=bool, default=0, group=hardware_flash
#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH
#ifdef PARAM_ASSERTIONS_ENABLED_FLASH // backwards compatibility with SDK < 2.0.0
#define PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH PARAM_ASSERTIONS_ENABLED_FLASH
#else
#define PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH 0
#endif
#endif
#define FLASH_PAGE_SIZE (1u << 8)
#define FLASH_SECTOR_SIZE (1u << 12)
#define FLASH_BLOCK_SIZE (1u << 16)
#ifndef FLASH_UNIQUE_ID_SIZE_BYTES
#define FLASH_UNIQUE_ID_SIZE_BYTES 8
#endif
// PICO_CONFIG: PICO_FLASH_SIZE_BYTES, size of primary flash in bytes, type=int, default=Usually provided via board header, group=hardware_flash
#ifdef __cplusplus
extern "C" {
#endif
void flash_start_xip(void);
void flash_range_erase(uint32_t flash_offs, size_t count);
void flash_range_program(uint32_t flash_offs, const uint8_t *data, size_t count);
void flash_get_unique_id(uint8_t *id_out);
void flash_do_cmd(const uint8_t *txbuf, uint8_t *rxbuf, size_t count);
void flash_flush_cache(void);
#if !PICO_RP2040
typedef enum {
FLASH_DEVINFO_SIZE_NONE = 0x0,
FLASH_DEVINFO_SIZE_8K = 0x1,
FLASH_DEVINFO_SIZE_16K = 0x2,
FLASH_DEVINFO_SIZE_32K = 0x3,
FLASH_DEVINFO_SIZE_64K = 0x4,
FLASH_DEVINFO_SIZE_128K = 0x5,
FLASH_DEVINFO_SIZE_256K = 0x6,
FLASH_DEVINFO_SIZE_512K = 0x7,
FLASH_DEVINFO_SIZE_1M = 0x8,
FLASH_DEVINFO_SIZE_2M = 0x9,
FLASH_DEVINFO_SIZE_4M = 0xa,
FLASH_DEVINFO_SIZE_8M = 0xb,
FLASH_DEVINFO_SIZE_16M = 0xc,
FLASH_DEVINFO_SIZE_MAX = 0xc
} flash_devinfo_size_t;
static inline uint32_t flash_devinfo_size_to_bytes(flash_devinfo_size_t size) {
if (size == FLASH_DEVINFO_SIZE_NONE) {
return 0;
} else {
return 4096u << (uint)size;
}
}
static inline flash_devinfo_size_t flash_devinfo_bytes_to_size(uint32_t bytes) {
// Must be zero or a power of two
valid_params_if(HARDWARE_FLASH, (bytes & (bytes - 1)) == 0u);
uint sectors = bytes / 4096u;
if (sectors <= 1u) {
return FLASH_DEVINFO_SIZE_NONE;
} else {
return (flash_devinfo_size_t) __builtin_ctz(sectors);
}
}
flash_devinfo_size_t flash_devinfo_get_cs_size(uint cs);
void flash_devinfo_set_cs_size(uint cs, flash_devinfo_size_t size);
bool flash_devinfo_get_d8h_erase_supported(void);
void flash_devinfo_set_d8h_erase_supported(bool supported);
uint flash_devinfo_get_cs_gpio(uint cs);
void flash_devinfo_set_cs_gpio(uint cs, uint gpio);
#endif // !PICO_RP2040
#ifdef __cplusplus
}
#endif
#endif
flash_range_program
void flash_range_program(uint32_t flash_offs, const uint8_t *data, size_t count)
Program flash.
Definition flash.c:222
flash_range_erase
void flash_range_erase(uint32_t flash_offs, size_t count)
Erase areas of flash.
Definition flash.c:191
flash_get_unique_id
void flash_get_unique_id(uint8_t *id_out)
Get flash unique 64 bit identifier.
Definition flash.c:336
flash_do_cmd
void flash_do_cmd(const uint8_t *txbuf, uint8_t *rxbuf, size_t count)
Execute bidirectional flash command.
Definition flash.c:272
flash_start_xip
void flash_start_xip(void)
Initialise QSPI interface and external QSPI devices for execute-in-place.
Definition flash.c:160
pico.h