Apply styles for changed files
This commit is contained in:
parent
1e4146da33
commit
3a009d05ea
@ -39,7 +39,8 @@ static libusb_context *ctx = NULL;
|
||||
|
||||
uint8_t get_usb_num_configs(struct libusb_device *dev);
|
||||
|
||||
int usbbus_prepare() {
|
||||
int usbbus_prepare()
|
||||
{
|
||||
static bool usb_initialized = false;
|
||||
int res;
|
||||
if (!usb_initialized) {
|
||||
@ -91,7 +92,8 @@ size_t usbbus_usb_scan(nfc_connstring connstrings[],
|
||||
const size_t connstrings_len,
|
||||
struct usbbus_device *nfc_usb_devices,
|
||||
const size_t num_nfc_usb_devices,
|
||||
char *usb_driver_name) {
|
||||
char *usb_driver_name)
|
||||
{
|
||||
usbbus_prepare();
|
||||
|
||||
size_t device_found = 0;
|
||||
@ -196,7 +198,8 @@ size_t usbbus_usb_scan(nfc_connstring connstrings[],
|
||||
void usbbus_get_usb_endpoints(struct libusb_device *dev,
|
||||
uint8_t *endpoint_in,
|
||||
uint8_t *endpoint_out,
|
||||
uint16_t *max_packet_size) {
|
||||
uint16_t *max_packet_size)
|
||||
{
|
||||
|
||||
bool endpoint_in_set = false;
|
||||
bool endpoint_out_set = false;
|
||||
@ -260,13 +263,15 @@ void usbbus_get_usb_endpoints(struct libusb_device *dev,
|
||||
}
|
||||
}
|
||||
|
||||
uint8_t get_usb_num_configs(struct libusb_device *dev) {
|
||||
uint8_t get_usb_num_configs(struct libusb_device *dev)
|
||||
{
|
||||
struct libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(dev, &descriptor);
|
||||
return descriptor.bNumConfigurations;
|
||||
}
|
||||
|
||||
void usbbus_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *udev, char *buffer, size_t len) {
|
||||
void usbbus_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *udev, char *buffer, size_t len)
|
||||
{
|
||||
struct libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(dev, &descriptor);
|
||||
if (descriptor.iManufacturer || descriptor.iProduct) {
|
||||
@ -284,8 +289,9 @@ void usbbus_get_usb_device_name(struct libusb_device *dev, libusb_device_handle
|
||||
}
|
||||
|
||||
|
||||
void usbbus_get_device(uint8_t dev_address, struct libusb_device ** dev, struct libusb_device_handle ** dev_handle) {
|
||||
struct libusb_device ** device_list;
|
||||
void usbbus_get_device(uint8_t dev_address, struct libusb_device **dev, struct libusb_device_handle **dev_handle)
|
||||
{
|
||||
struct libusb_device **device_list;
|
||||
ssize_t num_devices = libusb_get_device_list(ctx, &device_list);
|
||||
for (size_t i = 0; i < num_devices; i++) {
|
||||
if (libusb_get_device_address(device_list[i]) != dev_address) {
|
||||
@ -294,8 +300,8 @@ void usbbus_get_device(uint8_t dev_address, struct libusb_device ** dev, struct
|
||||
*dev = device_list[i];
|
||||
int res = libusb_open(*dev, dev_handle);
|
||||
if (res != 0 || dev_handle == NULL) {
|
||||
log_put(LOG_GROUP,LOG_CATEGORY,NFC_LOG_PRIORITY_ERROR,
|
||||
"Unable to open libusb device (%s)",libusb_strerror(res));
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_ERROR,
|
||||
"Unable to open libusb device (%s)", libusb_strerror(res));
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -307,26 +313,30 @@ void usbbus_get_device(uint8_t dev_address, struct libusb_device ** dev, struct
|
||||
}
|
||||
|
||||
|
||||
void usbbus_close(struct libusb_device * dev, struct libusb_device_handle * dev_handle) {
|
||||
void usbbus_close(struct libusb_device *dev, struct libusb_device_handle *dev_handle)
|
||||
{
|
||||
libusb_close(dev_handle);
|
||||
libusb_unref_device(dev);
|
||||
libusb_exit(ctx);
|
||||
}
|
||||
|
||||
uint16_t usbbus_get_vendor_id(struct libusb_device *dev) {
|
||||
uint16_t usbbus_get_vendor_id(struct libusb_device *dev)
|
||||
{
|
||||
struct libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(dev, &descriptor);
|
||||
return descriptor.idVendor;
|
||||
}
|
||||
|
||||
uint16_t usbbus_get_product_id(struct libusb_device *dev) {
|
||||
uint16_t usbbus_get_product_id(struct libusb_device *dev)
|
||||
{
|
||||
struct libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(dev, &descriptor);
|
||||
return descriptor.idProduct;
|
||||
}
|
||||
|
||||
|
||||
int usbbus_get_num_alternate_settings(struct libusb_device *dev, uint8_t config_idx) {
|
||||
int usbbus_get_num_alternate_settings(struct libusb_device *dev, uint8_t config_idx)
|
||||
{
|
||||
struct libusb_config_descriptor *usb_config;
|
||||
int r = libusb_get_config_descriptor(dev, config_idx, &usb_config);
|
||||
if (r != 0 || usb_config == NULL) {
|
||||
|
||||
@ -46,12 +46,12 @@ struct usbbus_device {
|
||||
|
||||
int usbbus_prepare();
|
||||
|
||||
size_t usbbus_usb_scan(nfc_connstring connstrings[], size_t connstrings_len, struct usbbus_device * nfc_usb_devices, size_t num_nfc_usb_devices, char * usb_driver_name);
|
||||
void usbbus_get_usb_endpoints(struct libusb_device *dev, uint8_t * endpoint_in, uint8_t * endpoint_out, uint16_t * max_packet_size);
|
||||
void usbbus_get_usb_device_name(struct libusb_device * dev, libusb_device_handle *udev, char *buffer, size_t len);
|
||||
void usbbus_get_device(uint8_t dev_address, struct libusb_device ** dev, struct libusb_device_handle ** dev_handle);
|
||||
void usbbus_close(struct libusb_device * dev, struct libusb_device_handle * dev_handle);
|
||||
uint16_t usbbus_get_vendor_id(struct libusb_device * dev);
|
||||
uint16_t usbbus_get_product_id(struct libusb_device * dev);
|
||||
size_t usbbus_usb_scan(nfc_connstring connstrings[], size_t connstrings_len, struct usbbus_device *nfc_usb_devices, size_t num_nfc_usb_devices, char *usb_driver_name);
|
||||
void usbbus_get_usb_endpoints(struct libusb_device *dev, uint8_t *endpoint_in, uint8_t *endpoint_out, uint16_t *max_packet_size);
|
||||
void usbbus_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *udev, char *buffer, size_t len);
|
||||
void usbbus_get_device(uint8_t dev_address, struct libusb_device **dev, struct libusb_device_handle **dev_handle);
|
||||
void usbbus_close(struct libusb_device *dev, struct libusb_device_handle *dev_handle);
|
||||
uint16_t usbbus_get_vendor_id(struct libusb_device *dev);
|
||||
uint16_t usbbus_get_product_id(struct libusb_device *dev);
|
||||
int usbbus_get_num_alternate_settings(struct libusb_device *dev, uint8_t config_idx);
|
||||
#endif
|
||||
|
||||
@ -177,7 +177,7 @@ struct acr122_usb_apdu_frame {
|
||||
|
||||
// Internal data struct
|
||||
struct acr122_usb_data {
|
||||
libusb_device * dev;
|
||||
libusb_device *dev;
|
||||
libusb_device_handle *pudh;
|
||||
uint8_t configIdx;
|
||||
uint8_t uiEndPointIn;
|
||||
@ -228,7 +228,8 @@ static int acr122_usb_send_apdu(nfc_device *pnd,
|
||||
const size_t out_size);
|
||||
|
||||
static int
|
||||
acr122_usb_bulk_read(struct acr122_usb_data *data, uint8_t abtRx[], const size_t szRx, const int timeout) {
|
||||
acr122_usb_bulk_read(struct acr122_usb_data *data, uint8_t abtRx[], const size_t szRx, const int timeout)
|
||||
{
|
||||
int actual_length;
|
||||
int res = libusb_bulk_transfer(data->pudh, data->uiEndPointIn, (unsigned char *) abtRx, szRx, &actual_length, timeout);
|
||||
if (res == 0) {
|
||||
@ -250,7 +251,8 @@ acr122_usb_bulk_read(struct acr122_usb_data *data, uint8_t abtRx[], const size_t
|
||||
}
|
||||
|
||||
static int
|
||||
acr122_usb_bulk_write(struct acr122_usb_data *data, uint8_t abtTx[], const size_t szTx, const int timeout) {
|
||||
acr122_usb_bulk_write(struct acr122_usb_data *data, uint8_t abtTx[], const size_t szTx, const int timeout)
|
||||
{
|
||||
LOG_HEX(NFC_LOG_GROUP_COM, "TX", abtTx, szTx);
|
||||
int actual_length;
|
||||
int res = libusb_bulk_transfer(data->pudh, data->uiEndPointOut, (unsigned char *) abtTx, szTx, &actual_length, timeout);
|
||||
@ -285,10 +287,11 @@ const struct acr122_usb_supported_device acr122_usb_supported_devices[] = {
|
||||
};
|
||||
|
||||
const size_t
|
||||
num_acr122_usb_supported_device = sizeof(acr122_usb_supported_devices) / sizeof(struct acr122_usb_supported_device);
|
||||
num_acr122_usb_supported_device = sizeof(acr122_usb_supported_devices) / sizeof(struct acr122_usb_supported_device);
|
||||
|
||||
static size_t
|
||||
acr122_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const size_t connstrings_len) {
|
||||
acr122_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const size_t connstrings_len)
|
||||
{
|
||||
(void) context;
|
||||
struct usbbus_device devices[num_acr122_usb_supported_device];
|
||||
for (size_t i = 0; i < num_acr122_usb_supported_device; i++) {
|
||||
@ -302,7 +305,8 @@ acr122_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const
|
||||
|
||||
|
||||
static bool
|
||||
acr122_usb_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *udev, char *buffer, size_t len) {
|
||||
acr122_usb_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *udev, char *buffer, size_t len)
|
||||
{
|
||||
*buffer = '\0';
|
||||
|
||||
usbbus_get_usb_device_name(dev, udev, buffer, len);
|
||||
@ -324,7 +328,8 @@ acr122_usb_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *
|
||||
}
|
||||
|
||||
static nfc_device *
|
||||
acr122_usb_open(const nfc_context *context, const nfc_connstring connstring) {
|
||||
acr122_usb_open(const nfc_context *context, const nfc_connstring connstring)
|
||||
{
|
||||
nfc_device *pnd = NULL;
|
||||
char *dev_address_str;
|
||||
char *config_idx_str;
|
||||
@ -443,7 +448,8 @@ acr122_usb_open(const nfc_context *context, const nfc_connstring connstring) {
|
||||
}
|
||||
|
||||
static void
|
||||
acr122_usb_close(nfc_device *pnd) {
|
||||
acr122_usb_close(nfc_device *pnd)
|
||||
{
|
||||
acr122_usb_ack(pnd);
|
||||
pn53x_idle(pnd);
|
||||
|
||||
@ -467,7 +473,8 @@ acr122_usb_close(nfc_device *pnd) {
|
||||
uint32_t htole32(uint32_t u32);
|
||||
|
||||
uint32_t
|
||||
htole32(uint32_t u32) {
|
||||
htole32(uint32_t u32)
|
||||
{
|
||||
union {
|
||||
uint8_t arr[4];
|
||||
uint32_t u32;
|
||||
@ -488,7 +495,8 @@ acr122_build_frame_from_apdu(nfc_device *pnd,
|
||||
const uint8_t p2,
|
||||
const uint8_t *data,
|
||||
const size_t data_len,
|
||||
const uint8_t le) {
|
||||
const uint8_t le)
|
||||
{
|
||||
if (data_len > sizeof(DRIVER_DATA(pnd)->apdu_frame.apdu_payload))
|
||||
return NFC_EINVARG;
|
||||
if ((data == NULL) && (data_len != 0))
|
||||
@ -510,7 +518,8 @@ acr122_build_frame_from_apdu(nfc_device *pnd,
|
||||
}
|
||||
|
||||
static int
|
||||
acr122_build_frame_from_tama(nfc_device *pnd, const uint8_t *tama, const size_t tama_len) {
|
||||
acr122_build_frame_from_tama(nfc_device *pnd, const uint8_t *tama, const size_t tama_len)
|
||||
{
|
||||
if (tama_len > sizeof(DRIVER_DATA(pnd)->tama_frame.tama_payload))
|
||||
return NFC_EINVARG;
|
||||
|
||||
@ -521,14 +530,15 @@ acr122_build_frame_from_tama(nfc_device *pnd, const uint8_t *tama, const size_t
|
||||
}
|
||||
|
||||
static int
|
||||
acr122_usb_send(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, const int timeout) {
|
||||
acr122_usb_send(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, const int timeout)
|
||||
{
|
||||
int res;
|
||||
if ((res = acr122_build_frame_from_tama(pnd, pbtData, szData)) < 0) {
|
||||
pnd->last_error = NFC_EINVARG;
|
||||
return pnd->last_error;
|
||||
}
|
||||
|
||||
if ((res = acr122_usb_bulk_write(DRIVER_DATA(pnd), (unsigned char *) &(DRIVER_DATA(pnd)->tama_frame), res, timeout))
|
||||
if ((res = acr122_usb_bulk_write(DRIVER_DATA(pnd), (unsigned char *) & (DRIVER_DATA(pnd)->tama_frame), res, timeout))
|
||||
< 0) {
|
||||
pnd->last_error = res;
|
||||
return pnd->last_error;
|
||||
@ -539,7 +549,8 @@ acr122_usb_send(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, co
|
||||
#define USBBUS_TIMEOUT_PER_PASS 200
|
||||
|
||||
static int
|
||||
acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, const int timeout) {
|
||||
acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, const int timeout)
|
||||
{
|
||||
off_t offset = 0;
|
||||
|
||||
uint8_t abtRxBuf[255 + sizeof(struct ccid_header)];
|
||||
@ -551,7 +562,7 @@ acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, co
|
||||
*/
|
||||
int usbbus_timeout;
|
||||
int remaining_time = timeout;
|
||||
read:
|
||||
read:
|
||||
if (timeout == USBBUS_INFINITE_TIMEOUT) {
|
||||
usbbus_timeout = USBBUS_TIMEOUT_PER_PASS;
|
||||
} else {
|
||||
@ -714,7 +725,8 @@ acr122_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, co
|
||||
}
|
||||
|
||||
int
|
||||
acr122_usb_ack(nfc_device *pnd) {
|
||||
acr122_usb_ack(nfc_device *pnd)
|
||||
{
|
||||
(void) pnd;
|
||||
int res = 0;
|
||||
uint8_t acr122_ack_frame[] =
|
||||
@ -722,7 +734,7 @@ acr122_usb_ack(nfc_device *pnd) {
|
||||
log_put(LOG_GROUP, LOG_CATEGORY, NFC_LOG_PRIORITY_DEBUG, "%s", "ACR122 Abort");
|
||||
if ((res = acr122_build_frame_from_tama(pnd, acr122_ack_frame, sizeof(acr122_ack_frame))) < 0)
|
||||
return res;
|
||||
if ((res = acr122_usb_bulk_write(DRIVER_DATA(pnd), (unsigned char *) &(DRIVER_DATA(pnd)->tama_frame), res, 1000))
|
||||
if ((res = acr122_usb_bulk_write(DRIVER_DATA(pnd), (unsigned char *) & (DRIVER_DATA(pnd)->tama_frame), res, 1000))
|
||||
< 0)
|
||||
return res;
|
||||
uint8_t abtRxBuf[255 + sizeof(struct ccid_header)];
|
||||
@ -739,11 +751,12 @@ acr122_usb_send_apdu(nfc_device *pnd,
|
||||
size_t data_len,
|
||||
const uint8_t le,
|
||||
uint8_t *out,
|
||||
const size_t out_size) {
|
||||
const size_t out_size)
|
||||
{
|
||||
int res;
|
||||
size_t frame_len = acr122_build_frame_from_apdu(pnd, ins, p1, p2, data, data_len, le);
|
||||
if ((res = acr122_usb_bulk_write(DRIVER_DATA(pnd),
|
||||
(unsigned char *) &(DRIVER_DATA(pnd)->apdu_frame),
|
||||
(unsigned char *) & (DRIVER_DATA(pnd)->apdu_frame),
|
||||
frame_len,
|
||||
1000)) < 0)
|
||||
return res;
|
||||
@ -753,7 +766,8 @@ acr122_usb_send_apdu(nfc_device *pnd,
|
||||
}
|
||||
|
||||
int
|
||||
acr122_usb_init(nfc_device *pnd) {
|
||||
acr122_usb_init(nfc_device *pnd)
|
||||
{
|
||||
int res = 0;
|
||||
int i;
|
||||
uint8_t abtRxBuf[255 + sizeof(struct ccid_header)];
|
||||
@ -812,7 +826,8 @@ acr122_usb_init(nfc_device *pnd) {
|
||||
}
|
||||
|
||||
static int
|
||||
acr122_usb_abort_command(nfc_device *pnd) {
|
||||
acr122_usb_abort_command(nfc_device *pnd)
|
||||
{
|
||||
DRIVER_DATA(pnd)->abort_flag = true;
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
|
||||
@ -78,7 +78,7 @@ typedef enum {
|
||||
|
||||
// Internal data struct
|
||||
struct pn53x_usb_data {
|
||||
libusb_device * dev;
|
||||
libusb_device *dev;
|
||||
libusb_device_handle *pudh;
|
||||
uint8_t configIdx;
|
||||
pn53x_usb_model model;
|
||||
@ -97,7 +97,8 @@ bool pn53x_usb_get_usb_device_name(struct libusb_device *dev, libusb_device_hand
|
||||
int pn53x_usb_init(nfc_device *pnd);
|
||||
|
||||
static int
|
||||
pn53x_usb_bulk_read(struct pn53x_usb_data *data, uint8_t abtRx[], const size_t szRx, const int timeout) {
|
||||
pn53x_usb_bulk_read(struct pn53x_usb_data *data, uint8_t abtRx[], const size_t szRx, const int timeout)
|
||||
{
|
||||
int actual_length;
|
||||
int res = libusb_bulk_transfer(data->pudh, data->uiEndPointIn & 0xff, abtRx, szRx, &actual_length, timeout);
|
||||
if (res == 0) {
|
||||
@ -115,7 +116,8 @@ pn53x_usb_bulk_read(struct pn53x_usb_data *data, uint8_t abtRx[], const size_t s
|
||||
}
|
||||
|
||||
static int
|
||||
pn53x_usb_bulk_write(struct pn53x_usb_data *data, uint8_t abtTx[], const size_t szTx, const int timeout) {
|
||||
pn53x_usb_bulk_write(struct pn53x_usb_data *data, uint8_t abtTx[], const size_t szTx, const int timeout)
|
||||
{
|
||||
LOG_HEX(NFC_LOG_GROUP_COM, "TX", abtTx, szTx);
|
||||
int actual_length;
|
||||
int res = libusb_bulk_transfer(data->pudh, data->uiEndPointOut & 0xff, abtTx, szTx, &actual_length, timeout);
|
||||
@ -184,7 +186,8 @@ const uint8_t btXramUsbDesc_asklogo[] = {
|
||||
0x00,
|
||||
};
|
||||
|
||||
static void pn533_fix_usbdesc(nfc_device *pnd) {
|
||||
static void pn533_fix_usbdesc(nfc_device *pnd)
|
||||
{
|
||||
// PN533 USB descriptors may have been corrupted by large commands/responses
|
||||
// so they need to be restored before closing usb connection.
|
||||
// cf PN5331B3HNC270 Release Note
|
||||
@ -240,7 +243,8 @@ static void pn533_fix_usbdesc(nfc_device *pnd) {
|
||||
}
|
||||
|
||||
static pn53x_usb_model
|
||||
pn53x_usb_get_device_model(uint16_t vendor_id, uint16_t product_id) {
|
||||
pn53x_usb_get_device_model(uint16_t vendor_id, uint16_t product_id)
|
||||
{
|
||||
for (size_t n = 0; n < sizeof(pn53x_usb_supported_devices) / sizeof(struct pn53x_usb_supported_device); n++) {
|
||||
if ((vendor_id == pn53x_usb_supported_devices[n].vendor_id) &&
|
||||
(product_id == pn53x_usb_supported_devices[n].product_id))
|
||||
@ -251,7 +255,8 @@ pn53x_usb_get_device_model(uint16_t vendor_id, uint16_t product_id) {
|
||||
}
|
||||
|
||||
static bool
|
||||
pn53x_usb_get_end_points_default(struct pn53x_usb_data *data) {
|
||||
pn53x_usb_get_end_points_default(struct pn53x_usb_data *data)
|
||||
{
|
||||
struct libusb_device_descriptor descriptor;
|
||||
libusb_get_device_descriptor(data->dev, &descriptor);
|
||||
|
||||
@ -274,7 +279,8 @@ pn53x_usb_get_end_points_default(struct pn53x_usb_data *data) {
|
||||
int pn53x_usb_ack(nfc_device *pnd);
|
||||
|
||||
static size_t
|
||||
pn53x_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const size_t connstrings_len) {
|
||||
pn53x_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const size_t connstrings_len)
|
||||
{
|
||||
struct usbbus_device devices[num_pn53x_usb_supported_devices];
|
||||
for (size_t i = 0; i < num_pn53x_usb_supported_devices; i++) {
|
||||
devices[i].product_id = pn53x_usb_supported_devices[i].product_id;
|
||||
@ -286,7 +292,8 @@ pn53x_usb_scan(const nfc_context *context, nfc_connstring connstrings[], const s
|
||||
}
|
||||
|
||||
bool
|
||||
pn53x_usb_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *udev, char *buffer, size_t len) {
|
||||
pn53x_usb_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *udev, char *buffer, size_t len)
|
||||
{
|
||||
*buffer = '\0';
|
||||
|
||||
usbbus_get_usb_device_name(dev, udev, buffer, len);
|
||||
@ -308,7 +315,8 @@ pn53x_usb_get_usb_device_name(struct libusb_device *dev, libusb_device_handle *u
|
||||
}
|
||||
|
||||
static nfc_device *
|
||||
pn53x_usb_open(const nfc_context *context, const nfc_connstring connstring) {
|
||||
pn53x_usb_open(const nfc_context *context, const nfc_connstring connstring)
|
||||
{
|
||||
nfc_device *pnd = NULL;
|
||||
|
||||
char *dev_address_str;
|
||||
@ -422,16 +430,20 @@ pn53x_usb_open(const nfc_context *context, const nfc_connstring connstring) {
|
||||
|
||||
switch (DRIVER_DATA(pnd)->model) {
|
||||
// empirical tuning
|
||||
case ASK_LOGO:CHIP_DATA(pnd)->timer_correction = 50;
|
||||
case ASK_LOGO:
|
||||
CHIP_DATA(pnd)->timer_correction = 50;
|
||||
CHIP_DATA(pnd)->progressive_field = true;
|
||||
break;
|
||||
case SCM_SCL3711:
|
||||
case SCM_SCL3712:
|
||||
case NXP_PN533:CHIP_DATA(pnd)->timer_correction = 46;
|
||||
case NXP_PN533:
|
||||
CHIP_DATA(pnd)->timer_correction = 46;
|
||||
break;
|
||||
case NXP_PN531:CHIP_DATA(pnd)->timer_correction = 50;
|
||||
case NXP_PN531:
|
||||
CHIP_DATA(pnd)->timer_correction = 50;
|
||||
break;
|
||||
case SONY_PN531:CHIP_DATA(pnd)->timer_correction = 54;
|
||||
case SONY_PN531:
|
||||
CHIP_DATA(pnd)->timer_correction = 54;
|
||||
break;
|
||||
case SONY_RCS360:
|
||||
case UNKNOWN:
|
||||
@ -457,7 +469,8 @@ pn53x_usb_open(const nfc_context *context, const nfc_connstring connstring) {
|
||||
}
|
||||
|
||||
static void
|
||||
pn53x_usb_close(nfc_device *pnd) {
|
||||
pn53x_usb_close(nfc_device *pnd)
|
||||
{
|
||||
pn53x_usb_ack(pnd);
|
||||
|
||||
if (DRIVER_DATA(pnd)->model == ASK_LOGO) {
|
||||
@ -481,7 +494,8 @@ pn53x_usb_close(nfc_device *pnd) {
|
||||
#define PN53X_USB_BUFFER_LEN (PN53x_EXTENDED_FRAME__DATA_MAX_LEN + PN53x_EXTENDED_FRAME__OVERHEAD)
|
||||
|
||||
static int
|
||||
pn53x_usb_send(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, const int timeout) {
|
||||
pn53x_usb_send(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, const int timeout)
|
||||
{
|
||||
uint8_t abtFrame[PN53X_USB_BUFFER_LEN] = {0x00, 0x00, 0xff}; // Every packet must start with "00 00 ff"
|
||||
size_t szFrame = 0;
|
||||
int res = 0;
|
||||
@ -531,7 +545,8 @@ pn53x_usb_send(nfc_device *pnd, const uint8_t *pbtData, const size_t szData, con
|
||||
#define USBBUS_TIMEOUT_PER_PASS 200
|
||||
|
||||
static int
|
||||
pn53x_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, const int timeout) {
|
||||
pn53x_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, const int timeout)
|
||||
{
|
||||
size_t len;
|
||||
off_t offset = 0;
|
||||
|
||||
@ -544,7 +559,7 @@ pn53x_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, con
|
||||
*/
|
||||
int usbbus_timeout;
|
||||
int remaining_time = timeout;
|
||||
read:
|
||||
read:
|
||||
if (timeout == USBBUS_INFINITE_TIMEOUT) {
|
||||
usbbus_timeout = USBBUS_TIMEOUT_PER_PASS;
|
||||
} else {
|
||||
@ -672,12 +687,14 @@ pn53x_usb_receive(nfc_device *pnd, uint8_t *pbtData, const size_t szDataLen, con
|
||||
}
|
||||
|
||||
int
|
||||
pn53x_usb_ack(nfc_device *pnd) {
|
||||
pn53x_usb_ack(nfc_device *pnd)
|
||||
{
|
||||
return pn53x_usb_bulk_write(DRIVER_DATA(pnd), (uint8_t *) pn53x_ack_frame, sizeof(pn53x_ack_frame), 1000);
|
||||
}
|
||||
|
||||
int
|
||||
pn53x_usb_init(nfc_device *pnd) {
|
||||
pn53x_usb_init(nfc_device *pnd)
|
||||
{
|
||||
int res = 0;
|
||||
// Sometimes PN53x USB doesn't reply ACK one the first frame, so we need to send a dummy one...
|
||||
//pn53x_check_communication (pnd); // Sony RC-S360 doesn't support this command for now so let's use a get_firmware_version instead:
|
||||
@ -739,7 +756,8 @@ pn53x_usb_init(nfc_device *pnd) {
|
||||
}
|
||||
|
||||
static int
|
||||
pn53x_usb_set_property_bool(nfc_device *pnd, const nfc_property property, const bool bEnable) {
|
||||
pn53x_usb_set_property_bool(nfc_device *pnd, const nfc_property property, const bool bEnable)
|
||||
{
|
||||
int res = 0;
|
||||
if ((res = pn53x_set_property_bool(pnd, property, bEnable)) < 0)
|
||||
return res;
|
||||
@ -777,7 +795,8 @@ pn53x_usb_set_property_bool(nfc_device *pnd, const nfc_property property, const
|
||||
}
|
||||
|
||||
static int
|
||||
pn53x_usb_abort_command(nfc_device *pnd) {
|
||||
pn53x_usb_abort_command(nfc_device *pnd)
|
||||
{
|
||||
DRIVER_DATA(pnd)->abort_flag = true;
|
||||
return NFC_SUCCESS;
|
||||
}
|
||||
@ -785,7 +804,8 @@ pn53x_usb_abort_command(nfc_device *pnd) {
|
||||
static int
|
||||
pn53x_usb_get_supported_modulation(nfc_device *pnd,
|
||||
const nfc_mode mode,
|
||||
const nfc_modulation_type **const supported_mt) {
|
||||
const nfc_modulation_type **const supported_mt)
|
||||
{
|
||||
if ((DRIVER_DATA(pnd)->model != ASK_LOGO) || (mode != N_TARGET))
|
||||
return pn53x_get_supported_modulation(pnd, mode, supported_mt);
|
||||
else // ASK_LOGO has no N_TARGET support
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user