48#ifndef PERIPH_FLASHPAGE_H
49#define PERIPH_FLASHPAGE_H
55#include "periph_cpu.h"
65#define CPU_FLASH_BASE (0)
74#define FLASHPAGE_WRITE_BLOCK_SIZE
86#define FLASHPAGE_WRITE_BLOCK_ALIGNMENT
94#if defined(DOXYGEN) || !defined(FLASHPAGE_ERASE_STATE)
95#define FLASHPAGE_ERASE_STATE (0xFFU)
106#define PERIPH_FLASHPAGE_CUSTOM_PAGESIZES
118#define PERIPH_FLASHPAGE_NEEDS_FLASHPAGE_ADDR
130#define PERIPH_FLASHPAGE_NEEDS_FLASHPAGE_PAGE
141#if !defined(PERIPH_FLASHPAGE_CUSTOM_PAGESIZES) || defined(DOXYGEN)
147#ifndef FLASHPAGE_SIZE
148#error "periph/flashpage: FLASHPAGE_SIZE not defined"
150#ifndef FLASHPAGE_NUMOF
151#error "periph/flashpage: FLASHPAGE_NUMOF not defined"
154#if defined(MODULE_PERIPH_FLASHPAGE_IN_ADDRESS_SPACE) || defined(DOXYGEN)
173#define FLASH_WRITABLE_INIT(name, size) \
174 __attribute__((aligned(FLASHPAGE_SIZE))) \
175 __attribute__((section(".flash_writable." #name))) \
176 static const uint8_t name [size * FLASHPAGE_SIZE]
341#ifdef FLASHPAGE_RWWEE_NUMOF
353static inline void *flashpage_rwwee_addr(
unsigned page)
369static inline int flashpage_rwwee_page(
const void *addr)
371 return (
int)(((int)addr - CPU_FLASH_RWWEE_BASE) /
FLASHPAGE_SIZE);
381void flashpage_rwwee_write_page(
unsigned page,
const void *data);
404void flashpage_rwwee_write(
void *target_addr,
const void *data,
size_t len);
413void flashpage_rwwee_read(
unsigned page,
void *data);
425int flashpage_rwwee_verify(
unsigned page,
const void *data);
440int flashpage_rwwee_write_and_verify(
unsigned page,
const void *data);
#define FLASHPAGE_SIZE
Flash page configuration.
int flashpage_write_and_verify(unsigned page, const void *data)
Write the given page and verify the results.
int flashpage_verify(unsigned page, const void *data)
Verify the given page against the given data.
void flashpage_erase(unsigned page)
Erase the given page.
unsigned flashpage_first_free(void)
Get number of first free flashpage.
static void * flashpage_addr(unsigned page)
Translate the given page number into the page's starting address.
static size_t flashpage_size(unsigned page)
Get the page size of the given page number.
void flashpage_write(void *target_addr, const void *data, size_t len)
Write any number of data bytes to a given location in the flash memory.
static unsigned flashpage_page(const void *addr)
Translate the given address into the corresponding page number.
#define CPU_FLASH_BASE
Per default, we expect the internal flash to start at address 0.
unsigned flashpage_last_free(void)
Get number of last free flashpage.
void flashpage_read(unsigned page, void *data)
Read the given page into the given memory location.
void flashpage_write_page(unsigned page, const void *data)
Write the given page with the given data.
@ FLASHPAGE_NOMATCH
page differs from target data
@ FLASHPAGE_OK
everything succeeded