[core] Fix swapped flash reading/writing API
This commit is contained in:
@@ -23,13 +23,13 @@ class FlashClass {
|
|||||||
/** @copydoc lt_flash_read() */
|
/** @copydoc lt_flash_read() */
|
||||||
inline bool readBlock(uint32_t offset, uint8_t *data, size_t length) {
|
inline bool readBlock(uint32_t offset, uint8_t *data, size_t length) {
|
||||||
//
|
//
|
||||||
return lt_flash_read(offset, data, length);
|
return lt_flash_read(offset, data, length) == length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @copydoc lt_flash_write() */
|
/** @copydoc lt_flash_write() */
|
||||||
inline bool writeBlock(uint32_t offset, uint8_t *data, size_t length) {
|
inline bool writeBlock(uint32_t offset, uint8_t *data, size_t length) {
|
||||||
//
|
//
|
||||||
return lt_flash_write(offset, data, length);
|
return lt_flash_write(offset, data, length) == length;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -40,9 +40,9 @@ bool lt_flash_erase_block(uint32_t offset);
|
|||||||
* @param offset starting offset (in bytes)
|
* @param offset starting offset (in bytes)
|
||||||
* @param data pointer to where to store the data
|
* @param data pointer to where to store the data
|
||||||
* @param length length of data to read
|
* @param length length of data to read
|
||||||
* @return whether reading was successful (i.e. all bytes were successfully read)
|
* @return length of data successfully read (should equal 'length')
|
||||||
*/
|
*/
|
||||||
bool lt_flash_read(uint32_t offset, uint8_t *data, size_t length);
|
uint32_t lt_flash_read(uint32_t offset, uint8_t *data, size_t length);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Write data to the flash.
|
* @brief Write data to the flash.
|
||||||
@@ -50,6 +50,6 @@ bool lt_flash_read(uint32_t offset, uint8_t *data, size_t length);
|
|||||||
* @param offset starting offset (in bytes)
|
* @param offset starting offset (in bytes)
|
||||||
* @param data pointer to data to write
|
* @param data pointer to data to write
|
||||||
* @param length length of data to write
|
* @param length length of data to write
|
||||||
* @return whether writing was successful (i.e. all bytes were successfully written)
|
* @return length of data successfully written (should equal 'length')
|
||||||
*/
|
*/
|
||||||
bool lt_flash_write(uint32_t offset, uint8_t *data, size_t length);
|
uint32_t lt_flash_write(uint32_t offset, uint8_t *data, size_t length);
|
||||||
|
|||||||
@@ -148,12 +148,12 @@ bool lt_flash_erase_block(uint32_t offset) {
|
|||||||
return fal_partition_erase(fal_root_part, offset, 1) >= 0;
|
return fal_partition_erase(fal_root_part, offset, 1) >= 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lt_flash_read(uint32_t offset, uint8_t *data, size_t length) {
|
uint32_t lt_flash_read(uint32_t offset, uint8_t *data, size_t length) {
|
||||||
return fal_partition_write(fal_root_part, offset, data, length) == length;
|
return fal_partition_read(fal_root_part, offset, data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool lt_flash_write(uint32_t offset, uint8_t *data, size_t length) {
|
uint32_t lt_flash_write(uint32_t offset, uint8_t *data, size_t length) {
|
||||||
return fal_partition_read(fal_root_part, offset, data, length) == length;
|
return fal_partition_write(fal_root_part, offset, data, length);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*__ __
|
/*__ __
|
||||||
|
|||||||
Reference in New Issue
Block a user