altos: Add BMI088 test framework using Nucleo32 board for stm32f042
[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         int                             (*method_1)(int x, int y);
46         //%mutable;
47 };
48
49 struct altos_bt_device {
50         //%immutable;
51         char                            name[256];
52         char                            addr[20];
53         //%mutable;
54 };
55
56 struct altos_error {
57         int                             code;
58         char                            string[1024];
59 };
60
61 #define LIBALTOS_SUCCESS        0
62 #define LIBALTOS_ERROR          -1
63 #define LIBALTOS_TIMEOUT        -2
64
65 /* Returns 0 for success, < 0 on error */
66 PUBLIC int
67 altos_init(void);
68
69 PUBLIC void
70 altos_fini(void);
71
72 PUBLIC void
73 altos_get_last_error(struct altos_error *error);
74
75 PUBLIC struct altos_list *
76 altos_list_start(void);
77
78 PUBLIC struct altos_list *
79 altos_ftdi_list_start(void);
80
81 /* Returns 1 for success, zero on end of list */
82 PUBLIC int
83 altos_list_next(struct altos_list *list, struct altos_device *device);
84
85 PUBLIC void
86 altos_list_finish(struct altos_list *list);
87
88 PUBLIC struct altos_file *
89 altos_open(struct altos_device *device);
90
91 PUBLIC void
92 altos_close(struct altos_file *file);
93
94 PUBLIC void
95 altos_free(struct altos_file *file);
96
97 /* Returns < 0 for error */
98 PUBLIC int
99 altos_putchar(struct altos_file *file, char c);
100
101 /* Returns < 0 for error */
102 PUBLIC int
103 altos_flush(struct altos_file *file);
104
105 /* Returns < 0 for error or timeout. timeout of 0 == wait forever */
106 PUBLIC int
107 altos_getchar(struct altos_file *file, int timeout);
108
109 PUBLIC struct altos_bt_list *
110 altos_bt_list_start(int inquiry_time);
111
112 PUBLIC int
113 altos_bt_list_next(struct altos_bt_list *list, struct altos_bt_device *device);
114
115 PUBLIC void
116 altos_bt_list_finish(struct altos_bt_list *list);
117
118 PUBLIC void
119 altos_bt_fill_in(char *name, char *addr, struct altos_bt_device *device);
120
121 PUBLIC struct altos_file *
122 altos_bt_open(struct altos_bt_device *device);
123
124 #endif /* _LIBALTOS_H_ */