LibDriver W25QXX
Loading...
Searching...
No Matches
w25qxx basic driver function

w25qxx basic driver modules More...

Collaboration diagram for w25qxx basic driver function:

Data Structures

struct  w25qxx_handle_s
 w25qxx handle structure definition More...
struct  w25qxx_info_s
 w25qxx information structure definition More...

Macros

#define W25QXX_WRITE_STATUS_TIMEOUT_MS   (1000U)
 w25qxx write status register timeout definition
#define W25QXX_ERASE_CHIP_TIMEOUT_MS   (1000U * 1000U)
 w25qxx erase chip timeout definition
#define W25QXX_ERASE_SECURITY_TIMEOUT_MS   (100U)
 w25qxx erase security timeout definition
#define W25QXX_PROGRAM_SECURITY_TIMEOUT_MS   (3U)
 w25qxx program security timeout definition
#define W25QXX_PAGE_PROGRAM_TIMEOUT_MS   (3U)
 w25qxx page program timeout definition
#define W25QXX_ERASE_4K_TIMEOUT_MS   (400U)
 w25qxx erase 4k timeout definition
#define W25QXX_ERASE_32K_TIMEOUT_MS   (1600U)
 w25qxx erase 32k timeout definition
#define W25QXX_ERASE_64K_TIMEOUT_MS   (2000U)
 w25qxx erase 64k timeout definition

Typedefs

typedef struct w25qxx_handle_s w25qxx_handle_t
 w25qxx handle structure definition
typedef struct w25qxx_info_s w25qxx_info_t
 w25qxx information structure definition

Enumerations

enum  w25qxx_type_t {
  W25Q10 = 0XEF10U , W25Q20 = 0XEF11U , W25Q40 = 0XEF12U , W25Q80 = 0XEF13U ,
  W25Q16 = 0XEF14U , W25Q32 = 0XEF15U , W25Q64 = 0XEF16U , W25Q128 = 0XEF17U ,
  W25Q256 = 0XEF18U , W25Q512 = 0XEF19U , W25Q01 = 0XEF20U , W25Q02 = 0XEF21U
}
 w25qxx type enumeration definition More...
enum  w25qxx_interface_t { W25QXX_INTERFACE_SPI = 0x00 , W25QXX_INTERFACE_QSPI = 0x01 }
 w25qxx interface enumeration definition More...
enum  w25qxx_bool_t { W25QXX_BOOL_FALSE = 0x00 , W25QXX_BOOL_TRUE = 0x01 }
 w25qxx bool enumeration definition More...
enum  w25qxx_address_mode_t { W25QXX_ADDRESS_MODE_3_BYTE = 0x00 , W25QXX_ADDRESS_MODE_4_BYTE = 0x01 }
 w25qxx address mode enumeration definition More...

Functions

uint8_t w25qxx_info (w25qxx_info_t *info)
 get chip's information
uint8_t w25qxx_set_dual_quad_spi (w25qxx_handle_t *handle, w25qxx_bool_t enable)
 enable or disable the dual quad spi
uint8_t w25qxx_get_dual_quad_spi (w25qxx_handle_t *handle, w25qxx_bool_t *enable)
 get the dual quad spi status
uint8_t w25qxx_set_type (w25qxx_handle_t *handle, w25qxx_type_t type)
 set the chip type
uint8_t w25qxx_get_type (w25qxx_handle_t *handle, w25qxx_type_t *type)
 get the chip type
uint8_t w25qxx_set_interface (w25qxx_handle_t *handle, w25qxx_interface_t interface)
 set the chip interface
uint8_t w25qxx_get_interface (w25qxx_handle_t *handle, w25qxx_interface_t *interface)
 get the chip interface
uint8_t w25qxx_set_address_mode (w25qxx_handle_t *handle, w25qxx_address_mode_t mode)
 set the chip address mode
uint8_t w25qxx_get_address_mode (w25qxx_handle_t *handle, w25qxx_address_mode_t *mode)
 get the chip address mode
uint8_t w25qxx_init (w25qxx_handle_t *handle)
 initialize the chip
uint8_t w25qxx_deinit (w25qxx_handle_t *handle)
 close the chip
uint8_t w25qxx_read (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read data
uint8_t w25qxx_write (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 write data
uint8_t w25qxx_only_spi_read (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read only in the spi interface
uint8_t w25qxx_fast_read (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read in the fast mode
uint8_t w25qxx_page_program (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint16_t len)
 page program
uint8_t w25qxx_sector_erase_4k (w25qxx_handle_t *handle, uint32_t addr)
 erase the 4k sector
uint8_t w25qxx_block_erase_32k (w25qxx_handle_t *handle, uint32_t addr)
 erase the 32k block
uint8_t w25qxx_block_erase_64k (w25qxx_handle_t *handle, uint32_t addr)
 erase the 64k block
uint8_t w25qxx_chip_erase (w25qxx_handle_t *handle)
 erase the chip
uint8_t w25qxx_power_down (w25qxx_handle_t *handle)
 power down
uint8_t w25qxx_release_power_down (w25qxx_handle_t *handle)
 release power down
uint8_t w25qxx_get_manufacturer_device_id (w25qxx_handle_t *handle, uint8_t *manufacturer, uint8_t *device_id)
 get the manufacturer && device id information

Detailed Description

w25qxx basic driver modules

Macro Definition Documentation

◆ W25QXX_ERASE_32K_TIMEOUT_MS

#define W25QXX_ERASE_32K_TIMEOUT_MS   (1600U)

w25qxx erase 32k timeout definition

max 1600ms

Definition at line 105 of file driver_w25qxx.h.

◆ W25QXX_ERASE_4K_TIMEOUT_MS

#define W25QXX_ERASE_4K_TIMEOUT_MS   (400U)

w25qxx erase 4k timeout definition

max 400ms

Definition at line 98 of file driver_w25qxx.h.

◆ W25QXX_ERASE_64K_TIMEOUT_MS

#define W25QXX_ERASE_64K_TIMEOUT_MS   (2000U)

w25qxx erase 64k timeout definition

max 2000ms

Definition at line 112 of file driver_w25qxx.h.

◆ W25QXX_ERASE_CHIP_TIMEOUT_MS

#define W25QXX_ERASE_CHIP_TIMEOUT_MS   (1000U * 1000U)

w25qxx erase chip timeout definition

max 1000s

Definition at line 70 of file driver_w25qxx.h.

◆ W25QXX_ERASE_SECURITY_TIMEOUT_MS

#define W25QXX_ERASE_SECURITY_TIMEOUT_MS   (100U)

w25qxx erase security timeout definition

max 100ms

Definition at line 77 of file driver_w25qxx.h.

◆ W25QXX_PAGE_PROGRAM_TIMEOUT_MS

#define W25QXX_PAGE_PROGRAM_TIMEOUT_MS   (3U)

w25qxx page program timeout definition

max 3ms

Definition at line 91 of file driver_w25qxx.h.

◆ W25QXX_PROGRAM_SECURITY_TIMEOUT_MS

#define W25QXX_PROGRAM_SECURITY_TIMEOUT_MS   (3U)

w25qxx program security timeout definition

max 3ms

Definition at line 84 of file driver_w25qxx.h.

◆ W25QXX_WRITE_STATUS_TIMEOUT_MS

#define W25QXX_WRITE_STATUS_TIMEOUT_MS   (1000U)

w25qxx write status register timeout definition

max 1000ms

Definition at line 63 of file driver_w25qxx.h.

Typedef Documentation

◆ w25qxx_handle_t

w25qxx handle structure definition

◆ w25qxx_info_t

typedef struct w25qxx_info_s w25qxx_info_t

w25qxx information structure definition

Enumeration Type Documentation

◆ w25qxx_address_mode_t

w25qxx address mode enumeration definition

Enumerator
W25QXX_ADDRESS_MODE_3_BYTE 

3 byte mode

W25QXX_ADDRESS_MODE_4_BYTE 

4 byte mode

Definition at line 155 of file driver_w25qxx.h.

◆ w25qxx_bool_t

w25qxx bool enumeration definition

Enumerator
W25QXX_BOOL_FALSE 

false

W25QXX_BOOL_TRUE 

true

Definition at line 146 of file driver_w25qxx.h.

◆ w25qxx_interface_t

w25qxx interface enumeration definition

Enumerator
W25QXX_INTERFACE_SPI 

spi interface

W25QXX_INTERFACE_QSPI 

dspi qspi interface

Definition at line 137 of file driver_w25qxx.h.

◆ w25qxx_type_t

w25qxx type enumeration definition

Enumerator
W25Q10 

w25q10, 1Mb

W25Q20 

w25q20, 2Mb

W25Q40 

w25q40, 4Mb

W25Q80 

w25q80, 8Mb

W25Q16 

w25q16, 16Mb

W25Q32 

w25q32, 32Mb

W25Q64 

w25q64, 64Mb

W25Q128 

w25q128, 128Mb

W25Q256 

w25q256, 256Mb

W25Q512 

w25q512, 512Mb

W25Q01 

w25q01, 1Gb

W25Q02 

w25q02, 2Gb

Definition at line 118 of file driver_w25qxx.h.

Function Documentation

◆ w25qxx_block_erase_32k()

uint8_t w25qxx_block_erase_32k ( w25qxx_handle_t * handle,
uint32_t addr )

erase the 32k block

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrerase address
Returns
status code
  • 0 success
  • 1 block erase 32k failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 addr is invalid
  • 5 address mode is invalid
  • 6 block erase 32k timeout
Note
none

Definition at line 5419 of file driver_w25qxx.c.

◆ w25qxx_block_erase_64k()

uint8_t w25qxx_block_erase_64k ( w25qxx_handle_t * handle,
uint32_t addr )

erase the 64k block

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrerase address
Returns
status code
  • 0 success
  • 1 block erase 64k failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 addr is invalid
  • 5 address mode is invalid
  • 6 block erase 64k timeout
Note
none

Definition at line 5758 of file driver_w25qxx.c.

◆ w25qxx_chip_erase()

uint8_t w25qxx_chip_erase ( w25qxx_handle_t * handle)

erase the chip

Parameters
[in]*handlepointer to a w25qxx handle structure
Returns
status code
  • 0 success
  • 1 chip erase failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 erase timeout
Note
none

Definition at line 1459 of file driver_w25qxx.c.

◆ w25qxx_deinit()

uint8_t w25qxx_deinit ( w25qxx_handle_t * handle)

close the chip

Parameters
[in]*handlepointer to a w25qxx handle structure
Returns
status code
  • 0 success
  • 1 spi or qspi deinit failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 power down failed
Note
none

Definition at line 7195 of file driver_w25qxx.c.

◆ w25qxx_fast_read()

uint8_t w25qxx_fast_read ( w25qxx_handle_t * handle,
uint32_t addr,
uint8_t * data,
uint32_t len )

read in the fast mode

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrread address
[out]*datapointer to a data buffer
[in]lendata length
Returns
status code
  • 0 success
  • 1 fast read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 address mode is invalid
Note
none

Definition at line 3634 of file driver_w25qxx.c.

◆ w25qxx_get_address_mode()

uint8_t w25qxx_get_address_mode ( w25qxx_handle_t * handle,
w25qxx_address_mode_t * mode )

get the chip address mode

Parameters
[in]*handlepointer to a w25qxx handle structure
[out]*modepointer to an address mode buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 405 of file driver_w25qxx.c.

◆ w25qxx_get_dual_quad_spi()

uint8_t w25qxx_get_dual_quad_spi ( w25qxx_handle_t * handle,
w25qxx_bool_t * enable )

get the dual quad spi status

Parameters
[in]*handlepointer to a w25qxx handle structure
[out]*enablepointer to a bool value buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 196 of file driver_w25qxx.c.

◆ w25qxx_get_interface()

uint8_t w25qxx_get_interface ( w25qxx_handle_t * handle,
w25qxx_interface_t * interface )

get the chip interface

Parameters
[in]*handlepointer to a w25qxx handle structure
[out]*interfacepointer to a chip interface buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 280 of file driver_w25qxx.c.

◆ w25qxx_get_manufacturer_device_id()

uint8_t w25qxx_get_manufacturer_device_id ( w25qxx_handle_t * handle,
uint8_t * manufacturer,
uint8_t * device_id )

get the manufacturer && device id information

Parameters
[in]*handlepointer to a w25qxx handle structure
[out]*manufacturerpointer to a manufacturer buffer
[out]*device_idpointer to a device id buffer
Returns
status code
  • 0 success
  • 1 get manufacturer device id failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1952 of file driver_w25qxx.c.

◆ w25qxx_get_type()

uint8_t w25qxx_get_type ( w25qxx_handle_t * handle,
w25qxx_type_t * type )

get the chip type

Parameters
[in]*handlepointer to a w25qxx handle structure
[out]*typepointer to a chip type buffer
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 238 of file driver_w25qxx.c.

◆ w25qxx_info()

uint8_t w25qxx_info ( w25qxx_info_t * info)

get chip's information

Parameters
[out]*infopointer to a w25qxx info structure
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 8566 of file driver_w25qxx.c.

◆ w25qxx_init()

uint8_t w25qxx_init ( w25qxx_handle_t * handle)

initialize the chip

Parameters
[in]*handlepointer to a w25qxx handle structure
Returns
status code
  • 0 success
  • 1 spi or qspi initialization failed
  • 2 handle is NULL
  • 3 linked functions is NULL
  • 4 get manufacturer device id failed
  • 5 enter qspi failed
  • 6 id is invalid
  • 7 reset failed
  • 8 set address mode failed
Note
none

Definition at line 6819 of file driver_w25qxx.c.

◆ w25qxx_only_spi_read()

uint8_t w25qxx_only_spi_read ( w25qxx_handle_t * handle,
uint32_t addr,
uint8_t * data,
uint32_t len )

read only in the spi interface

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrread address
[out]*datapointer to a data buffer
[in]lendata length
Returns
status code
  • 0 success
  • 1 only spi read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 address mode is invalid
  • 5 only spi interface can use this function
Note
none

Definition at line 3465 of file driver_w25qxx.c.

◆ w25qxx_page_program()

uint8_t w25qxx_page_program ( w25qxx_handle_t * handle,
uint32_t addr,
uint8_t * data,
uint16_t len )

page program

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrprogramming address
[in]*datapointer to a data buffer
[in]lendata length
Returns
status code
  • 0 success
  • 1 page program failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 addr is invalid
  • 5 address mode is invalid
  • 6 page program timeout
  • 7 length is over 256
Note
len <= 256

Definition at line 4569 of file driver_w25qxx.c.

◆ w25qxx_power_down()

uint8_t w25qxx_power_down ( w25qxx_handle_t * handle)

power down

Parameters
[in]*handlepointer to a w25qxx handle structure
Returns
status code
  • 0 success
  • 1 power down failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1792 of file driver_w25qxx.c.

◆ w25qxx_read()

uint8_t w25qxx_read ( w25qxx_handle_t * handle,
uint32_t addr,
uint8_t * data,
uint32_t len )

read data

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrread address
[out]*datapointer to a data buffer
[in]lendata length
Returns
status code
  • 0 success
  • 1 read failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 address mode is invalid
Note
none

Definition at line 7289 of file driver_w25qxx.c.

◆ w25qxx_release_power_down()

uint8_t w25qxx_release_power_down ( w25qxx_handle_t * handle)

release power down

Parameters
[in]*handlepointer to a w25qxx handle structure
Returns
status code
  • 0 success
  • 1 release power down failed
  • 2 handle is NULL
  • 3 handle is not initialized
Note
none

Definition at line 1875 of file driver_w25qxx.c.

◆ w25qxx_sector_erase_4k()

uint8_t w25qxx_sector_erase_4k ( w25qxx_handle_t * handle,
uint32_t addr )

erase the 4k sector

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrerase address
Returns
status code
  • 0 success
  • 1 sector erase 4k failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 addr is invalid
  • 5 address mode is invalid
  • 6 sector erase 4k timeout
Note
none

Definition at line 5080 of file driver_w25qxx.c.

◆ w25qxx_set_address_mode()

uint8_t w25qxx_set_address_mode ( w25qxx_handle_t * handle,
w25qxx_address_mode_t mode )

set the chip address mode

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]modeaddress mode
Returns
status code
  • 0 success
  • 1 set address mode failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 current type can't use this function
Note
none

Definition at line 304 of file driver_w25qxx.c.

◆ w25qxx_set_dual_quad_spi()

uint8_t w25qxx_set_dual_quad_spi ( w25qxx_handle_t * handle,
w25qxx_bool_t enable )

enable or disable the dual quad spi

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]enablebool value
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 175 of file driver_w25qxx.c.

◆ w25qxx_set_interface()

uint8_t w25qxx_set_interface ( w25qxx_handle_t * handle,
w25qxx_interface_t interface )

set the chip interface

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]interfacechip interface
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 259 of file driver_w25qxx.c.

◆ w25qxx_set_type()

uint8_t w25qxx_set_type ( w25qxx_handle_t * handle,
w25qxx_type_t type )

set the chip type

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]typechip type
Returns
status code
  • 0 success
  • 2 handle is NULL
Note
none

Definition at line 217 of file driver_w25qxx.c.

◆ w25qxx_write()

uint8_t w25qxx_write ( w25qxx_handle_t * handle,
uint32_t addr,
uint8_t * data,
uint32_t len )

write data

Parameters
[in]*handlepointer to a w25qxx handle structure
[in]addrwritten address
[in]*datapointer to a data buffer
[in]lendata length
Returns
status code
  • 0 success
  • 1 write failed
  • 2 handle is NULL
  • 3 handle is not initialized
  • 4 read failed
  • 5 erase sector failed
Note
none

Definition at line 8415 of file driver_w25qxx.c.