Formula Student Electronics & Software
The code for the embedded software
Loading...
Searching...
No Matches
main.cpp
Go to the documentation of this file.
1
#include "
comm/communicator.hpp
"
2
#include "
debugUtils.hpp
"
3
#include "
embedded/digitalReceiver.hpp
"
4
#include "
embedded/digitalSender.hpp
"
5
#include "
enum_utils.hpp
"
6
#include "
logic/outputCoordinator.hpp
"
7
#include "
logic/stateLogic.hpp
"
8
#include "
model/systemData.hpp
"
9
#include "
timings.hpp
"
10
11
SystemData
system_data
;
12
SystemData
13
system_data_copy
;
// Copy of the model for Communicator (where interrupt updates are stored)
14
Communicator
communicator
=
Communicator
(&
system_data_copy
);
// CAN
15
DigitalReceiver
digital_receiver
=
16
DigitalReceiver
(&
system_data_copy
.
hardware_data_
, &
system_data_copy
.
mission_
);
17
DigitalSender
digital_sender
=
DigitalSender
();
18
OutputCoordinator
output_coordinator
=
19
OutputCoordinator
(&
system_data
, &
communicator
, &
digital_sender
);
20
ASState
as_state
=
ASState
(&
system_data
, &
communicator
, &
output_coordinator
);
21
22
void
setup
() {
23
Serial.begin(9600);
24
Communicator::_systemData
= &
system_data_copy
;
25
communicator
.
init
();
26
output_coordinator
.
init
();
27
DEBUG_PRINT
(
"Starting up..."
);
28
}
29
30
void
loop
() {
31
digital_receiver
.
digital_reads
();
32
33
noInterrupts();
34
system_data
=
system_data_copy
;
35
interrupts();
36
37
as_state
.
calculate_state
();
38
39
uint8_t current_master_state =
to_underlying
(
as_state
.
state_
);
40
uint8_t current_checkup_state =
to_underlying
(
as_state
.
_checkup_manager_
.
checkup_state_
);
41
42
output_coordinator
.
process
(current_master_state, current_checkup_state);
43
44
delay(
LOOP_DELAY
);
45
}
ASState
The ASState class manages and transitions between different states of the vehicle system.
Definition
stateLogic.hpp:18
ASState::calculate_state
void calculate_state()
Calculates the state of the vehicle.
Definition
stateLogic.hpp:56
ASState::_checkup_manager_
CheckupManager _checkup_manager_
CheckupManager object for handling various checkup operations.
Definition
stateLogic.hpp:31
ASState::state_
State state_
Current state of the vehicle system, initialized to OFF.
Definition
stateLogic.hpp:32
CheckupManager::checkup_state_
CheckupState checkup_state_
Current state of the checkup process.
Definition
checkupManager.hpp:109
Communicator
Class that contains definitions of typical messages to send via CAN It serves only as an example of t...
Definition
communicator.hpp:41
Communicator::init
void init()
Initializes the CAN bus.
Definition
communicator.hpp:133
Communicator::_systemData
static SystemData * _systemData
Definition
communicator.hpp:48
DigitalReceiver
Class responsible for the reading of the digital inputs into the Master teensy.
Definition
digitalReceiver.hpp:17
DigitalReceiver::digital_reads
void digital_reads()
read all digital inputs
Definition
digitalReceiver.hpp:148
DigitalSender
Class responsible for controlling digital outputs in the Master Teensy.
Definition
digitalSender.hpp:15
OutputCoordinator
Definition
outputCoordinator.hpp:12
OutputCoordinator::init
void init()
Definition
outputCoordinator.hpp:40
OutputCoordinator::process
void process(uint8_t current_master_state, uint8_t current_checkup_state)
Definition
outputCoordinator.hpp:46
communicator.hpp
debugUtils.hpp
DEBUG_PRINT
#define DEBUG_PRINT(str)
Definition
debugUtils.hpp:30
digitalReceiver.hpp
digitalSender.hpp
enum_utils.hpp
to_underlying
constexpr auto to_underlying(Enum e) noexcept
Definition
enum_utils.hpp:4
communicator
Communicator communicator
Definition
main.cpp:14
as_state
ASState as_state
Definition
main.cpp:20
system_data
SystemData system_data
Definition
main.cpp:11
output_coordinator
OutputCoordinator output_coordinator
Definition
main.cpp:18
setup
void setup()
Definition
main.cpp:22
digital_sender
DigitalSender digital_sender
Definition
main.cpp:17
system_data_copy
SystemData system_data_copy
Definition
main.cpp:13
digital_receiver
DigitalReceiver digital_receiver
Definition
main.cpp:15
loop
void loop()
Definition
main.cpp:30
outputCoordinator.hpp
stateLogic.hpp
SystemData
The whole model of the system: holds all the data necessary.
Definition
systemData.hpp:11
SystemData::mission_
Mission mission_
Definition
systemData.hpp:16
SystemData::hardware_data_
HardwareData hardware_data_
Definition
systemData.hpp:15
systemData.hpp
timings.hpp
LOOP_DELAY
constexpr auto LOOP_DELAY
Definition
timings.hpp:8
master
src
main.cpp
Generated by
1.9.8