uniqueid  2.0.0.0
uniqueid.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 UNIQUEID_H
29 #define UNIQUEID_H
30 
31 #ifdef __cplusplus
32 extern "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 UNIQUEID_FAMILY_CODE 0x01
74  // uniqueid_set
76 
86 #define UNIQUEID_MAP_MIKROBUS( cfg, mikrobus ) \
87  cfg.gp0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
88  cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN );
89  // uniqueid_map
91 
96 typedef enum
97 {
102 
107 typedef struct
108 {
109  // Modules
110  one_wire_t ow;
112  one_wire_rom_address_t rom_addr;
113  uint8_t address;
115 } uniqueid_t;
116 
121 typedef struct
122 {
123  // Communication GPIO pins
124  pin_name_t gp0;
125  pin_name_t gp1;
130 
135 typedef enum
136 {
138  UNIQUEID_ERROR = -1
139 
141  // uniqueid
143 
160 
176 
192 
205 err_t uniqueid_read_id ( uniqueid_t *ctx, uint8_t *family, uint8_t *serial_num );
206 
207 #ifdef __cplusplus
208 }
209 #endif
210 #endif // UNIQUEID_H
211  // uniqueid
213 
214 // ------------------------------------------------------------------------ END
uniqueid_gpio_selection
void uniqueid_gpio_selection(uniqueid_cfg_t *cfg, uniqueid_gpio_sel_t gpio_sel)
UNIQUE ID driver interface setup function.
uniqueid_t::ow
one_wire_t ow
Definition: uniqueid.h:110
UNIQUEID_GPIO_1
@ UNIQUEID_GPIO_1
Definition: uniqueid.h:99
UNIQUEID_GPIO_0
@ UNIQUEID_GPIO_0
Definition: uniqueid.h:98
uniqueid_t::address
uint8_t address
Definition: uniqueid.h:113
uniqueid_init
err_t uniqueid_init(uniqueid_t *ctx, uniqueid_cfg_t *cfg)
UNIQUE ID initialization function.
UNIQUEID_OK
@ UNIQUEID_OK
Definition: uniqueid.h:137
uniqueid_cfg_t::gpio_sel
uniqueid_gpio_sel_t gpio_sel
Definition: uniqueid.h:127
uniqueid_cfg_t::gp0
pin_name_t gp0
Definition: uniqueid.h:124
uniqueid_read_id
err_t uniqueid_read_id(uniqueid_t *ctx, uint8_t *family, uint8_t *serial_num)
UNIQUE ID read Family Code and Serial Number function.
UNIQUEID_ERROR
@ UNIQUEID_ERROR
Definition: uniqueid.h:138
uniqueid_cfg_setup
void uniqueid_cfg_setup(uniqueid_cfg_t *cfg)
UNIQUE ID configuration object setup function.
uniqueid_return_value_t
uniqueid_return_value_t
UNIQUE ID Click return value data.
Definition: uniqueid.h:136
uniqueid_gpio_sel_t
uniqueid_gpio_sel_t
UNIQUE ID Click GPIO selector.
Definition: uniqueid.h:97
uniqueid_cfg_t
UNIQUE ID Click configuration object.
Definition: uniqueid.h:122
uniqueid_t::rom_addr
one_wire_rom_address_t rom_addr
Definition: uniqueid.h:112
uniqueid_t
UNIQUE ID Click context object.
Definition: uniqueid.h:108
uniqueid_cfg_t::gp1
pin_name_t gp1
Definition: uniqueid.h:125