mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2024-12-29 04:50:03 +01:00
sam0 flashpage_write: fix writes translation from RIOT to CPU pages
This commit is contained in:
parent
3ce4b7454f
commit
a0054654ee
@ -43,8 +43,10 @@ extern "C" {
|
||||
*/
|
||||
/* a flashpage in RIOT is mapped to a flash row on the SAM0s */
|
||||
#define FLASHPAGE_SIZE (256U)
|
||||
/* one SAM0 row contains 4 SAM0 pages -> 4x the amount of RIOT flashpages */
|
||||
#define FLASHPAGE_NUMOF (FLASH_NB_OF_PAGES / 4)
|
||||
/* one SAM0 row contains 4 SAM0 pages, so 4 SAM0 pages contain the amount of a RIOT flashpage */
|
||||
#define FLASHPAGE_PAGES_PER_ROW (4)
|
||||
/* number of RIOT flashpages on device */
|
||||
#define FLASHPAGE_NUMOF (FLASH_NB_OF_PAGES / FLASHPAGE_PAGES_PER_ROW)
|
||||
/* The minimum block size which can be written is 16B. However, the erase
|
||||
* block is always FLASHPAGE_SIZE (SAM0 row).
|
||||
*/
|
||||
|
@ -103,7 +103,16 @@ void flashpage_write(int page, const void *data)
|
||||
|
||||
/* write data to page */
|
||||
if (data != NULL) {
|
||||
flashpage_write_raw(page_addr, data, FLASHPAGE_SIZE);
|
||||
/* One RIOT page is FLASHPAGE_PAGES_PER_ROW SAM0 flash pages (a row) as
|
||||
* defined in the file cpu/sam0_common/include/cpu_conf.h, therefore we
|
||||
* have to split the write into FLASHPAGE_PAGES_PER_ROW raw calls
|
||||
* underneath, each writing a physical page in chunks of 4 bytes (see
|
||||
* flashpage_write_raw)
|
||||
* The erasing is done once as a full row is always reased.
|
||||
*/
|
||||
for (unsigned curpage = 0; curpage < FLASHPAGE_PAGES_PER_ROW; curpage++) {
|
||||
flashpage_write_raw(page_addr + (curpage * NVMCTRL_PAGE_SIZE / 4), (void *) ((uint32_t *) data + (curpage * NVMCTRL_PAGE_SIZE / 4)), NVMCTRL_PAGE_SIZE);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user