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
35#include "drv_digital_out.h"
36#include "drv_digital_in.h"
37#include "drv_i2c_master.h"
38
59#define EEPROM10_NBYTES_PAGE 32
60
66#define EEPROM10_DEVICE_ADDRESS_0 0x50
67#define EEPROM10_DEVICE_ADDRESS_1 0x51
68#define EEPROM10_DEVICE_ADDRESS_2 0x52
69#define EEPROM10_DEVICE_ADDRESS_3 0x53
70#define EEPROM10_DEVICE_ADDRESS_4 0x54
71#define EEPROM10_DEVICE_ADDRESS_5 0x55
72#define EEPROM10_DEVICE_ADDRESS_6 0x56
73#define EEPROM10_DEVICE_ADDRESS_7 0x57
74 // eeprom10_set
76
91#define EEPROM10_MAP_MIKROBUS( cfg, mikrobus ) \
92 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
93 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
94 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM )
95 // eeprom10_map // eeprom10
98
103typedef struct
104{
105 // Output pins
106 digital_out_t wp;
108 // Modules
109 i2c_master_t i2c;
111 // I2C slave address
114} eeprom10_t;
115
120typedef struct
121{
122 pin_name_t scl;
123 pin_name_t sda;
125 pin_name_t wp;
127 uint32_t i2c_speed;
128 uint8_t i2c_address;
131
136typedef enum
137{
139 EEPROM10_ERROR = -1
140
142
159
174
184
194
207err_t eeprom10_write_byte ( eeprom10_t *ctx, uint16_t address, uint8_t data_in );
208
221err_t eeprom10_write_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_in );
222
236err_t eeprom10_write_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_in, uint8_t len );
237
250err_t eeprom10_read_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out );
251
264err_t eeprom10_read_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_out );
265
279err_t eeprom10_read_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out, uint8_t len );
280
281#ifdef __cplusplus
282}
283#endif
284#endif // EEPROM10_H
285 // eeprom10
287
288// ------------------------------------------------------------------------ END
eeprom10_return_value_t
EEPROM 10 Click return value data.
Definition: eeprom10.h:137
@ EEPROM10_OK
Definition: eeprom10.h:138
@ EEPROM10_ERROR
Definition: eeprom10.h:139
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:121
uint32_t i2c_speed
Definition: eeprom10.h:127
pin_name_t wp
Definition: eeprom10.h:125
pin_name_t scl
Definition: eeprom10.h:122
pin_name_t sda
Definition: eeprom10.h:123
uint8_t i2c_address
Definition: eeprom10.h:128
EEPROM 10 Click context object.
Definition: eeprom10.h:104
i2c_master_t i2c
Definition: eeprom10.h:109
uint8_t slave_address
Definition: eeprom10.h:112
digital_out_t wp
Definition: eeprom10.h:106