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 
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_one_wire.h"
48 
69 #define UNIQUEID_FAMILY_CODE 0x01
70  // uniqueid_set
72 
82 #define UNIQUEID_MAP_MIKROBUS( cfg, mikrobus ) \
83  cfg.gp0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
84  cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN );
85  // uniqueid_map
87 
92 typedef enum
93 {
98 
103 typedef struct
104 {
105  // Modules
106  one_wire_t ow;
108  one_wire_rom_address_t rom_addr;
109  uint8_t address;
111 } uniqueid_t;
112 
117 typedef struct
118 {
119  // Communication GPIO pins
120  pin_name_t gp0;
121  pin_name_t gp1;
126 
131 typedef enum
132 {
134  UNIQUEID_ERROR = -1
135 
137  // uniqueid
139 
156 
172 
188 
201 err_t uniqueid_read_id ( uniqueid_t *ctx, uint8_t *family, uint8_t *serial_num );
202 
203 #ifdef __cplusplus
204 }
205 #endif
206 #endif // UNIQUEID_H
207  // uniqueid
209 
210 // ------------------------------------------------------------------------ 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:106
UNIQUEID_GPIO_1
@ UNIQUEID_GPIO_1
Definition: uniqueid.h:95
UNIQUEID_GPIO_0
@ UNIQUEID_GPIO_0
Definition: uniqueid.h:94
uniqueid_t::address
uint8_t address
Definition: uniqueid.h:109
uniqueid_init
err_t uniqueid_init(uniqueid_t *ctx, uniqueid_cfg_t *cfg)
UNIQUE ID initialization function.
UNIQUEID_OK
@ UNIQUEID_OK
Definition: uniqueid.h:133
uniqueid_cfg_t::gpio_sel
uniqueid_gpio_sel_t gpio_sel
Definition: uniqueid.h:123
uniqueid_cfg_t::gp0
pin_name_t gp0
Definition: uniqueid.h:120
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:134
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:132
uniqueid_gpio_sel_t
uniqueid_gpio_sel_t
UNIQUE ID click GPIO selector.
Definition: uniqueid.h:93
uniqueid_cfg_t
UNIQUE ID click configuration object.
Definition: uniqueid.h:118
uniqueid_t::rom_addr
one_wire_rom_address_t rom_addr
Definition: uniqueid.h:108
uniqueid_t
UNIQUE ID click context object.
Definition: uniqueid.h:104
uniqueid_cfg_t::gp1
pin_name_t gp1
Definition: uniqueid.h:121