update spec to support normal io pins
[mTask.git] / client / interface.h
index f3920eb..e6b14db 100644 (file)
@@ -1,37 +1,85 @@
 #ifndef INTERFACE_H
 #define INTERFACE_H
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #include <stdbool.h>
 #include <stdint.h>
 #include <stdarg.h>
 
-#ifndef STM
+#ifdef LINUX
+#define APINS 128
+#define DPINS 128
+#define STACKSIZE 1024
+#define MEMSIZE 1024
+#define HAVELED 1
+
 extern int gargc;
 extern char **gargv;
+
+#elif defined STM
+#define APINS 128
+#define DPINS 128
+#define STACKSIZE 1024
+#define MEMSIZE 1024
+#define HAVELED 1
+
+#elif defined ARDUINO_ESP8266_NODEMCU
+#define APINS 128
+#define DPINS 128
+#define STACKSIZE 1024
+#define MEMSIZE 1024
+#define HAVELED 0
+
+#elif defined ARDUINO_AVR_UNO
+#define APINS 128
+#define DPINS 128
+#define STACKSIZE 64
+#define MEMSIZE 256
+#define HAVELED 0
+#else
+//Add you device here
 #endif
 
 #define read16() 256*(uint8_t)read_byte() + (uint8_t)read_byte()
 #define from16(a, b) 256*a+b
-#define write16(i) { write_byte((uint8_t)i/256); write_byte((uint8_t)i%256); }
+#define write16(i) { write_byte((uint8_t)(i/256)); write_byte((uint8_t)(i%256)); }
+
+/* Communication */
+bool input_available(void);
 uint8_t read_byte(void);
 void write_byte(uint8_t b);
 
+/* Analog and digital pins */
+#if DPINS > 0
 void write_dpin(uint8_t i, bool b);
 bool read_dpin(uint8_t i);
-
+#endif
+#if APINS > 0
 void write_apin(uint8_t i, uint8_t a);
 uint8_t read_apin(uint8_t i);
+#endif
 
+/* UserLED */
+#if HAVELED == 1
 void led_on(uint8_t i);
 void led_off(uint8_t i);
+#endif
 
-long millis(void);
-bool input_available(void);
-void delay(long ms);
+/* Delay and communication */
+unsigned long getmillis(void);
+void msdelay(unsigned long ms);
 
-void setup(void);
+/* Auxilliary */
+void real_setup(void);
 void debug(char *fmt, ...);
 void pdie(char *s);
 void die(char *fmt, ...);
+void reset(void);
 
+#ifdef __cplusplus
+}
+#endif
 #endif