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
32 extern "C"{
33 #endif
34 
35 #include "mikrosdk_version.h"
36 
37 #ifdef __GNUC__
38 #if mikroSDK_GET_VERSION < 20800ul
39 #include "rcu_delays.h"
40 #else
41 #include "delays.h"
42 #endif
43 #endif
44 
45 #include "drv_digital_out.h"
46 #include "drv_digital_in.h"
47 #include "drv_i2c_master.h"
48 
69 #define EEPROM10_NBYTES_PAGE 32
70 
75 #define EEPROM10_BLOCK_ADDR_START 0x0000
76 #define EEPROM10_BLOCK_ADDR_END 0x0FFFu
77 
83 #define EEPROM10_DEVICE_ADDRESS_0 0x50
84 #define EEPROM10_DEVICE_ADDRESS_1 0x51
85 #define EEPROM10_DEVICE_ADDRESS_2 0x52
86 #define EEPROM10_DEVICE_ADDRESS_3 0x53
87 #define EEPROM10_DEVICE_ADDRESS_4 0x54
88 #define EEPROM10_DEVICE_ADDRESS_5 0x55
89 #define EEPROM10_DEVICE_ADDRESS_6 0x56
90 #define EEPROM10_DEVICE_ADDRESS_7 0x57
91  // eeprom10_set
93 
108 #define EEPROM10_MAP_MIKROBUS( cfg, mikrobus ) \
109  cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
110  cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
111  cfg.wp = MIKROBUS( mikrobus, MIKROBUS_PWM )
112  // eeprom10_map // eeprom10
115 
120 typedef struct
121 {
122  // Output pins
123  digital_out_t wp;
125  // Modules
126  i2c_master_t i2c;
128  // I2C slave address
129  uint8_t slave_address;
131 } eeprom10_t;
132 
137 typedef struct
138 {
139  pin_name_t scl;
140  pin_name_t sda;
142  pin_name_t wp;
144  uint32_t i2c_speed;
145  uint8_t i2c_address;
148 
153 typedef enum
154 {
156  EEPROM10_ERROR = -1
157 
159 
176 
191 
201 
211 
224 err_t eeprom10_write_byte ( eeprom10_t *ctx, uint16_t address, uint8_t data_in );
225 
238 err_t eeprom10_write_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_in );
239 
253 err_t eeprom10_write_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_in, uint8_t len );
254 
267 err_t eeprom10_read_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out );
268 
281 err_t eeprom10_read_page ( eeprom10_t *ctx, uint8_t address, uint8_t *data_out );
282 
296 err_t eeprom10_read_n_byte ( eeprom10_t *ctx, uint16_t address, uint8_t *data_out, uint8_t len );
297 
298 #ifdef __cplusplus
299 }
300 #endif
301 #endif // EEPROM10_H
302  // eeprom10
304 
305 // ------------------------------------------------------------------------ END
eeprom10_write_n_byte
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.
eeprom10_cfg_t::i2c_address
uint8_t i2c_address
Definition: eeprom10.h:145
eeprom10_read_n_byte
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.
eeprom10_cfg_t::i2c_speed
uint32_t i2c_speed
Definition: eeprom10.h:144
eeprom10_t::i2c
i2c_master_t i2c
Definition: eeprom10.h:126
EEPROM10_ERROR
@ EEPROM10_ERROR
Definition: eeprom10.h:156
eeprom10_write_page
err_t eeprom10_write_page(eeprom10_t *ctx, uint8_t address, uint8_t *data_in)
EEPROM 10 write page function.
eeprom10_t::slave_address
uint8_t slave_address
Definition: eeprom10.h:129
eeprom10_t
EEPROM 10 Click context object.
Definition: eeprom10.h:121
eeprom10_read_byte
err_t eeprom10_read_byte(eeprom10_t *ctx, uint16_t address, uint8_t *data_out)
EEPROM 10 read byte of data function.
eeprom10_cfg_t::sda
pin_name_t sda
Definition: eeprom10.h:140
eeprom10_read_page
err_t eeprom10_read_page(eeprom10_t *ctx, uint8_t address, uint8_t *data_out)
EEPROM 10 read page of data function.
eeprom10_init
err_t eeprom10_init(eeprom10_t *ctx, eeprom10_cfg_t *cfg)
EEPROM 10 initialization function.
eeprom10_cfg_t::scl
pin_name_t scl
Definition: eeprom10.h:139
eeprom10_t::wp
digital_out_t wp
Definition: eeprom10.h:123
eeprom10_write_enable
void eeprom10_write_enable(eeprom10_t *ctx)
EEPROM 10 write enable function.
eeprom10_write_byte
err_t eeprom10_write_byte(eeprom10_t *ctx, uint16_t address, uint8_t data_in)
EEPROM 10 write byte function.
eeprom10_return_value_t
eeprom10_return_value_t
EEPROM 10 Click return value data.
Definition: eeprom10.h:154
EEPROM10_OK
@ EEPROM10_OK
Definition: eeprom10.h:155
eeprom10_cfg_setup
void eeprom10_cfg_setup(eeprom10_cfg_t *cfg)
EEPROM 10 configuration object setup function.
eeprom10_write_protect
void eeprom10_write_protect(eeprom10_t *ctx)
EEPROM 10 write protection enable function.
eeprom10_cfg_t
EEPROM 10 Click configuration object.
Definition: eeprom10.h:138
eeprom10_cfg_t::wp
pin_name_t wp
Definition: eeprom10.h:142