makes GPIO_PIN_RST optional for the sx1276
[ExpressLRS.git] / src / include / native.h
blob6584e38512800deeee5060eed93b7ca2a93e5f25
1 #pragma once
3 #include <stdint.h>
4 #include <cstdlib>
5 #include <cstdint>
6 #include <cstring>
7 #include <cctype>
8 #include <stdio.h>
9 #include <unistd.h>
10 #include <math.h>
11 #include <sys/time.h>
13 typedef uint8_t byte;
15 #define HEX 16
16 #define DEC 10
18 class Stream
20 public:
21 Stream() {}
22 virtual ~Stream() {}
24 // Stream methods
25 virtual int available() = 0;
26 virtual int read() = 0;
27 virtual int peek() = 0;
28 virtual void flush() = 0;
30 // Print methods
31 virtual size_t write(uint8_t c) = 0;
32 virtual size_t write(uint8_t *s, int l) = 0;
35 class HardwareSerial: public Stream {
36 public:
37 // Stream methods
38 int available() {return 0;}
39 int read() {return -1;}
40 int peek() {return 0;}
41 void flush() {}
42 void end() {}
43 void begin(int baud) {}
44 void enableHalfDuplexRx() {}
46 // Print methods
47 size_t write(uint8_t c) {return 1;}
48 size_t write(uint8_t *s, int l) {return l;}
50 int print(const char *s) {return 0;}
51 int print(uint8_t s) {return 0;}
52 int print(uint8_t s, int radix) {return 0;}
53 int println() {return 0;}
54 int println(const char *s) {return 0;}
55 int println(uint8_t s) {return 0;}
56 int println(uint8_t s, int radix) {return 0;}
59 static HardwareSerial Serial;
61 inline void interrupts() {}
62 inline void noInterrupts() {}
64 inline unsigned long micros() {
65 struct timeval tv;
66 gettimeofday(&tv,NULL);
67 return tv.tv_sec*(uint64_t)1000000+tv.tv_usec;
70 inline void delay(int32_t time) {
71 usleep(time);
75 inline unsigned long millis() { return 0; }
76 inline void delayMicroseconds(int delay) { }
78 const char device_name[] = "testing";
79 const uint8_t device_name_size = sizeof(device_name);
81 #ifdef _WIN32
82 #define random rand
83 #define srandom srand
84 #endif