eeprom6 2.0.0.0
eeprom6.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 EEPROM6_H
29#define EEPROM6_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_one_wire.h"
52
73#define EEPROM6_CMD_WRITE_SCRATCHPAD 0x0F
74#define EEPROM6_CMD_READ_SCRATCHPAD 0xAA
75#define EEPROM6_CMD_COPY_SCRATCHPAD 0x55
76#define EEPROM6_CMD_READ_MEMORY 0xF0
77#define EEPROM6_CMD_EXTENDED_READ_MEMORY 0xA5
78
79 // eeprom6_cmd
80
95#define EEPROM6_FAMILY_CODE 0x43
96
101#define EEPROM6_ADDRESS_0 0x00
102#define EEPROM6_ADDRESS_1 0x01
103#define EEPROM6_ADDRESS_ALL 0xFF
104
105 // eeprom6_set
106
121#define EEPROM6_MAP_MIKROBUS( cfg, mikrobus ) \
122 cfg.gp0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
123 cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN );
124
125 // eeprom6_map
126 // eeprom6
127
138
143typedef struct
144{
145 // Modules
146 one_wire_t ow;
148 one_wire_rom_address_t rom_addr;
149 uint8_t address;
151} eeprom6_t;
152
157typedef struct
158{
159 // Communication gpio pins
160 pin_name_t gp0;
161 pin_name_t gp1;
166
171typedef enum
172{
174 EEPROM6_ERROR = -1
175
177
194
210
226
241
254
267
280err_t eeprom6_read_scratchpad ( eeprom6_t *ctx, uint8_t *scratchpad, uint8_t scratchpad_len );
281
294err_t eeprom6_write_scratchpad ( eeprom6_t *ctx, uint8_t *scratchpad, uint8_t scratchpad_len );
295
310err_t eeprom6_read_mem ( eeprom6_t *ctx, uint16_t reg_adr, uint8_t *data_in, uint16_t n_len );
311
325err_t eeprom6_write_mem ( eeprom6_t *ctx, uint16_t reg_adr, uint8_t *data_in, uint16_t n_len );
326
327#ifdef __cplusplus
328}
329#endif
330#endif // EEPROM6_H
331
332 // eeprom6
333
334// ------------------------------------------------------------------------ END
eeprom6_gpio_sel_t
EEPROM 6 Click gpio selector.
Definition eeprom6.h:133
@ EEPROM6_GPIO_1
Definition eeprom6.h:135
@ EEPROM6_GPIO_0
Definition eeprom6.h:134
eeprom6_return_value_t
EEPROM 6 Click return value data.
Definition eeprom6.h:172
@ EEPROM6_ERROR
Definition eeprom6.h:174
@ EEPROM6_OK
Definition eeprom6.h:173
void eeprom6_cfg_setup(eeprom6_cfg_t *cfg)
EEPROM 6 configuration object setup function.
err_t eeprom6_write_scratchpad(eeprom6_t *ctx, uint8_t *scratchpad, uint8_t scratchpad_len)
EEPROM 6 write scratchpad function.
err_t eeprom6_write_mem(eeprom6_t *ctx, uint16_t reg_adr, uint8_t *data_in, uint16_t n_len)
EEPROM 6 write memory function.
void eeprom6_gpio_selection(eeprom6_cfg_t *cfg, eeprom6_gpio_sel_t gpio_sel)
EEPROM 6 driver interface setup function.
err_t eeprom6_select_device(eeprom6_t *ctx)
EEPROM 6 select device function.
err_t eeprom6_check_communication(eeprom6_t *ctx)
EEPROM 6 check communication function.
err_t eeprom6_init(eeprom6_t *ctx, eeprom6_cfg_t *cfg)
EEPROM 6 initialization function.
err_t eeprom6_default_cfg(eeprom6_t *ctx)
EEPROM 6 default configuration function.
err_t eeprom6_read_scratchpad(eeprom6_t *ctx, uint8_t *scratchpad, uint8_t scratchpad_len)
EEPROM 6 read scratchpad function.
err_t eeprom6_read_mem(eeprom6_t *ctx, uint16_t reg_adr, uint8_t *data_in, uint16_t n_len)
EEPROM 6 read memory function.
EEPROM 6 Click configuration object.
Definition eeprom6.h:158
pin_name_t gp0
Definition eeprom6.h:160
eeprom6_gpio_sel_t gpio_sel
Definition eeprom6.h:163
pin_name_t gp1
Definition eeprom6.h:161
EEPROM 6 Click context object.
Definition eeprom6.h:144
one_wire_rom_address_t rom_addr
Definition eeprom6.h:148
uint8_t address
Definition eeprom6.h:149
one_wire_t ow
Definition eeprom6.h:146