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
65#define EEPROM10_BLOCK_ADDR_START 0x0000
66#define EEPROM10_BLOCK_ADDR_END 0x0FFFu
67
73#define EEPROM10_DEVICE_ADDRESS_0 0x50
74#define EEPROM10_DEVICE_ADDRESS_1 0x51
75#define EEPROM10_DEVICE_ADDRESS_2 0x52
76#define EEPROM10_DEVICE_ADDRESS_3 0x53
77#define EEPROM10_DEVICE_ADDRESS_4 0x54
78#define EEPROM10_DEVICE_ADDRESS_5 0x55
79#define EEPROM10_DEVICE_ADDRESS_6 0x56
80#define EEPROM10_DEVICE_ADDRESS_7 0x57
81 // eeprom10_set
83
98#define EEPROM10_MAP_MIKROBUS( cfg, mikrobus ) \
99 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
100 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
101 cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM )
102 // eeprom10_map // eeprom10
105
110typedef struct
111{
112 // Output pins
113 digital_out_t wp;
115 // Modules
116 i2c_master_t i2c;
118 // I2C slave address
121} eeprom10_t;
122
127typedef struct
128{
129 pin_name_t scl;
130 pin_name_t sda;
132 pin_name_t wp;
134 uint32_t i2c_speed;
135 uint8_t i2c_address;
138
143typedef enum
144{
146 EEPROM10_ERROR = -1
147
149
166
181
191
201
214err_t eeprom10_write_byte ( eeprom10_t *ctx, uint16_t address, uint8_t data_in );
215
228err_t eeprom10_write_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_in );
229
243err_t eeprom10_write_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_in, uint8_t len );
244
257err_t eeprom10_read_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out );
258
271err_t eeprom10_read_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_out );
272
286err_t eeprom10_read_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out, uint8_t len );
287
288#ifdef __cplusplus
289}
290#endif
291#endif // EEPROM10_H
292 // eeprom10
294
295// ------------------------------------------------------------------------ END
eeprom10_return_value_t
EEPROM 10 Click return value data.
Definition: eeprom10.h:144
@ EEPROM10_OK
Definition: eeprom10.h:145
@ EEPROM10_ERROR
Definition: eeprom10.h:146
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:128
uint32_t i2c_speed
Definition: eeprom10.h:134
pin_name_t wp
Definition: eeprom10.h:132
pin_name_t scl
Definition: eeprom10.h:129
pin_name_t sda
Definition: eeprom10.h:130
uint8_t i2c_address
Definition: eeprom10.h:135
EEPROM 10 Click context object.
Definition: eeprom10.h:111
i2c_master_t i2c
Definition: eeprom10.h:116
uint8_t slave_address
Definition: eeprom10.h:119
digital_out_t wp
Definition: eeprom10.h:113