mirror of
https://github.com/tillitis/tillitis-key1.git
synced 2025-07-20 21:58:44 -04:00
fw: Update flash_write_data() to handle sizes larger than 4096 bytes
This commit is contained in:
parent
5a9b77806f
commit
53bc2d5fa0
3 changed files with 20 additions and 11 deletions
|
@ -176,7 +176,11 @@ int flash_write_data(uint32_t address, uint8_t *data, size_t size)
|
|||
return -1;
|
||||
}
|
||||
|
||||
if (size <= 0 || size > 4096) {
|
||||
if (size <= 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (address % 256 != 0) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
@ -184,6 +188,12 @@ int flash_write_data(uint32_t address, uint8_t *data, size_t size)
|
|||
uint8_t *p_data = data;
|
||||
size_t n_bytes = 0;
|
||||
|
||||
// Page Program allows 1-256 bytes of a page to be written. A page is
|
||||
// 256 bytes. Behavior when writing past the end of a page is device
|
||||
// specific.
|
||||
//
|
||||
// We set the address LSByte to 0 and only write 256 bytes or less in
|
||||
// each transfer.
|
||||
uint8_t tx_buf[4] = {
|
||||
PAGE_PROGRAM, /* tx_buf[0] */
|
||||
(address >> ADDR_BYTE_3_BIT) & 0xFF, /* tx_buf[1] */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue