eeprom10 2.1.0.0
eeprom10.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 EEPROM10_H
29#define EEPROM10_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 EEPROM10_NBYTES_PAGE 32
74
79#define EEPROM10_BLOCK_ADDR_START 0x0000
80#define EEPROM10_BLOCK_ADDR_END 0x0FFFu
81
87#define EEPROM10_DEVICE_ADDRESS_0 0x50
88#define EEPROM10_DEVICE_ADDRESS_1 0x51
89#define EEPROM10_DEVICE_ADDRESS_2 0x52
90#define EEPROM10_DEVICE_ADDRESS_3 0x53
91#define EEPROM10_DEVICE_ADDRESS_4 0x54
92#define EEPROM10_DEVICE_ADDRESS_5 0x55
93#define EEPROM10_DEVICE_ADDRESS_6 0x56
94#define EEPROM10_DEVICE_ADDRESS_7 0x57
95
96 // eeprom10_set
97
112#define EEPROM10_MAP_MIKROBUS( cfg, mikrobus ) \
113 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
114 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
115 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM )
116
117 // eeprom10_map
118 // eeprom10
119
124typedef struct
125{
126 // Output pins
127 digital_out_t wp;
129 // Modules
130 i2c_master_t i2c;
132 // I2C slave address
135} eeprom10_t;
136
141typedef struct
142{
143 pin_name_t scl;
144 pin_name_t sda;
146 pin_name_t wp;
148 uint32_t i2c_speed;
149 uint8_t i2c_address;
152
157typedef enum
158{
160 EEPROM10_ERROR = -1
161
163
180
195
205
215
228err_t eeprom10_write_byte ( eeprom10_t *ctx, uint16_t address, uint8_t data_in );
229
242err_t eeprom10_write_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_in );
243
257err_t eeprom10_write_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_in, uint8_t len );
258
271err_t eeprom10_read_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out );
272
285err_t eeprom10_read_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_out );
286
300err_t eeprom10_read_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out, uint8_t len );
301
302#ifdef __cplusplus
303}
304#endif
305#endif // EEPROM10_H
306
307 // eeprom10
308
309// ------------------------------------------------------------------------ END
eeprom10_return_value_t
EEPROM 10 Click return value data.
Definition eeprom10.h:158
@ EEPROM10_OK
Definition eeprom10.h:159
@ EEPROM10_ERROR
Definition eeprom10.h:160
void eeprom10_write_enable(eeprom10_t *ctx)
EEPROM 10 write enable function.
void eeprom10_write_protect(eeprom10_t *ctx)
EEPROM 10 write protection enable function.
err_t eeprom10_read_n_byte(eeprom10_t *ctx, uint16_t address, uint8_t *data_out, uint8_t len)
EEPROM 10 read desired number of data function.
err_t eeprom10_init(eeprom10_t *ctx, eeprom10_cfg_t *cfg)
EEPROM 10 initialization function.
err_t eeprom10_write_byte(eeprom10_t *ctx, uint16_t address, uint8_t data_in)
EEPROM 10 write byte function.
err_t eeprom10_write_page(eeprom10_t *ctx, uint8_t address, uint8_t *data_in)
EEPROM 10 write page function.
void eeprom10_cfg_setup(eeprom10_cfg_t *cfg)
EEPROM 10 configuration object setup function.
err_t eeprom10_write_n_byte(eeprom10_t *ctx, uint16_t address, uint8_t *data_in, uint8_t len)
EEPROM 10 write desired number of data function.
err_t eeprom10_read_byte(eeprom10_t *ctx, uint16_t address, uint8_t *data_out)
EEPROM 10 read byte of data function.
err_t eeprom10_read_page(eeprom10_t *ctx, uint8_t address, uint8_t *data_out)
EEPROM 10 read page of data function.
EEPROM 10 Click configuration object.
Definition eeprom10.h:142
uint32_t i2c_speed
Definition eeprom10.h:148
pin_name_t wp
Definition eeprom10.h:146
pin_name_t scl
Definition eeprom10.h:143
pin_name_t sda
Definition eeprom10.h:144
uint8_t i2c_address
Definition eeprom10.h:149
EEPROM 10 Click context object.
Definition eeprom10.h:125
i2c_master_t i2c
Definition eeprom10.h:130
uint8_t slave_address
Definition eeprom10.h:133
digital_out_t wp
Definition eeprom10.h:127