nfctag4 2.0.0.0
nfctag4.h
Go to the documentation of this file.
1/*
2 * MikroSDK - MikroE Software Development Kit
3 * Copyright© 2020 MikroElektronika d.o.o.
4 *
5 * Permission is hereby granted, free of charge, to any person
6 * obtaining a copy of this software and associated documentation
7 * files (the "Software"), to deal in the Software without restriction,
8 * including without limitation the rights to use, copy, modify, merge,
9 * publish, distribute, sublicense, and/or sell copies of the Software,
10 * and to permit persons to whom the Software is furnished to do so,
11 * subject to the following conditions:
12 *
13 * The above copyright notice and this permission notice shall be
14 * included in all copies or substantial portions of the Software.
15 *
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE
22 * OR OTHER DEALINGS IN THE SOFTWARE.
23 */
24
33// ----------------------------------------------------------------------------
34
35#ifndef NFCTAG4_H
36#define NFCTAG4_H
37
42#ifdef PREINIT_SUPPORTED
43#include "preinit.h"
44#endif
45
46#ifdef MikroCCoreVersion
47 #if MikroCCoreVersion >= 1
48 #include "delays.h"
49 #endif
50#endif
51
52#include "drv_digital_out.h"
53#include "drv_digital_in.h"
54#include "drv_i2c_master.h"
55
56// -------------------------------------------------------------- PUBLIC MACROS
66#define NFCTAG4_MAP_MIKROBUS( cfg, mikrobus ) \
67 cfg.scl = MIKROBUS( mikrobus, MIKROBUS_SCL ); \
68 cfg.sda = MIKROBUS( mikrobus, MIKROBUS_SDA ); \
69 cfg.int_pin = MIKROBUS( mikrobus, MIKROBUS_INT )
76#define NFCTAG4_RETVAL uint8_t
77
78#define NFCTAG4_OK 0x00
79#define NFCTAG4_INIT_ERROR 0xFF
86#define NFCTAG4_DEVICE_ADDRESS 0x53
93#define NFCTAG4_MEMORY_USER 0x01
94#define NFCTAG4_MEMORY_DYNAMIC 0x02
95#define NFCTAG4_MEMORY_MAILBOX 0x03
96#define NFCTAG4_MEMORY_SYSTEM 0x04
103#define NFCTAG4_SYSTEM_REG_GPO 0x0000
104#define NFCTAG4_SYSTEM_REG_IT_TIME 0x0001
105#define NFCTAG4_SYSTEM_REG_EH_MODE 0x0002
106#define NFCTAG4_SYSTEM_REG_RF_MNGT 0x0003
107#define NFCTAG4_SYSTEM_REG_RFA1SS 0x0004
108#define NFCTAG4_SYSTEM_REG_ENDA1 0x0005
109#define NFCTAG4_SYSTEM_REG_RFA2SS 0x0006
110#define NFCTAG4_SYSTEM_REG_ENDA2 0x0007
111#define NFCTAG4_SYSTEM_REG_RFA3SS 0x0008
112#define NFCTAG4_SYSTEM_REG_ENDA3 0x0009
113#define NFCTAG4_SYSTEM_REG_RFA4SS 0x000A
114#define NFCTAG4_SYSTEM_REG_I2CSS 0x000B
115#define NFCTAG4_SYSTEM_REG_LOCK_CCFILE 0x000C
116#define NFCTAG4_SYSTEM_REG_MB_MODE 0x000D
117#define NFCTAG4_SYSTEM_REG_MB_WDG 0x000E
118#define NFCTAG4_SYSTEM_REG_LOCK_CFG 0x000F
119#define NFCTAG4_SYSTEM_REG_LOCK_DSFID 0x0010
120#define NFCTAG4_SYSTEM_REG_LOCK_AFI 0x0011
121#define NFCTAG4_SYSTEM_REG_DSFID 0x0012
122#define NFCTAG4_SYSTEM_REG_AFI 0x0013
123#define NFCTAG4_SYSTEM_REG_MEM_SIZE_1 0x0014
124#define NFCTAG4_SYSTEM_REG_MEM_SIZE_2 0x0015
125#define NFCTAG4_SYSTEM_REG_BLK_SIZE 0x0016
126#define NFCTAG4_SYSTEM_REG_IC_REF 0x0017
127#define NFCTAG4_SYSTEM_REG_UID_1 0x0018
128#define NFCTAG4_SYSTEM_REG_UID_2 0x0019
129#define NFCTAG4_SYSTEM_REG_UID_3 0x001A
130#define NFCTAG4_SYSTEM_REG_UID_4 0x001B
131#define NFCTAG4_SYSTEM_REG_UID_5 0x001C
132#define NFCTAG4_SYSTEM_REG_UID_6 0x001D
133#define NFCTAG4_SYSTEM_REG_UID_7 0x001E
134#define NFCTAG4_SYSTEM_REG_UID_8 0x001F
135#define NFCTAG4_SYSTEM_REG_IC_REV 0x0020
136#define NFCTAG4_SYSTEM_REG_ST_RES_1 0x0021
137#define NFCTAG4_SYSTEM_REG_ST_RES_2 0x0022
138#define NFCTAG4_SYSTEM_REG_ST_RES_3 0x0023
139#define NFCTAG4_SYSTEM_REG_I2C_PWD_1 0x0900
140#define NFCTAG4_SYSTEM_REG_I2C_PWD_2 0x0901
141#define NFCTAG4_SYSTEM_REG_I2C_PWD_3 0x0902
142#define NFCTAG4_SYSTEM_REG_I2C_PWD_4 0x0903
143#define NFCTAG4_SYSTEM_REG_I2C_PWD_5 0x0904
144#define NFCTAG4_SYSTEM_REG_I2C_PWD_6 0x0905
145#define NFCTAG4_SYSTEM_REG_I2C_PWD_7 0x0906
146#define NFCTAG4_SYSTEM_REG_I2C_PWD_8 0x0907
153#define NFCTAG4_DYNAMIC_REG_GPO_CTRL 0x2000
154#define NFCTAG4_DYNAMIC_REG_RESERVED_1 0x2001
155#define NFCTAG4_DYNAMIC_REG_EH_CTRL 0x2002
156#define NFCTAG4_DYNAMIC_REG_RF_MNGT 0x2003
157#define NFCTAG4_DYNAMIC_REG_I2C_SSO 0x2004
158#define NFCTAG4_DYNAMIC_REG_IT_STS 0x2005
159#define NFCTAG4_DYNAMIC_REG_MB_CTRL 0x2006
160#define NFCTAG4_DYNAMIC_REG_MB_LEN 0x2007
167#define NFCTAG4_MAILBOX_REG_BYTE_0 0x2008
174#define NFCTAG4_MAILBOX_DISABLE 0x00
175#define NFCTAG4_MAILBOX_ENABLE 0x01
182#define NFCTAG4_RF_DISABLE 0x00
183#define NFCTAG4_RF_ENABLE 0x01
186 // End group macro
187// --------------------------------------------------------------- PUBLIC TYPES
196typedef struct
197{
198
199 digital_in_t int_pin;
200
201 // Modules
202
203 i2c_master_t i2c;
204
205 // ctx variable
206
208
209} nfctag4_t;
210
214typedef struct
215{
216 // Communication gpio pins
217
218 pin_name_t scl;
219 pin_name_t sda;
220
221 // Additional gpio pins
222
223 pin_name_t int_pin;
224
225 // static variable
226
227 uint32_t i2c_speed;
228 uint8_t i2c_address;
229
231
232typedef struct
233{
234 uint8_t memory_area;
236 uint16_t n_registers;
237
239 // End types group
240// ----------------------------------------------- PUBLIC FUNCTION DECLARATIONS
241
247#ifdef __cplusplus
248extern "C"{
249#endif
250
260
270
279
290uint8_t nfctag4_int_get ( nfctag4_t* ctx );
291
304uint8_t nfctag4_i2c_get ( nfctag4_t* ctx, transfer_info* dev, uint8_t* register_buffer );
305
318uint8_t nfctag4_i2c_set ( nfctag4_t* ctx, transfer_info* dev, uint8_t* register_buffer );
319
331uint8_t nfctag4_password_present ( nfctag4_t* ctx, uint8_t* password_bytes );
332
344uint8_t nfctag4_password_write ( nfctag4_t* ctx, uint8_t* password_bytes );
345
357uint8_t nfctag4_enable_mailbox ( nfctag4_t* ctx, uint8_t enable_mailbox );
358
370uint8_t nfctag4_enable_rf ( nfctag4_t* ctx, uint8_t enable_rf );
371
372
373#ifdef __cplusplus
374}
375#endif
376#endif // _NFCTAG4_H_
377
378 // End public_function group
380
381// ------------------------------------------------------------------------- END
#define NFCTAG4_RETVAL
Definition nfctag4.h:76
uint8_t nfctag4_enable_mailbox(nfctag4_t *ctx, uint8_t enable_mailbox)
Enabling or disabling mailbox.
void nfctag4_default_cfg(nfctag4_t *ctx)
Click Default Configuration function.
uint8_t nfctag4_password_write(nfctag4_t *ctx, uint8_t *password_bytes)
Writing password to device.
NFCTAG4_RETVAL nfctag4_init(nfctag4_t *ctx, nfctag4_cfg_t *cfg)
Initialization function.
uint8_t nfctag4_enable_rf(nfctag4_t *ctx, uint8_t enable_rf)
Enabling or disabling RF.
void nfctag4_cfg_setup(nfctag4_cfg_t *cfg)
Config Object Initialization function.
uint8_t nfctag4_int_get(nfctag4_t *ctx)
Getting INT pin state.
uint8_t nfctag4_i2c_get(nfctag4_t *ctx, transfer_info *dev, uint8_t *register_buffer)
Getting registers via I2C.
uint8_t nfctag4_password_present(nfctag4_t *ctx, uint8_t *password_bytes)
Presenting password to device.
uint8_t nfctag4_i2c_set(nfctag4_t *ctx, transfer_info *dev, uint8_t *register_buffer)
Setting registers via I2C.
Click configuration structure definition.
Definition nfctag4.h:215
uint32_t i2c_speed
Definition nfctag4.h:227
pin_name_t scl
Definition nfctag4.h:218
pin_name_t int_pin
Definition nfctag4.h:223
pin_name_t sda
Definition nfctag4.h:219
uint8_t i2c_address
Definition nfctag4.h:228
Click ctx object definition.
Definition nfctag4.h:197
digital_in_t int_pin
Definition nfctag4.h:199
i2c_master_t i2c
Definition nfctag4.h:203
uint8_t slave_address
Definition nfctag4.h:207
Definition nfctag4.h:233
uint16_t register_address
Definition nfctag4.h:235
uint8_t memory_area
Definition nfctag4.h:234
uint16_t n_registers
Definition nfctag4.h:236