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.