39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_spi_master.h"
73#define RERAM2_CMD_WREN 0x06
74#define RERAM2_CMD_WRDI 0x04
75#define RERAM2_CMD_RDSR 0x05
76#define RERAM2_CMD_WRSR 0x01
77#define RERAM2_CMD_READ 0x03
78#define RERAM2_CMD_WRITE 0x02
79#define RERAM2_CMD_RDID 0x9F
80#define RERAM2_CMD_RDUID 0x83
81#define RERAM2_CMD_SLEEP 0xB9
82#define RERAM2_CMD_PWDN 0xE2
100#define RERAM2_DEVICE_ID 0x047FAA03
101#define RERAM2_MANUFACTURER_ID 0x04
102#define RERAM2_CONTINUATION_CODE 0x7F
103#define RERAM2_PRODUCT_ID 0xAA03
109#define RERAM2_HOLD_ENABLE 0x00
110#define RERAM2_HOLD_DISABLE 0x01
116#define RERAM2_WP_ENABLE 0x00
117#define RERAM2_WP_DISABLE 0x01
127#define RERAM2_SET_DATA_SAMPLE_EDGE SET_SPI_DATA_SAMPLE_EDGE
128#define RERAM2_SET_DATA_SAMPLE_MIDDLE SET_SPI_DATA_SAMPLE_MIDDLE
146#define RERAM2_MAP_MIKROBUS( cfg, mikrobus ) \
147 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
148 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
149 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
150 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
151 cfg.ho = MIKROBUS( mikrobus, MIKROBUS_RST ); \
152 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM )
err_t reram2_generic_read(reram2_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
ReRAM 2 data reading function.
err_t reram2_generic_write(reram2_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
ReRAM 2 data writing function.
err_t reram2_wake_up(reram2_t *ctx)
ReRAM 2 wake up function.
err_t reram2_set_hold(reram2_t *ctx, uint8_t en_hold)
ReRAM 2 set hold function.
err_t reram2_set_write_protect(reram2_t *ctx, uint8_t en_wp)
ReRAM 2 write protection function.
err_t reram2_read_device_id(reram2_t *ctx, reram2_dev_id_t *dev_id)
ReRAM 2 read device ID function.
err_t reram2_init(reram2_t *ctx, reram2_cfg_t *cfg)
ReRAM 2 initialization function.
err_t reram2_write_memory(reram2_t *ctx, uint32_t mem_addr, uint8_t *data_in, uint16_t len)
ReRAM 2 write memory function.
err_t reram2_send_command(reram2_t *ctx, uint8_t cmd)
ReRAM 2 set command function.
err_t reram2_check_device_id(reram2_t *ctx)
ReRAM 2 check device ID function.
err_t reram2_read_memory(reram2_t *ctx, uint32_t mem_addr, uint8_t *data_out, uint16_t len)
ReRAM 2 read memory function.
err_t reram2_get_status(reram2_t *ctx, reram2_status_t *status)
ReRAM 2 get status function.
void reram2_cfg_setup(reram2_cfg_t *cfg)
ReRAM 2 configuration object setup function.
err_t reram2_default_cfg(reram2_t *ctx)
ReRAM 2 default configuration function.
reram2_return_value_t
ReRAM 2 Click return value data.
Definition reram2.h:230
@ RERAM2_OK
Definition reram2.h:231
@ RERAM2_ERROR
Definition reram2.h:232
This file contains SPI specific macros, functions, etc.
ReRAM 2 Click configuration object.
Definition reram2.h:179
pin_name_t ho
Definition reram2.h:187
spi_master_chip_select_polarity_t cs_polarity
Definition reram2.h:193
pin_name_t sck
Definition reram2.h:183
spi_master_mode_t spi_mode
Definition reram2.h:192
pin_name_t mosi
Definition reram2.h:182
uint32_t spi_speed
Definition reram2.h:191
pin_name_t wp
Definition reram2.h:188
pin_name_t miso
Definition reram2.h:181
pin_name_t cs
Definition reram2.h:184
ReRAM 2 Click status object.
Definition reram2.h:215
uint16_t product_id
Definition reram2.h:218
uint8_t continuation_code
Definition reram2.h:217
uint8_t wafer_id
Definition reram2.h:220
uint8_t manufacturer_id
Definition reram2.h:216
uint16_t chip_id
Definition reram2.h:221
ReRAM 2 Click status object.
Definition reram2.h:202
uint8_t block_protect
Definition reram2.h:204
uint8_t write_protect
Definition reram2.h:203
uint8_t write_in_progress
Definition reram2.h:206
uint8_t write_enable_latch
Definition reram2.h:205
ReRAM 2 Click context object.
Definition reram2.h:162
spi_master_t spi
Definition reram2.h:168
digital_out_t ho
Definition reram2.h:164
pin_name_t chip_select
Definition reram2.h:170
digital_out_t wp
Definition reram2.h:165