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 FLASH4_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.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.io2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
74 cfg.io3 = MIKROBUS( mikrobus, MIKROBUS_INT )
81#define FLASH4_RETVAL uint8_t
84#define FLASH4_INIT_ERROR 0xFF
90#define FLASH4_MANUFACTURER_ID 0x01
91#define FLASH4_DEVICE_ID 0x19
97#define FLASH4_CMD_READ_ID 0x90
98#define FLASH4_CMD_READ_IDENTIFICATION 0x9F
99#define FLASH4_CMD_READ_ELECTRONIC_SIGNATURE 0xAB
100#define FLASH4_CMD_READ_SERIAL_FLASH_PARAMETERS 0x5A
101#define FLASH4_CMD_READ_STATUS_REG_1 0x05
102#define FLASH4_CMD_READ_STATUS_REG_2 0x07
103#define FLASH4_CMD_READ_CONFIGURATION_REG 0x35
104#define FLASH4_CMD_READ_BANK_REG 0x16
105#define FLASH4_CMD_WRITE_BANK_REG 0x17
106#define FLASH4_CMD_ACCESS_BANK_REG 0xB9
107#define FLASH4_CMD_WRITE_REGISTER_WRR 0x01
108#define FLASH4_CMD_WRITE_ENABLE_WREN 0x06
109#define FLASH4_CMD_WRITE_DISABLE_WRDI 0x04
110#define FLASH4_CMD_CLEAR_STATUS_REG 0x30
111#define FLASH4_CMD_READ_ECC_STATUS_REG 0x18
112#define FLASH4_CMD_READ_AUTO_BOOT_REG 0x14
113#define FLASH4_CMD_WRITE_AUTO_BOOT_REG 0x15
114#define FLASH4_CMD_PROGRAM_NVDLR 0x43
115#define FLASH4_CMD_WRITE_VDLR 0x4A
116#define FLASH4_CMD_READ_DATA_LEARNING_PATTERN 0x41
117#define FLASH4_CMD_READ_FLASH 0x03
118#define FLASH4_CMD_4READ_FLASH 0x13
119#define FLASH4_CMD_FAST_READ_FLASH 0x0B
120#define FLASH4_CMD_FAST_4READ_FLASH 0x0C
121#define FLASH4_CMD_FAST_READ_DDR 0x0D
122#define FLASH4_CMD_FAST_4READ_DDR 0x0E
123#define FLASH4_CMD_PAGE_PROGRAM 0x02
124#define FLASH4_CMD_PAGE_4PROGRAM 0x12
125#define FLASH4_CMD_PROGRAM_SUSPEND 0x85
126#define FLASH4_CMD_PROGRAM_RESUME 0x8A
127#define FLASH4_CMD_SECTOR_ERASE 0xD8
128#define FLASH4_CMD_SECTOR_4ERASE 0xDC
129#define FLASH4_CMD_BULK_ERASE 0xC7
130#define FLASH4_CMD_ERASE_SUSPEND 0x75
131#define FLASH4_CMD_ERASE_RESUME 0x7A
132#define FLASH4_CMD_WRITE_OTP_PROGRAM 0x42
133#define FLASH4_CMD_READ_OTP 0x4B
134#define FLASH4_CMD_READ_ASP 0x2B
135#define FLASH4_CMD_WRITE_ASP_PROGRAM 0x2F
136#define FLASH4_CMD_READ_DYB 0xE0
137#define FLASH4_CMD_WRITE_DYB 0xE1
138#define FLASH4_CMD_READ_PPB 0xE2
139#define FLASH4_CMD_WRITE_PPB 0xE3
140#define FLASH4_CMD_ERASE_PPB 0xE4
141#define FLASH4_CMD_READ_PPB_LOCK_BIT 0xA7
142#define FLASH4_CMD_WRITE_PPB_LOCK_BIT 0xA6
143#define FLASH4_CMD_SOFTWARE_RESET 0xF0
144#define FLASH4_CMD_MODE_BIT_RESET 0xFF
#define FLASH4_RETVAL
Definition flash4.h:81
void flash4_read_serial_flash_parameters(flash4_t *ctx, uint8_t *out_params, uint8_t c)
Read Serial Flash Discoverable Parameters function.
void flash4_generic_transfer(flash4_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
void flash4_sector_erase(flash4_t *ctx, uint32_t addr)
Sector Erase function.
uint8_t flash4_check_wel(flash4_t *ctx)
Function for wel.
FLASH4_RETVAL flash4_init(flash4_t *ctx, flash4_cfg_t *cfg)
Initialization function. *.
void flash4_read_flash(flash4_t *ctx, uint8_t *out_data, uint32_t addr, uint8_t n_data)
Read Flash function.
void flash4_cfg_setup(flash4_cfg_t *cfg)
Config Object Initialization function.
uint8_t flash4_check_es(flash4_t *ctx)
Function for es.
void flash4_write_byte(flash4_t *ctx, uint8_t reg, uint8_t data_buff)
Write one byte to register function.
void flash4_read_flash_4(flash4_t *ctx, uint8_t *out_data, uint32_t addr, uint8_t n_data)
Read Flash with 4 byte address function.
void flash4_fast_read_flash(flash4_t *ctx, uint8_t *out_data, uint32_t addr, uint8_t n_data_dummy)
Fast read Flash function.
void flash4_sector_erase_4(flash4_t *ctx, uint32_t addr)
Sector Erase for 4 bytes address function.
void flash4_write_command(flash4_t *ctx, uint8_t cmd)
Write command function.
void flash4_page_program_4(flash4_t *ctx, uint8_t *in_data, uint32_t addr, uint8_t n_data)
Write data to address with 4 byte address function.
void flash4_read_ecc(flash4_t *ctx, uint8_t *out_ecc, uint8_t n_dummy)
Read ECC Status Register function.
void flash4_reset(flash4_t *ctx)
Function for reset.
uint8_t flash4_check_ps(flash4_t *ctx)
Function for ps.
uint8_t flash4_check_wip(flash4_t *ctx)
Function for wip.
void flash4_read_identification(flash4_t *ctx, uint8_t *out_data, uint8_t n_data)
Read Identification function.
void flash4_read_manufacturer_id(flash4_t *ctx, uint8_t *device_id)
Read Manufacturer ID function.
void flash4_fast_read_flash_4(flash4_t *ctx, uint8_t *out_data, uint8_t addr, uint8_t n_data)
Fast read Flash with 4 byte address function.
uint8_t flash4_read_electronic_id(flash4_t *ctx)
Read Electronic Signature function.
void flash4_write_reg(flash4_t *ctx, uint8_t status, uint8_t config)
Write data to register function.
uint8_t flash4_read_byte(flash4_t *ctx, uint8_t reg)
Read byte from register function.
void flash4_read_auto_boot(flash4_t *ctx, uint8_t *out_ab)
Read AutoBoot Register function.
Click configuration structure definition.
Definition flash4.h:176
spi_master_chip_select_polarity_t cs_polarity
Definition flash4.h:194
pin_name_t io2
Definition flash4.h:187
pin_name_t sck
Definition flash4.h:181
spi_master_mode_t spi_mode
Definition flash4.h:193
pin_name_t mosi
Definition flash4.h:180
uint32_t spi_speed
Definition flash4.h:192
pin_name_t miso
Definition flash4.h:179
pin_name_t io3
Definition flash4.h:188
pin_name_t rst
Definition flash4.h:186
pin_name_t cs
Definition flash4.h:182
Click ctx object definition.
Definition flash4.h:157
digital_out_t cs
Definition flash4.h:160
spi_master_t spi
Definition flash4.h:167
digital_out_t io3
Definition flash4.h:162
digital_out_t io2
Definition flash4.h:163
digital_out_t rst
Definition flash4.h:161
pin_name_t chip_select
Definition flash4.h:168