From 95b35e67890fd906167224067d855cc855871f3c Mon Sep 17 00:00:00 2001 From: Daniele Lacamera Date: Mon, 24 Oct 2022 10:54:17 +0200 Subject: [PATCH] Fix ext API usage in uart/spi flash drivers --- src/spi_flash.c | 5 ++++- src/uart_flash.c | 4 ++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/spi_flash.c b/src/spi_flash.c index e276e109..25be4c17 100644 --- a/src/spi_flash.c +++ b/src/spi_flash.c @@ -111,6 +111,8 @@ static int RAMFUNCTION spi_flash_write_page(uint32_t address, const void *data, { const uint8_t *buf = data; int j = 0; + if (len < 1) + return -1; while (len > 0) { wait_busy(); flash_write_enable(); @@ -129,7 +131,7 @@ static int RAMFUNCTION spi_flash_write_page(uint32_t address, const void *data, spi_cs_off(SPI_CS_FLASH); } wait_busy(); - return j; + return 0; } static int RAMFUNCTION spi_flash_write_sb(uint32_t address, const void *data, int len) @@ -137,6 +139,7 @@ static int RAMFUNCTION spi_flash_write_sb(uint32_t address, const void *data, in const uint8_t *buf = data; uint8_t verify = 0; int j = 0; + wait_busy(); if (len < 1) return -1; diff --git a/src/uart_flash.c b/src/uart_flash.c index 3cc031d8..4b159e7f 100644 --- a/src/uart_flash.c +++ b/src/uart_flash.c @@ -91,7 +91,7 @@ int ext_flash_write(uintptr_t address, const uint8_t *data, int len) if (wait_ack() != 0) return -1; } - return i; + return 0; } int ext_flash_read(uintptr_t address, uint8_t *data, int len) @@ -118,7 +118,7 @@ int ext_flash_read(uintptr_t address, uint8_t *data, int len) return 0; uart_tx(CMD_ACK); } - return len; + return 0; } int ext_flash_erase(uintptr_t address, int len)