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 FLASH5_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.wp = MIKROBUS( mikrobus, MIKROBUS_RST ); \
73 cfg.hld = MIKROBUS( mikrobus, MIKROBUS_PWM );
80#define FLASH5_RETVAL uint8_t
83#define FLASH5_INIT_ERROR 0xFF
90#define FLASH5_MAX_addr 0xFFFF
91#define FLASH5_PAGESIZE 2048
98#define FLASH5_CMD_RESET 0xFF
99#define FLASH5_CMD_DEVICE_ID 0x9F
100#define FLASH5_CMD_READ_REG_STATUS1 0x05
101#define FLASH5_CMD_READ_REG_STATUS2 0x0F
102#define FLASH5_CMD_WRITE_REG_STATUS1 0x01
103#define FLASH5_CMD_WRITE_REG_STATUS2 0x1F
104#define FLASH5_CMD_WRITE_ENABLE 0x06
105#define FLASH5_CMD_WRITE_DISABLE 0x04
106#define FLASH5_CMD_BAD_BLOCK_MANAGE 0xA1
107#define FLASH5_CMD_READ_BBM_TABLE 0xA5
108#define FLASH5_CMD_LAST_ECC_FAIL_PAGE 0xA9
109#define FLASH5_CMD_BLOCK_ERASE 0xD8
110#define FLASH5_CMD_LOAD_DATA 0x02
111#define FLASH5_CMD__RND_LOAD_DATA 0x84
112#define FLASH5_CMD_QUAD_LOAD_DATA 0x32
113#define FLASH5_CMD_QUAD_RND_LOAD_DATA 0x34
114#define FLASH5_CMD_EXECUTE 0x10
115#define FLASH5_CMD_PAGE_READ_DATA 0x13
116#define FLASH5_CMD_READ_DATA 0x03
117#define FLASH5_CMD_FAST_READ 0x0B
118#define FLASH5_CMD_FAST_READ_4BYTE_addr 0x0C
119#define FLASH5_CMD_FAST_READ_DUAL_OUT 0x3B
120#define FLASH5_CMD_FAST_READ_DUAL_OUT_4BYTE_addr 0x3C
121#define FLASH5_CMD_FAST_READ_QUAD_OUT 0x6B
122#define FLASH5_CMD_FAST_READ_QUAD_OUT_4BYTE_addr 0x6C
123#define FLASH5_CMD_FAST_READ_DUAL_IO 0xBB
124#define FLASH5_CMD_FAST_READ_IO_4BYTE_addr 0xBC
125#define FLASH5_CMD_FAST_READ_QUAD_IO 0xEB
126#define FLASH5_CMD_FAST_READ_QUAD_IO_4BYTE_addr 0xEC
133#define FLASH5_REG_STATUS_1 0xA0
134#define FLASH5_REG_STATUS_2 0xB0
135#define FLASH5_REG_STATUS_3 0xC0
142#define FLASH5_RS1_WRITE_PROTECTION_ENABLE 0x02
143#define FLASH5_RS1_WRITE_PROTECTION_DISABLE 0x00
144#define FLASH5_RS1_SRP1_ENABLE 0x01
145#define FLASH5_RS1_SRP2_ENABLE 0x80
152#define FLASH5_RS2_PAGE_READ_MODE 0x08
153#define FLASH5_RS2_PAGE_CONTINOUS_READ_MODE 0x00
154#define FLASH5_RS2_ECC_ENABLED 0x10
155#define FLASH5_RS2_ECC_DISABLED 0x10
156#define FLASH5_RS2_OTP_LOCK 0x80
157#define FLASH5_RS2_OTP_ACCESS 0x40
158#define FLASH5_RS2_REG_STATUS_1_LOCK 0x20
165#define FLASH5_DEVICE_OK 0xFF
166#define FLASH5_DEVICE_ERROR 0xAA
173#define FLASH5_PIN_STATUS_HIGH 1
174#define FLASH5_PIN_STATUS_LOW 0
270 uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len );
#define FLASH5_RETVAL
Definition flash5.h:80
void flash5_page_read(flash5_t *ctx, uint16_t page_num)
Function for setting page read.
void flash5_execute_load(flash5_t *ctx, uint16_t page_num)
Function for executing page load.
void flash5_erase_page_data(flash5_t *ctx, uint16_t page_addr)
Function for eraseing one page.
void flash5_write_data(flash5_t *ctx, uint8_t reg_addr, uint8_t *data_buf, uint16_t n_buf_size)
Generic funcion for writing.
void flash5_page_load_memory(flash5_t *ctx, uint16_t column_addr, uint8_t *data_buf, uint16_t buf_size)
Function for loading one page.
void flash5_read_data(flash5_t *ctx, uint8_t reg_addr, uint8_t *data_buf, uint16_t n_buf_size)
Generic funcion for reading.
void flash5_send_cmd(flash5_t *ctx, uint8_t cmd_data)
Function for sending one Byte od data.
uint8_t flash5_set_hold_pin(flash5_t *ctx, uint8_t status)
Sets hold pin to one state.
void flash5_generic_transfer(flash5_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
uint8_t flash5_set_wp_pin(flash5_t *ctx, uint8_t status)
Sets wp pin to one state.
void flash5_cfg_setup(flash5_cfg_t *cfg)
Config Object Initialization function.
void flash5_continous_read_memory(flash5_t *ctx, uint8_t *data_buf, uint16_t buf_size)
Function for continous reading.
uint8_t flash5_read_status_data(flash5_t *ctx, uint8_t status_cmd, uint8_t status_addr)
Function for reading status data.
void flash5_software_reset(flash5_t *ctx)
Function for reseting device.
uint8_t flash5_device_id_check(flash5_t *ctx)
Funcion for checking device id.
void flash5_page_read_memory(flash5_t *ctx, uint16_t column_addr, uint8_t *data_buf, uint16_t buf_size)
Function for reading one page.
void flash5_write_status_data(flash5_t *ctx, uint8_t status_cmd, uint8_t status_addr, uint8_t status_data)
Function for writing status data.
FLASH5_RETVAL flash5_init(flash5_t *ctx, flash5_cfg_t *cfg)
Initialization function.
Click configuration structure definition.
Definition flash5.h:206
pin_name_t hld
Definition flash5.h:217
spi_master_chip_select_polarity_t cs_polarity
Definition flash5.h:223
pin_name_t sck
Definition flash5.h:211
spi_master_mode_t spi_mode
Definition flash5.h:222
pin_name_t mosi
Definition flash5.h:210
uint32_t spi_speed
Definition flash5.h:221
pin_name_t wp
Definition flash5.h:216
pin_name_t miso
Definition flash5.h:209
pin_name_t cs
Definition flash5.h:212
Click ctx object definition.
Definition flash5.h:188
digital_out_t cs
Definition flash5.h:191
digital_out_t hld
Definition flash5.h:193
spi_master_t spi
Definition flash5.h:197
pin_name_t chip_select
Definition flash5.h:198
digital_out_t wp
Definition flash5.h:192