Common IO - basic v1.0.0
Common IO - basic v1.0.0 Library
 
Loading...
Searching...
No Matches
iot_flash.h
Go to the documentation of this file.
1/*
2 * Common IO - basic V1.0.0
3 * Copyright (C) 2020 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a copy of
6 * this software and associated documentation files (the "Software"), to deal in
7 * the Software without restriction, including without limitation the rights to
8 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9 * the Software, and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included in all
13 * copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
17 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
18 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
19 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 *
22 * http://aws.amazon.com/freertos
23 * http://www.FreeRTOS.org
24 */
25
31#ifndef _IOT_FLASH_H_
32#define _IOT_FLASH_H_
33
42#define IOT_FLASH_SUCCESS ( 0 )
43#define IOT_FLASH_INVALID_VALUE ( 1 )
44#define IOT_FLASH_WRITE_FAILED ( 2 )
45#define IOT_FLASH_READ_FAILED ( 3 )
46#define IOT_FLASH_ERASE_FAILED ( 4 )
47#define IOT_FLASH_DEVICE_BUSY ( 5 )
48#define IOT_FLASH_CTRL_OP_FAILED ( 6 )
49#define IOT_FLASH_FUNCTION_NOT_SUPPORTED ( 7 )
54typedef enum
55{
60 eFlashEraseSuspended /*<! Flash erase operation suspended. */
62
66typedef enum
67{
73
77typedef enum
78{
82
86typedef struct IotFlashInfo
87{
88 uint32_t ulFlashSize;
89 uint32_t ulBlockSize;
90 uint32_t ulSectorSize;
91 uint32_t ulPageSize;
97 uint32_t ulFlashID;
99
103typedef struct IotFlashWriteProtectConfig
104{
105 uint32_t ulAddress;
106 uint32_t ulSize;
109
113typedef enum IotFlashIoctlRequest
114{
127
131struct IotFlashDescriptor;
132
138typedef struct IotFlashDescriptor * IotFlashHandle_t;
139
153 void * pvUserContext );
154
170IotFlashHandle_t iot_flash_open( int32_t lFlashInstance );
171
184
207void iot_flash_set_callback( IotFlashHandle_t const pxFlashHandle,
208 IotFlashCallback_t xCallback,
209 void * pvUserContext );
210
229int32_t iot_flash_ioctl( IotFlashHandle_t const pxFlashHandle,
230 IotFlashIoctlRequest_t xRequest,
231 void * const pvBuffer );
232
294int32_t iot_flash_erase_sectors( IotFlashHandle_t const pxFlashHandle,
295 uint32_t ulStartAddress,
296 size_t xSize );
297
311int32_t iot_flash_erase_chip( IotFlashHandle_t const pxFlashHandle );
312
334int32_t iot_flash_write_sync( IotFlashHandle_t const pxFlashHandle,
335 uint32_t ulAddress,
336 uint8_t * const pvBuffer,
337 size_t xBytes );
338
356int32_t iot_flash_read_sync( IotFlashHandle_t const pxFlashHandle,
357 uint32_t ulAddress,
358 uint8_t * const pvBuffer,
359 size_t xBytes );
360
385int32_t iot_flash_write_async( IotFlashHandle_t const pxFlashHandle,
386 uint32_t ulAddress,
387 uint8_t * const pvBuffer,
388 size_t xBytes );
389
413int32_t iot_flash_read_async( IotFlashHandle_t const pxFlashHandle,
414 uint32_t ulAddress,
415 uint8_t * const pvBuffer,
416 size_t xBytes );
417
430int32_t iot_flash_close( IotFlashHandle_t const pxFlashHandle );
431
436#endif /* ifndef _IOT_FLASH_H_ */
#define IOT_FLASH_ERASE_FAILED
Definition: iot_flash.h:46
#define IOT_FLASH_SUCCESS
Return values used by this driver.
Definition: iot_flash.h:42
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...
IotFlashIoctlRequest_t
Ioctl request types.
Definition: iot_flash.h:114
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....
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 ca...
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 fla...
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_ca...
Definition: iot_flash.h:152
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...
#define IOT_FLASH_READ_FAILED
Definition: iot_flash.h:45
IotFlashInfo_t * iot_flash_getinfo(IotFlashHandle_t const pxFlashHandle)
iot_flash_getinfo is used to get the information about the physical flash device.
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 ...
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 prog...
#define IOT_FLASH_WRITE_FAILED
Definition: iot_flash.h:44
struct IotFlashDescriptor * IotFlashHandle_t
IotFlashHandle_t type is the flash handle returned by calling iot_flash_open() this is initialized in...
Definition: iot_flash.h:138
IotFlashStatus_t
Flash current status.
Definition: iot_flash.h:55
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...
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....
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) operatio...
IotFlashOperationStatus_t
Flash driver last operation status.
Definition: iot_flash.h:67
IotFlashWriteProtect_t
Flash sector protection type.
Definition: iot_flash.h:78
@ eSetFlashBlockProtection
Definition: iot_flash.h:115
@ eGetFlashBlockProtection
Definition: iot_flash.h:116
@ eResumeFlashProgramErase
Definition: iot_flash.h:121
@ eGetFlashStatus
Definition: iot_flash.h:123
@ eGetFlashRxNoOfbytes
Definition: iot_flash.h:125
@ eGetFlashTxNoOfbytes
Definition: iot_flash.h:124
@ eSuspendFlashProgramErase
Definition: iot_flash.h:118
@ eFlashCmdInProgress
Definition: iot_flash.h:57
@ eFlashIdle
Definition: iot_flash.h:56
@ eFlashProgramSuspended
Definition: iot_flash.h:59
@ eFlashEraseFailed
Definition: iot_flash.h:58
@ eFlashLastWriteFailed
Definition: iot_flash.h:71
@ eFlashCompleted
Definition: iot_flash.h:68
@ eFlashLastReadFailed
Definition: iot_flash.h:70
@ eFlashLastEraseFailed
Definition: iot_flash.h:69
@ eFlashReadOnly
Definition: iot_flash.h:80
@ eFlashReadWrite
Definition: iot_flash.h:79
flash information
Definition: iot_flash.h:87
uint8_t ucAsyncSupported
Definition: iot_flash.h:95
uint32_t ulLockSupportSize
Definition: iot_flash.h:92
uint32_t ulFlashID
Definition: iot_flash.h:97
uint32_t ulFlashSize
Definition: iot_flash.h:88
uint32_t ulBlockSize
Definition: iot_flash.h:89
uint32_t ulPageSize
Definition: iot_flash.h:91
uint32_t ulSectorSize
Definition: iot_flash.h:90
Flash protection configuration.
Definition: iot_flash.h:104
IotFlashWriteProtect_t xProtectionLevel
Definition: iot_flash.h:107
uint32_t ulAddress
Definition: iot_flash.h:105
uint32_t ulSize
Definition: iot_flash.h:106