![]() |
CMSIS Driver
Version 1.10 - Preliminary
Middleware Driver API for microcontroller peripherals
|
Driver API for NOR Flash Device Interface (Driver_NOR.h) More...
Data Structures | |
struct | ARM_DRIVER_NOR |
Access structure of the NOR Flash Driver. More... | |
struct | ARM_NOR_DEVICE |
NOR Flash Device information. More... | |
struct | ARM_NOR_SECTOR |
NOR Flash Sector information. More... | |
Enumerations | |
enum | ARM_NOR_STATUS { ARM_NOR_OK = 0, ARM_NOR_ERROR = 1 } |
NOR Flash Status of executed operation. More... | |
Functions | |
ARM_DRV_VERSION | ARM_NOR_GetVersion (void) |
Get driver version. | |
ARM_NOR_STATUS | ARM_NOR_Initialize (uint32_t base_addr) |
Initialize NOR Flash interface. | |
ARM_NOR_STATUS | ARM_NOR_Uninitialize (void) |
Deinitialize NOR Flash interface. | |
ARM_NOR_STATUS | ARM_NOR_PowerControl (ARM_POWER_STATE state) |
Control NOR Flash interface power. | |
ARM_NOR_STATUS | ARM_NOR_ReadData (uint32_t addr, uint8_t *data, uint32_t size) |
Read data from NOR Flash. Optional function. Used for non-memory-mapped devices. | |
ARM_NOR_STATUS | ARM_NOR_WriteData (uint32_t addr, const uint8_t *data, uint32_t size) |
Write data to NOR Flash device. | |
ARM_NOR_STATUS | ARM_NOR_EraseSector (uint32_t addr) |
Erase NOR Flash Sector. | |
ARM_NOR_STATUS | ARM_NOR_EraseChip (void) |
Erase complete NOR Flash. Optional function for faster full chip erase. | |
Driver API for NOR Flash Device Interface (Driver_NOR.h)
NOR Flash is the preferred technology for embedded applications requiring a discrete non-volatile memory device. The low read latency characteristic of NOR devices allow direct code execution and to sore data in a single memory product. Wikipedia offers more information about the Flash Memories, including NOR.
The following header files define the Application Programming Interface (API) for the NOR interface:
The driver implementation is a typical part of the Device Family Pack (DFP) that supports the peripherals of the microcontroller family.
The driver functions are published in the access struct as explained in Driver Functions
A typical setup sequence for the driver is shown below:
Example Code:
struct ARM_DRIVER_NOR |
Access structure of the NOR Flash Driver.
The functions of the NOR Flash driver are accessed by function pointers exposed by this structure. Refer to Driver Functions for overview information.
Each instance of a NOR interface provides such an access structure. The instance is identified by a postfix number in the symbol name of the access structure, for example:
A middleware configuration setting allows connecting the middleware to a specific driver instance ARM_DRIVER_NORn. The default is 0, which connects a middleware to the first instance of a driver.
Data Fields | |
ARM_DRV_VERSION(* | GetVersion )(void) |
Pointer to ARM_NOR_GetVersion : Get driver version. | |
ARM_NOR_STATUS(* | Initialize )(uint32_t base_addr) |
Pointer to ARM_NOR_Initialize : Initialize NOR Flash Interface. | |
ARM_NOR_STATUS(* | Uninitialize )(void) |
Pointer to ARM_NOR_Uninitialize : De-initialize NOR Flash Interface. | |
ARM_NOR_STATUS(* | PowerControl )(ARM_POWER_STATE state) |
Pointer to ARM_NOR_PowerControl : Control NOR Flash Interface Power. | |
ARM_NOR_STATUS(* | ReadData )(uint32_t addr, uint8_t *data, uint32_t size) |
Pointer to ARM_NOR_ReadData : Read data from NOR Flash. Optional, NULL for parallel memory-mapped devices. | |
ARM_NOR_STATUS(* | WriteData )(uint32_t addr, const uint8_t *data, uint32_t size) |
Pointer to ARM_NOR_WriteData : Write data to NOR Flash. | |
ARM_NOR_STATUS(* | EraseSector )(uint32_t addr) |
Pointer to ARM_NOR_EraseSector : Erase NOR Flash Sector. | |
ARM_NOR_STATUS(* | EraseChip )(void) |
Pointer to ARM_NOR_EraseChip : Erase complete NOR Flash. Optional function. | |
ARM_NOR_STATUS(* EraseChip)(void) |
Pointer to ARM_NOR_EraseChip : Erase complete NOR Flash. Optional function.
ARM_NOR_STATUS(* EraseSector)(uint32_t addr) |
Pointer to ARM_NOR_EraseSector : Erase NOR Flash Sector.
ARM_DRV_VERSION(* GetVersion)(void) |
Pointer to ARM_NOR_GetVersion : Get driver version.
ARM_NOR_STATUS(* Initialize)(uint32_t base_addr) |
Pointer to ARM_NOR_Initialize : Initialize NOR Flash Interface.
ARM_NOR_STATUS(* PowerControl)(ARM_POWER_STATE state) |
Pointer to ARM_NOR_PowerControl : Control NOR Flash Interface Power.
ARM_NOR_STATUS(* ReadData)(uint32_t addr, uint8_t *data, uint32_t size) |
Pointer to ARM_NOR_ReadData : Read data from NOR Flash. Optional, NULL for parallel memory-mapped devices.
ARM_NOR_STATUS(* Uninitialize)(void) |
Pointer to ARM_NOR_Uninitialize : De-initialize NOR Flash Interface.
ARM_NOR_STATUS(* WriteData)(uint32_t addr, const uint8_t *data, uint32_t size) |
Pointer to ARM_NOR_WriteData : Write data to NOR Flash.
struct ARM_NOR_DEVICE |
NOR Flash Device information.
Stores the characteristics of a NOR Flash device. This includes sector start and end address, number of sectors, device size, and a default value for erased memory. This information is used by the middleware in order to properly interact with the NOR Flash Driver.
Data Fields | ||
---|---|---|
uint8_t | erased_value | Contents of erased memory. In most cases, this value is set to 0xFF. Accepted values are 0xFF or 0x00. |
uint32_t | sector_count | Number of sectors. |
ARM_NOR_SECTOR * | sector_info |
Sector layout. Copy flash sector layout information from Flash device datasheet. - Flash sectors must not be aligned continuously. Gaps are allowed in the device memory space. - Flash sectors can be reserved for application code. Do not include such sectors in the description table. |
uint32_t | size | Device size in bytes, typically hole size of the flash device. It is allowed to specify only a part of the device to be used for storage. The rest of the device can be used for the application code. In this case, replace EraseChip in the driver control block ARM_DRIVER_NOR with NULL. |
struct ARM_NOR_SECTOR |
NOR Flash Sector information.
Stores the sector layout information for a NOR Flash device. Copy the Flash sector layout information from Flash the device datasheet.
Parameter for:
Data Fields | ||
---|---|---|
uint32_t | end | Sector End address (start+size-4) |
uint32_t | start | Sector Start address. |
enum ARM_NOR_STATUS |
NOR Flash Status of executed operation.
Defines status and error codes returned by most of the NOR driver functions.
Returned by:
ARM_NOR_STATUS ARM_NOR_EraseChip | ( | void | ) |
Erase complete NOR Flash. Optional function for faster full chip erase.
This optional function erases the complete device. If the device does not support global erase or only a portion of the Flash memory space is used for storing files, then the value for this function should be set to NULL
in the driver control block ARM_DRIVER_NOR. Developers must customize this function.
ARM_NOR_STATUS ARM_NOR_EraseSector | ( | uint32_t | addr | ) |
Erase NOR Flash Sector.
[in] | addr | Sector address |
The function erases a flash sector specified by the parameter adr. Developers must customize this function.
DRV_VERSION ARM_NOR_GetVersion | ( | void | ) |
Get driver version.
Returns version information of the driver implementation in ARM_DRV_VERSION
Example:
ARM_NOR_STATUS ARM_NOR_Initialize | ( | uint32_t | base_addr | ) |
Initialize NOR Flash interface.
[in] | base_addr | Device base address |
The function initializes the NOR interface. It is called when the middleware component starts operation.
The function performs the following operations:
The parameter base_addr is the device base address in the memory map.
Example:
ARM_NOR_STATUS ARM_NOR_PowerControl | ( | ARM_POWER_STATE | state | ) |
Control NOR Flash interface power.
[in] | state | Power state |
Control NOR Flash Interface Power.
ARM_NOR_STATUS ARM_NOR_ReadData | ( | uint32_t | addr, |
uint8_t * | data, | ||
uint32_t | size | ||
) |
Read data from NOR Flash. Optional function. Used for non-memory-mapped devices.
[in] | addr | Starting data address. Must be 4-byte aligned. |
[out] | data | Pointer to buffer storing the data read from NOR Flash. |
[in] | size | Number of bytes to read. Must be a multiple of 4. |
Read data from NOR Flash. The function is used for non-memory mapped devices. For parallel memory-mapped devices, enter NULL
in the driver control block ARM_DRIVER_NOR. Then the internal function memcpy reads the data. Developers must customize this function.
ARM_NOR_STATUS ARM_NOR_Uninitialize | ( | void | ) |
Deinitialize NOR Flash interface.
The function ARM_NOR_Uninitialize de-initializes the resources of NOR interface and sets the peripheral to ARM_POWER_OFF power mode.
It is called when the middleware component stops operation and releases the software resources used by the interface.
ARM_NOR_STATUS ARM_NOR_WriteData | ( | uint32_t | addr, |
const uint8_t * | data, | ||
uint32_t | size | ||
) |
Write data to NOR Flash device.
[in] | addr | Data address. |
[in] | data | Pointer to a buffer containing the data to be written to NOR Flash. Must be a multiple of 4. |
[in] | size | Number of bytes to be written. Must be 4-byte-aligned. |
Write data to NOR Flash.