42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_spi_master.h"
67#define FLASH3_MAP_MIKROBUS( cfg, mikrobus ) \
68 cfg.miso= MIKROBUS( mikrobus, MIKROBUS_MISO ); \
69 cfg.mosi= MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
70 cfg.sck= MIKROBUS( mikrobus, MIKROBUS_SCK ); \
71 cfg.cs= MIKROBUS( mikrobus, MIKROBUS_CS ); \
72 cfg.hlo= MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.wp= MIKROBUS( mikrobus, MIKROBUS_PWM )
80#define FLASH3_RETVAL uint8_t
83#define FLASH3_INIT_ERROR 0xFF
90#define FLASH3_STATUS_WIP 0x01
91#define FLASH3_STATUS_WEL 0x02
92#define FLASH3_STATUS_BP_0 0x04
93#define FLASH3_STATUS_BP_1 0x08
94#define FLASH3_STATUS_BP_2 0x10
95#define FLASH3_STATUS_BP_3 0x20
96#define FLASH3_STATUS_QE 0x40
97#define FLASH3_STATUS_SRWD 0x80
104#define FLASH3_FUNC_TBS 0x02
105#define FLASH3_FUNC_PSUS 0x04
106#define FLASH3_FUNC_ESUS 0x08
107#define FLASH3_FUNC_IRL_0 0x10
108#define FLASH3_FUNC_IRL_1 0x20
109#define FLASH3_FUNC_IRL_2 0x40
110#define FLASH3_FUNC_IRL_3 0x80
117#define FLASH3_NOP 0x00
118#define FLASH3_WRSR 0x01
119#define FLASH3_PP 0x02
120#define FLASH3_WRDI 0x04
121#define FLASH3_RDSR 0x05
122#define FLASH3_WREN 0x06
123#define FLASH3_RDFR 0x48
124#define FLASH3_WRFR 0x42
125#define FLASH3_PERSUS 0x75
126#define FLASH3_PERRSM 0x7A
127#define FLASH3_DP 0xB9
128#define FLASH3_RDID 0xAB
129#define FLASH3_SRP 0xC0
130#define FLASH3_RDJDID 0x9F
131#define FLASH3_RDMDID 0x90
132#define FLASH3_RDJDIDQ 0xAF
133#define FLASH3_RDUID 0x4B
134#define FLASH3_RDSFDP 0x5A
135#define FLASH3_RSTEN 0x66
136#define FLASH3_RST 0x99
137#define FLASH3_IRER 0x64
138#define FLASH3_IRP 0x62
139#define FLASH3_IRRD 0x68
140#define FLASH3_SECUN_LOCK 0x26
141#define FLASH3_SECLOCK 0x24
148#define FLASH3_SECTOR_ER 0xD7
149#define FLASH3_BLOCK_ER32 0x52
150#define FLASH3_BLOCK_ER64 0xD8
151#define FLASH3_CHIP_ER 0xC7
158#define FLASH3_NORMAL_RD 0x03
159#define FLASH3_FAST_RD 0x0B
256 uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
#define FLASH3_RETVAL
Definition flash3.h:80
void flash3_generic_transfer(flash3_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void flash3_write_cmd(flash3_t *ctx, uint8_t cmd)
Write command function.
void flash3_normal_read(flash3_t *ctx, uint32_t addr, uint8_t *buff, uint32_t cnt)
Normal data read function.
void flash3_block64_erase(flash3_t *ctx, uint32_t address)
Block 64 erase function.
void flash3_wr_prot_enable(flash3_t *ctx)
Write Protect enable function.
void flash3_write(flash3_t *ctx, uint32_t addr, uint8_t *buff, uint32_t cnt)
Fast data read function.
void flash3_wr_prot_disable(flash3_t *ctx)
Disable write function.
void flash3_write_disable(flash3_t *ctx)
Enable write function.
FLASH3_RETVAL flash3_init(flash3_t *ctx, flash3_cfg_t *cfg)
Initialization function.
void flash3_fast_read(flash3_t *ctx, uint32_t addr, uint8_t *buff, uint32_t cnt)
Fast data read function.
void flash3_cfg_setup(flash3_cfg_t *cfg)
Config Object Initialization function.
void flash3_write_adv_cmd(flash3_t *ctx, uint8_t cmd, uint8_t *arg, uint32_t cnt)
Flash 3 Command Advanced function.
void flash3_pause(flash3_t *ctx)
Pause function.
uint8_t flash3_rd_stat_reg(flash3_t *ctx)
Reads Status Register function.
void flash3_block32_erase(flash3_t *ctx, uint32_t address)
Block 32 erase function.
void flash3_chip_erase(flash3_t *ctx)
Chip erase function.
void flash3_wr_stat_reg(flash3_t *ctx, uint8_t status)
Write Status Register function.
void flash3_wr_func_reg(flash3_t *ctx, uint8_t function)
Reads Function Register function.
uint8_t flash3_rd_func_reg(flash3_t *ctx)
Reads Function Register function.
void flash3_write_enable(flash3_t *ctx)
Enable write function.
void flash3_setting(flash3_t *ctx)
Initialisation function.
void flash3_unpause(flash3_t *ctx)
Unpause function.
void flash3_sector_erase(flash3_t *ctx, uint32_t address)
Sector erase function.
Click configuration structure definition.
Definition flash3.h:191
pin_name_t hlo
Definition flash3.h:201
spi_master_chip_select_polarity_t cs_polarity
Definition flash3.h:208
pin_name_t sck
Definition flash3.h:196
spi_master_mode_t spi_mode
Definition flash3.h:207
pin_name_t mosi
Definition flash3.h:195
uint32_t spi_speed
Definition flash3.h:206
pin_name_t wp
Definition flash3.h:202
pin_name_t miso
Definition flash3.h:194
pin_name_t cs
Definition flash3.h:197
Click ctx object definition.
Definition flash3.h:173
digital_out_t cs
Definition flash3.h:178
spi_master_t spi
Definition flash3.h:182
digital_out_t hlo
Definition flash3.h:176
pin_name_t chip_select
Definition flash3.h:183
digital_out_t wp
Definition flash3.h:177