Skip to content

Commit

Permalink
Added neutral switch gpio to ShiftController constructor
Browse files Browse the repository at this point in the history
  • Loading branch information
crsz20 committed Jul 12, 2024
1 parent f8e2158 commit 2511e59
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ namespace application {


ShiftController::ShiftController(int16_t &rpm_observer,
std::array<float, 2> &wheel_speeds_observer)
: rpm_(rpm_observer), wheel_speeds_(wheel_speeds_observer) {}
std::array<float, 2> &wheel_speeds_observer,
std::shared_ptr<platform::IGpio> neutral_switch_observer)
: rpm_(rpm_observer),
wheel_speeds_(wheel_speeds_observer),
neutral_switch_(neutral_switch_observer) {}

ShiftController::~ShiftController() { }

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
#include <cinttypes>

#include <array>
#include <memory>


// Custom DFR Libraries
#include "../../Platform/Interfaces/igpio.hpp"


namespace application {
Expand Down Expand Up @@ -65,7 +70,8 @@ class ShiftController {

public:
ShiftController(int16_t &rpm_observer,
std::array<float, 2> &wheel_speeds_observer);
std::array<float, 2> &wheel_speeds_observer,
std::shared_ptr<platform::IGpio> neutral_switch_observer);

~ShiftController();

Expand All @@ -83,6 +89,7 @@ class ShiftController {

int16_t& rpm_;
std::array<float, 2>& wheel_speeds_;
std::shared_ptr<platform::IGpio> neutral_switch_;
};

} // namespace application
Expand Down
7 changes: 6 additions & 1 deletion Firmware/Shifter_System/Program/Src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ extern CAN_HandleTypeDef hcan1;
#include "../../Core/Inc/retarget.h"
#include "Application/ShiftController/shift_controller.hpp"
#include "./Platform/STM/F4/CAN/bxcan_stmf4.hpp"
#include "./Platform/STM/F4/GPIO/gpio_stmf4.hpp"
#include "./Platform/Interfaces/ican.hpp"
#include "./Platform/Interfaces/igpio.hpp"
#include "./Sensor/ECU/PE3/iecu.hpp"
#include "./Sensor/ECU/PE3/pe3.hpp"

Expand Down Expand Up @@ -75,7 +77,10 @@ void cppMain() {
int16_t rpm = 0;
std::array<float, 2> wheel_speeds;

application::ShiftController shift_controller(rpm, wheel_speeds);
// TODO: initialize GPIO with proper pins and setup interrupt callback
auto neutral_switch = std::make_shared<platform::GpioStmF4>(GPIOF, GPIO_PIN_15);

application::ShiftController shift_controller(rpm, wheel_speeds, neutral_switch);

for(;;){

Expand Down

0 comments on commit 2511e59

Please sign in to comment.