clickid  2.1.0.0
clickid.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 CLICKID_H
29 #define CLICKID_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 CLICKID_CMD_WRITE_MEMORY 0x96
60 #define CLICKID_CMD_READ_MEMORY 0x69
61 #define CLICKID_CMD_RELEASE 0xAA
62  // clickid_cmd
64 
79 #define CLICKID_MEM_ACCESS_SUCCESS 0xAA
80 #define CLICKID_MEM_ACCESS_FAIL 0x55
81 
86 #define CLICKID_USER_EEPROM_START 0x0000
87 #define CLICKID_USER_EEPROM_END 0x01FF
88 #define CLICKID_PAGE_START 0x00
89 #define CLICKID_PAGE_END 0x1F
90 #define CLICKID_PAGE_SIZE 32
91 #define CLICKID_MANIFEST_START_ADDRESS 0x0020
92 
97 #define CLICKID_FAMILY_CODE 0xCC
98  // clickid_set
100 
115 #define CLICKID_MAP_MIKROBUS( cfg, mikrobus ) \
116  cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
117  cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
118  // clickid_map // clickid
121 
126 typedef struct
127 {
128  uint8_t major;
129  uint8_t minor;
130 
132 
137 typedef struct
138 {
140  uint16_t serial;
141  uint16_t type;
142  uint8_t custom;
143  uint8_t name[ 20 ];
146 
151 typedef struct
152 {
153  // Output pins
154  digital_out_t rst;
156  // Modules
157  one_wire_t ow;
159  one_wire_rom_address_t rom_addr;
161 } clickid_t;
162 
167 typedef struct
168 {
169  // Communication gpio pins
170  pin_name_t cs;
172  // Additional gpio pins
173  pin_name_t rst;
175 } clickid_cfg_t;
176 
181 typedef enum
182 {
184  CLICKID_ERROR = -1
185 
187 
204 
218 err_t clickid_init ( clickid_t *ctx, clickid_cfg_t *cfg );
219 
228 void clickid_deinit ( clickid_t *ctx );
229 
242 
257 err_t clickid_read_memory ( clickid_t *ctx, uint16_t address, uint8_t *data_out, uint16_t len );
258 
273 err_t clickid_write_memory ( clickid_t *ctx, uint16_t address, uint8_t *data_in, uint16_t len );
274 
288 
289 #ifdef __cplusplus
290 }
291 #endif
292 #endif // CLICKID_H
293  // clickid
295 
296 // ------------------------------------------------------------------------ END
clickid_information_t
ClickID information.
Definition: clickid.h:138
clickid_write_memory
err_t clickid_write_memory(clickid_t *ctx, uint16_t address, uint8_t *data_in, uint16_t len)
ClickID write memory function.
clickid_cfg_t
ClickID configuration object.
Definition: clickid.h:168
CLICKID_OK
@ CLICKID_OK
Definition: clickid.h:183
clickid_version_t::minor
uint8_t minor
Definition: clickid.h:129
clickid_deinit
void clickid_deinit(clickid_t *ctx)
ClickID de-initialization function.
clickid_cfg_setup
void clickid_cfg_setup(clickid_cfg_t *cfg)
ClickID configuration object setup function.
clickid_cfg_t::rst
pin_name_t rst
Definition: clickid.h:173
clickid_check_communication
err_t clickid_check_communication(clickid_t *ctx)
ClickID check communication function.
clickid_read_memory
err_t clickid_read_memory(clickid_t *ctx, uint16_t address, uint8_t *data_out, uint16_t len)
ClickID read memory function.
clickid_information_t::custom
uint8_t custom
Definition: clickid.h:142
clickid_information_t::hw_rev
clickid_version_t hw_rev
Definition: clickid.h:139
CLICKID_ERROR
@ CLICKID_ERROR
Definition: clickid.h:184
clickid_return_value_t
clickid_return_value_t
ClickID return value data.
Definition: clickid.h:182
clickid_t::ow
one_wire_t ow
Definition: clickid.h:157
clickid_information_t::type
uint16_t type
Definition: clickid.h:141
clickid_read_information
err_t clickid_read_information(clickid_t *ctx, clickid_information_t *info)
ClickID read information function.
clickid_version_t
ClickID version.
Definition: clickid.h:127
clickid_information_t::serial
uint16_t serial
Definition: clickid.h:140
clickid_cfg_t::cs
pin_name_t cs
Definition: clickid.h:170
clickid_version_t::major
uint8_t major
Definition: clickid.h:128
clickid_init
err_t clickid_init(clickid_t *ctx, clickid_cfg_t *cfg)
ClickID initialization function.
clickid_t::rom_addr
one_wire_rom_address_t rom_addr
Definition: clickid.h:159
clickid_t::rst
digital_out_t rst
Definition: clickid.h:154
clickid_t
ClickID context object.
Definition: clickid.h:152