Remove nfc-defines.h public header.

Use NULL instead of INVALID_DEVICE_INFO to know if device is valid.
Make distcheck OK
This commit is contained in:
Romuald Conty 2009-11-10 09:47:59 +00:00
parent 9fccd11fc7
commit aa8bb42d9f
27 changed files with 106 additions and 111 deletions

View file

@ -17,20 +17,23 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>
*
*
* @file pn533.c
* @brief
* @file pn533_usb.c
* @brief Driver for PN533 chip using USB
*/
/*
Thanks to d18c7db and Okko for example code
*/
#include "pn533.h"
#include "pn533_usb.h"
#include <usb.h>
#include <stdio.h>
#include <string.h>
#include "nfc-defines.h"
#include "../drivers.h"
// Bus
#include <usb.h>
#include "nfc-messages.h"
#define BUFFER_LENGTH 256
@ -40,10 +43,10 @@ typedef struct {
usb_dev_handle* pudh;
uint32_t uiEndPointIn;
uint32_t uiEndPointOut;
} dev_spec_pn533;
} dev_spec_pn533_usb;
// Find transfer endpoints for bulk transfers
static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp)
static void get_end_points(struct usb_device *dev, dev_spec_pn533_usb* pdsp)
{
uint32_t uiIndex;
uint32_t uiEndPoint;
@ -78,15 +81,15 @@ static void get_end_points(struct usb_device *dev, dev_spec_pn533* pdsp)
}
}
nfc_device_t* pn533_connect(const nfc_device_desc_t* pndd)
nfc_device_t* pn533_usb_connect(const nfc_device_desc_t* pndd)
{
int idvendor = 0x04e6;
int idproduct = 0x5591;
struct usb_bus *bus;
struct usb_device *dev;
nfc_device_t* pnd = INVALID_DEVICE_INFO;
dev_spec_pn533* pdsp;
dev_spec_pn533 dsp;
dev_spec_pn533_usb* pdsp;
dev_spec_pn533_usb dsp;
uint32_t uiDevIndex;
dsp.uiEndPointIn = 0;
@ -140,7 +143,7 @@ nfc_device_t* pn533_connect(const nfc_device_desc_t* pndd)
return INVALID_DEVICE_INFO;
}
// Allocate memory for the device info and specification, fill it and return the info
pdsp = malloc(sizeof(dev_spec_pn533));
pdsp = malloc(sizeof(dev_spec_pn533_usb));
*pdsp = dsp;
pnd = malloc(sizeof(nfc_device_t));
strcpy(pnd->acName,"PN533USB");
@ -157,22 +160,22 @@ nfc_device_t* pn533_connect(const nfc_device_desc_t* pndd)
return pnd;
}
void pn533_disconnect(nfc_device_t* pnd)
void pn533_usb_disconnect(nfc_device_t* pnd)
{
dev_spec_pn533* pdsp = (dev_spec_pn533*)pnd->ds;
dev_spec_pn533_usb* pdsp = (dev_spec_pn533_usb*)pnd->ds;
usb_release_interface(pdsp->pudh,0);
usb_close(pdsp->pudh);
free(pnd->ds);
free(pnd);
}
bool pn533_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
bool pn533_usb_transceive(const dev_spec ds, const byte_t* pbtTx, const size_t szTxLen, byte_t* pbtRx, size_t* pszRxLen)
{
size_t uiPos = 0;
int ret = 0;
byte_t abtTx[BUFFER_LENGTH] = { 0x00, 0x00, 0xff }; // Every packet must start with "00 00 ff"
byte_t abtRx[BUFFER_LENGTH];
dev_spec_pn533* pdsp = (dev_spec_pn533*)ds;
dev_spec_pn533_usb* pdsp = (dev_spec_pn533_usb*)ds;
// Packet length = data length (len) + checksum (1) + end of stream marker (1)
abtTx[3] = szTxLen;