mtd_flashpage.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2018 OTA keys S.A.
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
26 #ifndef MTD_FLASHPAGE_H
27 #define MTD_FLASHPAGE_H
28 
29 #include "mtd.h"
30 #include "periph/flashpage.h"
31 
32 #ifdef __cplusplus
33 extern "C"
34 {
35 #endif
36 
40 #define MTD_FLASHPAGE_INIT_VAL(_pages_per_sector) { \
41  .base = { \
42  .driver = &mtd_flashpage_driver, \
43  .sector_count = FLASHPAGE_NUMOF, \
44  .pages_per_sector = _pages_per_sector, \
45  .page_size = FLASHPAGE_SIZE / _pages_per_sector, \
46  .write_size = 1 \
47  }, \
48 }
49 
56 #define MTD_FLASHPAGE_AUX_INIT_VAL(start, len) { \
57  .base = { \
58  .driver = &mtd_flashpage_driver, \
59  .sector_count = len / FLASHPAGE_SIZE, \
60  .pages_per_sector = 1, \
61  .page_size = FLASHPAGE_SIZE, \
62  .write_size = 1, \
63  }, \
64  .offset = start / FLASHPAGE_SIZE, \
65 }
66 
70 extern const mtd_desc_t mtd_flashpage_driver;
71 
75 typedef struct {
77  uint32_t offset;
81 
82 #if CONFIG_SLOT_AUX_LEN || DOXYGEN
87 
91 extern mtd_dev_t *mtd_aux;
92 #endif
93 
105 #ifndef CONFIG_SLOT_AUX_LEN
106 #define CONFIG_SLOT_AUX_LEN 0
107 #endif
108 
112 #ifndef CONFIG_SLOT_AUX_MTD_OFFSET
113 #define CONFIG_SLOT_AUX_MTD_OFFSET 1
114 #endif
115 
116 #ifdef __cplusplus
117 }
118 #endif
119 
120 #endif /* MTD_FLASHPAGE_H */
Low-level flash page peripheral driver interface.
mtd_flashpage_t mtd_flash_aux_slot
MTD device representing the auxiliary flash slot.
mtd_dev_t * mtd_aux
Generic MTD device backed by the auxiliary flash slot.
const mtd_desc_t mtd_flashpage_driver
Flashpage MTD device operations table.
MTD driver interface.
Definition: mtd.h:204
MTD device descriptor.
Definition: mtd.h:112
MTD flashpage descriptor.
Definition: mtd_flashpage.h:75
mtd_dev_t base
MTD generic device.
Definition: mtd_flashpage.h:76
uint32_t offset
Offset in terms of MTD pages, which must comprise a whole number of sectors from the start of the fla...
Definition: mtd_flashpage.h:77