-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.cpp
118 lines (97 loc) · 3.42 KB
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
/*
* main.cpp:
* Created in 2024 by Ved Atal
***********************************************************************
*/
#include <wiringPi.h>
#include <wiringPiSPI.h>
#include <iostream>
#include "hardware_drivers/gpio.hpp"
#include "hardware_drivers/spi.hpp"
#include "ic_controllers/MCP23S17.hpp"
#include "ic_controllers/AD8802.hpp"
#include "ic_controllers/LTC2380.hpp"
class TestProgram {
private:
GPIODriver gpio;
SPIDriver spi;
MCP23S17Controller MCP23S17;
AD8802Controller AD8802;
LTC2380Controller LTC2380;
public:
/**
* Main program--executes all logic.
*/
void run() {
}
};
/**
* Ensures all bootups are successful, ITR is loaded, and user input is provided.
*/
bool preExecutionChecks() {
// Some safety and configuration steps prior to running tests.
if (systemBootupChecks() == false) {
std::cout << "Program failed to bootup properly. Exiting Program.\n";
return false;
} else {
std::cout << "Program bootup successful.\n";
}
return true;
};
/**
* Ensures all necessary systems properly initialize before running program.
* @returns false if validation failed.
*/
bool systemBootupChecks() {
bool passedChecks = true;
// Stage 1: Setup hardware library.
if (wiringPiSetup() == -1) {
std::cout << "RaspberryPi hardware library--WiringPi setup failed.\n";
passedChecks = false;
} else {
std::cout << "RaspberryPi hardware library--WiringPi setup successful.\n";
}
// Stage 2: Setup drivers.
if (passedChecks) {
if (gpio.initGPIO() == -1) {
std::cout << "RaspberryPi GPIO Driver setup failed.\n";
passedChecks = false;
} else {
std::cout << "RaspberryPi GPIO Driver setup successful.\n";
}
if (spi.initSPI() == -1) {
std::cout << "RaspberryPi SPI Driver setup failed.\n";
passedChecks = false;
} else {
std::cout << "RaspberryPi SPI Driver setup successful.\n";
}
}
// Stage 3: Setup boards.
if (passedChecks) {
if (dio.initMCP23S17(spi, gpio) == -1) {
std::cout << "MCP23S17 Board setup failed.\n";
passedChecks = false;
} else {
std::cout << "MCP23S17 Board setup successful.\n";
}
if (psu.initAD8802(spi, gpio) == -1) {
std::cout << "AD8802 Board setup failed.\n";
passedChecks = false;
} else {
std::cout << "PAD8802SU Board setup sucessful.\n";
}
if (dmm.initLTC2380(spi, gpio) == -1) {
std::cout << "LTC2380 Board setup failed.\n";
passedChecks = false;
} else {
std::cout << "LTC2380 Board setup sucessful.\n";
}
}
return passedChecks;
}
};
int main(void) {
TestProgram test;
test.run();
return 0;
}