42#ifdef PREINIT_SUPPORTED
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
52#include "drv_digital_out.h"
53#include "drv_spi_master.h"
62#define RERAM_ID_DATA 0x047FC903
68#define RERAM_CMD_WREN 0x6
69#define RERAM_CMD_WRDI 0x4
70#define RERAM_CMD_SLEEP 0xB9
82#define RERAM_BLOCK_PROT_NONE 0x0
83#define RERAM_BLOCK_PROT_UPPER_1_4 0x4
84#define RERAM_BLOCK_PROT_UPPER_1_2 0x8
85#define RERAM_BLOCK_PROT_ALL 0xC
86#define RERAM_BLOCK_PROT_MASK 0xC
93#define RERAM_WP_STAT_EN 0x80
94#define RERAM_WP_STAT_DIS 0x0
95#define RERAM_WP_STAT_MASK 0x80
104#define RERAM_FLAG_MASK_WEL 0x2
105#define RERAM_FLAG_MASK_WIP 0x1
112#define RERAM_MEM_ADDR_START 0x0
113#define RERAM_MEM_ADDR_END 0x7FFFF
114#define RERAM_TRANSFER_BYTES_MIN 1
115#define RERAM_TRANSFER_BYTES_MAX 256
122#define RERAM_MAP_MIKROBUS( cfg, mikrobus ) \
123 cfg.ho = MIKROBUS( mikrobus, MIKROBUS_RST ); \
124 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
125 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
126 cfg.sdo = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
127 cfg.sdi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
128 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM )
296 uint8_t *data_out, uint16_t n_bytes );
313 uint8_t *data_in, uint16_t n_bytes );
void reram_default_cfg(reram_t *ctx)
Click Default Configuration function.
reram_err_t reram_write_memory(reram_t *ctx, uint32_t mem_addr, uint8_t *data_in, uint16_t n_bytes)
Memory Write function.
void reram_wake_up(reram_t *ctx)
Wake Up function.
reram_err_t reram_send_cmd(reram_t *ctx, uint8_t cmd_code)
Command Send function.
reram_err_t reram_read_memory(reram_t *ctx, uint32_t mem_addr, uint8_t *data_out, uint16_t n_bytes)
Memory Read function.
void reram_write_status(reram_t *ctx, uint8_t data_in)
Status Write function.
void reram_set_write_protect_pin(reram_t *ctx, reram_pin_state_t state)
Write Protect Pin Set function.
reram_err_t reram_init(reram_t *ctx, reram_cfg_t *cfg)
Click Initialization function.
uint8_t reram_read_status(reram_t *ctx)
Status Read function.
void reram_set_hold_pin(reram_t *ctx, reram_pin_state_t state)
Hold Pin Set function.
uint32_t reram_read_id(reram_t *ctx)
ID Read function.
void reram_cfg_setup(reram_cfg_t *cfg)
Configuration Object Setup function.
reram_pin_state_t
Click pin state.
Definition reram.h:157
reram_err_t
Click error code.
Definition reram.h:144
@ RERAM_PIN_STATE_LOW
Definition reram.h:158
@ RERAM_PIN_STATE_HIGH
Definition reram.h:159
@ RERAM_ERR_MEM_ADDR
Definition reram.h:148
@ RERAM_ERR_DRV_INIT
Definition reram.h:146
@ RERAM_ERR_CMD
Definition reram.h:147
@ RERAM_OK
Definition reram.h:145
@ RERAM_ERR_NBYTES
Definition reram.h:149
Click configuration structure definition.
Definition reram.h:184
pin_name_t ho
Definition reram.h:186
pin_name_t sdi
Definition reram.h:190
spi_master_chip_select_polarity_t cs_polarity
Definition reram.h:195
pin_name_t sck
Definition reram.h:188
spi_master_mode_t spi_mode
Definition reram.h:194
uint32_t spi_speed
Definition reram.h:193
pin_name_t wp
Definition reram.h:191
pin_name_t sdo
Definition reram.h:189
pin_name_t cs
Definition reram.h:187
Click context object definition.
Definition reram.h:167
digital_out_t cs
Definition reram.h:168
spi_master_t spi
Definition reram.h:175
digital_out_t ho
Definition reram.h:172
pin_name_t chip_select
Definition reram.h:176
digital_out_t wp
Definition reram.h:171