042cc20e2b914798b0013459b1071f8a043fea98
[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 #elif defined NODEMCU
26 #define MAXTASKS 5
27 #define MAXSDSS 100
28 #define HAVELED 0
29 #define HAVEAIO 0
30 #define HAVEDIO 0
31
32 #else
33 //Add you device here
34 #endif
35
36 #define read16() 256*(uint8_t)read_byte() + (uint8_t)read_byte()
37 #define from16(a, b) 256*a+b
38 #define write16(i) { write_byte((uint8_t)i/256); write_byte((uint8_t)i%256); }
39
40 /* Communication */
41 bool input_available(void);
42 uint8_t read_byte(void);
43 void write_byte(uint8_t b);
44
45 /* Analog and digital pins */
46 #if HAVEDIO == 1
47 void write_dpin(uint8_t i, bool b);
48 bool read_dpin(uint8_t i);
49 #endif
50 #if HAVEAIO == 1
51 void write_apin(uint8_t i, uint8_t a);
52 uint8_t read_apin(uint8_t i);
53 #endif
54
55 /* UserLED */
56 #if HAVELED == 1
57 void led_on(uint8_t i);
58 void led_off(uint8_t i);
59 #endif
60
61 /* Delay and communication */
62 long millis(void);
63 void delay(long ms);
64
65 /* Auxilliary */
66 void setup(void);
67 void debug(char *fmt, ...);
68 void pdie(char *s);
69 void die(char *fmt, ...);
70
71 #endif