Fix ext API usage in uart/spi flash drivers

pull/245/head
Daniele Lacamera 2022-10-24 10:54:17 +02:00
parent 88a48e5332
commit 95b35e6789
2 changed files with 6 additions and 3 deletions

View File

@ -111,6 +111,8 @@ static int RAMFUNCTION spi_flash_write_page(uint32_t address, const void *data,
{ {
const uint8_t *buf = data; const uint8_t *buf = data;
int j = 0; int j = 0;
if (len < 1)
return -1;
while (len > 0) { while (len > 0) {
wait_busy(); wait_busy();
flash_write_enable(); 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); spi_cs_off(SPI_CS_FLASH);
} }
wait_busy(); wait_busy();
return j; return 0;
} }
static int RAMFUNCTION spi_flash_write_sb(uint32_t address, const void *data, int len) 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; const uint8_t *buf = data;
uint8_t verify = 0; uint8_t verify = 0;
int j = 0; int j = 0;
wait_busy(); wait_busy();
if (len < 1) if (len < 1)
return -1; return -1;

View File

@ -91,7 +91,7 @@ int ext_flash_write(uintptr_t address, const uint8_t *data, int len)
if (wait_ack() != 0) if (wait_ack() != 0)
return -1; return -1;
} }
return i; return 0;
} }
int ext_flash_read(uintptr_t address, uint8_t *data, int len) 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; return 0;
uart_tx(CMD_ACK); uart_tx(CMD_ACK);
} }
return len; return 0;
} }
int ext_flash_erase(uintptr_t address, int len) int ext_flash_erase(uintptr_t address, int len)