eeprom11 2.1.0.0
eeprom11.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 EEPROM11_H
29#define EEPROM11_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 EEPROM11_SET_WP_BLOCK0 0x31
74#define EEPROM11_SET_WP_BLOCK1 0x34
75#define EEPROM11_SET_WP_BLOCK2 0x35
76#define EEPROM11_SET_WP_BLOCK3 0x30
77#define EEPROM11_CLEAR_ALL_WP 0x33
78#define EEPROM11_READ_SWP0 0x31
79#define EEPROM11_READ_SWP1 0x34
80#define EEPROM11_READ_SWP2 0x35
81#define EEPROM11_READ_SWP3 0x30
82#define EEPROM11_SET_PAGE_ADDR_0 0x36
83#define EEPROM11_SET_PAGE_ADDR_1 0x37
84#define EEPROM11_READ_PAGE_ADDR 0x36
85
86 // eeprom11_reg
87
103#define EEPROM11_DEVICE_ADDRESS_0 0x50
104#define EEPROM11_DEVICE_ADDRESS_1 0x51
105#define EEPROM11_DEVICE_ADDRESS_2 0x52
106#define EEPROM11_DEVICE_ADDRESS_3 0x53
107#define EEPROM11_DEVICE_ADDRESS_4 0x54
108#define EEPROM11_DEVICE_ADDRESS_5 0x55
109#define EEPROM11_DEVICE_ADDRESS_6 0x56
110#define EEPROM11_DEVICE_ADDRESS_7 0x57
111 // eeprom11_set
112
127#define EEPROM11_MAP_MIKROBUS( cfg, mikrobus ) \
128 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
129 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA )
130
131 // eeprom11_map
132 // eeprom11
133
138typedef struct
139{
140 // Modules
141 i2c_master_t i2c;
143 // I2C slave address
146} eeprom11_t;
147
152typedef struct
153{
154 pin_name_t scl;
155 pin_name_t sda;
157 uint32_t i2c_speed;
158 uint8_t i2c_address;
161
166typedef enum
167{
169 EEPROM11_ERROR = -1
170
172
189
204
218
233err_t eeprom11_generic_write ( eeprom11_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len );
234
249err_t eeprom11_generic_read ( eeprom11_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len );
250
263err_t eeprom11_page_write ( eeprom11_t *ctx, uint8_t address, uint8_t *data_in );
264
276err_t eeprom11_clear_page ( eeprom11_t *ctx, uint8_t address );
277
289err_t eeprom11_set_wp ( eeprom11_t *ctx, uint8_t block_addr );
290
302
314err_t eeprom11_set_page_addr ( eeprom11_t *ctx, uint8_t page_addr );
315
316#ifdef __cplusplus
317}
318#endif
319#endif // EEPROM11_H
320
321 // eeprom11
322
323// ------------------------------------------------------------------------ END
eeprom11_return_value_t
EEPROM 11 Click return value data.
Definition eeprom11.h:167
@ EEPROM11_ERROR
Definition eeprom11.h:169
@ EEPROM11_OK
Definition eeprom11.h:168
err_t eeprom11_clear_page(eeprom11_t *ctx, uint8_t address)
EEPROM 11 page clear function.
err_t eeprom11_set_wp(eeprom11_t *ctx, uint8_t block_addr)
EEPROM 11 set write protection function.
err_t eeprom11_generic_write(eeprom11_t *ctx, uint8_t reg, uint8_t *data_in, uint8_t len)
EEPROM 11 I2C writing function.
void eeprom11_cfg_setup(eeprom11_cfg_t *cfg)
EEPROM 11 configuration object setup function.
err_t eeprom11_init(eeprom11_t *ctx, eeprom11_cfg_t *cfg)
EEPROM 11 initialization function.
err_t eeprom11_generic_read(eeprom11_t *ctx, uint8_t reg, uint8_t *data_out, uint8_t len)
EEPROM 11 I2C reading function.
err_t eeprom11_page_write(eeprom11_t *ctx, uint8_t address, uint8_t *data_in)
EEPROM 11 page write function.
err_t eeprom11_set_page_addr(eeprom11_t *ctx, uint8_t page_addr)
EEPROM 11 set page address function.
err_t eeprom11_clear_wp(eeprom11_t *ctx)
EEPROM 11 clear write protection function.
err_t eeprom11_default_cfg(eeprom11_t *ctx)
EEPROM 11 default configuration function.
EEPROM 11 Click configuration object.
Definition eeprom11.h:153
uint32_t i2c_speed
Definition eeprom11.h:157
pin_name_t scl
Definition eeprom11.h:154
pin_name_t sda
Definition eeprom11.h:155
uint8_t i2c_address
Definition eeprom11.h:158
EEPROM 11 Click context object.
Definition eeprom11.h:139
i2c_master_t i2c
Definition eeprom11.h:141
uint8_t slave_address
Definition eeprom11.h:144