summaryrefslogtreecommitdiffstats
path: root/include/hardware/nfc.h
diff options
context:
space:
mode:
authorMartijn Coenen <maco@google.com>2011-11-02 16:09:37 -0700
committerMartijn Coenen <maco@google.com>2011-11-04 09:05:22 -0700
commit44ae5b24766f8ce4b6b5de01f1deb296d99efd57 (patch)
treeab068b7523ac3f71d625c0eeed8996ac6fd2c6a3 /include/hardware/nfc.h
parentcf209523884350a3ad6af5840f1b0ae2dde9b98b (diff)
downloadhardware_libhardware-44ae5b24766f8ce4b6b5de01f1deb296d99efd57.zip
hardware_libhardware-44ae5b24766f8ce4b6b5de01f1deb296d99efd57.tar.gz
hardware_libhardware-44ae5b24766f8ce4b6b5de01f1deb296d99efd57.tar.bz2
New NFC HAL.
First implementation of a NFC HAL. This implementation doesn't offer a generic NFC device HAL (yet), but offers typed interfaces for different NFC controllers. Currently only the PN544 is supported. Change-Id: I3ac04dcd767fb12a433edbe88ec7068eb1930a57
Diffstat (limited to 'include/hardware/nfc.h')
-rw-r--r--include/hardware/nfc.h96
1 files changed, 96 insertions, 0 deletions
diff --git a/include/hardware/nfc.h b/include/hardware/nfc.h
new file mode 100644
index 0000000..ca3683b
--- /dev/null
+++ b/include/hardware/nfc.h
@@ -0,0 +1,96 @@
+/*
+ * Copyright (C) 2011 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+
+#ifndef ANDROID_NFC_HAL_INTERFACE_H
+#define ANDROID_NFC_HAL_INTERFACE_H
+
+#include <stdint.h>
+#include <strings.h>
+#include <sys/cdefs.h>
+#include <sys/types.h>
+
+#include <hardware/hardware.h>
+
+__BEGIN_DECLS
+
+#define NFC_HARDWARE_MODULE_ID "nfc"
+
+/*
+ * Begin PN544 specific HAL
+ */
+#define NFC_PN544_CONTROLLER "pn544"
+
+typedef struct nfc_module_t {
+ struct hw_module_t common;
+} nfc_module_t;
+
+/*
+ * PN544 linktypes.
+ * UART
+ * I2C
+ * USB (uses UART DAL)
+ */
+typedef enum {
+ PN544_LINK_TYPE_UART,
+ PN544_LINK_TYPE_I2C,
+ PN544_LINK_TYPE_USB,
+ PN544_LINK_TYPE_INVALID,
+} nfc_pn544_linktype;
+
+typedef struct {
+ struct hw_device_t common;
+
+ /* The number of EEPROM registers to write */
+ uint32_t num_eeprom_settings;
+
+ /* The actual EEPROM settings
+ * For PN544, each EEPROM setting is a 4-byte entry,
+ * of the format [0x00, addr_msb, addr_lsb, value].
+ */
+ uint8_t* eeprom_settings;
+
+ /* The link type to which the PN544 is connected */
+ nfc_pn544_linktype linktype;
+
+ /* The device node to which the PN544 is connected */
+ const char* device_node;
+
+ /* On Crespo we had an I2C issue that would cause us to sometimes read
+ * the I2C slave address (0x57) over the bus. libnfc contains
+ * a hack to ignore this byte and try to read the length byte
+ * again.
+ * Set to 0 to disable the workaround, 1 to enable it.
+ */
+ uint8_t enable_i2c_workaround;
+} nfc_pn544_device_t;
+
+static inline int nfc_pn544_open(const struct hw_module_t* module,
+ nfc_pn544_device_t** dev) {
+ return module->methods->open(module, NFC_PN544_CONTROLLER,
+ (struct hw_device_t**) dev);
+}
+
+static inline int nfc_pn544_close(nfc_pn544_device_t* dev) {
+ return dev->common.close(&dev->common);
+}
+/*
+ * End PN544 specific HAL
+ */
+
+__END_DECLS
+
+#endif // ANDROID_NFC_HAL_INTERFACE_H