LibDriver W25QXX  1.0.0
W25QXX full-featured driver
driver_w25qxx.h File Reference

driver w25qxx header file More...

#include <stdint.h>
#include <stdio.h>
#include <string.h>

Go to the source code of this file.

Data Structures

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

Macros

#define DRIVER_W25QXX_LINK_INIT(HANDLE, STRUCTURE)   memset(HANDLE, 0, sizeof(STRUCTURE))
 initialize w25qxx_handle_t structure More...
 
#define DRIVER_W25QXX_LINK_SPI_QSPI_INIT(HANDLE, FUC)   (HANDLE)->spi_qspi_init = FUC
 link spi_qspi_init function More...
 
#define DRIVER_W25QXX_LINK_SPI_QSPI_DEINIT(HANDLE, FUC)   (HANDLE)->spi_qspi_deinit = FUC
 link spi_qspi_deinit function More...
 
#define DRIVER_W25QXX_LINK_SPI_QSPI_WRITE_READ(HANDLE, FUC)   (HANDLE)->spi_qspi_write_read = FUC
 link spi_qspi_write_read function More...
 
#define DRIVER_W25QXX_LINK_DELAY_MS(HANDLE, FUC)   (HANDLE)->delay_ms = FUC
 link delay_ms function More...
 
#define DRIVER_W25QXX_LINK_DELAY_US(HANDLE, FUC)   (HANDLE)->delay_us = FUC
 link delay_us function More...
 
#define DRIVER_W25QXX_LINK_DEBUG_PRINT(HANDLE, FUC)   (HANDLE)->debug_print = FUC
 link debug_print function More...
 

Typedefs

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

Enumerations

enum  w25qxx_type_t {
  W25Q80 = 0XEF13U , W25Q16 = 0XEF14U , W25Q32 = 0XEF15U , W25Q64 = 0XEF16U ,
  W25Q128 = 0XEF17U , W25Q256 = 0XEF18U , W25Q512 = 0XEF19U , W25Q1024 = 0XEF20U ,
  W25Q2048 = 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...
 
enum  w25qxx_qspi_read_dummy_t { W25QXX_QSPI_READ_DUMMY_2_33MHZ = 0x00 , W25QXX_QSPI_READ_DUMMY_4_55MHZ = 0x01 , W25QXX_QSPI_READ_DUMMY_6_80MHZ = 0x02 , W25QXX_QSPI_READ_DUMMY_8_80MHZ = 0x03 }
 w25qxx qspi read dummy enumeration definition More...
 
enum  w25qxx_qspi_read_wrap_length_t { W25QXX_QSPI_READ_WRAP_LENGTH_8_BYTE = 0x00 , W25QXX_QSPI_READ_WRAP_LENGTH_16_BYTE = 0x01 , W25QXX_QSPI_READ_WRAP_LENGTH_32_BYTE = 0x02 , W25QXX_QSPI_READ_WRAP_LENGTH_64_BYTE = 0x03 }
 w25qxx qspi read wrap length enumeration definition More...
 
enum  w25qxx_security_register_t { W25QXX_SECURITY_REGISTER_1 = 0x10 , W25QXX_SECURITY_REGISTER_2 = 0x20 , W25QXX_SECURITY_REGISTER_3 = 0x30 }
 w25qxx security register enumeration definition More...
 
enum  w25qxx_burst_wrap_t {
  W25QXX_BURST_WRAP_NONE = 0x10 , W25QXX_BURST_WRAP_8_BYTE = 0x00 , W25QXX_BURST_WRAP_16_BYTE = 0x20 , W25QXX_BURST_WRAP_32_BYTE = 0x40 ,
  W25QXX_BURST_WRAP_64_BYTE = 0x60
}
 w25qxx burst wrap enumeration definition More...
 
enum  w25qxx_status1_t {
  W25QXX_STATUS1_STATUS_REGISTER_PROTECT_0 = (1 << 7) , W25QXX_STATUS1_SECTOR_PROTECT_OR_TOP_BOTTOM_PROTECT = (1 << 6) , W25QXX_STATUS1_TOP_BOTTOM_PROTECT_OR_BLOCK_PROTECT_3 = (1 << 5) , W25QXX_STATUS1_BLOCK_PROTECT_2 = (1 << 4) ,
  W25QXX_STATUS1_BLOCK_PROTECT_1 = (1 << 3) , W25QXX_STATUS1_BLOCK_PROTECT_0 = (1 << 2) , W25QXX_STATUS1_WRITE_ENABLE_LATCH = (1 << 1) , W25QXX_STATUS1_ERASE_WRITE_PROGRESS = (1 << 0)
}
 w25qxx status 1 enumeration definition More...
 
enum  w25qxx_status2_t {
  W25QXX_STATUS2_SUSPEND_STATUS = (1 << 7) , W25QXX_STATUS2_COMPLEMENT_PROTECT = (1 << 6) , W25QXX_STATUS2_SECURITY_REGISTER_3_LOCK_BITS = (1 << 5) , W25QXX_STATUS2_SECURITY_REGISTER_2_LOCK_BITS = (1 << 4) ,
  W25QXX_STATUS2_SECURITY_REGISTER_1_LOCK_BITS = (1 << 3) , W25QXX_STATUS2_QUAD_ENABLE = (1 << 1) , W25QXX_STATUS2_STATUS_REGISTER_PROTECT_1 = (1 << 0)
}
 w25qxx status 2 enumeration definition More...
 
enum  w25qxx_status3_t {
  W25QXX_STATUS3_HOLD_RESET_FUNCTION = (1 << 7) , W25QXX_STATUS3_OUTPUT_DRIVER_STRENGTH_100_PERCENTAGE = (0 << 5) , W25QXX_STATUS3_OUTPUT_DRIVER_STRENGTH_75_PERCENTAGE = (1 << 5) , W25QXX_STATUS3_OUTPUT_DRIVER_STRENGTH_50_PERCENTAGE = (2 << 5) ,
  W25QXX_STATUS3_OUTPUT_DRIVER_STRENGTH_25_PERCENTAGE = (3 << 5) , W25QXX_STATUS3_WRITE_PROTECT_SELECTION = (1 << 2) , W25QXX_STATUS3_POWER_UP_ADDRESS_MODE = (1 << 1) , W25QXX_STATUS3_CURRENT_ADDRESS_MODE = (1 << 0)
}
 w25qxx status 3 enumeration definition More...
 

Functions

uint8_t w25qxx_info (w25qxx_info_t *info)
 get chip's information More...
 
uint8_t w25qxx_set_dual_quad_spi (w25qxx_handle_t *handle, w25qxx_bool_t enable)
 enable or disable the dual quad spi More...
 
uint8_t w25qxx_get_dual_quad_spi (w25qxx_handle_t *handle, w25qxx_bool_t *enable)
 get the dual quad spi status More...
 
uint8_t w25qxx_set_type (w25qxx_handle_t *handle, w25qxx_type_t type)
 set the chip type More...
 
uint8_t w25qxx_get_type (w25qxx_handle_t *handle, w25qxx_type_t *type)
 get the chip type More...
 
uint8_t w25qxx_set_interface (w25qxx_handle_t *handle, w25qxx_interface_t interface)
 set the chip interface More...
 
uint8_t w25qxx_get_interface (w25qxx_handle_t *handle, w25qxx_interface_t *interface)
 get the chip interface More...
 
uint8_t w25qxx_set_address_mode (w25qxx_handle_t *handle, w25qxx_address_mode_t mode)
 set the chip address mode More...
 
uint8_t w25qxx_get_address_mode (w25qxx_handle_t *handle, w25qxx_address_mode_t *mode)
 get the chip address mode More...
 
uint8_t w25qxx_init (w25qxx_handle_t *handle)
 initialize the chip More...
 
uint8_t w25qxx_deinit (w25qxx_handle_t *handle)
 close the chip More...
 
uint8_t w25qxx_read (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read data More...
 
uint8_t w25qxx_write (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 write data More...
 
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 More...
 
uint8_t w25qxx_fast_read (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read in the fast mode More...
 
uint8_t w25qxx_page_program (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint16_t len)
 page program More...
 
uint8_t w25qxx_sector_erase_4k (w25qxx_handle_t *handle, uint32_t addr)
 erase the 4k sector More...
 
uint8_t w25qxx_block_erase_32k (w25qxx_handle_t *handle, uint32_t addr)
 erase the 32k block More...
 
uint8_t w25qxx_block_erase_64k (w25qxx_handle_t *handle, uint32_t addr)
 erase the 64k block More...
 
uint8_t w25qxx_chip_erase (w25qxx_handle_t *handle)
 erase the chip More...
 
uint8_t w25qxx_power_down (w25qxx_handle_t *handle)
 power down More...
 
uint8_t w25qxx_release_power_down (w25qxx_handle_t *handle)
 release power down More...
 
uint8_t w25qxx_get_manufacturer_device_id (w25qxx_handle_t *handle, uint8_t *manufacturer, uint8_t *device_id)
 get the manufacturer && device id information More...
 
uint8_t w25qxx_fast_read_dual_output (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read with dual output in the fast mode More...
 
uint8_t w25qxx_fast_read_quad_output (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read with quad output in the fast mode More...
 
uint8_t w25qxx_fast_read_dual_io (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read with dual io in the fast mode More...
 
uint8_t w25qxx_fast_read_quad_io (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 read with quad io in the fast mode More...
 
uint8_t w25qxx_word_read_quad_io (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 word read with quad io More...
 
uint8_t w25qxx_octal_word_read_quad_io (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint32_t len)
 octal word read with quad io More...
 
uint8_t w25qxx_page_program_quad_input (w25qxx_handle_t *handle, uint32_t addr, uint8_t *data, uint16_t len)
 quad page program with quad input More...
 
uint8_t w25qxx_enable_write (w25qxx_handle_t *handle)
 enable writing More...
 
uint8_t w25qxx_enable_volatile_sr_write (w25qxx_handle_t *handle)
 enable volatile sr writing More...
 
uint8_t w25qxx_disable_write (w25qxx_handle_t *handle)
 disable writing More...
 
uint8_t w25qxx_get_status1 (w25qxx_handle_t *handle, uint8_t *status)
 get the status 1 More...
 
uint8_t w25qxx_get_status2 (w25qxx_handle_t *handle, uint8_t *status)
 get the status 2 More...
 
uint8_t w25qxx_get_status3 (w25qxx_handle_t *handle, uint8_t *status)
 get the status 3 More...
 
uint8_t w25qxx_set_status1 (w25qxx_handle_t *handle, uint8_t status)
 set the status 1 More...
 
uint8_t w25qxx_set_status2 (w25qxx_handle_t *handle, uint8_t status)
 set the status 2 More...
 
uint8_t w25qxx_set_status3 (w25qxx_handle_t *handle, uint8_t status)
 set the status 3 More...
 
uint8_t w25qxx_erase_program_suspend (w25qxx_handle_t *handle)
 suspend erase or program More...
 
uint8_t w25qxx_erase_program_resume (w25qxx_handle_t *handle)
 resume erase or program More...
 
uint8_t w25qxx_get_manufacturer_device_id_dual_io (w25qxx_handle_t *handle, uint8_t *manufacturer, uint8_t *device_id)
 get the manufacturer && device id information with dual io More...
 
uint8_t w25qxx_get_manufacturer_device_id_quad_io (w25qxx_handle_t *handle, uint8_t *manufacturer, uint8_t *device_id)
 get the manufacturer && device id information with quad io More...
 
uint8_t w25qxx_get_jedec_id (w25qxx_handle_t *handle, uint8_t *manufacturer, uint8_t device_id[2])
 get the jedec id information More...
 
uint8_t w25qxx_global_block_lock (w25qxx_handle_t *handle)
 lock the whole block More...
 
uint8_t w25qxx_global_block_unlock (w25qxx_handle_t *handle)
 unlock the whole block More...
 
uint8_t w25qxx_set_read_parameters (w25qxx_handle_t *handle, w25qxx_qspi_read_dummy_t dummy, w25qxx_qspi_read_wrap_length_t length)
 set the read parameters More...
 
uint8_t w25qxx_enter_qspi_mode (w25qxx_handle_t *handle)
 enter the qspi mode More...
 
uint8_t w25qxx_exit_qspi_mode (w25qxx_handle_t *handle)
 exit the qspi mode More...
 
uint8_t w25qxx_enable_reset (w25qxx_handle_t *handle)
 enable the reset More...
 
uint8_t w25qxx_reset_device (w25qxx_handle_t *handle)
 reset the device More...
 
uint8_t w25qxx_get_unique_id (w25qxx_handle_t *handle, uint8_t id[8])
 get the unique id More...
 
uint8_t w25qxx_get_sfdp (w25qxx_handle_t *handle, uint8_t sfdp[256])
 get the sfdp More...
 
uint8_t w25qxx_erase_security_register (w25qxx_handle_t *handle, w25qxx_security_register_t num)
 erase the security register More...
 
uint8_t w25qxx_program_security_register (w25qxx_handle_t *handle, w25qxx_security_register_t num, uint8_t data[256])
 program the security register More...
 
uint8_t w25qxx_read_security_register (w25qxx_handle_t *handle, w25qxx_security_register_t num, uint8_t data[256])
 read the security register More...
 
uint8_t w25qxx_individual_block_lock (w25qxx_handle_t *handle, uint32_t addr)
 lock the individual block More...
 
uint8_t w25qxx_individual_block_unlock (w25qxx_handle_t *handle, uint32_t addr)
 unlock the individual block More...
 
uint8_t w25qxx_read_block_lock (w25qxx_handle_t *handle, uint32_t addr, uint8_t *value)
 read the block lock More...
 
uint8_t w25qxx_set_burst_with_wrap (w25qxx_handle_t *handle, w25qxx_burst_wrap_t wrap)
 set the burst with wrap More...
 
uint8_t w25qxx_write_read_reg (w25qxx_handle_t *handle, uint8_t instruction, uint8_t instruction_line, uint32_t address, uint8_t address_line, uint8_t address_len, uint32_t alternate, uint8_t alternate_line, uint8_t alternate_len, uint8_t dummy, uint8_t *in_buf, uint32_t in_len, uint8_t *out_buf, uint32_t out_len, uint8_t data_line)
 write and read register More...
 

Detailed Description

driver w25qxx header file

Copyright (c) 2015 - present LibDriver All rights reserved

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Version
1.0.0
Author
Shifeng Li
Date
2021-07-15

history

Date Version Author Description
2021/07/15 1.0 Shifeng Li first upload

Definition in file driver_w25qxx.h.