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 "drv_digital_out.h"
36 #include "drv_digital_in.h"
37 #include "drv_one_wire.h"
38 
59 #define UNIQUEID_FAMILY_CODE 0x01
60  // uniqueid_set
62 
72 #define UNIQUEID_MAP_MIKROBUS( cfg, mikrobus ) \
73  cfg.gp0 = MIKROBUS( mikrobus, MIKROBUS_PWM ); \
74  cfg.gp1 = MIKROBUS( mikrobus, MIKROBUS_AN );
75  // uniqueid_map
77 
82 typedef enum
83 {
88 
93 typedef struct
94 {
95  // Modules
96  one_wire_t ow;
98  one_wire_rom_address_t rom_addr;
99  uint8_t address;
101 } uniqueid_t;
102 
107 typedef struct
108 {
109  // Communication GPIO pins
110  pin_name_t gp0;
111  pin_name_t gp1;
116 
121 typedef enum
122 {
124  UNIQUEID_ERROR = -1
125 
127  // uniqueid
129 
146 
162 
178 
191 err_t uniqueid_read_id ( uniqueid_t *ctx, uint8_t *family, uint8_t *serial_num );
192 
193 #ifdef __cplusplus
194 }
195 #endif
196 #endif // UNIQUEID_H
197  // uniqueid
199 
200 // ------------------------------------------------------------------------ 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:96
UNIQUEID_GPIO_1
@ UNIQUEID_GPIO_1
Definition: uniqueid.h:85
UNIQUEID_GPIO_0
@ UNIQUEID_GPIO_0
Definition: uniqueid.h:84
uniqueid_t::address
uint8_t address
Definition: uniqueid.h:99
uniqueid_init
err_t uniqueid_init(uniqueid_t *ctx, uniqueid_cfg_t *cfg)
UNIQUE ID initialization function.
UNIQUEID_OK
@ UNIQUEID_OK
Definition: uniqueid.h:123
uniqueid_cfg_t::gpio_sel
uniqueid_gpio_sel_t gpio_sel
Definition: uniqueid.h:113
uniqueid_cfg_t::gp0
pin_name_t gp0
Definition: uniqueid.h:110
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:124
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:122
uniqueid_gpio_sel_t
uniqueid_gpio_sel_t
UNIQUE ID click GPIO selector.
Definition: uniqueid.h:83
uniqueid_cfg_t
UNIQUE ID click configuration object.
Definition: uniqueid.h:108
uniqueid_t::rom_addr
one_wire_rom_address_t rom_addr
Definition: uniqueid.h:98
uniqueid_t
UNIQUE ID click context object.
Definition: uniqueid.h:94
uniqueid_cfg_t::gp1
pin_name_t gp1
Definition: uniqueid.h:111