This file defines the flash interface used by settings.cpp.
More...
#include <stdint.h>
#include "ca821x_api.h"
Go to the source code of this file.
|
ca_error | utilsFlashInit (struct ca821x_dev *aInstance, const char *aApplicationName, uint32_t aNodeId) |
| Perform any initialization for flash driver. More...
|
|
ca_error | utilsFlashDeinit (struct ca821x_dev *aInstance) |
| Deinitialize the flash driver. More...
|
|
uint32_t | utilsFlashGetSize (struct ca821x_dev *aInstance) |
| Get the size of flash that can be read/write by the caller. More...
|
|
ca_error | utilsFlashErasePage (struct ca821x_dev *aInstance, uint32_t aAddress) |
| Erase one flash page that include the input address. More...
|
|
ca_error | utilsFlashStatusWait (struct ca821x_dev *aInstance, uint32_t aTimeout) |
| Check whether flash is ready or busy. More...
|
|
uint32_t | utilsFlashWrite (struct ca821x_dev *aInstance, uint32_t aAddress, const uint8_t *aData, uint32_t aSize) |
| Write flash. More...
|
|
uint32_t | utilsFlashRead (struct ca821x_dev *aInstance, uint32_t aAddress, uint8_t *aData, uint32_t aSize) |
| Read flash. More...
|
|
uint32_t | utilsFlashGetBaseAddress (struct ca821x_dev *aInstance) |
| Internal function for getting the base address. More...
|
|
uint32_t | utilsFlashGetUsedSize (struct ca821x_dev *aInstance) |
| Internal function for returning the amount of flash used. More...
|
|
void | utilsFlashSetBaseAddress (struct ca821x_dev *aInstance, uint32_t aAddress) |
| Internal function for setting the base address. More...
|
|
void | utilsFlashSetUsedSize (struct ca821x_dev *aInstance, uint32_t aSize) |
| Internal function for setting the amount of flash used. More...
|
|
This file defines the flash interface used by settings.cpp.
◆ utilsFlashDeinit()
Deinitialize the flash driver.
- Parameters
-
aInstance | Instance to deinitialize. Unused on baremetal. |
- Return values
-
CA_ERROR_SUCCESS | Initialize flash driver success. |
CA_ERROR_FAIL | Initialize flash driver fail. |
◆ utilsFlashErasePage()
Erase one flash page that include the input address.
This is a non-blocking function. It can work with utilsFlashStatusWait to check when erase is done.
The flash address starts from 0, and this function maps the input address to the physical address of flash for erasing. 0 is always mapped to the beginning of one flash page. The input address should never be mapped to the firmware space or any other protected flash space.
- Parameters
-
[in] | aInstance | API instance to initialize/whose storage to access. Unused on baremetal. |
[in] | aAddress | The start address of the flash to erase. |
- Return values
-
CA_ERROR_SUCCESS | Erase flash operation is started. |
CA_ERROR_FAIL | Erase flash operation is not started. |
CA_ERROR_INVALID_ARGS | aAddress is out of range of flash or not aligend. |
◆ utilsFlashGetBaseAddress()
uint32_t utilsFlashGetBaseAddress |
( |
struct ca821x_dev * |
aInstance | ) |
|
Internal function for getting the base address.
- Parameters
-
aInstance | The device to access |
- Returns
- uint32_t The base address
◆ utilsFlashGetSize()
uint32_t utilsFlashGetSize |
( |
struct ca821x_dev * |
aInstance | ) |
|
Get the size of flash that can be read/write by the caller.
The usable flash size is always the multiple of flash page size.
- Parameters
-
[in] | aInstance | API instance to initialize/whose storage to access. Unused on baremetal. |
- Returns
- The size of the flash.
◆ utilsFlashGetUsedSize()
uint32_t utilsFlashGetUsedSize |
( |
struct ca821x_dev * |
aInstance | ) |
|
Internal function for returning the amount of flash used.
- Parameters
-
aInstance | The device to access |
- Returns
- uint32_t How much flash is used starting from the base address
◆ utilsFlashInit()
ca_error utilsFlashInit |
( |
struct ca821x_dev * |
aInstance, |
|
|
const char * |
aApplicationName, |
|
|
uint32_t |
aNodeId |
|
) |
| |
Perform any initialization for flash driver.
- Parameters
-
[in] | aInstance | API instance to initialize/whose storage to access. Unused on baremetal. |
[in] | aApplicationName | Filename of the storage file, used to distinguish between storage applications. Unused on baremetal. |
[in] | aNodeId | Used to distinguish between different nodes on the same host. Unused on baremetal. |
- Return values
-
CA_ERROR_SUCCESS | Initialize flash driver success. |
CA_ERROR_FAIL | Initialize flash driver fail. |
◆ utilsFlashRead()
uint32_t utilsFlashRead |
( |
struct ca821x_dev * |
aInstance, |
|
|
uint32_t |
aAddress, |
|
|
uint8_t * |
aData, |
|
|
uint32_t |
aSize |
|
) |
| |
Read flash.
The flash address starts from 0, and this function maps the input address to the physical address of flash for reading. 0 is always mapped to the beginning of one flash page. The input address should never be mapped to the firmware space or any other protected flash space.
- Parameters
-
[in] | aInstance | API instance to initialize/whose storage to access. Unused on baremetal. |
[in] | aAddress | The start address of the flash to read. |
[out] | aData | The pointer of buffer for reading. |
[in] | aSize | The size of the data to read. |
- Returns
- The actual size of octets read to buffer. It is expected the same as aSize, and may be less than aSize. 0 indicates that something wrong happens when reading.
◆ utilsFlashSetBaseAddress()
void utilsFlashSetBaseAddress |
( |
struct ca821x_dev * |
aInstance, |
|
|
uint32_t |
aAddress |
|
) |
| |
Internal function for setting the base address.
- Parameters
-
aInstance | The device to access |
aAddress | The address |
◆ utilsFlashSetUsedSize()
void utilsFlashSetUsedSize |
( |
struct ca821x_dev * |
aInstance, |
|
|
uint32_t |
aSize |
|
) |
| |
Internal function for setting the amount of flash used.
- Parameters
-
aInstance | The device to access |
aSize | The size |
◆ utilsFlashStatusWait()
Check whether flash is ready or busy.
- Parameters
-
[in] | aInstance | API instance to initialize/whose storage to access. Unused on baremetal. |
[in] | aTimeout | The interval in milliseconds waiting for the flash operation to be done and become ready again. zero indicates that it is a polling function, and returns current status of flash immediately. non-zero indicates that it is blocking there until the operation is done and become ready, or timeout expires. |
- Return values
-
CA_ERROR_SUCCESS | Flash is ready for any operation. |
CA_ERROR_BUSY | Flash is busy. |
◆ utilsFlashWrite()
uint32_t utilsFlashWrite |
( |
struct ca821x_dev * |
aInstance, |
|
|
uint32_t |
aAddress, |
|
|
const uint8_t * |
aData, |
|
|
uint32_t |
aSize |
|
) |
| |
Write flash.
The write operation only clears bits, but never set bits.
The flash address starts from 0, and this function maps the input address to the physical address of flash for writing. 0 is always mapped to the beginning of one flash page. The input address should never be mapped to the firmware space or any other protected flash space.
- Parameters
-
[in] | aInstance | API instance to initialize/whose storage to access. Unused on baremetal. |
[in] | aAddress | The start address of the flash to write. |
[in] | aData | The pointer of the data to write. |
[in] | aSize | The size of the data to write. |
- Returns
- The actual size of octets write to flash. It is expected the same as aSize, and may be less than aSize. 0 indicates that something wrong happens when writing.