1 | /*
|
---|
2 | ifd_smartreader.h
|
---|
3 | Header file for Argolis smartreader+.
|
---|
4 | */
|
---|
5 | #ifdef HAVE_LIBUSB
|
---|
6 | #ifdef USE_PTHREAD
|
---|
7 |
|
---|
8 | #include <stdlib.h>
|
---|
9 | #include <stdio.h>
|
---|
10 | #include <ctype.h>
|
---|
11 | #include <unistd.h>
|
---|
12 |
|
---|
13 | #include <sys/time.h>
|
---|
14 | #include <sys/types.h>
|
---|
15 |
|
---|
16 | #include <pthread.h>
|
---|
17 | #include <memory.h>
|
---|
18 |
|
---|
19 | #include "ftdi.h"
|
---|
20 | #include "atr.h"
|
---|
21 |
|
---|
22 |
|
---|
23 | #define LOBYTE(w) ((BYTE)((w) & 0xff))
|
---|
24 | #define HIBYTE(w) ((BYTE)((w) >> 8))
|
---|
25 |
|
---|
26 | typedef struct {
|
---|
27 | int F;
|
---|
28 | float D;
|
---|
29 | int fs;
|
---|
30 | int N;
|
---|
31 | int T;
|
---|
32 | int inv;
|
---|
33 | } SR_CONFIG;
|
---|
34 |
|
---|
35 | unsigned char g_read_buffer[4096];
|
---|
36 | unsigned short g_read_buffer_size = 0;
|
---|
37 | pthread_mutex_t g_read_mutex = PTHREAD_MUTEX_INITIALIZER;
|
---|
38 | pthread_mutex_t g_usb_mutex = PTHREAD_MUTEX_INITIALIZER;
|
---|
39 | struct ftdi_context ftdic;
|
---|
40 | pthread_t rt;
|
---|
41 |
|
---|
42 | SR_CONFIG sr_config;
|
---|
43 |
|
---|
44 |
|
---|
45 | int SR_Init (int device_index);
|
---|
46 | int SR_Reset (ATR ** atr);
|
---|
47 | int SR_Transmit (BYTE * buffer, unsigned size);
|
---|
48 | int SR_Receive (BYTE * buffer, unsigned size);
|
---|
49 | int SR_SetBaudrate (int mhz);
|
---|
50 |
|
---|
51 | bool find_smartreader(int index, struct ftdi_context* ftdic);
|
---|
52 | void smart_flush(struct ftdi_context* ftdic);
|
---|
53 | int smart_read(struct ftdi_context* ftdic, unsigned char* buff, size_t size, int timeout_sec);
|
---|
54 | int smart_write(struct ftdi_context* ftdic, unsigned char* buff, size_t size, int udelay);
|
---|
55 | void EnableSmartReader(struct ftdi_context* ftdic, int clock, unsigned short Fi, unsigned char Di, unsigned char Ni, unsigned char inv);
|
---|
56 | void ResetSmartReader(struct ftdi_context* ftdic);
|
---|
57 | void* ReaderThread(void *p);
|
---|
58 |
|
---|
59 | #endf // USE_PTHREAD
|
---|
60 | #endif //HAVE_LIBUSB
|
---|