blob: ca3683b1ea5303d56a61d88df4d74573a605a6d2 [file] [log] [blame]
Martijn Coenen44ae5b22011-11-02 16:09:37 -07001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17
18#ifndef ANDROID_NFC_HAL_INTERFACE_H
19#define ANDROID_NFC_HAL_INTERFACE_H
20
21#include <stdint.h>
22#include <strings.h>
23#include <sys/cdefs.h>
24#include <sys/types.h>
25
26#include <hardware/hardware.h>
27
28__BEGIN_DECLS
29
30#define NFC_HARDWARE_MODULE_ID "nfc"
31
32/*
33 * Begin PN544 specific HAL
34 */
35#define NFC_PN544_CONTROLLER "pn544"
36
37typedef struct nfc_module_t {
38 struct hw_module_t common;
39} nfc_module_t;
40
41/*
42 * PN544 linktypes.
43 * UART
44 * I2C
45 * USB (uses UART DAL)
46 */
47typedef enum {
48 PN544_LINK_TYPE_UART,
49 PN544_LINK_TYPE_I2C,
50 PN544_LINK_TYPE_USB,
51 PN544_LINK_TYPE_INVALID,
52} nfc_pn544_linktype;
53
54typedef struct {
55 struct hw_device_t common;
56
57 /* The number of EEPROM registers to write */
58 uint32_t num_eeprom_settings;
59
60 /* The actual EEPROM settings
61 * For PN544, each EEPROM setting is a 4-byte entry,
62 * of the format [0x00, addr_msb, addr_lsb, value].
63 */
64 uint8_t* eeprom_settings;
65
66 /* The link type to which the PN544 is connected */
67 nfc_pn544_linktype linktype;
68
69 /* The device node to which the PN544 is connected */
70 const char* device_node;
71
72 /* On Crespo we had an I2C issue that would cause us to sometimes read
73 * the I2C slave address (0x57) over the bus. libnfc contains
74 * a hack to ignore this byte and try to read the length byte
75 * again.
76 * Set to 0 to disable the workaround, 1 to enable it.
77 */
78 uint8_t enable_i2c_workaround;
79} nfc_pn544_device_t;
80
81static inline int nfc_pn544_open(const struct hw_module_t* module,
82 nfc_pn544_device_t** dev) {
83 return module->methods->open(module, NFC_PN544_CONTROLLER,
84 (struct hw_device_t**) dev);
85}
86
87static inline int nfc_pn544_close(nfc_pn544_device_t* dev) {
88 return dev->common.close(&dev->common);
89}
90/*
91 * End PN544 specific HAL
92 */
93
94__END_DECLS
95
96#endif // ANDROID_NFC_HAL_INTERFACE_H