CMSIS Driver  Version 1.10 - Preliminary
Middleware Driver API for microcontroller peripherals
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
NOR Interface

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.
 

Description

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.

NOR Structure

 

NOR_Schematics.png
Simplified NOR Flash Schematic

 

NOR API

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.

Driver Functions

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:


Data Structure Documentation

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:

  • ARM_DRIVER_NOR0 is the name of the access struct of the first instance (no. 0).
  • ARM_DRIVER_NOR1 is the name of the access struct of the second instance (no. 1).

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.
 

Field Documentation

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.

  • 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.

Parameter for:

Data Fields
uint32_t end Sector End address (start+size-4)
uint32_t start Sector Start address.

Enumeration Type Documentation

NOR Flash Status of executed operation.

Defines status and error codes returned by most of the NOR driver functions.

Returned by:

Enumerator:
ARM_NOR_OK 

Operation succeeded.

ARM_NOR_ERROR 

Unspecified error.

Function Documentation

ARM_NOR_STATUS ARM_NOR_EraseChip ( void  )

Erase complete NOR Flash. Optional function for faster full chip erase.

Returns
execution status ARM_NOR_STATUS

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.

Parameters
[in]addrSector address
Returns
execution status ARM_NOR_STATUS

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
ARM_DRV_VERSION

Returns version information of the driver implementation in ARM_DRV_VERSION

  • API version is the version of the CMSIS-Driver specification used to implement this driver.
  • Driver version is source code version of the actual driver implementation.

Example:

extern ARM_DRIVER_NOR ARM_Driver_NOR0;
ARM_DRIVER_NOR *drv_info;
void read_version (void) {
ARM_DRV_VERSION version;
drv_info = &ARM_Driver_NOR0;
version = drv_info->GetVersion ();
if (version.api < 0x10A) { // requires at minimum API version 1.10 or higher
// error handling
return;
}
}
ARM_NOR_STATUS ARM_NOR_Initialize ( uint32_t  base_addr)

Initialize NOR Flash interface.

Parameters
[in]base_addrDevice base address
Returns
execution status ARM_NOR_STATUS

The function initializes the NOR interface. It is called when the middleware component starts operation.

The function performs the following operations:

  • Initializes the resources needed for the NOR interface.
  • Sets the peripheral to ARM_POWER_LOW power mode.

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.

Parameters
[in]statePower state
Returns
execution status ARM_NOR_STATUS

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.

Parameters
[in]addrStarting data address. Must be 4-byte aligned.
[out]dataPointer to buffer storing the data read from NOR Flash.
[in]sizeNumber of bytes to read. Must be a multiple of 4.
Returns
execution status ARM_NOR_STATUS

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.

Returns
execution status ARM_NOR_STATUS

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.

Parameters
[in]addrData address.
[in]dataPointer to a buffer containing the data to be written to NOR Flash. Must be a multiple of 4.
[in]sizeNumber of bytes to be written. Must be 4-byte-aligned.
Returns
execution status ARM_NOR_STATUS

Write data to NOR Flash.