altos/stm: Note that ao_i2c_recv_dma_isr isn't actually used
[fw/altos] / libaltos / libaltos.h
1 /*
2  * Copyright © 2010 Keith Packard <keithp@keithp.com>
3  *
4  * This program is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation; either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * This program is distributed in the hope that it will be useful, but
10  * WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License along
15  * with this program; if not, write to the Free Software Foundation, Inc.,
16  * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
17  */
18
19 #ifndef _LIBALTOS_H_
20 #define _LIBALTOS_H_
21
22 #include <stdlib.h>
23
24 #if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
25 # ifndef BUILD_STATIC
26 #  ifdef BUILD_DLL
27 #   define PUBLIC __declspec(dllexport)
28 #  else
29 #   define PUBLIC __declspec(dllimport)
30 #  endif
31 # endif /* BUILD_STATIC */
32 #endif
33
34 #ifndef PUBLIC
35 # define PUBLIC
36 #endif
37
38 struct altos_device {
39         //%immutable;
40         int                             vendor;
41         int                             product;
42         int                             serial;
43         char                            name[256];
44         char                            path[256];
45         //%mutable;
46 };
47
48 struct altos_bt_device {
49         //%immutable;
50         char                            name[256];
51         char                            addr[20];
52         //%mutable;
53 };
54
55 struct altos_error {
56         int                             code;
57         char                            string[1024];
58 };
59
60 #define LIBALTOS_SUCCESS        0
61 #define LIBALTOS_ERROR          -1
62 #define LIBALTOS_TIMEOUT        -2
63
64 /* Returns 0 for success, < 0 on error */
65 PUBLIC int
66 altos_init(void);
67
68 PUBLIC void
69 altos_fini(void);
70
71 PUBLIC void
72 altos_get_last_error(struct altos_error *error);
73
74 PUBLIC struct altos_list *
75 altos_list_start(void);
76
77 PUBLIC struct altos_list *
78 altos_ftdi_list_start(void);
79
80 /* Returns 1 for success, zero on end of list */
81 PUBLIC int
82 altos_list_next(struct altos_list *list, struct altos_device *device);
83
84 PUBLIC void
85 altos_list_finish(struct altos_list *list);
86
87 PUBLIC struct altos_file *
88 altos_open(struct altos_device *device);
89
90 PUBLIC void
91 altos_close(struct altos_file *file);
92
93 PUBLIC void
94 altos_free(struct altos_file *file);
95
96 /* Returns < 0 for error */
97 PUBLIC int
98 altos_putchar(struct altos_file *file, char c);
99
100 /* Returns < 0 for error */
101 PUBLIC int
102 altos_flush(struct altos_file *file);
103
104 /* Returns < 0 for error or timeout. timeout of 0 == wait forever */
105 PUBLIC int
106 altos_getchar(struct altos_file *file, int timeout);
107
108 PUBLIC struct altos_bt_list *
109 altos_bt_list_start(int inquiry_time);
110
111 PUBLIC int
112 altos_bt_list_next(struct altos_bt_list *list, struct altos_bt_device *device);
113
114 PUBLIC void
115 altos_bt_list_finish(struct altos_bt_list *list);
116
117 PUBLIC void
118 altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device);
119
120 PUBLIC struct altos_file *
121 altos_bt_open(struct altos_bt_device *device);
122
123 #endif /* _LIBALTOS_H_ */