tkl_flash | Flash Driver
The tkl_flash.c file is automatically generated by the TuyaOS v&v tool and provides basic operation functions for Flash storage, including reading, writing, erasing Flash, and obtaining Flash information. In the automatically generated code framework, developers can add their own implementations between the "BEGIN" and "END" comments to maintain the persistence of user code.
API Descriptionโ
tkl_flash_readโ
OPERATE_RET tkl_flash_read(uint32_t addr, uint8_t *dst, uint32_t size);
Functionalityโ
Reads data from Flash.
Parametersโ
addr: The Flash address to read from.dst: Pointer to the buffer where the read data will be stored.size: The size of the data to read.
Return Valueโ
OPRT_OK: Read operation successful.- Other error codes: Please refer to
tuya_error_code.h.
tkl_flash_writeโ
OPERATE_RET tkl_flash_write(uint32_t addr, const uint8_t *src, uint32_t size);
Functionalityโ
Writes data to Flash.
Parametersโ
addr: The Flash address to write to.src: Pointer to the buffer containing the data to write.size: The size of the data to write.
Return Valueโ
OPRT_OK: Write operation successful.- Other error codes: Please refer to
tuya_error_code.h.
tkl_flash_eraseโ
OPERATE_RET tkl_flash_erase(uint32_t addr, uint32_t size);
Functionalityโ
Erases data from Flash.
Parametersโ
addr: The Flash address to erase.size: The size of the Flash block to erase.
Return Valueโ
OPRT_OK: Erase operation successful.- Other error codes: Please refer to
tuya_error_code.h.
tkl_flash_lock/unlockโ
OPERATE_RET tkl_flash_lock(uint32_t addr, uint32_t size);
OPERATE_RET tkl_flash_unlock(uint32_t addr, uint32_t size);
Functionalityโ
Locks or unlocks a region of Flash. These functions are currently implemented as unsupported operations.
Parametersโ
addr: The starting Flash address to lock or unlock.size: The size of the region to lock or unlock.
Return Valueโ
OPRT_OK: Lock or unlock operation successful.- Other error codes: Please refer to
tuya_error_code.h.
tkl_flash_get_one_type_infoโ
OPERATE_RET tkl_flash_get_one_type_info(TUYA_FLASH_TYPE_E type, TUYA_FLASH_BASE_INFO_T* info);
Functionalityโ
Obtains information for a specified Flash type.
Parametersโ
type: The Flash type for which to query information.info: Pointer to a structure where Flash information will be stored, typically the layout of a storage type in Flash.
Return Valueโ
OPRT_OK: Information successfully obtained.- Other error codes: Please refer to
tuya_error_code.h.
Notesโ
TUYA_FLASH_TYPE_Eis an enumeration for Flash types.TUYA_FLASH_BASE_INFO_Tis a structure for Flash information.