738dd85ee39c3d6ec391eccfcca4abdc5ee283a1
[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 STACKSIZE 1024
14 #define MEMSIZE 1024
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 STACKSIZE 1024
24 #define MEMSIZE 1024
25 #define HAVELED 1
26 #define HAVEAIO 1
27 #define HAVEDIO 1
28
29 #elif defined ARDUINO_ESP8266_NODEMCU
30 #define STACKSIZE 1024
31 #define MEMSIZE 1024
32 #define HAVELED 0
33 #define HAVEAIO 0
34 #define HAVEDIO 0
35
36 #elif defined ARDUINO_AVR_UNO
37 #define STACKSIZE 64
38 #define MEMSIZE 256
39 #define HAVELED 0
40 #define HAVEAIO 0
41 #define HAVEDIO 0
42 #else
43 //Add you device here
44 #endif
45
46 #define read16() 256*(uint8_t)read_byte() + (uint8_t)read_byte()
47 #define from16(a, b) 256*a+b
48 #define write16(i) { write_byte((uint8_t)(i/256)); write_byte((uint8_t)(i%256)); }
49
50 /* Communication */
51 bool input_available(void);
52 uint8_t read_byte(void);
53 void write_byte(uint8_t b);
54
55 /* Analog and digital pins */
56 #if HAVEDIO == 1
57 void write_dpin(uint8_t i, bool b);
58 bool read_dpin(uint8_t i);
59 #endif
60 #if HAVEAIO == 1
61 void write_apin(uint8_t i, uint8_t a);
62 uint8_t read_apin(uint8_t i);
63 #endif
64
65 /* UserLED */
66 #if HAVELED == 1
67 void led_on(uint8_t i);
68 void led_off(uint8_t i);
69 #endif
70
71 /* Delay and communication */
72 unsigned long getmillis(void);
73 void msdelay(unsigned long ms);
74
75 /* Auxilliary */
76 void real_setup(void);
77 void debug(char *fmt, ...);
78 void pdie(char *s);
79 void die(char *fmt, ...);
80 void reset(void);
81
82 #ifdef __cplusplus
83 }
84 #endif
85 #endif