ChibiOS  0.0.0
Collaboration diagram for M25Q:

Detailed Description

Macros

#define _m25q_methods   _jesd216_flash_methods
 M25Q specific methods. More...
 

Version identification

#define EX_M25Q_VERSION   "1.0.0"
 M25Q driver version string. More...
 
#define EX_M25Q_MAJOR   1
 M25Q driver version major number. More...
 
#define EX_M25Q_MINOR   0
 M25Q driver version minor number. More...
 
#define EX_M25Q_PATCH   0
 M25Q driver version patch number. More...
 

Command codes

#define M25Q_CMD_RESET_ENABLE   0x66
 
#define M25Q_CMD_RESET_MEMORY   0x99
 
#define M25Q_CMD_READ_ID   0x9F
 
#define M25Q_CMD_MULTIPLE_IO_READ_ID   0xAF
 
#define M25Q_CMD_READ_DISCOVERY_PARAMETER   0x5A
 
#define M25Q_CMD_READ   0x03
 
#define M25Q_CMD_FAST_READ   0x0B
 
#define M25Q_CMD_WRITE_ENABLE   0x06
 
#define M25Q_CMD_WRITE_DISABLE   0x04
 
#define M25Q_CMD_READ_STATUS_REGISTER   0x05
 
#define M25Q_CMD_WRITE_STATUS_REGISTER   0x01
 
#define M25Q_CMD_READ_LOCK_REGISTER   0xE8
 
#define M25Q_CMD_WRITE_LOCK_REGISTER   0xE5
 
#define M25Q_CMD_READ_FLAG_STATUS_REGISTER   0x70
 
#define M25Q_CMD_CLEAR_FLAG_STATUS_REGISTER   0x50
 
#define M25Q_CMD_READ_NV_CONFIGURATION_REGISTER   0xB5
 
#define M25Q_CMD_WRITE_NV_CONFIGURATION_REGISTER   0xB1
 
#define M25Q_CMD_READ_V_CONF_REGISTER   0x85
 
#define M25Q_CMD_WRITE_V_CONF_REGISTER   0x81
 
#define M25Q_CMD_READ_ENHANCED_V_CONF_REGISTER   0x65
 
#define M25Q_CMD_WRITE_ENHANCED_V_CONF_REGISTER   0x61
 
#define M25Q_CMD_PAGE_PROGRAM   0x02
 
#define M25Q_CMD_SUBSECTOR_ERASE   0x20
 
#define M25Q_CMD_SECTOR_ERASE   0xD8
 
#define M25Q_CMD_BULK_ERASE   0xC7
 
#define M25Q_CMD_PROGRAM_ERASE_RESUME   0x7A
 
#define M25Q_CMD_PROGRAM_ERASE_SUSPEND   0x75
 
#define M25Q_CMD_READ_OTP_ARRAY   0x4B
 
#define M25Q_CMD_PROGRAM_OTP_ARRAY   0x42
 

Flags status register bits

#define M25Q_FLAGS_PROGRAM_ERASE   0x80U
 
#define M25Q_FLAGS_ERASE_SUSPEND   0x40U
 
#define M25Q_FLAGS_ERASE_ERROR   0x20U
 
#define M25Q_FLAGS_PROGRAM_ERROR   0x10U
 
#define M25Q_FLAGS_VPP_ERROR   0x08U
 
#define M25Q_FLAGS_PROGRAM_SUSPEND   0x04U
 
#define M25Q_FLAGS_PROTECTION_ERROR   0x02U
 
#define M25Q_FLAGS_RESERVED   0x01U
 
#define M25Q_FLAGS_ALL_ERRORS
 

Configuration options

#define M25Q_READ_DUMMY_CYCLES   8
 Number of dummy cycles for fast read (1..15). More...
 
#define M25Q_SWITCH_WIDTH   TRUE
 Switch QSPI bus width on initialization. More...
 
#define M25Q_NICE_WAITING   TRUE
 Delays insertions. More...
 
#define M25Q_USE_SUB_SECTORS   FALSE
 Uses 4kB sub-sectors rather than 64kB sectors. More...
 
#define M25Q_SUPPORTED_MANUFACTURE_IDS   {0x20}
 Supported JEDEC manufacturer identifiers. More...
 
#define M25Q_SUPPORTED_MEMORY_TYPE_IDS   {0xBA, 0xBB}
 Supported memory type identifiers. More...
 
#define M25Q_COMPARE_BUFFER_SIZE   32
 Size of the compare buffer. More...
 

Data Structures

struct  M25QConfig
 Type of a M25Q configuration structure. More...
 
struct  M25QDriverVMT
 M25Q virtual methods table. More...
 
struct  M25QDriver
 Type of M25Q flash class. More...
 

Functions

void m25qObjectInit (M25QDriver *devp)
 Initializes an instance. More...
 
void m25qStart (M25QDriver *devp, const M25QConfig *config)
 Configures and activates N25Q128 driver. More...
 
void m25qStop (M25QDriver *devp)
 Deactivates the N25Q128 driver. More...
 
void m25qMemoryMap (M25QDriver *devp, uint8_t **addrp)
 Enters the memory Mapping mode. More...
 
void m25qMemoryUnmap (M25QDriver *devp)
 Leaves the memory Mapping mode. More...
 

Variables

static const struct M25QDriverVMT m25q_vmt
 Virtual methods table. More...
 
static flash_descriptor_t m25q_descriptor
 N25Q128 descriptor. More...
 

Macro Definition Documentation

#define EX_M25Q_VERSION   "1.0.0"

M25Q driver version string.

Definition at line 45 of file m25q.h.

#define EX_M25Q_MAJOR   1

M25Q driver version major number.

Definition at line 50 of file m25q.h.

#define EX_M25Q_MINOR   0

M25Q driver version minor number.

Definition at line 55 of file m25q.h.

#define EX_M25Q_PATCH   0

M25Q driver version patch number.

Definition at line 60 of file m25q.h.

#define M25Q_READ_DUMMY_CYCLES   8

Number of dummy cycles for fast read (1..15).

This is the number of dummy cycles to be used for fast read operations.

Definition at line 130 of file m25q.h.

Referenced by m25qMemoryMap(), and m25qStart().

#define M25Q_SWITCH_WIDTH   TRUE

Switch QSPI bus width on initialization.

A bus width initialization is performed by writing the Enhanced Volatile Configuration Register. If the flash device is configured using the Non Volatile Configuration Register then this option is not required.

Note
This option is only valid in QSPI bus modes.

Definition at line 142 of file m25q.h.

#define M25Q_NICE_WAITING   TRUE

Delays insertions.

If enabled this options inserts delays into the flash waiting routines releasing some extra CPU time for threads with lower priority, this may slow down the driver a bit however.

Definition at line 152 of file m25q.h.

#define M25Q_USE_SUB_SECTORS   FALSE

Uses 4kB sub-sectors rather than 64kB sectors.

Definition at line 159 of file m25q.h.

#define M25Q_SUPPORTED_MANUFACTURE_IDS   {0x20}

Supported JEDEC manufacturer identifiers.

Definition at line 166 of file m25q.h.

#define M25Q_SUPPORTED_MEMORY_TYPE_IDS   {0xBA, 0xBB}

Supported memory type identifiers.

Definition at line 173 of file m25q.h.

#define M25Q_COMPARE_BUFFER_SIZE   32

Size of the compare buffer.

This buffer is allocated in the stack frame of the function flashVerifyErase() and its size must be a power of two. Larger buffers lead to better verify performance but increase stack usage for that function.

Definition at line 184 of file m25q.h.

#define _m25q_methods   _jesd216_flash_methods

M25Q specific methods.

Definition at line 214 of file m25q.h.

Function Documentation

void m25qObjectInit ( M25QDriver devp)

Initializes an instance.

Parameters
[out]devppointer to the M25QDriver object
Function Class:Initializer, this function just initializes an object and can be invoked before the kernel is initialized.

Definition at line 627 of file m25q.c.

References M25QDriver::config, m25q_vmt, osalDbgCheck, and M25QDriver::vmt.

void m25qStart ( M25QDriver devp,
const M25QConfig config 
)

Configures and activates N25Q128 driver.

Parameters
[in]devppointer to the M25QDriver object
[in]configpointer to the configuration
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 644 of file m25q.c.

References M25QDriver::config, M25QDriver::device_id, M25Q_READ_DUMMY_CYCLES, osalDbgAssert, osalDbgCheck, qspiCommand(), qspiReceive(), qspiSend(), and flash_descriptor_t::sectors_count.

Here is the call graph for this function:

void m25qStop ( M25QDriver devp)

Deactivates the N25Q128 driver.

Parameters
[in]devppointer to the M25QDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 735 of file m25q.c.

References M25QDriver::config, osalDbgAssert, and osalDbgCheck.

void m25qMemoryMap ( M25QDriver devp,
uint8_t **  addrp 
)

Enters the memory Mapping mode.

The memory mapping mode is only available when the QSPI mode is selected and the underlying QSPI controller supports the feature.

Parameters
[in]devppointer to the M25QDriver object
[out]addrppointer to the memory start address of the mapped flash or NULL
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 773 of file m25q.c.

References M25QDriver::config, M25Q_READ_DUMMY_CYCLES, and qspiMapFlash().

Here is the call graph for this function:

void m25qMemoryUnmap ( M25QDriver devp)

Leaves the memory Mapping mode.

Parameters
[in]devppointer to the M25QDriver object
Function Class:Normal API, this function can be invoked by regular system threads but not from within a lock zone.

Definition at line 821 of file m25q.c.

References M25QDriver::config, and qspiUnmapFlash().

Here is the call graph for this function:

Variable Documentation

const struct M25QDriverVMT m25q_vmt
static
Initial value:
= {
(size_t)0,
m25q_get_descriptor, m25q_read, m25q_program,
m25q_start_erase_all, m25q_start_erase_sector,
m25q_query_erase, m25q_verify_erase,
m25q_read_sfdp
}

Virtual methods table.

Definition at line 73 of file m25q.c.

Referenced by m25qObjectInit().

flash_descriptor_t m25q_descriptor
static
Initial value:
= {
.attributes = FLASH_ATTR_ERASED_IS_ONE | FLASH_ATTR_REWRITABLE |
FLASH_ATTR_SUSPEND_ERASE_CAPABLE,
.page_size = 256U,
.sectors_count = 0U,
.sectors = NULL,
.sectors_size = SECTOR_SIZE,
.address = 0U
}

N25Q128 descriptor.

Definition at line 84 of file m25q.c.