b9c223a522f7c40e8b51007bb732c901a7dbc77c
[mTask.git] / int / nucleo-f767-blinky / src / interface.h
1 #ifndef MAIN_H
2 #define MAIN_H
3
4 #include <stdbool.h>
5 #include <stdint.h>
6
7 #ifndef STM32F767xx
8 extern int gargc;
9 extern char **gargv;
10 #endif
11
12 uint8_t read_byte();
13 void write_byte(uint8_t b);
14
15 void write_dpin(uint8_t i, bool b);
16 bool read_dpin(uint8_t i);
17
18 void write_apin(uint8_t i, uint8_t a);
19 uint8_t read_apin(uint8_t i);
20
21 long millis();
22 bool input_available();
23 void delay(long ms);
24
25 void setup();
26
27 #define read16() 256*read_byte() + read_byte()
28 #ifdef STM32F767xx
29 #define debug(s, ...) ;
30 #define pdie(s) ;
31 #define die(s, ...) ;
32 #else
33
34 #ifdef DEBUG
35 #define debug(s, ...) printf(s, ##__VA_ARGS__);
36 #else
37 #define debug(s, ...) ;
38 #endif
39
40 #define pdie(s) {perror(s); exit(1);}
41 #define die(s, ...) {fprintf(stderr, s, ##__VA_ARGS__); exit(1);}
42 #endif
43
44 #endif