libnfc  1.4.2
drivers.h
Go to the documentation of this file.
1 /*-
2  * Public platform independent Near Field Communication (NFC) library
3  *
4  * Copyright (C) 2009, Roel Verdult
5  *
6  * This program is free software: you can redistribute it and/or modify it
7  * under the terms of the GNU Lesser General Public License as published by the
8  * Free Software Foundation, either version 3 of the License, or (at your
9  * option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful, but WITHOUT
12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
13  * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
14  * more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>
18  */
19 
25 #ifndef __NFC_DRIVERS_H__
26 # define __NFC_DRIVERS_H__
27 
28 # include <nfc/nfc-types.h>
29 
30 # include "chips/pn53x.h"
31 
32 # if defined (DRIVER_ACR122_ENABLED)
33 # include "drivers/acr122.h"
34 # endif /* DRIVER_ACR122_ENABLED */
35 
36 # if defined (DRIVER_PN531_USB_ENABLED) || defined (DRIVER_PN533_USB_ENABLED)
37 # include "drivers/pn53x_usb.h"
38 # endif /* DRIVER_PN531_USB_ENABLED || DRIVER_PN533_USB_ENABLED */
39 
40 # if defined (DRIVER_PN531_USB_ENABLED)
41 # include "drivers/pn531_usb.h"
42 # endif /* DRIVER_PN531_USB_ENABLED */
43 
44 # if defined (DRIVER_PN533_USB_ENABLED)
45 # include "drivers/pn533_usb.h"
46 # endif /* DRIVER_PN533_USB_ENABLED */
47 
48 # if defined (DRIVER_ARYGON_ENABLED)
49 # include "drivers/arygon.h"
50 # endif /* DRIVER_ARYGON_ENABLED */
51 
52 # if defined (DRIVER_PN532_UART_ENABLED)
53 # include "drivers/pn532_uart.h"
54 # endif /* DRIVER_PN532_UART_ENABLED */
55 
56 # define DRIVERS_MAX_DEVICES 16
57 # define MAX_FRAME_LEN 264
58 
59 static const struct driver_callbacks drivers_callbacks_list[] = {
60 // Driver Name Chip callbacks Pick Device List Devices Connect Transceive Disconnect
61 # if defined (DRIVER_PN531_USB_ENABLED)
62  {PN531_USB_DRIVER_NAME, &pn53x_callbacks_list, pn531_usb_pick_device, pn531_usb_list_devices, pn531_usb_connect,
63  NULL, pn53x_usb_transceive, pn53x_usb_disconnect},
64 # endif /* DRIVER_PN531_USB_ENABLED */
65 # if defined (DRIVER_PN533_USB_ENABLED)
66  {PN533_USB_DRIVER_NAME, &pn53x_callbacks_list, pn533_usb_pick_device, pn533_usb_list_devices, pn533_usb_connect,
67  pn533_usb_init, pn53x_usb_transceive, pn53x_usb_disconnect},
68 # endif /* DRIVER_PN533_USB_ENABLED */
69 # if defined (DRIVER_ACR122_ENABLED)
70  {ACR122_DRIVER_NAME, &pn53x_callbacks_list, acr122_pick_device, acr122_list_devices, acr122_connect,
71  NULL, acr122_transceive, acr122_disconnect},
72 # endif /* DRIVER_ACR122_ENABLED */
73 # if defined (DRIVER_ARYGON_ENABLED)
74  {ARYGON_DRIVER_NAME, &pn53x_callbacks_list, arygon_pick_device, arygon_list_devices, arygon_connect,
75  NULL, arygon_transceive, arygon_disconnect},
76 # endif /* DRIVER_ARYGON_ENABLED */
77 # if defined (DRIVER_PN532_UART_ENABLED)
78  {PN532_UART_DRIVER_NAME, &pn53x_callbacks_list, pn532_uart_pick_device, pn532_uart_list_devices, pn532_uart_connect,
79  NULL, pn532_uart_transceive, pn532_uart_disconnect},
80 # endif /* DRIVER_PN532_UART_ENABLED */
81 };
82 
83 # ifdef DEBUG
84  /*
85  * TODO Move this helper macro for dumping drivers messages.
86  * Here is not the best place for such a macro, however, I
87  * can't see any convenient place ATM.
88  */
89 # define PRINT_HEX(pcTag, pbtData, szBytes) do { \
90  size_t __szPos; \
91  printf(" %s: ", pcTag); \
92  for (__szPos=0; __szPos < (size_t)(szBytes); __szPos++) { \
93  printf("%02x ",pbtData[__szPos]); \
94  } \
95  printf("\n"); \
96  } while (0);
97 # endif
98 
99 #endif // __NFC_DRIVERS_H__