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