Main VCU program entry point. More...
#include <Arduino.h>#include "BoardConfig.h"#include "Pedal.hpp"#include "BMS.hpp"#include "Enums.hpp"#include "CarState.hpp"#include "Scheduler.hpp"#include "Curves.hpp"#include "Telemetry.hpp"#include "Debug.hpp"#include <mcp2515.h>Go to the source code of this file.
Macros | |
| #define | mcp2515_motor mcp2515_DL |
| #define | mcp2515_BMS mcp2515_DL |
Functions | |
| MCP2515 | mcp2515_motor (CS_CAN_MOTOR) |
| MCP2515 | mcp2515_BMS (CS_CAN_BMS) |
| MCP2515 | mcp2515_DL (CS_CAN_DL) |
| Pedal | pedal (mcp2515_DL, car, car.pedal.apps_5v) |
| void | schedulerMotorRead () |
| void | schedulerPedalSend () |
| void | scheduler_bms () |
| void | schedulerTelemetryPedal () |
| void | schedulerTelemetryMotor () |
| void | schedulerTelemetryBms () |
| void | setup () |
| Setup function for initializing the VCU system. Initializes MCP2515s, IO pins, as well as own modules such as Pedal and Debug. | |
| void | loop () |
| Main loop function for the VCU system. Handles car state transitions, pipes dataflow between modules. | |
Variables | |
| constexpr uint8_t | INPUT_COUNT = 5 |
| constexpr uint8_t | OUTPUT_COUNT = 3 |
| constexpr uint8_t | pins_in [INPUT_COUNT] = {DRIVE_MODE_BTN, BRAKE_IN, APPS_5V, APPS_3V3, HALL_SENSOR} |
| constexpr uint8_t | pins_out [OUTPUT_COUNT] = {FRG, BRAKE_LIGHT, BUZZER} |
| constexpr uint8_t | NUM_MCP = 3 |
| MCP2515 | MCPS [NUM_MCP] = { mcp2515_DL , mcp2515_DL , mcp2515_DL} |
| constexpr uint16_t | BUSSIN_MILLIS = 2000 |
| constexpr uint16_t | BMS_OVERRIDE_MILLIS = 1000 |
| constexpr uint16_t | BRAKE_THRESHOLD = BRAKE_TABLE[0].in |
| bool | brake_pressed = false |
| struct CarState | car |
| Global car state structure. | |
| BMS | bms (mcp2515_DL, car) |
| Telemetry | telem (mcp2515_DL, car) |
| Scheduler< 3, NUM_MCP > | scheduler (10000, 500, *micros) |
| #define mcp2515_BMS mcp2515_DL |
| #define mcp2515_motor mcp2515_DL |
| void loop | ( | ) |
Main loop function for the VCU system. Handles car state transitions, pipes dataflow between modules.
Definition at line 175 of file main.cpp.
References APPS_3V3, APPS_5V, TelemetryFramePedal::StateByteStatus::bits, Bms, BMS_OVERRIDE_MILLIS, TelemetryFramePedal::brake, BRAKE_IN, BRAKE_LIGHT, brake_pressed, BRAKE_THRESHOLD, Bussin, BUSSIN_MILLIS, BUTTON_ACTIVE, BUZZER, car, TelemetryFramePedal::StateByteStatus::Bits::car_status, Drive, DRIVE_MODE_BTN, TelemetryFramePedal::StateByteStatus::Bits::force_stop, FRG, HALL_SENSOR, TelemetryFramePedal::hall_sensor, TelemetryFramePedal::StateByteStatus::Bits::hv_ready, Init, CarState::millis, CarState::pedal, pedal(), Pedal::pedal_final, scheduler, scheduler_bms(), Startin, TelemetryFramePedal::status, CarState::status_millis, THROTTLE_TABLE, and Pedal::update().
| MCP2515 mcp2515_BMS | ( | CS_CAN_BMS | ) |
| MCP2515 mcp2515_motor | ( | CS_CAN_MOTOR | ) |
| Pedal pedal | ( | mcp2515_DL | , |
| car | , | ||
| car.pedal. | apps_5v | ||
| ) |
Referenced by loop(), Pedal::pedalTorqueMapping(), schedulerMotorRead(), schedulerPedalSend(), and setup().
| void scheduler_bms | ( | ) |
Definition at line 86 of file main.cpp.
References bms, and BMS::checkHv().
Referenced by loop().
| void schedulerMotorRead | ( | ) |
Definition at line 78 of file main.cpp.
References pedal(), and Pedal::readMotor().
Referenced by setup().
| void schedulerPedalSend | ( | ) |
Definition at line 82 of file main.cpp.
References pedal(), and Pedal::sendFrame().
Referenced by setup().
| void schedulerTelemetryBms | ( | ) |
Definition at line 98 of file main.cpp.
References Telemetry::sendBms(), and telem.
Referenced by setup().
| void schedulerTelemetryMotor | ( | ) |
Definition at line 94 of file main.cpp.
References Telemetry::sendMotor(), and telem.
Referenced by setup().
| void schedulerTelemetryPedal | ( | ) |
Definition at line 90 of file main.cpp.
References Telemetry::sendPedal(), and telem.
Referenced by setup().
| void setup | ( | ) |
Setup function for initializing the VCU system. Initializes MCP2515s, IO pins, as well as own modules such as Pedal and Debug.
Definition at line 113 of file main.cpp.
References bms, CAN_RATE, Datalogger, DBGLN_GENERAL(), BMS::initFilter(), Pedal::initFilter(), Debug_Serial::initialize(), Debug_CAN::initialize(), Pedal::initMotor(), INPUT_COUNT, MCP2515_CRYSTAL_FREQ, mcp2515_DL(), MCPS, Motor, NUM_MCP, OUTPUT_COUNT, pedal(), pins_in, pins_out, scheduler, schedulerMotorRead(), schedulerPedalSend(), schedulerTelemetryBms(), schedulerTelemetryMotor(), and schedulerTelemetryPedal().
| BMS bms(mcp2515_DL, car) | ( | mcp2515_DL | , |
| car | |||
| ) |
Referenced by scheduler_bms(), and setup().
|
constexpr |
|
constexpr |
|
constexpr |
| struct CarState car |
|
constexpr |
| MCP2515 MCPS[NUM_MCP] = { mcp2515_DL , mcp2515_DL , mcp2515_DL} |
|
constexpr |
|
constexpr |
|
constexpr |
|
constexpr |
| Telemetry telem(mcp2515_DL, car) | ( | mcp2515_DL | , |
| car | |||
| ) |
Referenced by schedulerTelemetryBms(), schedulerTelemetryMotor(), and schedulerTelemetryPedal().