FreeRTOS: Common I/O
AWS IoT Common I/O library
Return to main page ↑
iot_flash.h File Reference

This file contains all the Flash HAL API definitions. More...

Go to the source code of this file.

Data Structures

struct  IotFlashInfo_t
 flash information More...
 
struct  IotFlashWriteProtectConfig_t
 Flash protection configuration. More...
 

Macros

#define IOT_FLASH_SUCCESS   ( 0 )
 Return values used by this driver. More...
 
#define IOT_FLASH_INVALID_VALUE   ( 1 )
 
#define IOT_FLASH_WRITE_FAILED   ( 2 )
 
#define IOT_FLASH_READ_FAILED   ( 3 )
 
#define IOT_FLASH_ERASE_FAILED   ( 4 )
 
#define IOT_FLASH_DEVICE_BUSY   ( 5 )
 
#define IOT_FLASH_CTRL_OP_FAILED   ( 6 )
 
#define IOT_FLASH_FUNCTION_NOT_SUPPORTED   ( 7 )
 

Typedefs

typedef struct IotFlashDescriptor * IotFlashHandle_t
 IotFlashHandle_t type is the flash handle returned by calling iot_flash_open() this is initialized in open and returned to caller. Caller must pass this pointer to the rest of the APIs.
 
typedef void(* IotFlashCallback_t) (IotFlashOperationStatus_t xStatus, void *pvUserContext)
 Flash notification callback type. This callback can be passed to the driver by using iot_flash_set_callback API (the callback is used only if flash supports asynchronous operations, which can be checked from flashInfo.ucAsyncSupported value. More...
 

Enumerations

enum  IotFlashStatus_t {
  eFlashIdle, eFlashCmdInProgress, eFlashEraseFailed, eFlashProgramSuspended,
  eFlashEraseSuspended
}
 Flash current status. More...
 
enum  IotFlashOperationStatus_t { eFlashCompleted = IOT_FLASH_SUCCESS, eFlashLastEraseFailed = IOT_FLASH_ERASE_FAILED, eFlashLastReadFailed = IOT_FLASH_READ_FAILED, eFlashLastWriteFailed = IOT_FLASH_WRITE_FAILED }
 Flash driver last operation status. More...
 
enum  IotFlashWriteProtect_t { eFlashReadWrite, eFlashReadOnly }
 Flash sector protection type. More...
 
enum  IotFlashIoctlRequest_t {
  eSetFlashBlockProtection, eGetFlashBlockProtection, eSuspendFlashProgramErase, eResumeFlashProgramErase,
  eGetFlashStatus, eGetFlashTxNoOfbytes, eGetFlashRxNoOfbytes
}
 Ioctl request types. More...
 

Functions

IotFlashHandle_t iot_flash_open (int32_t lFlashInstance)
 iot_flash_open is used to initialize the flash device. This must be called before using any other flash APIs. This function Initializes the peripheral, configures buses etc. More...
 
IotFlashInfo_tiot_flash_getinfo (IotFlashHandle_t const pxFlashHandle)
 iot_flash_getinfo is used to get the information about the physical flash device. More...
 
void iot_flash_set_callback (IotFlashHandle_t const pxFlashHandle, IotFlashCallback_t xCallback, void *pvUserContext)
 iot_flash_set_callback is used to set the callback to be called upon completion of erase/program/read. The callback is used only if the underlying HW supports asynchronous operations. Caller can check if asynchronous operations are supported by checking the "ucAsyncSupported" flag in IotFlashInfo_t structure. If asynchronous operations are not supported, then erase/write/read operations are blocking operations, and this API has no affect, i.e even if a callback is set, it will never be called back. More...
 
int32_t iot_flash_ioctl (IotFlashHandle_t const pxFlashHandle, IotFlashIoctlRequest_t xRequest, void *const pvBuffer)
 iot_flash_ioctl is used to configure the flash parameters and setup certain flash operations and also used to read flash info and configuration. More...
 
int32_t iot_flash_erase_sectors (IotFlashHandle_t const pxFlashHandle, uint32_t ulStartAddress, size_t xSize)
 iot_flash_erase_sectors is used to erase data in flash from the start of the address specified until the startAddress plus size passed. The address passed in 'ulAddress' must be aligned to ulSectorSize, and size must be a multiple of ulSectorSize. If there is another flash operation is in progress, the erase_sectors API will return an error and this usually happens if flash supports asynchronous erase/write/read operations. More...
 
int32_t iot_flash_erase_chip (IotFlashHandle_t const pxFlashHandle)
 iot_erase_chip is used to erase the entire flash chip. If there is another flash operation is in progress, the erase_chip API will return an error. More...
 
int32_t iot_flash_write_sync (IotFlashHandle_t const pxFlashHandle, uint32_t ulAddress, uint8_t *const pvBuffer, size_t xBytes)
 iot_flash_write_sync is used to write data to flash starting at the address provided. The sector(s) being written to, must be erased first before any write can take place. This is a blocking operation and waits until the number of bytes are written before returning. If there is another flash operation is in progress, write will return an error. More...
 
int32_t iot_flash_read_sync (IotFlashHandle_t const pxFlashHandle, uint32_t ulAddress, uint8_t *const pvBuffer, size_t xBytes)
 iot_flash_read_sync is used to read data from flash. This is a blocking operation and waits until the number of bytes are read before returning. If there is another flash operation is in progress, this will return an error. More...
 
int32_t iot_flash_write_async (IotFlashHandle_t const pxFlashHandle, uint32_t ulAddress, uint8_t *const pvBuffer, size_t xBytes)
 iot_flash_write_async is used to write data to flash starting at the address provided. The sector(s) being written to, must be erased first before any write can take place. This is an asynchronous (non-blocking) operation and returns as soon as the write operation is started. When the write is completed, user callback is called to notify that the write is complete. The caller can check the status of the operation by using eGetStatus IOCTL. User must register for a callback when using the non-blocking operations to know when they are complete. If there is another flash operation is in progress, write will return an error. More...
 
int32_t iot_flash_read_async (IotFlashHandle_t const pxFlashHandle, uint32_t ulAddress, uint8_t *const pvBuffer, size_t xBytes)
 iot_flash_read_async is used to read data from flash. This is an asynchronous (non-blocking) operation and returns as soon as the read operation is started. When the read is completed, user callback is called to notify that the read is complete. The caller can check the status of the operation by using eGetStatus IOCTL and use the buffer. User must register for a callback when using the non-blocking operations to know when they are complete. If there is another flash operation is in progress, this will return an error. More...
 
int32_t iot_flash_close (IotFlashHandle_t const pxFlashHandle)
 iot_flash_close is used to close the flash device. If any operations are in progress when close is called, flash driver aborts those if possible. More...
 

Detailed Description

This file contains all the Flash HAL API definitions.