From 3aa5203bc56a42389b6928d0d4bfa7df33e749d9 Mon Sep 17 00:00:00 2001 From: Koen Zandberg Date: Mon, 9 Nov 2020 16:45:35 +0100 Subject: [PATCH] mtd_flashpage: only depend on periph_flashpage The features in flashpage_raw are now default in flashpage and do not have to be included as a separate dependency --- drivers/mtd_flashpage/Makefile.dep | 2 +- drivers/mtd_flashpage/mtd_flashpage.c | 12 ++++++------ tests/mtd_flashpage/main.c | 3 ++- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/drivers/mtd_flashpage/Makefile.dep b/drivers/mtd_flashpage/Makefile.dep index 7cbdfe6a25..301ac6efde 100644 --- a/drivers/mtd_flashpage/Makefile.dep +++ b/drivers/mtd_flashpage/Makefile.dep @@ -1,2 +1,2 @@ FEATURES_REQUIRED += periph_flashpage -FEATURES_REQUIRED += periph_flashpage_raw +FEATURES_REQUIRED += periph_flashpage_pagewise diff --git a/drivers/mtd_flashpage/mtd_flashpage.c b/drivers/mtd_flashpage/mtd_flashpage.c index af47d847f8..5be1f5d005 100644 --- a/drivers/mtd_flashpage/mtd_flashpage.c +++ b/drivers/mtd_flashpage/mtd_flashpage.c @@ -42,7 +42,7 @@ static int _read(mtd_dev_t *dev, void *buf, uint32_t addr, uint32_t size) (void)dev; - if (addr % FLASHPAGE_RAW_ALIGNMENT) { + if (addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT) { return -EINVAL; } @@ -61,13 +61,13 @@ static int _write(mtd_dev_t *dev, const void *buf, uint32_t addr, uint32_t size) { (void)dev; - if (addr % FLASHPAGE_RAW_ALIGNMENT) { + if (addr % FLASHPAGE_WRITE_BLOCK_ALIGNMENT) { return -EINVAL; } - if ((uintptr_t)buf % FLASHPAGE_RAW_ALIGNMENT) { + if ((uintptr_t)buf % FLASHPAGE_WRITE_BLOCK_ALIGNMENT) { return -EINVAL; } - if (size % FLASHPAGE_RAW_BLOCKSIZE) { + if (size % FLASHPAGE_WRITE_BLOCK_SIZE) { return -EOVERFLOW; } if (addr + size > MTD_FLASHPAGE_END_ADDR) { @@ -80,7 +80,7 @@ static int _write(mtd_dev_t *dev, const void *buf, uint32_t addr, uint32_t size) uint32_t dst_addr = addr; #endif - flashpage_write_raw((void *)dst_addr, buf, size); + flashpage_write((void *)dst_addr, buf, size); return 0; } @@ -106,7 +106,7 @@ int _erase(mtd_dev_t *dev, uint32_t addr, uint32_t size) #endif for (size_t i = 0; i < size; i += sector_size) { - flashpage_write(flashpage_page((void *)(dst_addr + i)), NULL); + flashpage_erase(flashpage_page((void *)(dst_addr + i))); } return 0; diff --git a/tests/mtd_flashpage/main.c b/tests/mtd_flashpage/main.c index 72f8eaacc9..399b3b69f5 100644 --- a/tests/mtd_flashpage/main.c +++ b/tests/mtd_flashpage/main.c @@ -122,7 +122,8 @@ static void test_mtd_write_erase(void) static void test_mtd_write_read(void) { - const char buf[] __attribute__ ((aligned (FLASHPAGE_RAW_ALIGNMENT))) = "ABCDEFGHIJKLMNO"; + const char buf[] __attribute__ ((aligned (FLASHPAGE_WRITE_BLOCK_ALIGNMENT))) + = "ABCDEFGHIJKLMNO"; /* stm32l0x and stm32l1x erase its flash with 0's */ #if defined(CPU_FAM_STM32L0) || defined(CPU_FAM_STM32L1)