Add new supported device: ASK / LoGO. (Thanks to ASK for sending one sample of this device)

This commit is contained in:
Romuald Conty 2011-02-01 21:20:48 +00:00
parent 659d7a9de1
commit 58ad2a5760
8 changed files with 49 additions and 18 deletions

View file

@ -133,6 +133,8 @@ struct driver_callbacks {
bool (*list_devices) (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound);
/** Connect callback */
nfc_device_t *(*connect) (const nfc_device_desc_t * pndd);
/** Init callback */
void (*init) (nfc_device_t * pnd);
/** Transceive callback */
bool (*transceive) (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx, size_t * pszRx);
/** Disconnect callback */

View file

@ -60,23 +60,23 @@ static const struct driver_callbacks drivers_callbacks_list[] = {
// Driver Name Chip callbacks Pick Device List Devices Connect Transceive Disconnect
# if defined (DRIVER_PN531_USB_ENABLED)
{PN531_USB_DRIVER_NAME, &pn53x_callbacks_list, pn531_usb_pick_device, pn531_usb_list_devices, pn531_usb_connect,
pn53x_usb_transceive, pn53x_usb_disconnect},
NULL, pn53x_usb_transceive, pn53x_usb_disconnect},
# endif /* DRIVER_PN531_USB_ENABLED */
# if defined (DRIVER_PN533_USB_ENABLED)
{PN533_USB_DRIVER_NAME, &pn53x_callbacks_list, pn533_usb_pick_device, pn533_usb_list_devices, pn533_usb_connect,
pn53x_usb_transceive, pn53x_usb_disconnect},
pn533_usb_init, pn53x_usb_transceive, pn53x_usb_disconnect},
# endif /* DRIVER_PN533_USB_ENABLED */
# if defined (DRIVER_ACR122_ENABLED)
{ACR122_DRIVER_NAME, &pn53x_callbacks_list, acr122_pick_device, acr122_list_devices, acr122_connect,
acr122_transceive, acr122_disconnect},
NULL, acr122_transceive, acr122_disconnect},
# endif /* DRIVER_ACR122_ENABLED */
# if defined (DRIVER_ARYGON_ENABLED)
{ARYGON_DRIVER_NAME, &pn53x_callbacks_list, arygon_pick_device, arygon_list_devices, arygon_connect,
arygon_transceive, arygon_disconnect},
NULL, arygon_transceive, arygon_disconnect},
# endif /* DRIVER_ARYGON_ENABLED */
# if defined (DRIVER_PN532_UART_ENABLED)
{PN532_UART_DRIVER_NAME, &pn53x_callbacks_list, pn532_uart_pick_device, pn532_uart_list_devices, pn532_uart_connect,
pn532_uart_transceive, pn532_uart_disconnect},
NULL, pn532_uart_transceive, pn532_uart_disconnect},
# endif /* DRIVER_PN532_UART_ENABLED */
};

View file

@ -63,8 +63,10 @@ bool
pn533_usb_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound)
{
// array of {vendor,product} pairs for USB devices
usb_candidate_t candidates[] = { {0x04CC, 0x2533}
, {0x04E6, 0x5591}
usb_candidate_t candidates[] = {
{ 0x04CC, 0x2533 }, // NXP - PN533
{ 0x04E6, 0x5591 }, // SCM Micro - SCL3711-NFC&RW
{ 0x1FD3, 0x0608 } // ASK - LoGO
};
return pn53x_usb_list_devices (&pnddDevices[0], szDevices, pszDeviceFound, &candidates[0],
@ -76,3 +78,18 @@ pn533_usb_connect (const nfc_device_desc_t * pndd)
{
return pn53x_usb_connect (pndd, pndd->acDevice, NC_PN533);
}
void
pn533_usb_init (nfc_device_t * pnd)
{
usb_spec_t* pus = (usb_spec_t*) pnd->nds;
DBG ("pus->uc.idVendor == 0x%04x, pus->uc.idProduct == 0x%04x", pus->uc.idVendor, pus->uc.idProduct);
if ((pus->uc.idVendor == 0x1FD3) && (pus->uc.idProduct == 0x0608)) { // ASK - LoGO
DBG ("ASK LoGO initialization.");
pn53x_set_reg (pnd, 0x6106, 0xFF, 0x1B);
pn53x_set_reg (pnd, 0x6306, 0xFF, 0x14);
pn53x_set_reg (pnd, 0xFFFD, 0xFF, 0x37);
pn53x_set_reg (pnd, 0xFFB0, 0xFF, 0x3B);
}
}

View file

@ -28,6 +28,7 @@
// Functions used by developer to handle connection to this device
nfc_device_t *pn533_usb_connect (const nfc_device_desc_t * pndd);
void pn533_usb_init (nfc_device_t * pnd);
bool pn533_usb_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound);
nfc_device_desc_t *pn533_usb_pick_device (void);

View file

@ -172,14 +172,14 @@ pn53x_usb_connect (const nfc_device_desc_t * pndd, const char *target_name, int
for (bus = usb_get_busses (); bus; bus = bus->next) {
for (dev = bus->devices; dev; dev = dev->next, uiBusIndex--) {
// DBG("Checking device %04x:%04x",dev->descriptor.idVendor,dev->descriptor.idProduct);
DBG ("Checking device %04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct);
if (uiBusIndex == 0) {
// Open the USB device
us.pudh = usb_open (dev);
get_end_points (dev, &us);
if (usb_set_configuration (us.pudh, 1) < 0) {
DBG ("%s", "Setting config failed");
ERR ("Unable to set USB configuration, please check USB permissions for device %04x:%04x", dev->descriptor.idVendor, dev->descriptor.idProduct);
usb_close (us.pudh);
// we failed to use the specified device
return NULL;
@ -191,6 +191,9 @@ pn53x_usb_connect (const nfc_device_desc_t * pndd, const char *target_name, int
// we failed to use the specified device
return NULL;
}
// Copy VendorId and ProductId
us.uc.idVendor = dev->descriptor.idVendor;
us.uc.idProduct = dev->descriptor.idProduct;
// Allocate memory for the device info and specification, fill it and return the info
pus = malloc (sizeof (usb_spec_t));
*pus = us;

View file

@ -23,22 +23,24 @@
#include <usb.h>
typedef struct {
uint16_t idVendor;
uint16_t idProduct;
} usb_candidate_t;
typedef struct {
usb_dev_handle *pudh;
usb_candidate_t uc;
uint32_t uiEndPointIn;
uint32_t uiEndPointOut;
uint32_t wMaxPacketSize;
} usb_spec_t;
typedef struct {
uint16_t idVendor;
uint16_t idProduct;
} usb_candidate_t;
nfc_device_t *pn53x_usb_connect (const nfc_device_desc_t * pndd, const char *target_name, int target_chip);
void get_end_points (struct usb_device *dev, usb_spec_t * pus);
void pn53x_usb_disconnect (nfc_device_t * pnd);
bool pn53x_usb_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
size_t * pszRx);
bool pn53x_usb_list_devices (nfc_device_desc_t pnddDevices[], size_t szDevices, size_t * pszDeviceFound,
usb_candidate_t candidates[], int num_candidates, char *target_name);
nfc_device_t *pn53x_usb_connect (const nfc_device_desc_t * pndd, const char *target_name, int target_chip);
bool pn53x_usb_transceive (nfc_device_t * pnd, const byte_t * pbtTx, const size_t szTx, byte_t * pbtRx,
size_t * pszRx);
void pn53x_usb_disconnect (nfc_device_t * pnd);

View file

@ -107,9 +107,14 @@ nfc_connect (nfc_device_desc_t * pndd)
// Great we have claimed a device
pnd->pdc = &(drivers_callbacks_list[uiDriver]);
// TODO: Put this pn53x related in driver_init()
if (!pn53x_init (pnd))
return NULL;
if (pnd->pdc->init) {
pnd->pdc->init (pnd);
}
// Set default configuration options
// Make sure we reset the CRC and parity to chip handling.
if (!nfc_configure (pnd, NDO_HANDLE_CRC, true))

View file

@ -11,5 +11,6 @@ ATTRS{idVendor}=="054c", ATTRS{idProduct}=="0193", MODE="0664", GROUP="plugdev"
# PN533
ATTRS{idVendor}=="04cc", ATTRS{idProduct}=="2533", MODE="0664", GROUP="plugdev"
ATTRS{idVendor}=="04e6", ATTRS{idProduct}=="5591", MODE="0664", GROUP="plugdev"
ATTRS{idVendor}=="1fd3", ATTRS{idProduct}=="0608", MODE="0664", GROUP="plugdev"
LABEL="pn53x_rules_end"