1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

drivers: add MTD_DRIVER_FLAG_DIRECT_WRITE to mtd drivers

- EEPROMs don't need read-modify-write cylce
 - SD cards will handle read-modify-write internally
This commit is contained in:
Benjamin Valentin 2021-01-24 00:28:51 +01:00
parent e8bbe1d1c7
commit c569d9a1d9
5 changed files with 12 additions and 1 deletions

View File

@ -80,5 +80,6 @@ const mtd_desc_t mtd_at24cxxx_driver = {
.write = _mtd_at24cxxx_write,
.write_page = mtd_at24cxxx_write_page,
.erase = _mtd_at24cxxx_erase,
.power = _mtd_at24cxxx_power
.power = _mtd_at24cxxx_power,
.flags = MTD_DRIVER_FLAG_DIRECT_WRITE,
};

View File

@ -90,4 +90,5 @@ const mtd_desc_t mtd_at25xxx_driver = {
.write_page = mtd_at25xxx_write_page,
.erase = mtd_at25xxx_erase,
.power = mtd_at25xxx_power,
.flags = MTD_DRIVER_FLAG_DIRECT_WRITE,
};

View File

@ -143,4 +143,5 @@ const mtd_desc_t mtd_mci_driver = {
.write_page = mtd_mci_write_page,
.erase_sector = mtd_mci_erase_sector,
.power = mtd_mci_power,
.flags = MTD_DRIVER_FLAG_DIRECT_WRITE,
};

View File

@ -158,4 +158,5 @@ const mtd_desc_t mtd_sdcard_driver = {
.write_page = mtd_sdcard_write_page,
.erase = mtd_sdcard_erase,
.power = mtd_sdcard_power,
.flags = MTD_DRIVER_FLAG_DIRECT_WRITE,
};

View File

@ -406,6 +406,13 @@ static int cmd_test(int argc, char **argv)
assert(mtd_read_page(dev, buffer, page_0, offset, sizeof(test_str)) == 0);
assert(memcmp(test_str, buffer, sizeof(test_str)) == 0);
/* overwrite first test string, rely on MTD for read-modify-write */
const char test_str_2[] = "Hello World!";
offset = 5;
assert(mtd_write_page_hl(dev, test_str_2, page_0, offset, sizeof(test_str_2)) == 0);
assert(mtd_read_page(dev, buffer, page_0, offset, sizeof(test_str_2)) == 0);
assert(memcmp(test_str_2, buffer, sizeof(test_str_2)) == 0);
puts("[SUCCESS]");
free(buffer);