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
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 CLICKID_CMD_WRITE_MEMORY 0x96
74#define CLICKID_CMD_READ_MEMORY 0x69
75#define CLICKID_CMD_RELEASE 0xAA
76
77 // clickid_cmd
78
93#define CLICKID_MEM_ACCESS_SUCCESS 0xAA
94#define CLICKID_MEM_ACCESS_FAIL 0x55
95
100#define CLICKID_USER_EEPROM_START 0x0000
101#define CLICKID_USER_EEPROM_END 0x01FF
102#define CLICKID_PAGE_START 0x00
103#define CLICKID_PAGE_END 0x1F
104#define CLICKID_PAGE_SIZE 32
105#define CLICKID_MANIFEST_START_ADDRESS 0x0020
106
111#define CLICKID_FAMILY_CODE 0xCC
112
113 // clickid_set
114
129#define CLICKID_MAP_MIKROBUS( cfg, mikrobus ) \
130 cfg.rst = MIKROBUS( mikrobus, MIKROBUS_RST ); \
131 cfg.cs = MIKROBUS( mikrobus, MIKROBUS_CS );
132
133 // clickid_map
134 // clickid
135
140typedef struct
141{
142 uint8_t major;
143 uint8_t minor;
144
146
151typedef struct
152{
154 uint16_t serial;
155 uint16_t type;
156 uint8_t custom;
157 uint8_t name[ 20 ];
160
165typedef struct
166{
167 // Output pins
168 digital_out_t rst;
170 // Modules
171 one_wire_t ow;
173 one_wire_rom_address_t rom_addr;
175} clickid_t;
176
181typedef struct
182{
183 // Communication gpio pins
184 pin_name_t cs;
186 // Additional gpio pins
187 pin_name_t rst;
190
195typedef enum
196{
198 CLICKID_ERROR = -1
199
201
218
233
243
256
271err_t clickid_read_memory ( clickid_t *ctx, uint16_t address, uint8_t *data_out, uint16_t len );
272
287err_t clickid_write_memory ( clickid_t *ctx, uint16_t address, uint8_t *data_in, uint16_t len );
288
302
303#ifdef __cplusplus
304}
305#endif
306#endif // CLICKID_H
307
308 // clickid
309
310// ------------------------------------------------------------------------ END
clickid_return_value_t
ClickID return value data.
Definition clickid.h:196
@ CLICKID_OK
Definition clickid.h:197
@ CLICKID_ERROR
Definition clickid.h:198
void clickid_deinit(clickid_t *ctx)
ClickID de-initialization function.
err_t clickid_read_information(clickid_t *ctx, clickid_information_t *info)
ClickID read information function.
err_t clickid_read_memory(clickid_t *ctx, uint16_t address, uint8_t *data_out, uint16_t len)
ClickID read memory function.
err_t clickid_write_memory(clickid_t *ctx, uint16_t address, uint8_t *data_in, uint16_t len)
ClickID write memory function.
err_t clickid_init(clickid_t *ctx, clickid_cfg_t *cfg)
ClickID initialization function.
void clickid_cfg_setup(clickid_cfg_t *cfg)
ClickID configuration object setup function.
err_t clickid_check_communication(clickid_t *ctx)
ClickID check communication function.
ClickID configuration object.
Definition clickid.h:182
pin_name_t rst
Definition clickid.h:187
pin_name_t cs
Definition clickid.h:184
ClickID information.
Definition clickid.h:152
clickid_version_t hw_rev
Definition clickid.h:153
uint16_t serial
Definition clickid.h:154
uint8_t custom
Definition clickid.h:156
uint16_t type
Definition clickid.h:155
ClickID context object.
Definition clickid.h:166
one_wire_rom_address_t rom_addr
Definition clickid.h:173
digital_out_t rst
Definition clickid.h:168
one_wire_t ow
Definition clickid.h:171
ClickID version.
Definition clickid.h:141
uint8_t major
Definition clickid.h:142
uint8_t minor
Definition clickid.h:143