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 EERAM2_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.hld = MIKROBUS( mikrobus, MIKROBUS_PWM )
79#define EERAM2_RETVAL uint8_t
82#define EERAM2_INIT_ERROR 0xFF
89#define EERAM2_CMD_WREN 0x06
90#define EERAM2_CMD_WRDI 0x04
97#define EERAM2_CMD_WRITE 0x02
98#define EERAM2_CMD_READ 0x03
99#define EERAM2_CMD_SECURE_WRITE 0x12
100#define EERAM2_CMD_SECURE_READ 0x13
107#define EERAM2_CMD_WRSR 0x01
108#define EERAM2_CMD_RDSR 0x05
115#define EERAM2_CMD_STORE 0x08
116#define EERAM2_CMD_RECALL 0x09
123#define EERAM2_CMD_WRNUR 0xC2
124#define EERAM2_CMD_RDNUR 0xC3
131#define EERAM2_CMD_HIBERNATE 0xB9
138#define EERAM2_HOLD_DISABLE 0x00
139#define EERAM2_HOLD_ENABLE 0x01
146#define EERAM2_WRITE_DISABLE 0x00
147#define EERAM2_WRITE_ENABLE 0x01
154#define EERAM2_STATUS_ASE_ENABLE 0x00
155#define EERAM2_STATUS_ASE_DISABLE 0x40
156#define EERAM2_STATUS_BP_LVL_0 0x00
157#define EERAM2_STATUS_BP_LVL_1 0x04
158#define EERAM2_STATUS_BP_LVL_2 0x08
159#define EERAM2_STATUS_BP_LVL_3 0x0C
166#define EERAM2_ERROR 0x00
167#define EERAM2_SUCCESS 0x01
174#define EERAM2_SRAM_ADDR_FIRST 0x00000000
175#define EERAM2_SRAM_ADDR_LAST 0x00FFFFFF
#define EERAM2_RETVAL
Definition eeram2.h:79
void eeram2_cfg_setup(eeram2_cfg_t *cfg)
Config Object Initialization function.
void eeram2_set_on_hold_status(eeram2_t *ctx, uint8_t en_hold)
Set On-hold status function.
uint8_t eeram2_secure_write(eeram2_t *ctx, uint16_t reg, uint8_t *p_tx_data)
Secure SRAM write function.
EERAM2_RETVAL eeram2_init(eeram2_t *ctx, eeram2_cfg_t *cfg)
Initialization function.
uint8_t eeram2_read_continuous(eeram2_t *ctx, uint32_t reg, uint8_t *p_rx_data, uint8_t n_bytes)
Continuous read the data into SRAM function.
uint8_t eeram2_read_nonvolatile(eeram2_t *ctx, uint8_t *p_rx_data)
Nonvolatile user space write function.
uint8_t eeram2_read_byte(eeram2_t *ctx, uint32_t reg)
Read the data byte from SRAM function.
void eeram2_set_command(eeram2_t *ctx, uint8_t command)
Set command function.
uint8_t eeram2_secure_read(eeram2_t *ctx, uint16_t reg, uint8_t *p_rx_data)
Secure SRAM read function.
void eeram2_generic_transfer(eeram2_t *ctx, uint8_t *wr_buf, uint16_t wr_len, uint8_t *rd_buf, uint16_t rd_len)
Generic transfer function.
uint8_t eeram2_write_nonvolatile(eeram2_t *ctx, uint8_t *p_tx_data)
Nonvolatile user space read function.
void eeram2_set_status(eeram2_t *ctx, uint8_t tx_data)
Set status register function.
uint8_t eeram2_write_continuous(eeram2_t *ctx, uint32_t reg, uint8_t *p_tx_data, uint8_t n_bytes)
Continuous write the data into SRAM function.
uint8_t eeram2_get_status(eeram2_t *ctx)
Read status register function.
void eeram2_set_write_status(eeram2_t *ctx, uint8_t en_write)
Set write status function.
uint8_t eeram2_write_byte(eeram2_t *ctx, uint32_t reg, uint8_t tx_data)
Write the data byte into SRAM function.
Click configuration structure definition.
Definition eeram2.h:205
pin_name_t hld
Definition eeram2.h:215
spi_master_chip_select_polarity_t cs_polarity
Definition eeram2.h:221
pin_name_t sck
Definition eeram2.h:210
spi_master_mode_t spi_mode
Definition eeram2.h:220
pin_name_t mosi
Definition eeram2.h:209
uint32_t spi_speed
Definition eeram2.h:219
pin_name_t miso
Definition eeram2.h:208
pin_name_t cs
Definition eeram2.h:211
Click ctx object definition.
Definition eeram2.h:189
digital_out_t cs
Definition eeram2.h:191
digital_out_t hld
Definition eeram2.h:192
spi_master_t spi
Definition eeram2.h:196
pin_name_t chip_select
Definition eeram2.h:197