flash.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_FLASH_H
8#define _HARDWARE_FLASH_H
9
10#include "pico.h"
11
37// PICO_CONFIG: PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH, Enable/disable assertions in the hardware_flash module, type=bool, default=0, group=hardware_flash
38#ifndef PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH
39#ifdef PARAM_ASSERTIONS_ENABLED_FLASH // backwards compatibility with SDK < 2.0.0
40#define PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH PARAM_ASSERTIONS_ENABLED_FLASH
41#else
42#define PARAM_ASSERTIONS_ENABLED_HARDWARE_FLASH 0
43#endif
44#endif
45#define FLASH_PAGE_SIZE (1u << 8)
46#define FLASH_SECTOR_SIZE (1u << 12)
47#define FLASH_BLOCK_SIZE (1u << 16)
48
49#define FLASH_UNIQUE_ID_SIZE_BYTES 8
50
51// PICO_CONFIG: PICO_FLASH_SIZE_BYTES, size of primary flash in bytes, type=int, default=Usually provided via board header, group=hardware_flash
52
53#ifdef __cplusplus
54extern "C" {
55#endif
56
67void flash_range_erase(uint32_t flash_offs, size_t count);
68
81void flash_range_program(uint32_t flash_offs, const uint8_t *data, size_t count);
82
93void flash_get_unique_id(uint8_t *id_out);
94
118void flash_do_cmd(const uint8_t *txbuf, uint8_t *rxbuf, size_t count);
119
120void flash_flush_cache(void);
121
122#ifdef __cplusplus
123}
124#endif
125
126#endif
void flash_range_program(uint32_t flash_offs, const uint8_t *data, size_t count)
Program flash.
Definition: flash.c:103
void flash_range_erase(uint32_t flash_offs, size_t count)
Erase areas of flash.
Definition: flash.c:75
void flash_get_unique_id(uint8_t *id_out)
Get flash unique 64 bit identifier.
Definition: flash.c:209
void flash_do_cmd(const uint8_t *txbuf, uint8_t *rxbuf, size_t count)
Execute bidirectional flash command.
Definition: flash.c:149