Avionics
Core avionics package for CURE flight computers
Loading...
Searching...
No Matches
ArduinoHAL.h
Go to the documentation of this file.
1#ifndef ARDUINOHAL_H
2#define ARDUINOHAL_H
3
4#ifdef ARDUINO
5#include "Arduino.h"
6#include <SPI.h>
7#include <Adafruit_Sensor.h>
8
9#include <Adafruit_SPIFlash.h>
10#include <SdFat.h>
11#include <SdFatConfig.h>
12
13#else // Everything below will only be compiled if we are not on an Arduino
14
15#include <string>
16using String = std::string;
17
18#include <iostream>
19#include <cstring>
20
21#include <chrono>
22
23#include "spi_mock.h"
24
25// Within here we must define the mock functions for the Arduino functions
26#include <thread>
27
29#include "serial_mock.h"
30
31#define OUTPUT 1
32#define INPUT 0
33#define HIGH 1
34#define LOW 0
35
36inline void pinMode(int pin, int mode) { //NOLINT
37 // Do nothing
38}
39
40inline void digitalWrite(int pin, int value) { //NOLINT
41 // Do nothing
42}
43
44
45// millis mock which still gives us the time since the program started in milliseconds
46static auto program_start = std::chrono::high_resolution_clock::now();
47inline unsigned long millis() {
48 return std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::high_resolution_clock::now() - program_start).count();
49}
50
51inline void delay(unsigned long ms) { // NOLINT
52 // Wait using the real time clock
53 std::this_thread::sleep_for(std::chrono::milliseconds(ms));
54}
55
56
57#endif // ARDUINO
58#endif // ARDUINOHAL_H