39#ifdef PREINIT_SUPPORTED
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_spi_master.h"
74#define NVSRAM4_STATUS_RDY 0x01
75#define NVSRAM4_STATUS_WEN 0x02
76#define NVSRAM4_STATUS_BP0 0x04
77#define NVSRAM4_STATUS_BP1 0x08
78#define NVSRAM4_STATUS_SNL 0x40
79#define NVSRAM4_STATUS_WPEN 0x80
81#define NVSRAM4_RTC_FLAGS 0x00
82#define NVSRAM4_RTC_TK_CENTURIES 0x01
83#define NVSRAM4_RTC_ALARM_SECONDS 0x02
84#define NVSRAM4_RTC_ALARM_MINUTES 0x03
85#define NVSRAM4_RTC_ALARM_HOURS 0x04
86#define NVSRAM4_RTC_ALARM_DAY 0x05
87#define NVSRAM4_RTC_INTERRUPT_STATUS 0x06
88#define NVSRAM4_RTC_WATCHDOG_TIMER 0x07
89#define NVSRAM4_RTC_CALIBRATION 0x08
90#define NVSRAM4_RTC_TK_SECONDS 0x09
91#define NVSRAM4_RTC_TK_MINUTES 0x0A
92#define NVSRAM4_RTC_TK_HOURS 0x0B
93#define NVSRAM4_RTC_TK_DAY 0x0C
94#define NVSRAM4_RTC_TK_DATE 0x0D
95#define NVSRAM4_RTC_TK_MONTHS 0x0E
96#define NVSRAM4_RTC_TK_YEARS 0x0F
125#define NVSRAM4_STATUS_RDSR 0x05
126#define NVSRAM4_STATUS_FRDSR 0x0A
127#define NVSRAM4_STATUS_WRSR 0x01
128#define NVSRAM4_STATUS_WREN 0x06
129#define NVSRAM4_STATUS_WRDI 0x04
143#define NVSRAM4_SRAM_READ 0x03
144#define NVSRAM4_SRAM_FREAD 0x0B
145#define NVSRAM4_SRAM_WRITE 0x02
159#define NVSRAM4_SRAM_RDRTC 0x13
160#define NVSRAM4_SRAM_FAST_RDRTC 0x1D
161#define NVSRAM4_SRAM_WRTC 0x12
175#define NVSRAM4_SPEC_NV_STORE 0x3C
176#define NVSRAM4_SPEC_NV_RECALL 0x60
177#define NVSRAM4_SPEC_NV_ASENB 0x59
178#define NVSRAM4_SPEC_NV_ASDISB 0x19
192#define NVSRAM4_SPEC_SLEEP 0xB9
193#define NVSRAM4_SPEC_WRSN 0xC2
194#define NVSRAM4_SPEC_RDSN 0xC3
195#define NVSRAM4_SPEC_FRDSN 0xC9
196#define NVSRAM4_SPEC_RDID 0x9F
197#define NVSRAM4_SPEC_FRDID 0x99
211#define NVSRAM4_STATUS_RDY 0x01
212#define NVSRAM4_STATUS_WEN 0x02
213#define NVSRAM4_STATUS_BP0 0x04
214#define NVSRAM4_STATUS_BP1 0x08
215#define NVSRAM4_STATUS_SNL 0x40
216#define NVSRAM4_STATUS_WPEN 0x80
230#define NVSRAM4_HOLD_ENABLE 0x00
231#define NVSRAM4_HOLD_DISABLE 0x01
246#define NVSRAM4_HSB_ENABLE 0x00
247#define NVSRAM4_HSB_DISABLE 0x01
262#define NVSRAM4_WP_ENABLE 0x00
263#define NVSRAM4_WP_DISABLE 0x01
281#define NVSRAM4_SUCCESS 0
282#define NVSRAM4_ERROR -1
301#define NVSRAM4_MAP_MIKROBUS( cfg, mikrobus ) \
302 cfg.miso = MIKROBUS( mikrobus, MIKROBUS_MISO ); \
303 cfg.mosi = MIKROBUS( mikrobus, MIKROBUS_MOSI ); \
304 cfg.sck = MIKROBUS( mikrobus, MIKROBUS_SCK ); \
305 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS ); \
306 cfg.hld = MIKROBUS( mikrobus, MIKROBUS_AN ); \
307 cfg.hsb = MIKROBUS( mikrobus, MIKROBUS_RST ); \
308 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
309 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
void nvsram4_write_status(nvsram4_t *ctx, uint8_t st_data)
nvSRAM 4 write status function.
err_t nvsram4_set_rtc_time(nvsram4_t *ctx, nvsram4_rtc_time_t rtc_time)
nvSRAM 4 set RTC time function.
void nvsram4_get_rtc_date(nvsram4_t *ctx, nvsram4_rtc_date_t *rtc_date)
nvSRAM 4 get RTC date function.
err_t nvsram4_burst_write_memory(nvsram4_t *ctx, uint32_t mem_addr, uint8_t *data_in, uint8_t n_bytes)
nvSRAM 4 burst write memory function.
void nvsram4_rtc_write_reg(nvsram4_t *ctx, uint8_t rtc_reg, uint8_t data_in)
nvSRAM 4 rtc write register function.
err_t nvsram4_init(nvsram4_t *ctx, nvsram4_cfg_t *cfg)
nvSRAM 4 initialization function.
void nvsram4_default_cfg(nvsram4_t *ctx)
nvSRAM 4 default configuration function.
err_t nvsram4_generic_write(nvsram4_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
nvSRAM 4 data writing function.
uint8_t nvsram4_read_status(nvsram4_t *ctx)
nvSRAM 4 read status function.
err_t nvsram4_set_rtc_alarm(nvsram4_t *ctx, nvsram4_rtc_alarm_t rtc_alarm)
nvSRAM 4 set RTC alarm function.
void nvsram4_enable_rtc_write(nvsram4_t *ctx)
nvSRAM 4 enable rtc register write function.
uint8_t nvsram4_rtc_read_reg(nvsram4_t *ctx, uint8_t rtc_reg)
nvSRAM 4 rtc read register function.
err_t nvsram4_hw_write_protection(nvsram4_t *ctx, uint8_t en_wp)
nvSRAM 4 write protection function.
err_t nvsram4_hardware_store(nvsram4_t *ctx, uint8_t en_hw_store)
nvSRAM 4 hardware store function.
err_t nvsram4_set_rtc_date(nvsram4_t *ctx, nvsram4_rtc_date_t rtc_date)
nvSRAM 4 set RTC date function.
err_t nvsram4_set_cmd(nvsram4_t *ctx, uint8_t cmd)
nvSRAM 4 set command function.
void nvsram4_get_rtc_alarm(nvsram4_t *ctx, nvsram4_rtc_alarm_t *rtc_alarm)
nvSRAM 4 get RTC alarm function.
void nvsram4_cfg_setup(nvsram4_cfg_t *cfg)
nvSRAM 4 configuration object setup function.
void nvsram4_disable_rtc_write(nvsram4_t *ctx)
nvSRAM 4 disable rtc register write function.
err_t nvsram4_burst_read_memory(nvsram4_t *ctx, uint32_t mem_addr, uint8_t *data_out, uint8_t n_bytes)
nvSRAM 4 burst read memory function.
uint32_t nvsram4_read_id(nvsram4_t *ctx)
nvSRAM 4 read device ID function.
err_t nvsram4_generic_read(nvsram4_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
nvSRAM 4 data reading function.
void nvsram4_get_rtc_time(nvsram4_t *ctx, nvsram4_rtc_time_t *rtc_time)
nvSRAM 4 get RTC time function.
err_t nvsram4_hold(nvsram4_t *ctx, uint8_t en_hold)
nvSRAM 4 set hold function.
nvSRAM 4 Click configuration object.
Definition nvsram4.h:343
pin_name_t hld
Definition nvsram4.h:353
spi_master_chip_select_polarity_t cs_polarity
Definition nvsram4.h:362
pin_name_t sck
Definition nvsram4.h:348
spi_master_mode_t spi_mode
Definition nvsram4.h:361
pin_name_t mosi
Definition nvsram4.h:347
uint32_t spi_speed
Definition nvsram4.h:360
pin_name_t wp
Definition nvsram4.h:355
pin_name_t hsb
Definition nvsram4.h:354
pin_name_t int_pin
Definition nvsram4.h:356
pin_name_t miso
Definition nvsram4.h:346
pin_name_t cs
Definition nvsram4.h:349
uint8_t hours
Definition nvsram4.h:390
uint8_t day
Definition nvsram4.h:389
uint8_t min
Definition nvsram4.h:391
uint8_t sec
Definition nvsram4.h:392
uint8_t month
Definition nvsram4.h:379
uint8_t day
Definition nvsram4.h:380
uint8_t year
Definition nvsram4.h:378
uint8_t day_of_week
Definition nvsram4.h:381
uint8_t hours
Definition nvsram4.h:369
uint8_t min
Definition nvsram4.h:370
uint8_t sec
Definition nvsram4.h:371
nvSRAM 4 Click context object.
Definition nvsram4.h:319
digital_out_t hld
Definition nvsram4.h:322
spi_master_t spi
Definition nvsram4.h:332
digital_in_t int_pin
Definition nvsram4.h:328
digital_out_t hsb
Definition nvsram4.h:323
pin_name_t chip_select
Definition nvsram4.h:334
digital_out_t wp
Definition nvsram4.h:324