39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define SQIFLASH_STATUS_WEL 0x02
75#define SQIFLASH_STATUS_WSE 0x04
76#define SQIFLASH_STATUS_WSP 0x08
77#define SQIFLASH_STATUS_WPLD 0x10
78#define SQIFLASH_STATUS_SEC 0x20
79#define SQIFLASH_STATUS_RES 0x40
80#define SQIFLASH_STATUS_BUSY 0x80
81#define SQIFLASH_CFG_RES 0x01
82#define SQIFLASH_CFG_IOC 0x02
83#define SQIFLASH_CFG_BPNV 0x08
84#define SQIFLASH_CFG_WPEN 0x80
90#define SQIFLASH_INSTR_NOP 0x00
91#define SQIFLASH_INSTR_RSTEN 0x66
92#define SQIFLASH_INSTR_RST 0x99
93#define SQIFLASH_INSTR_EQIO 0x38
94#define SQIFLASH_INSTR_RSTQIO 0xFF
95#define SQIFLASH_INSTR_RDSR 0x05
96#define SQIFLASH_INSTR_WRSR 0x01
97#define SQIFLASH_INSTR_RDCR 0x35
98#define SQIFLASH_INSTR_READ 0x03
99#define SQIFLASH_INSTR_HS_READ 0x0B
100#define SQIFLASH_INSTR_SQOR 0x6B
101#define SQIFLASH_INSTR_SQIOR 0xEB
102#define SQIFLASH_INSTR_SDOR 0x3B
103#define SQIFLASH_INSTR_SDIOR 0xBB
104#define SQIFLASH_INSTR_SB 0xC0
105#define SQIFLASH_INSTR_RBSQI 0x0C
106#define SQIFLASH_INSTR_RBSPI 0xEC
107#define SQIFLASH_INSTR_JEDECID 0x9F
108#define SQIFLASH_INSTR_QUAD_JID 0xAF
109#define SQIFLASH_INSTR_SFDP 0x5A
110#define SQIFLASH_INSTR_WREN 0x06
111#define SQIFLASH_INSTR_WRDI 0x04
112#define SQIFLASH_INSTR_SE 0x20
113#define SQIFLASH_INSTR_BE 0xD8
114#define SQIFLASH_INSTR_CE 0xC7
115#define SQIFLASH_INSTR_PP 0x02
116#define SQIFLASH_INSTR_SPI_QUAD 0x32
117#define SQIFLASH_INSTR_WRSU 0xB0
118#define SQIFLASH_INSTR_WRRE 0x30
119#define SQIFLASH_INSTR_RBPR 0x72
120#define SQIFLASH_INSTR_WBPR 0x42
121#define SQIFLASH_INSTR_LBPR 0x8D
122#define SQIFLASH_INSTR_NVWLDR 0xE8
123#define SQIFLASH_INSTR_ULBPR 0x98
124#define SQIFLASH_INSTR_RSID 0x88
125#define SQIFLASH_INSTR_PSID 0xA5
126#define SQIFLASH_INSTR_LSID 0x85
127#define SQIFLASH_START_PAGE_ADDRESS 0x010000ul
128#define SQIFLASH_END_PAGE_ADDRESS 0x7FFFFFul
129#define SQIFLASH_FLASH_PAGE_SIZE 256
139#define SQIFLASH_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
140#define SQIFLASH_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
158#define SQIFLASH_MAP_MIKROBUS( cfg, mikrobus ) \
159 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
160 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
161 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
162 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
163 cfg.sq3 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
164 cfg.sq2 = MIKROBUS( mikrobus, MIKROBUS_PWM )
689 uint8_t *buffer, uint32_t data_count );
uint8_t sqiflash_program_status(sqiflash_t *ctx)
SQI FLASH Program Status.
uint8_t sqiflash_get_status_reg(sqiflash_t *ctx)
SQI FLASH Get Status Register.
err_t sqiflash_generic_read(sqiflash_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
SQI FLASH data reading function.
void sqiflash_write_generic(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Write.
void sqiflash_hold_enable(sqiflash_t *ctx)
SQI FLASH Hold Enable.
uint8_t sqiflash_erase_status(sqiflash_t *ctx)
SQI FLASH Erase Status.
void sqiflash_nonvolatile_write_lock(sqiflash_t *ctx, uint8_t *buffer)
SQI FLASH Non-Volatile Write-Lock.
void sqiflash_quad_write(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Quad Write.
void sqiflash_quad_io_read(sqiflash_t *ctx, uint32_t address, uint8_t mode, uint8_t *buffer, uint32_t data_count)
SQI FLASH Quad I/O Read.
err_t sqiflash_generic_write(sqiflash_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
SQI FLASH data writing function.
uint8_t sqiflash_protect_status(sqiflash_t *ctx)
SQI FLASH Protect Status.
void sqiflash_write_protect_enable(sqiflash_t *ctx)
SQI FLASH Write Protect Enable .
uint8_t sqiflash_write_status(sqiflash_t *ctx)
SQI FLASH Write Status.
void sqiflash_read_generic(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Read.
uint8_t sqiflash_security_status(sqiflash_t *ctx)
SQI FLASH Security Status.
void sqiflash_block_erase(sqiflash_t *ctx, uint32_t address)
SQI FLASH Block Erase.
uint8_t sqiflash_get_config_reg(sqiflash_t *ctx)
SQI FLASH Get Config Register.
void sqiflash_spi_get_security_id(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Security ID SPI.
void sqiflash_write_resume(sqiflash_t *ctx)
SQI FLASH Write Resume.
void sqiflash_write_suspend(sqiflash_t *ctx)
SQI FLASH Write Suspend.
void sqiflash_write_protect_disable(sqiflash_t *ctx)
SQI FLASH Write Protect Disable.
void sqiflash_write_disable(sqiflash_t *ctx)
SQI FLASH Write Disable.
void sqiflash_quad_enable(sqiflash_t *ctx)
SQI FLASH Quad Enable.
void sqiflash_read_dual_io(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Read Dual I/O.
void sqiflash_sector_erase(sqiflash_t *ctx, uint32_t address)
SQI FLASH Sector Erase.
void sqiflash_read_dual_output(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Read Dual Output.
void sqiflash_write_status_reg(sqiflash_t *ctx, uint8_t s_reg)
SQI FLASH Write Status Register.
err_t sqiflash_init(sqiflash_t *ctx, sqiflash_cfg_t *cfg)
SQI FLASH initialization function.
void sqiflash_reset(sqiflash_t *ctx)
SQI FLASH Reset.
uint8_t sqiflash_device_id(sqiflash_t *ctx)
SQI FLASH Device ID.
uint8_t sqiflash_quad_device_id(sqiflash_t *ctx)
SQI FLASH Quad Device ID.
void sqiflash_read_sqi_burst_wrap(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Read Burst with Wrap through SQI.
void sqiflash_lock_bpr(sqiflash_t *ctx)
SQI FLASH Lock Block Protection Register.
uint8_t sqiflash_device_type(sqiflash_t *ctx)
SQI FLASH Device Type.
void sqiflash_quad_out_read(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Quad Output Read.
void sqiflash_read_spi_burst_wrap(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Read Burst with Wrap through SPI.
void sqiflash_chip_erase(sqiflash_t *ctx)
SQI FLASH Chip Erase.
void sqiflash_sqi_get_security_id(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Security ID SQI.
void sqiflash_cfg_setup(sqiflash_cfg_t *cfg)
SQI FLASH configuration object setup function.
void sqiflash_sqi_get_bpr(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Block Protection Register SQI.
void sqiflash_lock_security_id(sqiflash_t *ctx)
SQI FLASH Lock Security Status.
void sqiflash_set_bpr(sqiflash_t *ctx, uint8_t *buffer)
SQI FLASH Set Block Protection Register.
void sqiflash_quad_reset(sqiflash_t *ctx)
SQI FLASH Quad Reset.
void sqiflash_global_block_unlock(sqiflash_t *ctx)
SQI FLASH Global Block Unlock.
void sqiflash_set_burst(sqiflash_t *ctx, uint8_t length)
SQI FLASH Set Burst.
uint8_t sqiflash_quad_device_type(sqiflash_t *ctx)
SQI FLASH Quad Device Type.
void sqiflash_set_security_id(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Set Security ID.
void sqiflash_spi_get_bpr(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Block Protection Register SPI.
uint8_t sqiflash_quad_device_manufac(sqiflash_t *ctx)
SQI FLASH Quad Device Manufacturer.
uint8_t sqiflash_device_manufac(sqiflash_t *ctx)
SQI FLASH Device Manufacturer.
void sqiflash_get_sfdp_params(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH get Serial Flash Discoverable.
uint8_t sqiflash_busy(sqiflash_t *ctx)
SQI FLASH Busy.
void sqiflash_highspeed_r_read(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH High Speed Read.
void sqiflash_write_enable(sqiflash_t *ctx)
SQI FLASH Write Enable.
void sqiflash_hold_disable(sqiflash_t *ctx)
SQI FLASH Hold Disable.
uint32_t address
Definition main.c:35
This file contains SPI specific macros, functions, etc.
sqiflash_return_value_t
SQI FLASH Click return value data.
Definition sqiflash.h:214
@ SQIFLASH_ERROR
Definition sqiflash.h:216
@ SQIFLASH_OK
Definition sqiflash.h:215
SQI FLASH Click configuration object.
Definition sqiflash.h:191
pin_name_t sq3
Definition sqiflash.h:199
spi_master_chip_select_polarity_t cs_polarity
Definition sqiflash.h:205
pin_name_t sck
Definition sqiflash.h:195
spi_master_mode_t spi_mode
Definition sqiflash.h:204
pin_name_t sq2
Definition sqiflash.h:200
pin_name_t mosi
Definition sqiflash.h:194
uint32_t spi_speed
Definition sqiflash.h:203
pin_name_t miso
Definition sqiflash.h:193
pin_name_t cs
Definition sqiflash.h:196
SQI FLASH Click context object.
Definition sqiflash.h:174
spi_master_t spi
Definition sqiflash.h:180
digital_out_t sq3
Definition sqiflash.h:176
digital_out_t sq2
Definition sqiflash.h:177
pin_name_t chip_select
Definition sqiflash.h:182