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