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_E
is an enumeration for Flash types.TUYA_FLASH_BASE_INFO_T
is a structure for Flash information.