STM32 W25Qxx QuadSPI Driver  0.1a
https://github.com/Crazy-Geeks/STM32-W25Q-QSPI
Modules | Data Structures | Functions
W25Q_Driver

W25Q QSPI Driver. More...

Modules

 W25Q Chip's Parameters
 User's chip parameters.
 
 W25Q Chip's Commands
 W25Q Chip commands from datasheet.
 
 Exported types
 External fields and data.
 
 Private fields
 Private variables and defines.
 
 Private Methods
 Internal lib's functions.
 
 Public methods
 Public Methods.
 

Data Structures

struct  W25Q_STATUS_REG
 W25Q Status Registers @TODO: Mem protected recognition. More...
 

Functions

W25Q_STATE W25Q_Init (void)
 Initalize function. More...
 
W25Q_STATE W25Q_EnableVolatileSR (void)
 Make Status Register Volatile. More...
 
W25Q_STATE W25Q_ReadStatusReg (u8_t *reg_data, u8_t reg_num)
 Read status register to variable. More...
 
W25Q_STATE W25Q_WriteStatusReg (u8_t reg_data, u8_t reg_num)
 Write status register from variable. More...
 
W25Q_STATE W25Q_ReadStatusStruct (W25Q_STATUS_REG *status)
 Read all status registers to struct. More...
 
W25Q_STATE W25Q_IsBusy (void)
 Check chip's busy status. More...
 
W25Q_STATE W25Q_ReadSByte (i8_t *buf, u8_t pageShift, u32_t pageNum)
 Read signed 8-bit variable. More...
 
W25Q_STATE W25Q_ReadByte (u8_t *buf, u8_t pageShift, u32_t pageNum)
 Read 8-bit variable. More...
 
W25Q_STATE W25Q_ReadSWord (i16_t *buf, u8_t pageShift, u32_t pageNum)
 Read signed 16-bit variable. More...
 
W25Q_STATE W25Q_ReadWord (u16_t *buf, u8_t pageShift, u32_t pageNum)
 Read 16-bit variable. More...
 
W25Q_STATE W25Q_ReadSLong (i32_t *buf, u8_t pageShift, u32_t pageNum)
 Read signed 32-bit variable. More...
 
W25Q_STATE W25Q_ReadLong (u32_t *buf, u8_t pageShift, u32_t pageNum)
 Read 32-bit variable. More...
 
W25Q_STATE W25Q_ReadData (u8_t *buf, u16_t len, u8_t pageShift, u32_t pageNum)
 Read any 8-bit data. More...
 
W25Q_STATE W25Q_ReadRaw (u8_t *buf, u16_t data_len, u32_t rawAddr)
 Read data from raw addr. More...
 
W25Q_STATE W25Q_SingleRead (u8_t *buf, u32_t len, u32_t Addr)
 Read data from raw addr by single line. More...
 
W25Q_STATE W25Q_EraseSector (u32_t SectAddr)
 Erase 4KB Sector. More...
 
W25Q_STATE W25Q_EraseBlock (u32_t BlockAddr, u8_t size)
 Erase 32KB/64KB Sector. More...
 
W25Q_STATE W25Q_EraseChip (void)
 Erase all chip. More...
 
W25Q_STATE W25Q_ProgramSByte (i8_t buf, u8_t pageShift, u32_t pageNum)
 Program signed 8-bit variable. More...
 
W25Q_STATE W25Q_ProgramByte (u8_t buf, u8_t pageShift, u32_t pageNum)
 Program 8-bit variable. More...
 
W25Q_STATE W25Q_ProgramSWord (i16_t buf, u8_t pageShift, u32_t pageNum)
 Program signed 16-bit variable. More...
 
W25Q_STATE W25Q_ProgramWord (u16_t buf, u8_t pageShift, u32_t pageNum)
 Program 16-bit variable. More...
 
W25Q_STATE W25Q_ProgramSLong (i32_t buf, u8_t pageShift, u32_t pageNum)
 Program signed 32-bit variable. More...
 
W25Q_STATE W25Q_ProgramLong (u32_t buf, u8_t pageShift, u32_t pageNum)
 Program 32-bit variable. More...
 
W25Q_STATE W25Q_ProgramData (u8_t *buf, u16_t len, u8_t pageShift, u32_t pageNum)
 Program any 8-bit data. More...
 
W25Q_STATE W25Q_ProgramRaw (u8_t *buf, u16_t data_len, u32_t rawAddr)
 Program data to raw addr. More...
 
W25Q_STATE W25Q_SetBurstWrap (u8_t WrapSize)
 Set Burst with Wrap. More...
 
W25Q_STATE W25Q_ProgSuspend (void)
 Pause Programm/Erase operation. More...
 
W25Q_STATE W25Q_ProgResume (void)
 Resume Programm/Erase operation. More...
 
W25Q_STATE W25Q_Sleep (void)
 Set low current consumption. More...
 
W25Q_STATE W25Q_WakeUP (void)
 Wake the chip up from sleep mode. More...
 
W25Q_STATE W25Q_ReadID (u8_t *buf)
 Read chip ID. More...
 
W25Q_STATE W25Q_ReadFullID (u8_t *buf)
 Read full chip ID (Manufacturer ID + Device ID) More...
 
W25Q_STATE W25Q_ReadUID (u8_t *buf)
 Read unique chip ID. More...
 
W25Q_STATE W25Q_ReadJEDECID (u8_t *buf)
 Read ID by JEDEC Standards. More...
 
W25Q_STATE W25Q_ReadSFDPRegister (u8_t *buf)
 Read device descriptor (SFDP Standard) More...
 
W25Q_STATE W25Q_EraseSecurityRegisters (u8_t numReg)
 Erase security register. More...
 
W25Q_STATE W25Q_ProgSecurityRegisters (u8_t *buf, u8_t numReg, u8_t byteAddr)
 Program security register. More...
 
W25Q_STATE W25Q_ReadSecurityRegisters (u8_t *buf, u8_t numReg, u8_t byteAddr)
 Read security register. More...
 
W25Q_STATE W25Q_BlockReadOnly (u32_t Addr, bool enable)
 Individual block/sector read-only lock. More...
 
W25Q_STATE W25Q_BlockReadOnlyCheck (bool *state, u32_t Addr)
 Check block's/sector's read-only lock status. More...
 
W25Q_STATE W25Q_GlobalReadOnly (bool enable)
 Set read-only param to all chip. More...
 
W25Q_STATE W25Q_SwReset (bool force)
 Software reset. More...
 
W25Q_STATE W25Q_WriteEnable (bool enable)
 Toggle WOL bit. More...
 
W25Q_STATE W25Q_Enter4ByteMode (bool enable)
 Toggle ADS bit. More...
 
W25Q_STATE W25Q_SetExtendedAddr (u8_t Addr)
 Set addr in 3-byte mode. More...
 
W25Q_STATE W25Q_GetExtendedAddr (u8_t *outAddr)
 Get addr in 3-byte mode. More...
 
enum  W25Q_STATE {
  W25Q_OK = 0 , W25Q_BUSY = 1 , W25Q_PARAM_ERR = 2 , W25Q_CHIP_ERR = 3 ,
  W25Q_SPI_ERR = 4 , W25Q_CHIP_IGNORE = 5
}
 W25Q Return State Lib's functions status returns. More...
 

Detailed Description

W25Q QSPI Driver.

Enumeration Type Documentation

◆ W25Q_STATE

enum W25Q_STATE

W25Q Return State Lib's functions status returns.

Enumerator
W25Q_OK 

Chip OK - Execution fine.

W25Q_BUSY 

Chip busy.

W25Q_PARAM_ERR 

Function parameters error.

W25Q_CHIP_ERR 

Chip error.

W25Q_SPI_ERR 

SPI Bus err.

W25Q_CHIP_IGNORE 

Chip ignore state.

Function Documentation

◆ W25Q_BlockReadOnly()

W25Q_STATE W25Q_BlockReadOnly ( u32_t  Addr,
bool  enable 
)

Individual block/sector read-only lock.

Individual block/sector read-only lock.

Attention
Func in development
Parameters
[in]AddrBlock address
[in]enable1-Enable/0-Disable
Returns
W25Q_STATE enum

◆ W25Q_BlockReadOnlyCheck()

W25Q_STATE W25Q_BlockReadOnlyCheck ( bool *  state,
u32_t  Addr 
)

Check block's/sector's read-only lock status.

Check block's/sector's read-only lock status.

Attention
Func in development
Parameters
[out]stateBlock read-only status (1-locked/0-unlocked)
[in]AddrBlock address
Returns
W25Q_STATE enum

◆ W25Q_EnableVolatileSR()

W25Q_STATE W25Q_EnableVolatileSR ( void  )

Make Status Register Volatile.

Make Status Register Volatile.

Attention
Func in development
Parameters
none
Returns
W25Q_STATE enum

◆ W25Q_Enter4ByteMode()

W25Q_STATE W25Q_Enter4ByteMode ( bool  enable)

Toggle ADS bit.

W25Q Toggle 4-byte mode.

Note
Affects only ADS bit
Parameters
[in]enable1-enable/0-disable
Returns
W25Q_STATE enum

◆ W25Q_EraseBlock()

W25Q_STATE W25Q_EraseBlock ( u32_t  BlockAddr,
u8_t  size 
)

Erase 32KB/64KB Sector.

Erase 32KB/64KB Sector.

Note
Should be executed before writing
Parameters
[in]BlockAddrBlock start address
[in]sizeSize of block: 32KB or 64KB
Returns
W25Q_STATE enum

◆ W25Q_EraseChip()

W25Q_STATE W25Q_EraseChip ( void  )

Erase all chip.

Erase all chip.

Note
Should be executed before writing
Parameters
none
Returns
W25Q_STATE enum

◆ W25Q_EraseSector()

W25Q_STATE W25Q_EraseSector ( u32_t  SectAddr)

Erase 4KB Sector.

Erase 4KB Sector.

Note
Should be executed before writing
Parameters
[in]SectAddrSector start address
Returns
W25Q_STATE enum

◆ W25Q_EraseSecurityRegisters()

W25Q_STATE W25Q_EraseSecurityRegisters ( u8_t  numReg)

Erase security register.

Erase security register.

Attention
Func in development
Parameters
[in]numRegNumber of security register (1..3 / 0-all)
Returns
W25Q_STATE enum

◆ W25Q_GetExtendedAddr()

W25Q_STATE W25Q_GetExtendedAddr ( u8_t outAddr)

Get addr in 3-byte mode.

W25Q Get extended byte Read extended byte in 3-byte mode.

Attention
Func in development
Parameters
[out]Addr4th byte of addr
Returns
W25Q_STATE enum

◆ W25Q_GlobalReadOnly()

W25Q_STATE W25Q_GlobalReadOnly ( bool  enable)

Set read-only param to all chip.

Set read-only param to all chip.

Attention
Func in development
Parameters
[in]enable1-enable/0-disable
Returns
W25Q_STATE enum

◆ W25Q_Init()

W25Q_STATE W25Q_Init ( void  )

Initalize function.

Initalize function.

Parameters
none
Returns
W25Q_STATE enum

◆ W25Q_IsBusy()

W25Q_STATE W25Q_IsBusy ( void  )

Check chip's busy status.

Check chip's busy status.

Parameters
none
Returns
W25Q_STATE enum (W25Q_OK / W25Q_BUSY)

◆ W25Q_ProgramByte()

W25Q_STATE W25Q_ProgramByte ( u8_t  buf,
u8_t  pageShift,
u32_t  pageNum 
)

Program 8-bit variable.

Program 8-bit variable.

Parameters
[in]bufData to be written (single)
[in]pageShiftByte shift inside page (0..254)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ProgramData()

W25Q_STATE W25Q_ProgramData ( u8_t buf,
u16_t  len,
u8_t  pageShift,
u32_t  pageNum 
)

Program any 8-bit data.

Program any 8-bit data.

Note
Use memcpy to prepare data
Parameters
[in]bufPointer to data to be written (single or array)
[in]lenLength of data (1..256)
[in]pageShiftByte shift inside page (0..255 - len)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ProgramLong()

W25Q_STATE W25Q_ProgramLong ( u32_t  buf,
u8_t  pageShift,
u32_t  pageNum 
)

Program 32-bit variable.

Program 32-bit variable.

Parameters
[in]bufData to be written (single)
[in]pageShiftByte shift inside page (0..251)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ProgramRaw()

W25Q_STATE W25Q_ProgramRaw ( u8_t buf,
u16_t  data_len,
u32_t  rawAddr 
)

Program data to raw addr.

Program data to raw addr.

Note
Address is in [byte] size
Be carefull with page overrun
Parameters
[in]bufPointer to data to be written (single or array)
[in]data_lenLength of data (1..256)
[in]rawAddrStart address of chip's cell
Returns
W25Q_STATE enum

◆ W25Q_ProgramSByte()

W25Q_STATE W25Q_ProgramSByte ( i8_t  buf,
u8_t  pageShift,
u32_t  pageNum 
)

Program signed 8-bit variable.

Program signed 8-bit variable.

Parameters
[in]bufData to be written (single)
[in]pageShiftByte shift inside page (0..254)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ProgramSLong()

W25Q_STATE W25Q_ProgramSLong ( i32_t  buf,
u8_t  pageShift,
u32_t  pageNum 
)

Program signed 32-bit variable.

Program signed 32-bit variable.

Parameters
[in]bufData to be written (single)
[in]pageShiftByte shift inside page (0..251)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ProgramSWord()

W25Q_STATE W25Q_ProgramSWord ( i16_t  buf,
u8_t  pageShift,
u32_t  pageNum 
)

Program signed 16-bit variable.

Program signed 16-bit variable.

Parameters
[in]bufData to be written (single)
[in]pageShiftByte shift inside page (0..253)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ProgramWord()

W25Q_STATE W25Q_ProgramWord ( u16_t  buf,
u8_t  pageShift,
u32_t  pageNum 
)

Program 16-bit variable.

Program 16-bit variable.

Parameters
[in]bufData to be written (single)
[in]pageShiftByte shift inside page (0..253)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ProgResume()

W25Q_STATE W25Q_ProgResume ( void  )

Resume Programm/Erase operation.

Resume Programm/Erase operation.

Note
SUS == 1, otherwise ignored
Parameters
none
Returns
W25Q_STATE enum

◆ W25Q_ProgSecurityRegisters()

W25Q_STATE W25Q_ProgSecurityRegisters ( u8_t buf,
u8_t  numReg,
u8_t  byteAddr 
)

Program security register.

Program security register.

Attention
Func in development
Parameters
[in]bufPointer to 8-bit data bufer
[in]numRegNumber of security register (1..3)
[in]byteAddrByte addr in register (0..255)
Returns
W25Q_STATE enum

◆ W25Q_ProgSuspend()

W25Q_STATE W25Q_ProgSuspend ( void  )

Pause Programm/Erase operation.

Pause Programm/Erase operation.

Note
SUS == 0 && BUSY == 1, otherwise ignored
Power loose during suspend state may corrupt data
Parameters
none
Returns
W25Q_STATE enum

◆ W25Q_ReadByte()

W25Q_STATE W25Q_ReadByte ( u8_t buf,
u8_t  pageShift,
u32_t  pageNum 
)

Read 8-bit variable.

Read 8-bit variable.

Parameters
[out]bufData to be read (single)
[in]pageShiftByte shift inside page (0..254)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ReadData()

W25Q_STATE W25Q_ReadData ( u8_t buf,
u16_t  len,
u8_t  pageShift,
u32_t  pageNum 
)

Read any 8-bit data.

Read any 8-bit data.

Note
Use memcpy to decode data
Parameters
[out]bufPointer to data to be read (single or array)
[in]lenLength of data (1..256)
[in]pageShiftByte shift inside page (0..255 - len)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ReadFullID()

W25Q_STATE W25Q_ReadFullID ( u8_t buf)

Read full chip ID (Manufacturer ID + Device ID)

Read full chip ID (Manufacturer ID + Device ID)

Attention
Func in development
Parameters
[out]bufPointer to data from ID register
Returns
W25Q_STATE enum

◆ W25Q_ReadID()

W25Q_STATE W25Q_ReadID ( u8_t buf)

Read chip ID.

Read chip ID.

Parameters
[out]bufPointer to output data (1 byte)
Returns
W25Q_STATE enum

◆ W25Q_ReadJEDECID()

W25Q_STATE W25Q_ReadJEDECID ( u8_t buf)

Read ID by JEDEC Standards.

Read ID by JEDEC Standards.

Attention
Func in development
Parameters
[out]bufPointer to data from ID register
Returns
W25Q_STATE enum

◆ W25Q_ReadLong()

W25Q_STATE W25Q_ReadLong ( u32_t buf,
u8_t  pageShift,
u32_t  pageNum 
)

Read 32-bit variable.

Read 32-bit variable.

Parameters
[out]bufData to be read (single)
[in]pageShiftByte shift inside page (0..251)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ReadRaw()

W25Q_STATE W25Q_ReadRaw ( u8_t buf,
u16_t  data_len,
u32_t  rawAddr 
)

Read data from raw addr.

Read data from raw addr.

Note
Address is in [byte] size
Be carefull with page overrun
Parameters
[out]bufPointer to data to be written (single or array)
[in]data_lenLength of data (1..256)
[in]rawAddrStart address of chip's cell
Returns
W25Q_STATE enum

◆ W25Q_ReadSByte()

W25Q_STATE W25Q_ReadSByte ( i8_t buf,
u8_t  pageShift,
u32_t  pageNum 
)

Read signed 8-bit variable.

Read signed 8-bit variable.

Parameters
[out]bufData to be read (single)
[in]pageShiftByte shift inside page (0..254)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ReadSecurityRegisters()

W25Q_STATE W25Q_ReadSecurityRegisters ( u8_t buf,
u8_t  numReg,
u8_t  byteAddr 
)

Read security register.

Read security register.

Attention
Func in development
Parameters
[out]bufPointer to 8-bit data bufer
[in]numRegNumber of security register (1..3)
[in]byteAddrByte addr in register (0..255)
Returns
W25Q_STATE enum

◆ W25Q_ReadSFDPRegister()

W25Q_STATE W25Q_ReadSFDPRegister ( u8_t buf)

Read device descriptor (SFDP Standard)

Read device descriptor (SFDP Standard)

Attention
Func in development
Parameters
[out]bufPointer to data from ID register
Returns
W25Q_STATE enum

◆ W25Q_ReadSLong()

W25Q_STATE W25Q_ReadSLong ( i32_t buf,
u8_t  pageShift,
u32_t  pageNum 
)

Read signed 32-bit variable.

Read signed 32-bit variable.

Parameters
[out]bufData to be read (single)
[in]pageShiftByte shift inside page (0..251)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ReadStatusReg()

W25Q_STATE W25Q_ReadStatusReg ( u8_t reg_data,
u8_t  reg_num 
)

Read status register to variable.

Read status register to variable.

Parameters
[out]reg_data1 byte
[in]reg_numDesired register 1..3
Returns
W25Q_STATE enum

◆ W25Q_ReadStatusStruct()

W25Q_STATE W25Q_ReadStatusStruct ( W25Q_STATUS_REG status)

Read all status registers to struct.

Read all status registers to struct.

Parameters
[out]statusW25Q_STATUS_REG Pointer
Returns
W25Q_STATE enum

◆ W25Q_ReadSWord()

W25Q_STATE W25Q_ReadSWord ( i16_t buf,
u8_t  pageShift,
u32_t  pageNum 
)

Read signed 16-bit variable.

Read signed 16-bit variable.

Parameters
[out]bufData to be read (single)
[in]pageShiftByte shift inside page (0..253)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_ReadUID()

W25Q_STATE W25Q_ReadUID ( u8_t buf)

Read unique chip ID.

Read unique chip ID.

Attention
Func in development
Parameters
[out]bufPointer to data from ID register
Returns
W25Q_STATE enum

◆ W25Q_ReadWord()

W25Q_STATE W25Q_ReadWord ( u16_t buf,
u8_t  pageShift,
u32_t  pageNum 
)

Read 16-bit variable.

Read 16-bit variable.

Parameters
[out]bufData to be read (single)
[in]pageShiftByte shift inside page (0..253)
[in]pageNumPage number (0..PAGE_COUNT)
Returns
W25Q_STATE enum

◆ W25Q_SetBurstWrap()

W25Q_STATE W25Q_SetBurstWrap ( u8_t  WrapSize)

Set Burst with Wrap.

Set Burst with Wrap.

Attention
Func in development
Parameters
[in]WrapSizeWrap size: 8/16/32/64 / 0 - disable
Returns
W25Q_STATE enum

◆ W25Q_SetExtendedAddr()

W25Q_STATE W25Q_SetExtendedAddr ( u8_t  Addr)

Set addr in 3-byte mode.

W25Q Set extended byte Extended byte in 3-byte mode.

Attention
Func in development
Parameters
[in]Addr4th byte of addr
Returns
W25Q_STATE enum

◆ W25Q_SingleRead()

W25Q_STATE W25Q_SingleRead ( u8_t buf,
u32_t  len,
u32_t  Addr 
)

Read data from raw addr by single line.

Read data from raw addr by single line.

Note
Works only with SINGLE SPI Line
Parameters
[out]bufPointer to data array
[in]lenLength of array
[in]AddrAddress to data
Returns
W25Q_STATE enum

◆ W25Q_Sleep()

W25Q_STATE W25Q_Sleep ( void  )

Set low current consumption.

Set low current consumption.

Note
Use WakeUP or ReadID
Parameters
none
Returns
W25Q_STATE enum

◆ W25Q_SwReset()

W25Q_STATE W25Q_SwReset ( bool  force)

Software reset.

Software reset.

Parameters
[in]forceEnable/disable (0/1) force reset - wait for BUSY and SUSpend
Returns
W25Q_STATE enum

◆ W25Q_WakeUP()

W25Q_STATE W25Q_WakeUP ( void  )

Wake the chip up from sleep mode.

Wake the chip up from sleep mode.

Parameters
none
Returns
W25Q_STATE enum

◆ W25Q_WriteEnable()

W25Q_STATE W25Q_WriteEnable ( bool  enable)

Toggle WOL bit.

W25Q Toggle WEL bit Toggle write enable latch.

Parameters
[in]enable1-enable write/0-disable write
Returns
W25Q_STATE enum

◆ W25Q_WriteStatusReg()

W25Q_STATE W25Q_WriteStatusReg ( u8_t  reg_data,
u8_t  reg_num 
)

Write status register from variable.

Write status register from variable.

Parameters
[in]reg_data1 byte
[in]reg_numDesired register 1..3
Returns
W25Q_STATE enum