eeprom12 2.1.0.0
eeprom12.h
Go to the documentation of this file.
1/****************************************************************************
2** Copyright (C) 2020 MikroElektronika d.o.o.
3** Contact: https://www.mikroe.com/contact
4**
5** Permission is hereby granted, free of charge, to any person obtaining a copy
6** of this software and associated documentation files (the "Software"), to deal
7** in the Software without restriction, including without limitation the rights
8** to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9** copies of the Software, and to permit persons to whom the Software is
10** furnished to do so, subject to the following conditions:
11** The above copyright notice and this permission notice shall be
12** included in all copies or substantial portions of the Software.
13**
14** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
16** OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18** DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
19** OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
20** USE OR OTHER DEALINGS IN THE SOFTWARE.
21****************************************************************************/
22
28#ifndef EEPROM12_H
29#define EEPROM12_H
30
31#ifdef __cplusplus
32extern "C"{
33#endif
34
39#ifdef PREINIT_SUPPORTED
40#include "preinit.h"
41#endif
42
43#ifdef MikroCCoreVersion
44 #if MikroCCoreVersion >= 1
45 #include "delays.h"
46 #endif
47#endif
48
49#include "drv_digital_out.h"
50#include "drv_digital_in.h"
51#include "drv_i2c_master.h"
52
73#define EEPROM12_REG_IDENTIFICATION_PAGE 0x0000u
74#define EEPROM12_REG_IDENTIFICATION_PAGE_LOCK 0x0200u
75#define EEPROM12_REG_CONFIG_DEVICE_ADDRESS 0xC000u
76
77 // eeprom12_reg
78
93#define EEPROM12_MEMORY_ADDRESS_MIN 0x0000u
94#define EEPROM12_MEMORY_ADDRESS_MAX 0x7FFFu
95#define EEPROM12_PAGE_SIZE 64
96#define EEPROM12_PAGE_MAX 512
97
102#define EEPROM12_CDA_DAL_BIT_MASK 0x01
103#define EEPROM12_CDA_CEA_BIT_MASK 0x07
104
109#define EEPROM12_DEFAULT_CHIP_ENABLE_ADDRESS 0x00
110
116#define EEPROM12_DEVICE_ADDRESS_MEMORY 0x50
117#define EEPROM12_DEVICE_ADDRESS_PAGE 0x58
118
119 // eeprom12_set
120
135#define EEPROM12_MAP_MIKROBUS( cfg, mikrobus ) \
136 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
137 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
138 cfg.wc = MIKROBUS( mikrobus, MIKROBUS_PWM )
139
140 // eeprom12_map
141 // eeprom12
142
147typedef struct
148{
149 // Output pins
150 digital_out_t wc;
152 // Modules
153 i2c_master_t i2c;
155 // I2C slave address
158 uint8_t chip_en_addr; /* Chip enable address */
159
160} eeprom12_t;
161
166typedef struct
167{
168 pin_name_t scl;
169 pin_name_t sda;
171 pin_name_t wc;
173 uint32_t i2c_speed;
174 uint8_t i2c_address;
177
182typedef enum
183{
185 EEPROM12_ERROR = -1
186
188
205
220
232
244
259err_t eeprom12_generic_write ( eeprom12_t *ctx, uint16_t reg, uint8_t *data_in, uint8_t len );
260
275err_t eeprom12_generic_read ( eeprom12_t *ctx, uint16_t reg, uint8_t *data_out, uint8_t len );
276
293err_t eeprom12_memory_write ( eeprom12_t *ctx, uint16_t mem_addr, uint8_t *data_in, uint8_t len );
294
311err_t eeprom12_memory_read ( eeprom12_t *ctx, uint16_t mem_addr, uint8_t *data_out, uint8_t len );
312
329err_t eeprom12_memory_page_write ( eeprom12_t *ctx, uint16_t page_addr, uint8_t *data_in, uint8_t len );
330
347err_t eeprom12_memory_page_read ( eeprom12_t *ctx, uint16_t page_addr, uint8_t *data_out, uint8_t len );
348
365err_t eeprom12_id_page_write ( eeprom12_t *ctx, uint16_t id_page_addr, uint8_t *data_in );
366
383err_t eeprom12_id_page_read ( eeprom12_t *ctx, uint16_t id_page_addr, uint8_t *data_out );
384
404err_t eeprom12_config_dev_addr ( eeprom12_t *ctx, uint8_t cda, uint8_t dal );
405
421err_t eeprom12_read_lock_status ( eeprom12_t *ctx, uint8_t *lock_status );
422
423#ifdef __cplusplus
424}
425#endif
426#endif // EEPROM12_H
427
428 // eeprom12
429
430// ------------------------------------------------------------------------ END
eeprom12_return_value_t
EEPROM 12 Click return value data.
Definition eeprom12.h:183
@ EEPROM12_ERROR
Definition eeprom12.h:185
@ EEPROM12_OK
Definition eeprom12.h:184
void eeprom12_cfg_setup(eeprom12_cfg_t *cfg)
EEPROM 12 configuration object setup function.
err_t eeprom12_memory_read(eeprom12_t *ctx, uint16_t mem_addr, uint8_t *data_out, uint8_t len)
EEPROM 12 memory read function.
err_t eeprom12_memory_page_write(eeprom12_t *ctx, uint16_t page_addr, uint8_t *data_in, uint8_t len)
EEPROM 12 memory page write function.
err_t eeprom12_id_page_read(eeprom12_t *ctx, uint16_t id_page_addr, uint8_t *data_out)
EEPROM 12 identification page read function.
void eeprom12_write_disable(eeprom12_t *ctx)
EEPROM 12 write disable function.
err_t eeprom12_id_page_write(eeprom12_t *ctx, uint16_t id_page_addr, uint8_t *data_in)
EEPROM 12 identification page write function.
err_t eeprom12_read_lock_status(eeprom12_t *ctx, uint8_t *lock_status)
EEPROM 12 read lock status function.
err_t eeprom12_memory_write(eeprom12_t *ctx, uint16_t mem_addr, uint8_t *data_in, uint8_t len)
EEPROM 12 memory write function.
void eeprom12_write_enable(eeprom12_t *ctx)
EEPROM 12 write enable function.
err_t eeprom12_memory_page_read(eeprom12_t *ctx, uint16_t page_addr, uint8_t *data_out, uint8_t len)
EEPROM 12 memory page read function.
err_t eeprom12_generic_read(eeprom12_t *ctx, uint16_t reg, uint8_t *data_out, uint8_t len)
EEPROM 12 I2C reading function.
err_t eeprom12_generic_write(eeprom12_t *ctx, uint16_t reg, uint8_t *data_in, uint8_t len)
EEPROM 12 I2C writing function.
err_t eeprom12_init(eeprom12_t *ctx, eeprom12_cfg_t *cfg)
EEPROM 12 initialization function.
err_t eeprom12_config_dev_addr(eeprom12_t *ctx, uint8_t cda, uint8_t dal)
EEPROM 12 configuate device address function.
EEPROM 12 Click configuration object.
Definition eeprom12.h:167
uint32_t i2c_speed
Definition eeprom12.h:173
pin_name_t wc
Definition eeprom12.h:171
pin_name_t scl
Definition eeprom12.h:168
pin_name_t sda
Definition eeprom12.h:169
uint8_t i2c_address
Definition eeprom12.h:174
EEPROM 12 Click context object.
Definition eeprom12.h:148
digital_out_t wc
Definition eeprom12.h:150
uint8_t chip_en_addr
Definition eeprom12.h:158
i2c_master_t i2c
Definition eeprom12.h:153
uint8_t slave_address
Definition eeprom12.h:156