Go to the documentation of this file.
35 #ifndef SEMPERFLASH2_H
36 #define SEMPERFLASH2_H
38 #include "drv_digital_out.h"
39 #include "drv_digital_in.h"
40 #include "drv_spi_master.h"
53 #define SEMPERFLASH2_MAP_MIKROBUS( cfg, mikrobus ) \
54 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
55 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
56 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
57 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
58 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
59 cfg.io2 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
60 cfg.io3 = MIKROBUS( mikrobus, MIKROBUS_INT )
67 #define SEMPERFLASH2_RETVAL uint8_t
69 #define SEMPERFLASH2_OK 0x00
70 #define SEMPERFLASH2_INIT_ERROR 0xFF
77 #define SEMPERFLASH2_MANUFACTURER_DEVICE_ID 0x9F
78 #define SEMPERFLASH2_JEDEC_SERIAL_FLASH_DISCOVER_PARAMS 0x5A
79 #define SEMPERFLASH2_DEVICE_ID 0x4C
80 #define SEMPERFLASH2_READ_STATUS_REG_1 0x05
81 #define SEMPERFLASH2_READ_STATUS_REG_2 0x07
82 #define SEMPERFLASH2_READ_CFG_REG_1 0x35
83 #define SEMPERFLASH2_READ_ANY_REG 0x65
84 #define SEMPERFLASH2_WRITE_ENABLE 0x06
85 #define SEMPERFLASH2_WRITE_ENABLE_VOLATILE 0x50
86 #define SEMPERFLASH2_WRITE_DISABLE 0x04
87 #define SEMPERFLASH2_WRITE_REG 0x01
88 #define SEMPERFLASH2_WRITE_ANY_REG 0x71
89 #define SEMPERFLASH2_CLEAR_PROGRAM_ERASE_ERROR 0x30
90 #define SEMPERFLASH2_ENTER_4_BYTE_ADDR_MODE 0xB7
91 #define SEMPERFLASH2_EXIT_4_BYTE_ADDR_MODE 0xB8
92 #define SEMPERFLASH2_READ_DATA_LEARN_PATT_REG 0x41
93 #define SEMPERFLASH2_PROGRAM_DATA_LEARN_PATT 0x43
94 #define SEMPERFLASH2_WRITE_DATA_LEARN_PATT 0x4A
95 #define SEMPERFLASH2_AUTOBOOT_REG_WRITE 0x15
96 #define SEMPERFLASH2_READ_ECC_STATUS 0x19
97 #define SEMPERFLASH2_CLEAR_ECC_STATUS 0x1B
98 #define SEMPERFLASH2_DATA_INT_CHECK 0x5B
99 #define SEMPERFLASH2_READ_0 0x03
100 #define SEMPERFLASH2_READ_1 0x13
101 #define SEMPERFLASH2_FAST_READ_0 0x0B
102 #define SEMPERFLASH2_FAST_READ_1 0x0C
103 #define SEMPERFLASH2_PROGRAM_PAGE_0 0x02
104 #define SEMPERFLASH2_PROGRAM_PAGE_1 0x12
105 #define SEMPERFLASH2_ERASE_4K_0 0x20
106 #define SEMPERFLASH2_ERASE_4K_1 0x21
107 #define SEMPERFLASH2_ERASE_256K_1 0xD8
108 #define SEMPERFLASH2_ERASE_256K_2 0xDC
109 #define SEMPERFLASH2_ERASE_CHIP_1 0x60
110 #define SEMPERFLASH2_ERASE_CHIP_2 0xC7
111 #define SEMPERFLASH2_ERASE_STATUS 0xD0
112 #define SEMPERFLASH2_ERASE_CNT 0x5D
113 #define SEMPERFLASH2_SUSPEND_ERASE_PROG_DATA_CHECK 0x75
114 #define SEMPERFLASH2_SUSPEND_ERASE_PROG 0x85
115 #define SEMPERFLASH2_RESUME_ERASE_PROG_DATA_CHECK 0x7A
116 #define SEMPERFLASH2_RESUME_ERASE_PROG 0x8A
117 #define SEMPERFLASH2_PROG_SECURE_SILICON_REGION 0x42
118 #define SEMPERFLASH2_READ_SECURE_SILICON_REGION 0x4B
119 #define SEMPERFLASH2_ASP_PROG 0x2F
120 #define SEMPERFLASH2_READ_DYNAMIC_PROTECION_BIT 0xFA
121 #define SEMPERFLASH2_WRITE_DYNAMIC_PROTECION_BIT 0xFB
122 #define SEMPERFLASH2_READ_PRESISTENT_PROTECTION_BIT 0xFC
123 #define SEMPERFLASH2_PROG_PRESISTENT_PROTECTION_BIT 0xFD
124 #define SEMPERFLASH2_ERASE_PRESISTENT_PROTECTION_BIT 0xE4
125 #define SEMPERFLASH2_WRITE_PPB_PROTECTION_LOCK_BIT 0xA6
126 #define SEMPERFLASH2_READ_PROG_PRESISTENT_PROTECION_LOCK_BIT 0xA7
127 #define SEMPERFLASH2_PROG_PASSWORD 0xE8
128 #define SEMPERFLASH2_PASSWORD_UNLOCK 0xE9
129 #define SEMPERFLASH2_SOFT_RESET_ENABLE 0x66
130 #define SEMPERFLASH2_SOFT_RESET 0x99
131 #define SEMPERFLASH2_LEGACY_SOFT_RESET 0xF0
132 #define SEMPERFLASH2_ENTER_DEEP_POWER_DOWN_MODE 0xB9
134 #define SEMPERFLASH2_PIN_STATE_HIGH 1
135 #define SEMPERFLASH2_PIN_STATE_LOW 0
137 #define SEMPERFLASH2_ID_ERROR 0xCC
138 #define SEMPERFLASH2_SIZE_ERROR 0xBB
139 #define SEMPERFLASH2_SUCCESS 0xAA
141 #define SEMPERFLASH2_MANUFACTURER_DEVICE_ID_VALUE 0x34
142 #define SEMPERFLASH2_DEVICE_ID_BYTE_SIZE 8
144 #define SEMPERFLASH2_STATUS_REG_1_DEFAULT 0x00
145 #define SEMPERFLASH2_STATUS_REG_1_PROGRAM_ERASE_REG_WRITE_ENABLE 0x02
146 #define SEMPERFLASH2_STATUS_REG_1_DEVICE_BUSY 0x01
147 #define SEMPERFLASH2_CFG_1_DEFAULT 0x00
148 #define SEMPERFLASH2_CFG_2_DEFAULT 0x00
149 #define SEMPERFLASH2_CFG_3_DEFAULT 0x00
150 #define SEMPERFLASH2_CFG_4_DEFAULT 0x00
152 #define SEMPERFLASH2_MANUFACTURER_DEVICE_ID_VALUE 0x34
153 #define SEMPERFLASH2_MEMORY_BUF_MAX_SIZE 512
394 #endif // _SEMPERFLASH2_H_
Click configuration structure definition.
Definition: semperflash2.h:186
uint8_t spi_mode
Definition: semperflash2.h:203
uint8_t semperflash2_get_device_id(semperflash2_t *ctx, uint8_t *id_buf)
Get device ID function.
uint8_t semperflash2_check_status_reg_1(semperflash2_t *ctx)
Check status register function.
void semperflash2_send_cmd(semperflash2_t *ctx, uint8_t cmd)
Send command function.
pin_name_t miso
Definition: semperflash2.h:189
pin_name_t rst
Definition: semperflash2.h:196
#define SEMPERFLASH2_RETVAL
Definition: semperflash2.h:67
uint8_t semperflash2_read_memory(semperflash2_t *ctx, uint32_t addr, uint8_t *data_buf, uint16_t buf_size)
Read memory function.
uint8_t cfg1
Definition: semperflash2.h:214
digital_out_t cs
Definition: semperflash2.h:173
void semperflash2_write_config(semperflash2_t *ctx, semperflash2_config_t *cfg_data)
Write configuration function.
Click ctx object definition.
Definition: semperflash2.h:167
spi_master_chip_select_polarity_t cs_polarity
Definition: semperflash2.h:204
pin_name_t io2
Definition: semperflash2.h:197
void semperflash2_generic_write(semperflash2_t *ctx, uint8_t *write_buf, uint16_t buf_size)
Writing data function.
digital_out_t io2
Definition: semperflash2.h:171
pin_name_t chip_select
Definition: semperflash2.h:178
uint8_t semperflash2_check_manufacturer_id(semperflash2_t *ctx)
Check manufacturer ID function.
void semperflash2_transfer_data(semperflash2_t *ctx, uint8_t *write_buf, uint16_t wbuf_size, uint8_t *read_buf, uint16_t rbuf_size)
Transfer data function.
void semperflash2_default_cfg(semperflash2_t *ctx)
Click Default Configuration function.
pin_name_t io3
Definition: semperflash2.h:198
digital_out_t rst
Definition: semperflash2.h:170
Flash configuration structure.
Definition: semperflash2.h:212
pin_name_t cs
Definition: semperflash2.h:192
spi_master_t spi
Definition: semperflash2.h:177
uint8_t cfg3
Definition: semperflash2.h:216
uint32_t spi_speed
Definition: semperflash2.h:202
pin_name_t sck
Definition: semperflash2.h:191
uint8_t semperflash2_write_memory(semperflash2_t *ctx, uint32_t addr, uint8_t *data_buf, uint16_t buf_size)
Write memory function.
SEMPERFLASH2_RETVAL semperflash2_init(semperflash2_t *ctx, semperflash2_cfg_t *cfg)
Initialization function.
void semperflash2_erase_memory(semperflash2_t *ctx, uint32_t addr)
Erase memory function.
pin_name_t mosi
Definition: semperflash2.h:190
uint8_t cfg4
Definition: semperflash2.h:217
uint8_t status_reg1
Definition: semperflash2.h:213
void semperflash2_cfg_setup(semperflash2_cfg_t *cfg)
Config Object Initialization function.
uint8_t cfg2
Definition: semperflash2.h:215
digital_out_t io3
Definition: semperflash2.h:172