1 | /*
|
---|
2 | icc_async.h
|
---|
3 | Asynchronous integrated circuit cards handling functions
|
---|
4 |
|
---|
5 | This file is part of the Unix driver for Towitoko smartcard readers
|
---|
6 | Copyright (C) 2000 2001 Carlos Prados <cprados@yahoo.com>
|
---|
7 |
|
---|
8 | This version is modified by doz21 to work in a special manner ;)
|
---|
9 |
|
---|
10 | This library is free software; you can redistribute it and/or
|
---|
11 | modify it under the terms of the GNU Lesser General Public
|
---|
12 | License as published by the Free Software Foundation; either
|
---|
13 | version 2 of the License, or (at your option) any later version.
|
---|
14 |
|
---|
15 | This library is distributed in the hope that it will be useful,
|
---|
16 | but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
17 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
18 | Lesser General Public License for more details.
|
---|
19 |
|
---|
20 | You should have received a copy of the GNU Lesser General Public
|
---|
21 | License along with this library; if not, write to the Free Software
|
---|
22 | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
---|
23 | */
|
---|
24 |
|
---|
25 | #ifndef _ICC_ASYNC_
|
---|
26 | #define _ICC_ASYNC_
|
---|
27 |
|
---|
28 | #include "defines.h"
|
---|
29 | #include "atr.h"
|
---|
30 |
|
---|
31 | /*
|
---|
32 | * Exported constants definition
|
---|
33 | */
|
---|
34 |
|
---|
35 | /* Return codes */
|
---|
36 | #define ICC_ASYNC_OK 0
|
---|
37 | #define ICC_ASYNC_IFD_ERROR 1
|
---|
38 | #define ICC_ASYNC_ATR_ERROR 2
|
---|
39 |
|
---|
40 | /* Card status */
|
---|
41 | #define IFD_TOWITOKO_NOCARD_NOCHANGE 0x00
|
---|
42 | #define IFD_TOWITOKO_CARD_NOCHANGE 0x40
|
---|
43 | #define IFD_TOWITOKO_NOCARD_CHANGE 0x80
|
---|
44 | #define IFD_TOWITOKO_CARD_CHANGE 0xC0
|
---|
45 | #define IFD_TOWITOKO_CARD(status) (((status) & 0x40) == 0x40)
|
---|
46 | #define IFD_TOWITOKO_CHANGE(status) (((status) & 0x80) == 0x80)
|
---|
47 |
|
---|
48 | /*
|
---|
49 | * Exported types definition
|
---|
50 | */
|
---|
51 |
|
---|
52 | typedef struct
|
---|
53 | {
|
---|
54 | unsigned block_delay; /* Delay (ms) after starting to transmit */
|
---|
55 | unsigned char_delay; /* Delay (ms) after transmiting each sucesive char*/
|
---|
56 | unsigned block_timeout; /* Max timeout (ms) to receive first char */
|
---|
57 | unsigned char_timeout; /* Max timeout (ms) to receive sucesive characters */
|
---|
58 | }
|
---|
59 | ICC_Async_Timings;
|
---|
60 |
|
---|
61 | typedef struct
|
---|
62 | {
|
---|
63 | ATR *atr; /* Answer to reset of this ICC */
|
---|
64 | int convention; /* Convention of this ICC */
|
---|
65 | unsigned long baudrate; /* Current baudrate (bps) for transmiting to this ICC */
|
---|
66 | ICC_Async_Timings timings; /* Current timings for transmiting to this ICC */
|
---|
67 | BYTE protocol_type; /* Type of protocol */
|
---|
68 | }
|
---|
69 | ICC_Async;
|
---|
70 |
|
---|
71 | /*
|
---|
72 | * Exported functions declaration
|
---|
73 | */
|
---|
74 |
|
---|
75 | /* Creation and Deletion */
|
---|
76 | extern ICC_Async * ICC_Async_New (void);
|
---|
77 | extern void ICC_Async_Delete (ICC_Async * icc);
|
---|
78 |
|
---|
79 | /* Initialization and Deactivation */
|
---|
80 | extern int ICC_Async_Init (ICC_Async * icc);
|
---|
81 | extern int ICC_Async_Close (ICC_Async * icc);
|
---|
82 |
|
---|
83 | /* Attributes */
|
---|
84 | extern int ICC_Async_SetTimings (ICC_Async * icc, ICC_Async_Timings * timings);
|
---|
85 | extern int ICC_Async_GetTimings (ICC_Async * icc, ICC_Async_Timings * timings);
|
---|
86 | extern int ICC_Async_SetBaudrate (ICC_Async * icc, unsigned long baudrate);
|
---|
87 | extern int ICC_Async_GetBaudrate (ICC_Async * icc, unsigned long * baudrate);
|
---|
88 | extern ATR *ICC_Async_GetAtr (ICC_Async * icc);
|
---|
89 | extern unsigned long ICC_Async_GetClockRate ();
|
---|
90 |
|
---|
91 | /* Operations */
|
---|
92 | extern int ICC_Async_Transmit (ICC_Async * icc, unsigned size, BYTE * buffer);
|
---|
93 | extern int ICC_Async_Receive (ICC_Async * icc, unsigned size, BYTE * buffer);
|
---|
94 |
|
---|
95 | #endif /* _ICC_ASYNC_ */
|
---|
96 |
|
---|