Go to the documentation of this file.
35 #include "mikrosdk_version.h"
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_spi_master.h"
70 #define SQIFLASH_STATUS_WEL 0x02
71 #define SQIFLASH_STATUS_WSE 0x04
72 #define SQIFLASH_STATUS_WSP 0x08
73 #define SQIFLASH_STATUS_WPLD 0x10
74 #define SQIFLASH_STATUS_SEC 0x20
75 #define SQIFLASH_STATUS_RES 0x40
76 #define SQIFLASH_STATUS_BUSY 0x80
77 #define SQIFLASH_CFG_RES 0x01
78 #define SQIFLASH_CFG_IOC 0x02
79 #define SQIFLASH_CFG_BPNV 0x08
80 #define SQIFLASH_CFG_WPEN 0x80
86 #define SQIFLASH_INSTR_NOP 0x00
87 #define SQIFLASH_INSTR_RSTEN 0x66
88 #define SQIFLASH_INSTR_RST 0x99
89 #define SQIFLASH_INSTR_EQIO 0x38
90 #define SQIFLASH_INSTR_RSTQIO 0xFF
91 #define SQIFLASH_INSTR_RDSR 0x05
92 #define SQIFLASH_INSTR_WRSR 0x01
93 #define SQIFLASH_INSTR_RDCR 0x35
94 #define SQIFLASH_INSTR_READ 0x03
95 #define SQIFLASH_INSTR_HS_READ 0x0B
96 #define SQIFLASH_INSTR_SQOR 0x6B
97 #define SQIFLASH_INSTR_SQIOR 0xEB
98 #define SQIFLASH_INSTR_SDOR 0x3B
99 #define SQIFLASH_INSTR_SDIOR 0xBB
100 #define SQIFLASH_INSTR_SB 0xC0
101 #define SQIFLASH_INSTR_RBSQI 0x0C
102 #define SQIFLASH_INSTR_RBSPI 0xEC
103 #define SQIFLASH_INSTR_JEDECID 0x9F
104 #define SQIFLASH_INSTR_QUAD_JID 0xAF
105 #define SQIFLASH_INSTR_SFDP 0x5A
106 #define SQIFLASH_INSTR_WREN 0x06
107 #define SQIFLASH_INSTR_WRDI 0x04
108 #define SQIFLASH_INSTR_SE 0x20
109 #define SQIFLASH_INSTR_BE 0xD8
110 #define SQIFLASH_INSTR_CE 0xC7
111 #define SQIFLASH_INSTR_PP 0x02
112 #define SQIFLASH_INSTR_SPI_QUAD 0x32
113 #define SQIFLASH_INSTR_WRSU 0xB0
114 #define SQIFLASH_INSTR_WRRE 0x30
115 #define SQIFLASH_INSTR_RBPR 0x72
116 #define SQIFLASH_INSTR_WBPR 0x42
117 #define SQIFLASH_INSTR_LBPR 0x8D
118 #define SQIFLASH_INSTR_NVWLDR 0xE8
119 #define SQIFLASH_INSTR_ULBPR 0x98
120 #define SQIFLASH_INSTR_RSID 0x88
121 #define SQIFLASH_INSTR_PSID 0xA5
122 #define SQIFLASH_INSTR_LSID 0x85
123 #define SQIFLASH_START_PAGE_ADDRESS 0x010000ul
124 #define SQIFLASH_END_PAGE_ADDRESS 0x7FFFFFul
125 #define SQIFLASH_FLASH_PAGE_SIZE 256
135 #define SQIFLASH_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
136 #define SQIFLASH_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
154 #define SQIFLASH_MAP_MIKROBUS( cfg, mikrobus ) \
155 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
156 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
157 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
158 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
159 cfg.sq3 = MIKROBUS( mikrobus, MIKROBUS_RST ); \
160 cfg.sq2 = MIKROBUS( mikrobus, MIKROBUS_PWM )
685 uint8_t *buffer, uint32_t data_count );
void sqiflash_quad_enable(sqiflash_t *ctx)
SQI FLASH Quad Enable.
uint8_t sqiflash_program_status(sqiflash_t *ctx)
SQI FLASH Program Status.
void sqiflash_read_dual_output(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Read Dual Output.
pin_name_t sck
Definition: sqiflash.h:191
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_erase_status(sqiflash_t *ctx)
SQI FLASH Erase Status.
uint8_t sqiflash_security_status(sqiflash_t *ctx)
SQI FLASH Security Status.
pin_name_t mosi
Definition: sqiflash.h:190
void sqiflash_lock_security_id(sqiflash_t *ctx)
SQI FLASH Lock Security Status.
void sqiflash_write_resume(sqiflash_t *ctx)
SQI FLASH Write Resume.
uint8_t sqiflash_device_type(sqiflash_t *ctx)
SQI FLASH Device Type.
void sqiflash_write_status_reg(sqiflash_t *ctx, uint8_t s_reg)
SQI FLASH Write Status Register.
void sqiflash_quad_out_read(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Quad Output Read.
This file contains SPI specific macros, functions, etc.
void sqiflash_block_erase(sqiflash_t *ctx, uint32_t address)
SQI FLASH Block Erase.
uint8_t sqiflash_quad_device_id(sqiflash_t *ctx)
SQI FLASH Quad Device ID.
pin_name_t miso
Definition: sqiflash.h:189
void sqiflash_set_burst(sqiflash_t *ctx, uint8_t length)
SQI FLASH Set Burst.
void sqiflash_chip_erase(sqiflash_t *ctx)
SQI FLASH Chip Erase.
void sqiflash_write_enable(sqiflash_t *ctx)
SQI FLASH Write Enable.
uint8_t sqiflash_write_status(sqiflash_t *ctx)
SQI FLASH Write Status.
void sqiflash_hold_disable(sqiflash_t *ctx)
SQI FLASH Hold Disable.
SQI FLASH Click context object.
Definition: sqiflash.h:170
err_t sqiflash_init(sqiflash_t *ctx, sqiflash_cfg_t *cfg)
SQI FLASH initialization function.
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.
digital_out_t sq3
Definition: sqiflash.h:172
void sqiflash_set_security_id(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Set Security ID.
spi_master_chip_select_polarity_t cs_polarity
Definition: sqiflash.h:201
void sqiflash_global_block_unlock(sqiflash_t *ctx)
SQI FLASH Global Block Unlock.
SQI FLASH Click configuration object.
Definition: sqiflash.h:187
void sqiflash_write_generic(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Write.
err_t sqiflash_generic_read(sqiflash_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
SQI FLASH data reading function.
@ SQIFLASH_OK
Definition: sqiflash.h:211
void sqiflash_write_protect_enable(sqiflash_t *ctx)
SQI FLASH Write Protect Enable .
void sqiflash_cfg_setup(sqiflash_cfg_t *cfg)
SQI FLASH configuration object setup function.
uint8_t sqiflash_device_manufac(sqiflash_t *ctx)
SQI FLASH Device Manufacturer.
void sqiflash_sqi_get_bpr(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Block Protection Register SQI.
void sqiflash_sqi_get_security_id(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Security ID SQI.
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_hold_enable(sqiflash_t *ctx)
SQI FLASH Hold Enable.
pin_name_t sq3
Definition: sqiflash.h:195
void sqiflash_write_disable(sqiflash_t *ctx)
SQI FLASH Write Disable.
void sqiflash_quad_reset(sqiflash_t *ctx)
SQI FLASH Quad Reset.
void sqiflash_read_generic(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Read.
uint8_t sqiflash_quad_device_type(sqiflash_t *ctx)
SQI FLASH Quad Device Type.
void sqiflash_sector_erase(sqiflash_t *ctx, uint32_t address)
SQI FLASH Sector Erase.
digital_out_t sq2
Definition: sqiflash.h:173
uint8_t sqiflash_device_id(sqiflash_t *ctx)
SQI FLASH Device ID.
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.
uint8_t sqiflash_get_config_reg(sqiflash_t *ctx)
SQI FLASH Get Config Register.
err_t sqiflash_generic_write(sqiflash_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
SQI FLASH data writing function.
@ SQIFLASH_ERROR
Definition: sqiflash.h:212
uint32_t address
Definition: main.c:35
spi_master_mode_t spi_mode
Definition: sqiflash.h:200
void sqiflash_write_suspend(sqiflash_t *ctx)
SQI FLASH Write Suspend.
pin_name_t chip_select
Definition: sqiflash.h:178
uint8_t sqiflash_get_status_reg(sqiflash_t *ctx)
SQI FLASH Get Status Register.
void sqiflash_lock_bpr(sqiflash_t *ctx)
SQI FLASH Lock Block Protection Register.
pin_name_t sq2
Definition: sqiflash.h:196
pin_name_t cs
Definition: sqiflash.h:192
void sqiflash_spi_get_security_id(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Security ID SPI.
uint8_t sqiflash_protect_status(sqiflash_t *ctx)
SQI FLASH Protect Status.
void sqiflash_quad_write(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH Quad Write.
void sqiflash_write_protect_disable(sqiflash_t *ctx)
SQI FLASH Write Protect Disable.
uint32_t spi_speed
Definition: sqiflash.h:199
uint8_t sqiflash_quad_device_manufac(sqiflash_t *ctx)
SQI FLASH Quad Device Manufacturer.
void sqiflash_highspeed_r_read(sqiflash_t *ctx, uint32_t address, uint8_t *buffer, uint32_t data_count)
SQI FLASH High Speed Read.
spi_master_t spi
Definition: sqiflash.h:176
uint8_t sqiflash_busy(sqiflash_t *ctx)
SQI FLASH Busy.
sqiflash_return_value_t
SQI FLASH Click return value data.
Definition: sqiflash.h:210
void sqiflash_set_bpr(sqiflash_t *ctx, uint8_t *buffer)
SQI FLASH Set Block Protection Register.
void sqiflash_spi_get_bpr(sqiflash_t *ctx, uint8_t *buffer, uint32_t data_count)
SQI FLASH Get Block Protection Register SPI.
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_nonvolatile_write_lock(sqiflash_t *ctx, uint8_t *buffer)
SQI FLASH Non-Volatile Write-Lock.
void sqiflash_reset(sqiflash_t *ctx)
SQI FLASH Reset.