9e818104dc94fdfd639fbf2b442ca1e24bbc1671
[mTask.git] / client / interface.h
1 #ifndef INTERFACE_H
2 #define INTERFACE_H
3
4 #include <stdbool.h>
5 #include <stdint.h>
6 #include <stdarg.h>
7
8 #ifdef LINUX
9 #define MAXTASKS 5
10 #define MAXSDSS 100
11 #define HAVELED 1
12 #define HAVEAIO 1
13 #define HAVEDIO 1
14
15 extern int gargc;
16 extern char **gargv;
17
18 #elif defined STM
19 #define MAXTASKS 5
20 #define MAXSDSS 100
21 #define HAVELED 1
22 #define HAVEAIO 1
23 #define HAVEDIO 1
24
25 #else
26 //Add you device here
27 #endif
28
29 #define read16() 256*(uint8_t)read_byte() + (uint8_t)read_byte()
30 #define from16(a, b) 256*a+b
31 #define write16(i) { write_byte((uint8_t)i/256); write_byte((uint8_t)i%256); }
32
33 /* Communication */
34 bool input_available(void);
35 uint8_t read_byte(void);
36 void write_byte(uint8_t b);
37
38 /* Analog and digital pins */
39 #if HAVEDIO == 1
40 void write_dpin(uint8_t i, bool b);
41 bool read_dpin(uint8_t i);
42 #endif
43 #if HAVEAIO == 1
44 void write_apin(uint8_t i, uint8_t a);
45 uint8_t read_apin(uint8_t i);
46 #endif
47
48 /* UserLED */
49 #if HAVELED == 1
50 void led_on(uint8_t i);
51 void led_off(uint8_t i);
52 #endif
53
54 /* Delay and communication */
55 long millis(void);
56 void delay(long ms);
57
58 /* Auxilliary */
59 void setup(void);
60 void debug(char *fmt, ...);
61 void pdie(char *s);
62 void die(char *fmt, ...);
63
64 #endif