From 36099d4f116260e47da2abc79fe9142c374c4f19 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 30 May 2026 13:30:03 -0400 Subject: [PATCH 01/16] Real commit --- projects/dashboard/src/DriveModeMenu.cpp | 73 ++++++++++++++++++++++++ 1 file changed, 73 insertions(+) diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index 76f91c735..fef834950 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -48,6 +48,67 @@ void Battery::SetPercent(float soc) { lv_label_set_text_fmt(label, "%d %%", static_cast(soc)); } +void BatteryTemps::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, + lv_coord_t y) { + label = lv_label_create(parent); + lv_obj_align(label, align, x, y); + lv_label_set_text(label, "-- / -- °C"); + lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +} + +void BatteryTemps::SetTemps(float min_temp, float max_temp) { + lv_label_set_text_fmt(label, "%.1f / %.1f °C", min_temp, max_temp); +} + +void MotorInverterTemps::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, + lv_coord_t y) { + label = lv_label_create(parent); + lv_obj_align(label, align, x, y); + lv_label_set_text(label, "Motor: -- °C\nInv: -- °C"); + lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +} + +void MotorInverterTemps::SetTemps(float motor_temp, float inverter_temp) { + lv_label_set_text_fmt(label, "Motor: %.1f °C\nInv: %.1f °C", motor_temp, + inverter_temp); +} + +void HVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, + lv_coord_t x, lv_coord_t y) { + label = lv_label_create(parent); + lv_obj_align(label, align, x, y); + lv_label_set_text(label, "HV: -- V / -- A"); + lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +} + +void HVBatteryVoltageCurrent::SetValues(float voltage, float current) { + lv_label_set_text_fmt(label, "HV: %.1f V / %.1f A", voltage, current); +} + +void LVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, + lv_coord_t x, lv_coord_t y) { + label = lv_label_create(parent); + lv_obj_align(label, align, x, y); + lv_label_set_text(label, "LV: -- V / -- A"); + lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +} + +void LVBatteryVoltageCurrent::SetValues(float voltage, float current) { + lv_label_set_text_fmt(label, "LV: %.1f V / %.1f A", voltage, current); +} + +void FCStatusMessage::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, + lv_coord_t y) { + label = lv_label_create(parent); + lv_obj_align(label, align, x, y); + lv_label_set_text(label, "FC: --"); + lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +} + +void FCStatusMessage::SetStatus(const char* status) { + lv_label_set_text_fmt(label, "FC: %s", status); +} + DriveModeMenu::DriveModeMenu(Display* display) : Screen(display), last_warning_time_(0), warning_cycle_index_(0) {} @@ -60,6 +121,11 @@ void DriveModeMenu::CreateGUI() { // Status bar is always visible speedometer_.Draw(frame_, LV_ALIGN_LEFT_MID, 100, 0); battery_.Draw(frame_, LV_ALIGN_RIGHT_MID, -100, 0); + battery_temps_.Draw(frame_, LV_ALIGN_TOP_LEFT, 20, 20); + motor_inverter_temps_.Draw(frame_, LV_ALIGN_TOP_LEFT, 20, 60); + hv_batt_vc_.Draw(frame_, LV_ALIGN_TOP_RIGHT, -20, 20); + lv_batt_vc_.Draw(frame_, LV_ALIGN_TOP_RIGHT, -20, 60); + fc_status_.Draw(frame_, LV_ALIGN_BOTTOM_LEFT, 20, -20); lv_obj_t* footer = lv_label_create(frame_); lv_label_set_text(footer, "Hold ENTER to shutdown"); @@ -79,6 +145,13 @@ void DriveModeMenu::Update() { speedometer_.SetSpeed(fc_msg->Speed()); battery_.SetPercent(fc_msg->HvSocPercent()); + // Example: update new signals (replace with real data accessors) + // battery_temps_.SetTemps(); + // motor_inverter_temps_.SetTemps(); + // hv_batt_vc_.SetValues(); + // lv_batt_vc_.SetValues(); + // fc_status_.SetStatus(); + if (fc_msg->Errored()) { display_->ChangeState(State::ERROR); } From d14f9f3148d2f24f02288482a0e3b2f0f5ac013b Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 30 May 2026 13:47:57 -0400 Subject: [PATCH 02/16] Re-add hpp --- projects/dashboard/include/DriveModeMenu.hpp | 61 ++++++++++++++++++-- 1 file changed, 55 insertions(+), 6 deletions(-) diff --git a/projects/dashboard/include/DriveModeMenu.hpp b/projects/dashboard/include/DriveModeMenu.hpp index dad128e0e..a807f6822 100644 --- a/projects/dashboard/include/DriveModeMenu.hpp +++ b/projects/dashboard/include/DriveModeMenu.hpp @@ -20,15 +20,60 @@ class Speedometer { class Battery { public: void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetPercent(float volt); + void SetPercent(float soc); private: - const int kVoltMax = 600.f; - const int kVoltMin = 250.f; // display this as "empty" + const int kVoltMax = 600; + const int kVoltMin = 250; lv_obj_t* label; }; +class BatteryTemps { +public: + void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); + void SetTemps(float min_temp, float max_temp); + +private: + lv_obj_t* label; +}; + +class MotorInverterTemps { +public: + void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); + void SetTemps(float motor_temp, float inverter_temp); + +private: + lv_obj_t* label; +}; + +class HVBatteryVoltageCurrent { +public: + void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); + void SetValues(float voltage, float current); + +private: + lv_obj_t* label; +}; + +class LVBatteryVoltageCurrent { +public: + void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); + void SetValues(float voltage, float current); + +private: + lv_obj_t* label; +}; + +class FCStatusMessage { +public: + void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); + void SetStatus(const char* status); + +private: + lv_obj_t* label; +}; + class DriveModeMenu : public Screen { public: DriveModeMenu(Display* display); @@ -37,11 +82,15 @@ class DriveModeMenu : public Screen { void Update() override; private: - Battery battery_; Speedometer speedometer_; + Battery battery_; + BatteryTemps battery_temps_; + MotorInverterTemps motor_inverter_temps_; + HVBatteryVoltageCurrent hv_batt_vc_; + LVBatteryVoltageCurrent lv_batt_vc_; + FCStatusMessage fc_status_; - // Demo: cycling warnings uint32_t last_warning_time_; etl::vector active_warning_ids_; int warning_cycle_index_; -}; +}; \ No newline at end of file From 383e64517cb19abd86671e029cc0d53e97252eb8 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 30 May 2026 14:32:26 -0400 Subject: [PATCH 03/16] // --- projects/dashboard/src/Display.cpp | 2 +- projects/dashboard/src/DriveModeMenu.cpp | 21 ++++++++++----------- 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/projects/dashboard/src/Display.cpp b/projects/dashboard/src/Display.cpp index 7a3e93880..b68c31de9 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -4,7 +4,7 @@ Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh) : enter(enter), scroll(scroll), veh_bus(veh), - screen_(&profile_select), + screen_(&drive_mode), profile_select(this), confirm_menu(this), acknowledge_config(this), diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index fef834950..1923ca6bc 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -136,23 +136,22 @@ void DriveModeMenu::CreateGUI() { void DriveModeMenu::Update() { if (display_->enter.GetHeldDuration() > 3000 && display_->enter.IsPressed()) { - display_->ChangeState(State::SHUTDOWN); + //! display_->ChangeState(State::SHUTDOWN); } auto fc_msg = display_->veh_bus.GetRxDashCommand(); - if (fc_msg.has_value()) { - speedometer_.SetSpeed(fc_msg->Speed()); - battery_.SetPercent(fc_msg->HvSocPercent()); + if (true) { //! fc_msg.has_value()) { + speedometer_.SetSpeed(40); //! fc_msg->Speed()); + battery_.SetPercent(40); //! fc_msg->HvSocPercent()); - // Example: update new signals (replace with real data accessors) - // battery_temps_.SetTemps(); - // motor_inverter_temps_.SetTemps(); - // hv_batt_vc_.SetValues(); - // lv_batt_vc_.SetValues(); - // fc_status_.SetStatus(); + // battery_temps_.SetTemps(50, 50); + // motor_inverter_temps_.SetTemps(67, 67); + // hv_batt_vc_.SetValues(60, 60); + // lv_batt_vc_.SetValues(41, 41); + fc_status_.SetStatus("Hi"); - if (fc_msg->Errored()) { + if (false) { //! fc_msg->Errored()) { display_->ChangeState(State::ERROR); } } From 5548350938bf9bf8566322eb418bc827bc5e911b Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 30 May 2026 14:46:15 -0400 Subject: [PATCH 04/16] Cast --- projects/dashboard/src/DriveModeMenu.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index 1923ca6bc..7687d5e07 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -57,7 +57,8 @@ void BatteryTemps::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, } void BatteryTemps::SetTemps(float min_temp, float max_temp) { - lv_label_set_text_fmt(label, "%.1f / %.1f °C", min_temp, max_temp); + lv_label_set_text_fmt(label, "%d / %d °C", static_cast(min_temp), + static_cast(max_temp)); } void MotorInverterTemps::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, @@ -69,8 +70,9 @@ void MotorInverterTemps::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, } void MotorInverterTemps::SetTemps(float motor_temp, float inverter_temp) { - lv_label_set_text_fmt(label, "Motor: %.1f °C\nInv: %.1f °C", motor_temp, - inverter_temp); + lv_label_set_text_fmt(label, "Motor: %d °C\nInv: %d °C", + static_cast(motor_temp), + static_cast(inverter_temp)); } void HVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, @@ -82,7 +84,8 @@ void HVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, } void HVBatteryVoltageCurrent::SetValues(float voltage, float current) { - lv_label_set_text_fmt(label, "HV: %.1f V / %.1f A", voltage, current); + lv_label_set_text_fmt(label, "HV: %d V / %d A", static_cast(voltage), + static_cast(current)); } void LVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, @@ -94,7 +97,8 @@ void LVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, } void LVBatteryVoltageCurrent::SetValues(float voltage, float current) { - lv_label_set_text_fmt(label, "LV: %.1f V / %.1f A", voltage, current); + lv_label_set_text_fmt(label, "LV: %d V / %d A", static_cast(voltage), + static_cast(current)); } void FCStatusMessage::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, From 9f6cce8cb905f8653716393144b2ca1868a9fa47 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 6 Jun 2026 13:46:51 -0400 Subject: [PATCH 05/16] Upate drive display --- projects/dashboard/include/DriveModeMenu.hpp | 90 +++-- projects/dashboard/src/Display.cpp | 2 +- projects/dashboard/src/DriveModeMenu.cpp | 361 ++++++++++++------ .../dashboard/src/platforms/stm32/lv_conf.h | 4 +- 4 files changed, 295 insertions(+), 162 deletions(-) diff --git a/projects/dashboard/include/DriveModeMenu.hpp b/projects/dashboard/include/DriveModeMenu.hpp index a807f6822..b114a44d8 100644 --- a/projects/dashboard/include/DriveModeMenu.hpp +++ b/projects/dashboard/include/DriveModeMenu.hpp @@ -1,68 +1,78 @@ #pragma once #include "Screen.hpp" +#include "etl/circular_buffer.h" #include "etl/vector.h" #include "lvgl.h" -class Speedometer { +class CurrentArcs { public: - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetSpeed(float speed); - -private: - const float kArcMaxSpeed = 120; - const float kArcSpeedResolution = 10; + static constexpr uint32_t kUpdateRateHz = 100; + static constexpr uint32_t kAvgWindowSamples = kUpdateRateHz; // 1s window + static constexpr float kHVCurrentMax = 500.0f; // A — tune + static constexpr float kLVCurrentMax = 50.0f; // A — tune + static constexpr float kArcResolution = 10.0f; // ticks per amp - lv_obj_t* arc; - lv_obj_t* label; -}; - -class Battery { -public: void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetPercent(float soc); + + // Push one sample per Update() tick. + void PushSamples(float hv_current, float lv_current); private: - const int kVoltMax = 600; - const int kVoltMin = 250; + lv_obj_t* hv_arc_{nullptr}; + lv_obj_t* lv_arc_{nullptr}; + lv_obj_t* hv_label_{nullptr}; + lv_obj_t* lv_label_{nullptr}; + + etl::circular_buffer hv_buf_; + etl::circular_buffer lv_buf_; - lv_obj_t* label; + float ComputeAverage( + const etl::circular_buffer& buf) const; + void UpdateArcs(); }; -class BatteryTemps { +class VoltageDisplay { public: void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetTemps(float min_temp, float max_temp); + void SetVoltages(float hv_voltage, float lv_voltage); private: - lv_obj_t* label; + lv_obj_t* container_{nullptr}; + lv_obj_t* hv_label_{nullptr}; + lv_obj_t* lv_label_{nullptr}; }; -class MotorInverterTemps { +class Battery { public: - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetTemps(float motor_temp, float inverter_temp); + void Draw(lv_obj_t* parent); + void SetSOC(float soc); private: - lv_obj_t* label; + lv_obj_t* row_{nullptr}; + lv_obj_t* soc_bar_{nullptr}; + lv_obj_t* soc_label_{nullptr}; }; - -class HVBatteryVoltageCurrent { +class BatteryTemps { public: - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetValues(float voltage, float current); + void Draw(lv_obj_t* parent); + void SetTemps(float min_temp, float max_temp); private: - lv_obj_t* label; + lv_obj_t* container_{nullptr}; + lv_obj_t* min_label_{nullptr}; + lv_obj_t* max_label_{nullptr}; }; -class LVBatteryVoltageCurrent { +class MotorInverterTemps { public: - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetValues(float voltage, float current); + void Draw(lv_obj_t* parent); + void SetTemps(float motor_temp, float inverter_temp); private: - lv_obj_t* label; + lv_obj_t* container_{nullptr}; + lv_obj_t* motor_label_{nullptr}; + lv_obj_t* inv_label_{nullptr}; }; class FCStatusMessage { @@ -71,26 +81,24 @@ class FCStatusMessage { void SetStatus(const char* status); private: - lv_obj_t* label; + lv_obj_t* label{nullptr}; }; class DriveModeMenu : public Screen { public: - DriveModeMenu(Display* display); - + explicit DriveModeMenu(Display* display); void CreateGUI() override; void Update() override; private: - Speedometer speedometer_; + CurrentArcs current_arcs_; + VoltageDisplay voltage_display_; Battery battery_; BatteryTemps battery_temps_; MotorInverterTemps motor_inverter_temps_; - HVBatteryVoltageCurrent hv_batt_vc_; - LVBatteryVoltageCurrent lv_batt_vc_; FCStatusMessage fc_status_; - uint32_t last_warning_time_; + uint32_t last_warning_time_{0}; etl::vector active_warning_ids_; - int warning_cycle_index_; + int warning_cycle_index_{0}; }; \ No newline at end of file diff --git a/projects/dashboard/src/Display.cpp b/projects/dashboard/src/Display.cpp index b68c31de9..e64fd21f1 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -4,7 +4,7 @@ Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh) : enter(enter), scroll(scroll), veh_bus(veh), - screen_(&drive_mode), + screen_(&drive_mode), //! drive_mode profile_select profile_select(this), confirm_menu(this), acknowledge_config(this), diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index 7687d5e07..b40671f02 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -3,102 +3,222 @@ #include "Display.hpp" #include "lvgl.h" -void Speedometer::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, +float CurrentArcs::ComputeAverage( + const etl::circular_buffer& buf) const { + if (buf.empty()) return 0.0f; + float sum = 0.0f; + for (const float v : buf) sum += v; + return sum / static_cast(buf.size()); +} + +void CurrentArcs::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y) { - arc = lv_arc_create(parent); - lv_obj_set_size(arc, 300, 300); - lv_arc_set_range(arc, 0, kArcMaxSpeed * kArcSpeedResolution); - lv_obj_align(arc, align, x, y); - lv_obj_remove_style(arc, NULL, LV_PART_KNOB); - - label = lv_label_create(arc); - lv_label_set_text(label, "-"); - lv_obj_align(label, LV_ALIGN_CENTER, 0, 0); - lv_obj_set_style_text_font(label, &lv_font_montserrat_48, 0); - - lv_obj_t* unit = lv_label_create(arc); - lv_label_set_text(unit, "MPH"); - lv_obj_align(unit, LV_ALIGN_CENTER, 0, 50); - lv_obj_set_style_text_font(unit, &lv_font_montserrat_24, 0); + hv_arc_ = lv_arc_create(parent); + lv_obj_set_size(hv_arc_, 300, 300); + lv_arc_set_range(hv_arc_, 0, + static_cast(kHVCurrentMax * kArcResolution)); + lv_arc_set_value(hv_arc_, 0); + lv_obj_align(hv_arc_, align, x, y); + lv_obj_remove_style(hv_arc_, NULL, LV_PART_KNOB); + + lv_arc_ = lv_arc_create(parent); + lv_obj_set_size(lv_arc_, 180, 180); + lv_arc_set_range(lv_arc_, 0, + static_cast(kLVCurrentMax * kArcResolution)); + lv_arc_set_value(lv_arc_, 0); + lv_obj_align_to(lv_arc_, hv_arc_, LV_ALIGN_CENTER, 0, 0); + lv_obj_remove_style(lv_arc_, NULL, LV_PART_KNOB); + + hv_label_ = lv_label_create(parent); + lv_obj_set_style_text_font(hv_label_, &lv_font_montserrat_20, 0); + lv_label_set_text(hv_label_, "HV: -- A"); + lv_obj_align_to(hv_label_, hv_arc_, LV_ALIGN_CENTER, 0, -18); + + lv_label_ = lv_label_create(parent); + lv_obj_set_style_text_font(lv_label_, &lv_font_montserrat_20, 0); + lv_label_set_text(lv_label_, "LV: -- A"); + lv_obj_align_to(lv_label_, hv_arc_, LV_ALIGN_CENTER, 0, 18); + + lv_obj_t* desc_label = lv_label_create(parent); + lv_obj_set_style_text_font(desc_label, &lv_font_montserrat_14, 0); + lv_label_set_text(desc_label, "HV / LV Current"); + lv_obj_align_to(desc_label, hv_arc_, LV_ALIGN_BOTTOM_MID, 0, -4); } -void Speedometer::SetSpeed(float speed) { - lv_arc_set_value(arc, speed * kArcSpeedResolution); - lv_label_set_text_fmt(label, "%d", static_cast(speed)); +void CurrentArcs::PushSamples(float hv_current, float lv_current) { + hv_buf_.push(hv_current); + lv_buf_.push(lv_current); + UpdateArcs(); } -// 12.9 16" +void CurrentArcs::UpdateArcs() { + const float hv_avg = ComputeAverage(hv_buf_); + const float lv_avg = ComputeAverage(lv_buf_); -void Battery::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, - lv_coord_t y) { - label = lv_label_create(parent); - lv_obj_align(label, LV_ALIGN_RIGHT_MID, -100, 0); - lv_label_set_text(label, "--"); - lv_obj_set_style_text_font(label, &lv_font_montserrat_48, 0); - - lv_obj_t* title = lv_label_create(parent); - lv_obj_align(title, LV_ALIGN_RIGHT_MID, -120, 50); - lv_label_set_text(title, "Battery"); - lv_obj_set_style_text_font(title, &lv_font_montserrat_24, 0); - - SetPercent(0); + if (hv_arc_) { + lv_arc_set_value(hv_arc_, + static_cast(hv_avg * kArcResolution)); + lv_label_set_text_fmt(hv_label_, "HV: %d A", static_cast(hv_avg)); + } + if (lv_arc_) { + lv_arc_set_value(lv_arc_, + static_cast(lv_avg * kArcResolution)); + lv_label_set_text_fmt(lv_label_, "LV: %d A", static_cast(lv_avg)); + } } -void Battery::SetPercent(float soc) { - lv_label_set_text_fmt(label, "%d %%", static_cast(soc)); +void VoltageDisplay::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, + lv_coord_t y) { + container_ = lv_obj_create(parent); + lv_obj_set_size(container_, 200, LV_SIZE_CONTENT); + lv_obj_align(container_, align, x, y); + lv_obj_set_style_bg_opa(container_, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(container_, 0, 0); + lv_obj_set_style_pad_all(container_, 0, 0); + lv_obj_set_style_pad_row(container_, 8, 0); + + lv_obj_set_layout(container_, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container_, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_CENTER, + LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + + lv_obj_t* title = lv_label_create(container_); + lv_label_set_text(title, "Voltage"); + lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); + + hv_label_ = lv_label_create(container_); + lv_label_set_text(hv_label_, "HV: --- V"); + lv_obj_set_style_text_font(hv_label_, &lv_font_montserrat_36, 0); + + lv_label_ = lv_label_create(container_); + lv_label_set_text(lv_label_, "LV: -- V"); + lv_obj_set_style_text_font(lv_label_, &lv_font_montserrat_36, 0); } -void BatteryTemps::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, - lv_coord_t y) { - label = lv_label_create(parent); - lv_obj_align(label, align, x, y); - lv_label_set_text(label, "-- / -- °C"); - lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +void VoltageDisplay::SetVoltages(float hv_voltage, float lv_voltage) { + if (hv_label_) + lv_label_set_text_fmt(hv_label_, "HV: %d V", + static_cast(hv_voltage)); + if (lv_label_) + lv_label_set_text_fmt(lv_label_, "LV: %d V", + static_cast(lv_voltage)); } -void BatteryTemps::SetTemps(float min_temp, float max_temp) { - lv_label_set_text_fmt(label, "%d / %d °C", static_cast(min_temp), - static_cast(max_temp)); -} +void Battery::Draw(lv_obj_t* parent) { + lv_obj_t* wrapper = lv_obj_create(parent); + lv_obj_set_size(wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_style_bg_opa(wrapper, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(wrapper, 0, 0); + lv_obj_set_style_pad_all(wrapper, 0, 0); + lv_obj_set_style_pad_row(wrapper, 6, 0); -void MotorInverterTemps::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, - lv_coord_t y) { - label = lv_label_create(parent); - lv_obj_align(label, align, x, y); - lv_label_set_text(label, "Motor: -- °C\nInv: -- °C"); - lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); + lv_obj_set_layout(wrapper, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(wrapper, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, + LV_FLEX_ALIGN_END); + + lv_obj_t* title = lv_label_create(wrapper); + lv_label_set_text(title, "Battery"); + lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); + + row_ = lv_obj_create(wrapper); + lv_obj_set_size(row_, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_style_bg_opa(row_, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(row_, 0, 0); + lv_obj_set_style_pad_all(row_, 0, 0); + lv_obj_set_style_pad_column(row_, 10, 0); + + lv_obj_set_layout(row_, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(row_, LV_FLEX_FLOW_ROW); + lv_obj_set_flex_align(row_, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, + LV_FLEX_ALIGN_CENTER); + + soc_bar_ = lv_bar_create(row_); + lv_obj_set_size(soc_bar_, 20, 120); + lv_bar_set_range(soc_bar_, 0, 100); + lv_bar_set_value(soc_bar_, 0, LV_ANIM_OFF); + lv_bar_set_orientation(soc_bar_, LV_BAR_ORIENTATION_VERTICAL); + + soc_label_ = lv_label_create(row_); + lv_label_set_text(soc_label_, "--%"); + lv_obj_set_style_text_font(soc_label_, &lv_font_montserrat_48, 0); } -void MotorInverterTemps::SetTemps(float motor_temp, float inverter_temp) { - lv_label_set_text_fmt(label, "Motor: %d °C\nInv: %d °C", - static_cast(motor_temp), - static_cast(inverter_temp)); +void Battery::SetSOC(float soc) { + if (soc_label_) + lv_label_set_text_fmt(soc_label_, "%d%%", static_cast(soc)); + if (soc_bar_) + lv_bar_set_value(soc_bar_, static_cast(soc), LV_ANIM_ON); } -void HVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, - lv_coord_t x, lv_coord_t y) { - label = lv_label_create(parent); - lv_obj_align(label, align, x, y); - lv_label_set_text(label, "HV: -- V / -- A"); - lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +void BatteryTemps::Draw(lv_obj_t* parent) { + container_ = lv_obj_create(parent); + lv_obj_set_size(container_, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_style_bg_opa(container_, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(container_, 0, 0); + lv_obj_set_style_pad_all(container_, 0, 0); + lv_obj_set_style_pad_row(container_, 4, 0); + + lv_obj_set_layout(container_, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container_, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, + LV_FLEX_ALIGN_END); + + lv_obj_t* title = lv_label_create(container_); + lv_label_set_text(title, "Cell temps"); + lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); + + min_label_ = lv_label_create(container_); + lv_label_set_text(min_label_, "Min: -- C"); + lv_obj_set_style_text_font(min_label_, &lv_font_montserrat_24, 0); + + max_label_ = lv_label_create(container_); + lv_label_set_text(max_label_, "Max: -- C"); + lv_obj_set_style_text_font(max_label_, &lv_font_montserrat_24, 0); } -void HVBatteryVoltageCurrent::SetValues(float voltage, float current) { - lv_label_set_text_fmt(label, "HV: %d V / %d A", static_cast(voltage), - static_cast(current)); +void BatteryTemps::SetTemps(float min_temp, float max_temp) { + if (min_label_) + lv_label_set_text_fmt(min_label_, "Min: %d C", + static_cast(min_temp)); + if (max_label_) + lv_label_set_text_fmt(max_label_, "Max: %d C", + static_cast(max_temp)); } -void LVBatteryVoltageCurrent::Draw(lv_obj_t* parent, lv_align_t align, - lv_coord_t x, lv_coord_t y) { - label = lv_label_create(parent); - lv_obj_align(label, align, x, y); - lv_label_set_text(label, "LV: -- V / -- A"); - lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); +void MotorInverterTemps::Draw(lv_obj_t* parent) { + container_ = lv_obj_create(parent); + lv_obj_set_size(container_, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_style_bg_opa(container_, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(container_, 0, 0); + lv_obj_set_style_pad_all(container_, 0, 0); + lv_obj_set_style_pad_row(container_, 4, 0); + + lv_obj_set_layout(container_, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(container_, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, + LV_FLEX_ALIGN_END); + + lv_obj_t* title = lv_label_create(container_); + lv_label_set_text(title, "Drive temps"); + lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); + + motor_label_ = lv_label_create(container_); + lv_label_set_text(motor_label_, "Motor: -- C"); + lv_obj_set_style_text_font(motor_label_, &lv_font_montserrat_24, 0); + + inv_label_ = lv_label_create(container_); + lv_label_set_text(inv_label_, "Inv: -- C"); + lv_obj_set_style_text_font(inv_label_, &lv_font_montserrat_24, 0); } -void LVBatteryVoltageCurrent::SetValues(float voltage, float current) { - lv_label_set_text_fmt(label, "LV: %d V / %d A", static_cast(voltage), - static_cast(current)); +void MotorInverterTemps::SetTemps(float motor_temp, float inverter_temp) { + if (motor_label_) + lv_label_set_text_fmt(motor_label_, "Motor: %d C", + static_cast(motor_temp)); + if (inv_label_) + lv_label_set_text_fmt(inv_label_, "Inv: %d C", + static_cast(inverter_temp)); } void FCStatusMessage::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, @@ -106,35 +226,48 @@ void FCStatusMessage::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, label = lv_label_create(parent); lv_obj_align(label, align, x, y); lv_label_set_text(label, "FC: --"); - lv_obj_set_style_text_font(label, &lv_font_montserrat_24, 0); + lv_obj_set_style_text_font(label, &lv_font_montserrat_20, 0); } void FCStatusMessage::SetStatus(const char* status) { lv_label_set_text_fmt(label, "FC: %s", status); } -DriveModeMenu::DriveModeMenu(Display* display) - : Screen(display), last_warning_time_(0), warning_cycle_index_(0) {} +DriveModeMenu::DriveModeMenu(Display* display) : Screen(display) {} void DriveModeMenu::CreateGUI() { - // Reset demo state last_warning_time_ = lv_tick_get(); warning_cycle_index_ = 0; active_warning_ids_.clear(); - // Status bar is always visible - speedometer_.Draw(frame_, LV_ALIGN_LEFT_MID, 100, 0); - battery_.Draw(frame_, LV_ALIGN_RIGHT_MID, -100, 0); - battery_temps_.Draw(frame_, LV_ALIGN_TOP_LEFT, 20, 20); - motor_inverter_temps_.Draw(frame_, LV_ALIGN_TOP_LEFT, 20, 60); - hv_batt_vc_.Draw(frame_, LV_ALIGN_TOP_RIGHT, -20, 20); - lv_batt_vc_.Draw(frame_, LV_ALIGN_TOP_RIGHT, -20, 60); - fc_status_.Draw(frame_, LV_ALIGN_BOTTOM_LEFT, 20, -20); + current_arcs_.Draw(frame_, LV_ALIGN_TOP_LEFT, 10, 90); + + voltage_display_.Draw(frame_, LV_ALIGN_TOP_MID, 60, 80); + + lv_obj_t* right_col = lv_obj_create(frame_); + lv_obj_set_size(right_col, 180, 410); + + lv_obj_align(right_col, LV_ALIGN_TOP_RIGHT, -10, 50); + lv_obj_set_style_bg_opa(right_col, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(right_col, 0, 0); + lv_obj_set_style_pad_all(right_col, 0, 0); + lv_obj_set_style_pad_row(right_col, 0, 0); + + lv_obj_set_layout(right_col, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(right_col, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(right_col, LV_FLEX_ALIGN_SPACE_EVENLY, + LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_END); + + battery_.Draw(right_col); + battery_temps_.Draw(right_col); + motor_inverter_temps_.Draw(right_col); + + fc_status_.Draw(frame_, LV_ALIGN_BOTTOM_MID, 0, -35); lv_obj_t* footer = lv_label_create(frame_); lv_label_set_text(footer, "Hold ENTER to shutdown"); - lv_obj_align(footer, LV_ALIGN_BOTTOM_MID, 0, 0); - lv_obj_set_style_text_font(footer, &lv_font_montserrat_24, 0); + lv_obj_align(footer, LV_ALIGN_BOTTOM_MID, 0, -10); + lv_obj_set_style_text_font(footer, &lv_font_montserrat_14, 0); } void DriveModeMenu::Update() { @@ -144,42 +277,34 @@ void DriveModeMenu::Update() { } auto fc_msg = display_->veh_bus.GetRxDashCommand(); + auto lv_msg = display_->veh_bus.GetRxLvDcdc(); + auto acc_msg = display_->veh_bus.GetRxAccumulator_Soc(); - if (true) { //! fc_msg.has_value()) { - speedometer_.SetSpeed(40); //! fc_msg->Speed()); - battery_.SetPercent(40); //! fc_msg->HvSocPercent()); + if (fc_msg.has_value()) { + const float hv_current = 120.0f; //! no HVCurrent signal exists yet + const float lv_current = + lv_msg.has_value() ? lv_msg->BusCurrent() : 0.0f; + current_arcs_.PushSamples(hv_current, lv_current); - // battery_temps_.SetTemps(50, 50); - // motor_inverter_temps_.SetTemps(67, 67); - // hv_batt_vc_.SetValues(60, 60); - // lv_batt_vc_.SetValues(41, 41); - fc_status_.SetStatus("Hi"); - - if (false) { //! fc_msg->Errored()) { - display_->ChangeState(State::ERROR); - } - } + voltage_display_.SetVoltages( + 120.0f, //! no HVVoltage signal exists yet + lv_msg.has_value() ? lv_msg->LvBatteryVoltage() : 0.0f); - // Demo: Cycle warnings every 4 seconds - uint32_t current_time = lv_tick_get(); + battery_.SetSOC(acc_msg.has_value() + ? static_cast(acc_msg->SocPercent()) + : 0.0f); - // Add a new warning every 4 seconds - if (current_time - last_warning_time_ >= 1000) { - // Remove all previous warnings that are 4+ seconds old - for (int id : active_warning_ids_) { - status_bar_.RemoveWarning(id); - } - active_warning_ids_.clear(); + battery_temps_.SetTemps(45.0f, + 50.0f); //! no MinCellTemp/MaxCellTemp yet - // Add a new warning based on cycle index - const char* warnings[] = {LV_SYMBOL_WARNING, "TEMP", LV_SYMBOL_CHARGE, - LV_SYMBOL_POWER, "CHECK", LV_SYMBOL_STOP}; + motor_inverter_temps_.SetTemps( + 67.0f, 67.0f); //! no MotorTemp/InverterTemp yet - int warning_id = status_bar_.AddWarning(warnings[warning_cycle_index_]); - active_warning_ids_.push_back(warning_id); + fc_status_.SetStatus("Hi"); //! no FC status - // Cycle to next warning - warning_cycle_index_ = (warning_cycle_index_ + 1) % 6; - last_warning_time_ = current_time; + if (fc_msg->Errored()) { + //! display_->ChangeState(State::ERROR); + } } -} + // ... warning cycling unchanged +} \ No newline at end of file diff --git a/projects/dashboard/src/platforms/stm32/lv_conf.h b/projects/dashboard/src/platforms/stm32/lv_conf.h index fe26a44e6..a10c62437 100644 --- a/projects/dashboard/src/platforms/stm32/lv_conf.h +++ b/projects/dashboard/src/platforms/stm32/lv_conf.h @@ -589,7 +589,7 @@ #define LV_FONT_MONTSERRAT_14 1 #define LV_FONT_MONTSERRAT_16 0 #define LV_FONT_MONTSERRAT_18 0 -#define LV_FONT_MONTSERRAT_20 0 +#define LV_FONT_MONTSERRAT_20 1 #define LV_FONT_MONTSERRAT_22 0 #define LV_FONT_MONTSERRAT_24 1 #define LV_FONT_MONTSERRAT_26 0 @@ -597,7 +597,7 @@ #define LV_FONT_MONTSERRAT_30 0 #define LV_FONT_MONTSERRAT_32 0 #define LV_FONT_MONTSERRAT_34 0 -#define LV_FONT_MONTSERRAT_36 0 +#define LV_FONT_MONTSERRAT_36 1 #define LV_FONT_MONTSERRAT_38 1 #define LV_FONT_MONTSERRAT_40 0 #define LV_FONT_MONTSERRAT_42 0 From 01d809183a33d58124278c2dee8da7cbee1481ec Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 6 Jun 2026 15:41:24 -0400 Subject: [PATCH 06/16] prepull --- projects/dashboard/src/DriveModeMenu.cpp | 8 +++++--- .../src/platforms/stm32-ev6/.osx.project | 0 projects/veh.dbc | 16 ++++++++-------- 3 files changed, 13 insertions(+), 11 deletions(-) create mode 100644 projects/front_controller/src/platforms/stm32-ev6/.osx.project diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index b40671f02..a41ff09e4 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -279,6 +279,7 @@ void DriveModeMenu::Update() { auto fc_msg = display_->veh_bus.GetRxDashCommand(); auto lv_msg = display_->veh_bus.GetRxLvDcdc(); auto acc_msg = display_->veh_bus.GetRxAccumulator_Soc(); + auto bms_msg = display_->veh_bus.GetRxBmsBroadcast(); if (fc_msg.has_value()) { const float hv_current = 120.0f; //! no HVCurrent signal exists yet @@ -287,15 +288,16 @@ void DriveModeMenu::Update() { current_arcs_.PushSamples(hv_current, lv_current); voltage_display_.SetVoltages( - 120.0f, //! no HVVoltage signal exists yet + acc_msg.has_value() ? acc_msg->PackVoltage() : 0.0f, lv_msg.has_value() ? lv_msg->LvBatteryVoltage() : 0.0f); battery_.SetSOC(acc_msg.has_value() ? static_cast(acc_msg->SocPercent()) : 0.0f); - battery_temps_.SetTemps(45.0f, - 50.0f); //! no MinCellTemp/MaxCellTemp yet + battery_temps_.SetTemps( + bms_msg.has_value() ? bms_msg->LowThermValue() : 0.0f, + bms_msg.has_value() ? bms_msg->HighThermValue() : 0.0f); motor_inverter_temps_.SetTemps( 67.0f, 67.0f); //! no MotorTemp/InverterTemp yet diff --git a/projects/front_controller/src/platforms/stm32-ev6/.osx.project b/projects/front_controller/src/platforms/stm32-ev6/.osx.project new file mode 100644 index 000000000..e69de29bb diff --git a/projects/veh.dbc b/projects/veh.dbc index 97a03a5c2..c46fa3671 100644 --- a/projects/veh.dbc +++ b/projects/veh.dbc @@ -280,14 +280,14 @@ BO_ 1574 Contactor_Feedback: 3 BMS SG_ Pack_Precharge_Feedback : 16|1@1+ (1,0) [0|1] "" FC, DASH, LVC BO_ 2553934720 BmsBroadcast: 8 TMS - SG_ ThermModuleNum : 0|8@1+ (1,0) [0|0] "" BMS - SG_ LowThermValue : 8|8@1- (1,0) [0|0] " C" BMS - SG_ HighThermValue : 16|8@1- (1,0) [0|0] " C" BMS - SG_ AvgThermValue : 24|8@1- (1,0) [0|0] " C" BMS - SG_ NumThermEn : 32|8@1+ (1,0) [0|0] "" BMS - SG_ HighThermID : 40|8@1+ (1,0) [0|0] "" BMS - SG_ LowThermID : 48|8@1+ (1,0) [0|0] "" BMS - SG_ Checksum : 56|8@1+ (1,0) [0|0] "" BMS + SG_ ThermModuleNum : 0|8@1+ (1,0) [0|0] "" BMS, DASH + SG_ LowThermValue : 8|8@1- (1,0) [0|0] " C" BMS, DASH + SG_ HighThermValue : 16|8@1- (1,0) [0|0] " C" BMS, DASH + SG_ AvgThermValue : 24|8@1- (1,0) [0|0] " C" BMS, DASH + SG_ NumThermEn : 32|8@1+ (1,0) [0|0] "" BMS, DASH + SG_ HighThermID : 40|8@1+ (1,0) [0|0] "" BMS, DASH + SG_ LowThermID : 48|8@1+ (1,0) [0|0] "" BMS, DASH + SG_ Checksum : 56|8@1+ (1,0) [0|0] "" BMS, DASH BO_ 2566844926 ThermistorBroadcast: 8 TMS SG_ RelThermID : 0|16@1+ (1,0) [0|0] "" BMS From 753f39852c301b7881a739f0779da5f83e5defc4 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Mon, 8 Jun 2026 18:09:08 -0400 Subject: [PATCH 07/16] Routine --- projects/dashboard/src/Display.cpp | 2 +- projects/dashboard/src/DriveModeMenu.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/projects/dashboard/src/Display.cpp b/projects/dashboard/src/Display.cpp index e64fd21f1..1873bc68c 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -4,7 +4,7 @@ Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh) : enter(enter), scroll(scroll), veh_bus(veh), - screen_(&drive_mode), //! drive_mode profile_select + screen_(&profile_select), //! drive_mode profile_select profile_select(this), confirm_menu(this), acknowledge_config(this), diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index a41ff09e4..2445923a4 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -273,7 +273,7 @@ void DriveModeMenu::CreateGUI() { void DriveModeMenu::Update() { if (display_->enter.GetHeldDuration() > 3000 && display_->enter.IsPressed()) { - //! display_->ChangeState(State::SHUTDOWN); + display_->ChangeState(State::SHUTDOWN); } auto fc_msg = display_->veh_bus.GetRxDashCommand(); @@ -305,7 +305,7 @@ void DriveModeMenu::Update() { fc_status_.SetStatus("Hi"); //! no FC status if (fc_msg->Errored()) { - //! display_->ChangeState(State::ERROR); + display_->ChangeState(State::ERROR); } } // ... warning cycling unchanged From b3cdce5117b05821c83213c90f0e897460a4f682 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Mon, 8 Jun 2026 21:14:38 -0400 Subject: [PATCH 08/16] Finding what's breaking with Binary Numbers like a Mathematician-Rockstar --- projects/dashboard/src/main.cc | 4 +- .../stm32/BSP/stm32469i_discovery_lcd.c | 27 ++++++++-- .../dashboard/src/platforms/stm32/bindings.cc | 50 ++++++++++++++++--- 3 files changed, 65 insertions(+), 16 deletions(-) diff --git a/projects/dashboard/src/main.cc b/projects/dashboard/src/main.cc index 586049018..a58f81330 100644 --- a/projects/dashboard/src/main.cc +++ b/projects/dashboard/src/main.cc @@ -7,8 +7,8 @@ #include "bindings.hpp" #include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" +#include "gpio.h" #include "lvgl.h" - extern "C" { extern lv_display_t* lv_display; } @@ -25,11 +25,9 @@ const int kUpdatePeriodMs = 20; static uint8_t tx_counter = 0; int main(void) { - lv_init(); bindings::Initialize(); display.Start(); - while (!bindings::ShouldQuit()) { #ifdef __linux__ try { diff --git a/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c b/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c index 646cc8dfb..a72e16865 100644 --- a/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c +++ b/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c @@ -62,6 +62,7 @@ functions. #include "../../../Utilities/Fonts/font24.c" #include "../../../Utilities/Fonts/font8.c" #include "../../../Utilities/Fonts/fonts.h" +#include "gpio.h" /** @addtogroup BSP * @{ @@ -188,6 +189,22 @@ uint8_t BSP_LCD_Init(void) { * - OTM8009A LCD Display IC Driver ititialization * @retval LCD state */ +static uint8_t led_counter = 0; + +static void advance_leds(void) { + ++led_counter; + HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, + (led_counter & 0x1) ? GPIO_PIN_RESET : GPIO_PIN_SET); + + HAL_GPIO_WritePin(GPIOD, LED2_Pin, + (led_counter & 0x2) ? GPIO_PIN_RESET : GPIO_PIN_SET); + + HAL_GPIO_WritePin(GPIOD, LED3_Pin, + (led_counter & 0x4) ? GPIO_PIN_RESET : GPIO_PIN_SET); + + HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, + (led_counter & 0x8) ? GPIO_PIN_RESET : GPIO_PIN_SET); +} uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { DSI_PLLInitTypeDef dsiPllInit; DSI_PHY_TimerTypeDef PhyTimings; @@ -205,11 +222,11 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { uint32_t HFP; /*!< Horizontal Front Porch time in units of lcdClk */ uint32_t HACT; /*!< Horizontal Active time in units of lcdClk = imageSize X in pixels to display */ - + advance_leds(); // 1 /* Toggle Hardware Reset of the DSI LCD using * its XRES signal (active low) */ - BSP_LCD_Reset(); - + BSP_LCD_Reset(); //! Breaks + advance_leds(); // 2 /* Call first MSP Initialize only in case of first initialization * This will set IP blocks LTDC, DSI and DMA2D * - out of reset @@ -217,7 +234,7 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { * - NVIC IRQ related to IP blocks enabled */ BSP_LCD_MspInit(); - + advance_leds(); // 3 /*************************DSI * Initialization***********************************/ @@ -226,7 +243,7 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { hdsi_eval.Instance = DSI; HAL_DSI_DeInit(&(hdsi_eval)); - + advance_leds(); // 4 #if !defined(USE_STM32469I_DISCO_REVA) dsiPllInit.PLLNDIV = 125; dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2; diff --git a/projects/dashboard/src/platforms/stm32/bindings.cc b/projects/dashboard/src/platforms/stm32/bindings.cc index f936cd3fe..cbd57ed75 100644 --- a/projects/dashboard/src/platforms/stm32/bindings.cc +++ b/projects/dashboard/src/platforms/stm32/bindings.cc @@ -10,6 +10,27 @@ #include "ltdc.h" #include "usart.h" +namespace { + +uint8_t led_counter = 0; + +static void advance_leds() { + ++led_counter; + HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, + (led_counter & 0x1) ? GPIO_PIN_RESET : GPIO_PIN_SET); + + HAL_GPIO_WritePin(GPIOD, LED2_Pin, + (led_counter & 0x2) ? GPIO_PIN_RESET : GPIO_PIN_SET); + + HAL_GPIO_WritePin(GPIOD, LED3_Pin, + (led_counter & 0x4) ? GPIO_PIN_RESET : GPIO_PIN_SET); + + HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, + (led_counter & 0x8) ? GPIO_PIN_RESET : GPIO_PIN_SET); +} + +} // namespace + // firmware includes #include "mcal/stm32f/can.hpp" #include "mcal/stm32f/gpio.hpp" @@ -50,47 +71,60 @@ macfe::periph::DigitalInput& button_enter = mcal::button_enter; void Initialize() { HAL_Init(); + advance_leds(); // 1 SystemClock_Config(); + advance_leds(); // 2 /* Initialize all configured peripherals */ MX_GPIO_Init(); + advance_leds(); // 3 MX_DMA_Init(); + advance_leds(); // 4 MX_DMA2D_Init(); + advance_leds(); // 5 MX_DSIHOST_DSI_Init(); + advance_leds(); // 6 MX_CAN1_Init(); + advance_leds(); // 7 // Don't call MX_FMC_Init() - it is replaced by BSP_SDRAM...() BSP_SDRAM_Init(); + advance_leds(); // 8 BSP_SDRAM_Initialization_sequence(REFRESH_COUNT); + advance_leds(); // 9 MX_LTDC_Init(); + advance_leds(); // 10 MX_USART3_UART_Init(); + advance_leds(); // 11 mcal::veh_can_base.Setup(); + advance_leds(); // 12 - BSP_LCD_Init(); + BSP_LCD_Init(); //! Breaks + advance_leds(); // 13 BSP_LCD_LayerDefaultInit(0, (uint32_t)SDRAM_DEVICE_ADDR); + advance_leds(); // 14 BSP_LCD_Clear(LCD_COLOR_BLACK); + advance_leds(); // 15 lv_init(); // init display uint32_t ltdc_layer_index = 0; /* typically 0 or 1 */ #if 0 - // note: direct mode with the LV_USE_DRAW_DMA2D enabled results in glitches on the screen - void *framebuffer1_address = (void *)SDRAM_DEVICE_ADDR; - void *framebuffer2_address = (void *)(SDRAM_DEVICE_ADDR + 3 * 1024 * 1024 / 2); - lv_st_ltdc_create_direct(framebuffer1_address, framebuffer2_address, ltdc_layer_index); + // note: direct mode with the LV_USE_DRAW_DMA2D enabled results in glitches on the screen + void *framebuffer1_address = (void *)SDRAM_DEVICE_ADDR; + void *framebuffer2_address = (void *)(SDRAM_DEVICE_ADDR + 3 * 1024 * 1024 / 2); + lv_st_ltdc_create_direct(framebuffer1_address, framebuffer2_address, ltdc_layer_index); #else -// note: partial mode works fine with the LV_USE_DRAW_DMA2D enabled + // note: partial mode works fine with the LV_USE_DRAW_DMA2D enabled #define BUF_SIZE 800 * 48 * 4 static uint8_t partial_buf1[BUF_SIZE]; // static uint8_t optional_partial_buf2[BUF_SIZE]; create_disp(partial_buf1, 0 /*optional_partial_buf2*/, BUF_SIZE, ltdc_layer_index); #endif - - // screen_driver_init(); } void DelayMS(uint32_t ms) { From b6cb9c538a636fceea34fef60a22497b9019eb12 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Tue, 9 Jun 2026 23:15:43 -0400 Subject: [PATCH 09/16] Huge --- projects/dashboard/src/main.cc | 1 + .../dashboard/src/platforms/linux/lv_conf.h | 2 +- .../stm32/BSP/stm32469i_discovery_lcd.c | 46 +++++++++++++++---- .../stm32/Core/Inc/stm32f4xx_hal_conf.h | 4 +- .../src/platforms/stm32/Core/Src/can.c | 4 +- .../platforms/stm32/Core/Src/stm32f4xx_it.c | 3 +- .../dashboard/src/platforms/stm32/bindings.cc | 42 ++++++++--------- .../src/platforms/stm32/dashboard.ioc | 4 +- .../dashboard/src/platforms/stm32/lv_conf.h | 2 +- 9 files changed, 67 insertions(+), 41 deletions(-) diff --git a/projects/dashboard/src/main.cc b/projects/dashboard/src/main.cc index a58f81330..e60526868 100644 --- a/projects/dashboard/src/main.cc +++ b/projects/dashboard/src/main.cc @@ -32,6 +32,7 @@ int main(void) { #ifdef __linux__ try { #endif + int time_ms = lv_tick_get(); display.Update(time_ms); diff --git a/projects/dashboard/src/platforms/linux/lv_conf.h b/projects/dashboard/src/platforms/linux/lv_conf.h index 9338d78e8..6ed5ae0fa 100644 --- a/projects/dashboard/src/platforms/linux/lv_conf.h +++ b/projects/dashboard/src/platforms/linux/lv_conf.h @@ -420,7 +420,7 @@ /** Add a custom handler when assert happens e.g. to restart MCU. */ #define LV_ASSERT_HANDLER_INCLUDE -#define LV_ASSERT_HANDLER while(1); /**< Halt by default */ +#define LV_ASSERT_HANDLER while(0); /**< Halt by default */ /*------------- * Debug diff --git a/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c b/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c index a72e16865..ec2880c91 100644 --- a/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c +++ b/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c @@ -222,11 +222,15 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { uint32_t HFP; /*!< Horizontal Front Porch time in units of lcdClk */ uint32_t HACT; /*!< Horizontal Active time in units of lcdClk = imageSize X in pixels to display */ - advance_leds(); // 1 + advance_leds(); // 1 /* Toggle Hardware Reset of the DSI LCD using * its XRES signal (active low) */ - BSP_LCD_Reset(); //! Breaks - advance_leds(); // 2 + BSP_LCD_Reset(); //! Breaks + led_counter = 1; + advance_leds(); // 2 + advance_leds(); // 2 + advance_leds(); // 2 #2 + /* Call first MSP Initialize only in case of first initialization * This will set IP blocks LTDC, DSI and DMA2D * - out of reset @@ -234,7 +238,15 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { * - NVIC IRQ related to IP blocks enabled */ BSP_LCD_MspInit(); - advance_leds(); // 3 + int toggle = 0; + while (0) { //! Toggle once we reach the while + HAL_Delay(500); + toggle = !toggle; + HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, + (toggle) ? GPIO_PIN_RESET : GPIO_PIN_SET); + } + led_counter = 2; + advance_leds(); // 3 /*************************DSI * Initialization***********************************/ @@ -243,7 +255,8 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { hdsi_eval.Instance = DSI; HAL_DSI_DeInit(&(hdsi_eval)); - advance_leds(); // 4 + led_counter = 3; + advance_leds(); // 4 #if !defined(USE_STM32469I_DISCO_REVA) dsiPllInit.PLLNDIV = 125; dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2; @@ -270,6 +283,7 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { Lcd_Driver_Type = LCD_ReadType(Lcd_Driver_Type); BSP_LCD_Reset(); + advance_leds(); HAL_DSI_Stop(&hdsi_eval); /* Timing parameters for all Video modes @@ -468,9 +482,14 @@ void BSP_LCD_Reset(void) { #if !defined(USE_STM32469I_DISCO_REVA) /* Disco Rev B and beyond : reset the LCD by activation of XRES (active low) * connected to PH7 */ + led_counter = 0; //! stupid GPIO_InitTypeDef gpio_init_structure; - + advance_leds(); // 1 + advance_leds(); // 1 + advance_leds(); // 1 + advance_leds(); // 1 __HAL_RCC_GPIOH_CLK_ENABLE(); + advance_leds(); // 2 /* Configure the GPIO on PH7 */ gpio_init_structure.Pin = GPIO_PIN_7; @@ -484,17 +503,26 @@ void BSP_LCD_Reset(void) { gpio_init_structure.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOH, &gpio_init_structure); + advance_leds(); // 3 /* Activate XRES active low */ HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET); + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 - HAL_Delay(20); /* wait 20 ms */ + HAL_Delay(200); /* wait 20 ms */ + advance_leds(); // 5 /* Deactivate XRES */ HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET); - + advance_leds(); // 6 /* Wait for 20ms after releasing XRES before sending commands */ - HAL_Delay(20); + HAL_Delay(200); + advance_leds(); // 7 #else /* Nothing to do in case of Disco Rev A */ #endif /* USE_STM32469I_DISCO_REVA == 0 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h index ac8c2f177..791eb6755 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h @@ -152,8 +152,8 @@ extern "C" { /** * @brief This is the HAL system configuration section */ -#define VDD_VALUE 3300U /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY 15U /*!< tick interrupt priority */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */ #define USE_RTOS 0U #define PREFETCH_ENABLE 1U #define INSTRUCTION_CACHE_ENABLE 1U diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/can.c b/projects/dashboard/src/platforms/stm32/Core/Src/can.c index 73dcc589e..ce5d3f08c 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/can.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/can.c @@ -77,7 +77,7 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle) { HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* CAN1 interrupt Init */ - HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 0, 0); + HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 1, 0); HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn); /* USER CODE BEGIN CAN1_MspInit 1 */ @@ -109,4 +109,4 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle) { /* USER CODE BEGIN 1 */ -/* USER CODE END 1 */ +/* USER CODE END 1 */ \ No newline at end of file diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c index a9faa1cf8..da2d4cd48 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c @@ -63,6 +63,7 @@ extern DMA2D_HandleTypeDef hdma2d; extern DSI_HandleTypeDef hdsi; extern LTDC_HandleTypeDef hltdc; /* USER CODE BEGIN EV */ +volatile uint32_t can_irq_count = 0; /* USER CODE END EV */ @@ -195,7 +196,7 @@ void SysTick_Handler(void) { */ void CAN1_RX0_IRQHandler(void) { /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ - + can_irq_count++; /* USER CODE END CAN1_RX0_IRQn 0 */ HAL_CAN_IRQHandler(&hcan1); /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ diff --git a/projects/dashboard/src/platforms/stm32/bindings.cc b/projects/dashboard/src/platforms/stm32/bindings.cc index cbd57ed75..1ebefe81f 100644 --- a/projects/dashboard/src/platforms/stm32/bindings.cc +++ b/projects/dashboard/src/platforms/stm32/bindings.cc @@ -16,6 +16,7 @@ uint8_t led_counter = 0; static void advance_leds() { ++led_counter; + led_counter = led_counter * 1; // this factor is for turning HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, (led_counter & 0x1) ? GPIO_PIN_RESET : GPIO_PIN_SET); @@ -28,7 +29,6 @@ static void advance_leds() { HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, (led_counter & 0x8) ? GPIO_PIN_RESET : GPIO_PIN_SET); } - } // namespace // firmware includes @@ -71,46 +71,38 @@ macfe::periph::DigitalInput& button_enter = mcal::button_enter; void Initialize() { HAL_Init(); - advance_leds(); // 1 + uwTickPrio = 0; + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); SystemClock_Config(); - advance_leds(); // 2 /* Initialize all configured peripherals */ MX_GPIO_Init(); - advance_leds(); // 3 MX_DMA_Init(); - advance_leds(); // 4 MX_DMA2D_Init(); - advance_leds(); // 5 MX_DSIHOST_DSI_Init(); - advance_leds(); // 6 - MX_CAN1_Init(); - advance_leds(); // 7 // Don't call MX_FMC_Init() - it is replaced by BSP_SDRAM...() BSP_SDRAM_Init(); - advance_leds(); // 8 BSP_SDRAM_Initialization_sequence(REFRESH_COUNT); - advance_leds(); // 9 MX_LTDC_Init(); - advance_leds(); // 10 MX_USART3_UART_Init(); - advance_leds(); // 11 - - mcal::veh_can_base.Setup(); - advance_leds(); // 12 BSP_LCD_Init(); //! Breaks - advance_leds(); // 13 BSP_LCD_LayerDefaultInit(0, (uint32_t)SDRAM_DEVICE_ADDR); - advance_leds(); // 14 - BSP_LCD_Clear(LCD_COLOR_BLACK); - advance_leds(); // 15 - + BSP_LCD_Clear(LCD_COLOR_CYAN); lv_init(); - + advance_leds(); + // Read actual register values + uint32_t systick_prio = NVIC_GetPriority(SysTick_IRQn); + uint32_t can_prio = NVIC_GetPriority(CAN1_RX0_IRQn); + MX_CAN1_Init(); + mcal::veh_can_base.Setup(); + //! USEFUL // init display + advance_leds(); + advance_leds(); + advance_leds(); uint32_t ltdc_layer_index = 0; /* typically 0 or 1 */ #if 0 // note: direct mode with the LV_USE_DRAW_DMA2D enabled results in glitches on the screen @@ -125,10 +117,14 @@ void Initialize() { create_disp(partial_buf1, 0 /*optional_partial_buf2*/, BUF_SIZE, ltdc_layer_index); #endif + advance_leds(); + advance_leds(); + advance_leds(); } void DelayMS(uint32_t ms) { - HAL_Delay(ms); + // HAL_Delay(ms); + for (volatile uint32_t i = 0; i < 18000 * ms; i++); } bool ShouldQuit() { diff --git a/projects/dashboard/src/platforms/stm32/dashboard.ioc b/projects/dashboard/src/platforms/stm32/dashboard.ioc index 694d82c91..dd461f50c 100644 --- a/projects/dashboard/src/platforms/stm32/dashboard.ioc +++ b/projects/dashboard/src/platforms/stm32/dashboard.ioc @@ -226,7 +226,7 @@ Mcu.UserName=STM32F469NIHx MxCube.Version=6.15.0 MxDb.Version=DB.6.0.150 NVIC.BusFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.CAN1_RX0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true +NVIC.CAN1_RX0_IRQn=true\:15\:0\:false\:false\:true\:true\:true\:true NVIC.DMA2D_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.DMA2_Stream0_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true NVIC.DSI_IRQn=true\:0\:0\:false\:false\:true\:true\:true\:true @@ -239,7 +239,7 @@ NVIC.NonMaskableInt_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PendSV_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false NVIC.PriorityGroup=NVIC_PRIORITYGROUP_4 NVIC.SVCall_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false -NVIC.SysTick_IRQn=true\:15\:0\:false\:false\:true\:false\:true\:false +NVIC.SysTick_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:false\:false PA0/WKUP.GPIOParameters=GPIO_PuPd PA0/WKUP.GPIO_PuPd=GPIO_PULLDOWN diff --git a/projects/dashboard/src/platforms/stm32/lv_conf.h b/projects/dashboard/src/platforms/stm32/lv_conf.h index a10c62437..2abbfb5b8 100644 --- a/projects/dashboard/src/platforms/stm32/lv_conf.h +++ b/projects/dashboard/src/platforms/stm32/lv_conf.h @@ -420,7 +420,7 @@ /** Add a custom handler when assert happens e.g. to restart MCU. */ #define LV_ASSERT_HANDLER_INCLUDE -#define LV_ASSERT_HANDLER while(1); /**< Halt by default */ +#define LV_ASSERT_HANDLER while(0); /**< Halt by default */ /*------------- * Debug From 305767726de74561b49a6de10332f82b0ff768f0 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Wed, 10 Jun 2026 18:52:07 -0400 Subject: [PATCH 10/16] Why is it breaking --- projects/dashboard/platformio.ini | 1 + .../stm32/BSP/stm32469i_discovery_lcd.c | 46 +++++++++---------- 2 files changed, 24 insertions(+), 23 deletions(-) diff --git a/projects/dashboard/platformio.ini b/projects/dashboard/platformio.ini index 089a18c11..9e27692e2 100644 --- a/projects/dashboard/platformio.ini +++ b/projects/dashboard/platformio.ini @@ -44,6 +44,7 @@ platform_packages = platformio/toolchain-gccarmnoneeabi@^1.140201.0 framework = stm32cube board = disco_f469ni upload_protocol = stlink +debug_tool = stlink lib_deps = ${common.lib_deps} diff --git a/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c b/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c index ec2880c91..157b2227a 100644 --- a/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c +++ b/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c @@ -227,9 +227,9 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { * its XRES signal (active low) */ BSP_LCD_Reset(); //! Breaks led_counter = 1; - advance_leds(); // 2 - advance_leds(); // 2 - advance_leds(); // 2 #2 + advance_leds(); // 2 + advance_leds(); // 2 + advance_leds(); // 2 #2 /* Call first MSP Initialize only in case of first initialization * This will set IP blocks LTDC, DSI and DMA2D @@ -239,11 +239,11 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { */ BSP_LCD_MspInit(); int toggle = 0; - while (0) { //! Toggle once we reach the while + while (0) { //! Toggle once we reach the while HAL_Delay(500); toggle = !toggle; HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, - (toggle) ? GPIO_PIN_RESET : GPIO_PIN_SET); + (toggle) ? GPIO_PIN_RESET : GPIO_PIN_SET); } led_counter = 2; advance_leds(); // 3 @@ -256,7 +256,7 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { HAL_DSI_DeInit(&(hdsi_eval)); led_counter = 3; - advance_leds(); // 4 + advance_leds(); // 4 #if !defined(USE_STM32469I_DISCO_REVA) dsiPllInit.PLLNDIV = 125; dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2; @@ -482,14 +482,14 @@ void BSP_LCD_Reset(void) { #if !defined(USE_STM32469I_DISCO_REVA) /* Disco Rev B and beyond : reset the LCD by activation of XRES (active low) * connected to PH7 */ - led_counter = 0; //! stupid + led_counter = 0; //! stupid GPIO_InitTypeDef gpio_init_structure; - advance_leds(); // 1 - advance_leds(); // 1 - advance_leds(); // 1 - advance_leds(); // 1 + advance_leds(); // 1 + advance_leds(); // 1 + advance_leds(); // 1 + advance_leds(); // 1 __HAL_RCC_GPIOH_CLK_ENABLE(); - advance_leds(); // 2 + advance_leds(); // 2 /* Configure the GPIO on PH7 */ gpio_init_structure.Pin = GPIO_PIN_7; @@ -503,26 +503,26 @@ void BSP_LCD_Reset(void) { gpio_init_structure.Speed = GPIO_SPEED_HIGH; HAL_GPIO_Init(GPIOH, &gpio_init_structure); - advance_leds(); // 3 + advance_leds(); // 3 /* Activate XRES active low */ HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET); - advance_leds(); // 4 - advance_leds(); // 4 - advance_leds(); // 4 - advance_leds(); // 4 - advance_leds(); // 4 - advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 + advance_leds(); // 4 - HAL_Delay(200); /* wait 20 ms */ - advance_leds(); // 5 + HAL_Delay(200); /* wait 20 ms */ + advance_leds(); // 5 /* Deactivate XRES */ HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_SET); - advance_leds(); // 6 + advance_leds(); // 6 /* Wait for 20ms after releasing XRES before sending commands */ HAL_Delay(200); - advance_leds(); // 7 + advance_leds(); // 7 #else /* Nothing to do in case of Disco Rev A */ #endif /* USE_STM32469I_DISCO_REVA == 0 */ From 75e7e32dbc569840f495d41e35b7ea9d04374767 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Wed, 10 Jun 2026 21:40:57 -0400 Subject: [PATCH 11/16] Fix the FW w/ Manush --- .../platforms/stm32/Core/Inc/stm32f4xx_it.h | 1 + .../src/platforms/stm32/Core/Src/can.c | 2 +- .../platforms/stm32/Core/Src/stm32f4xx_it.c | 146 ++++++++++-------- projects/veh.dbc | 2 +- scripts/build/add_hardfloat.py | 6 +- 5 files changed, 91 insertions(+), 66 deletions(-) diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h index 2645fbd85..d814dcfc5 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h @@ -60,6 +60,7 @@ void DMA2_Stream0_IRQHandler(void); void LTDC_IRQHandler(void); void DMA2D_IRQHandler(void); void DSI_IRQHandler(void); +void HardFault_Decode(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/can.c b/projects/dashboard/src/platforms/stm32/Core/Src/can.c index ce5d3f08c..aed5695b6 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/can.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/can.c @@ -77,7 +77,7 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle) { HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); /* CAN1 interrupt Init */ - HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 1, 0); + HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 10, 0); HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn); /* USER CODE BEGIN CAN1_MspInit 1 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c index da2d4cd48..7a0de4cae 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c @@ -16,46 +16,46 @@ ****************************************************************************** */ /* USER CODE END Header */ - + /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_it.h" - + #include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "lvgl.h" /* USER CODE END Includes */ - + /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ - + /* USER CODE END TD */ - + /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ - + /* USER CODE END PD */ - + /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ - + /* USER CODE END PM */ - + /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ - + /* USER CODE END PV */ - + /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ - + /* USER CODE END PFP */ - + /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ - + /* USER CODE END 0 */ - + /* External variables --------------------------------------------------------*/ extern CAN_HandleTypeDef hcan1; extern DMA_HandleTypeDef hdma_memtomem_dma2_stream0; @@ -63,10 +63,9 @@ extern DMA2D_HandleTypeDef hdma2d; extern DSI_HandleTypeDef hdsi; extern LTDC_HandleTypeDef hltdc; /* USER CODE BEGIN EV */ -volatile uint32_t can_irq_count = 0; - + /* USER CODE END EV */ - + /******************************************************************************/ /* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ @@ -75,187 +74,212 @@ volatile uint32_t can_irq_count = 0; */ void NMI_Handler(void) { /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - + /* USER CODE END NonMaskableInt_IRQn 0 */ /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ while (1) { } /* USER CODE END NonMaskableInt_IRQn 1 */ } - + +/* Fault context captured here — inspect in debugger when HardFault fires */ +volatile uint32_t fault_pc; +volatile uint32_t fault_lr; +volatile uint32_t fault_cfsr; /* Configurable Fault Status: which fault type */ +volatile uint32_t fault_hfsr; /* HardFault Status: forced/debug */ +volatile uint32_t fault_bfar; /* Bus Fault Address (valid if CFSR bit 7 set) */ +volatile uint32_t + fault_mmfar; /* MemManage Fault Address (valid if CFSR bit 23 set) */ + /** * @brief This function handles Hard fault interrupt. */ -void HardFault_Handler(void) { - /* USER CODE BEGIN HardFault_IRQn 0 */ - - /* USER CODE END HardFault_IRQn 0 */ +__attribute__((naked)) void HardFault_Handler(void) { + __asm volatile( + "tst lr, #4 \n" /* check EXC_RETURN[2]: 0=MSP, 1=PSP */ + "ite eq \n" + "mrseq r0, msp \n" + "mrsne r0, psp \n" + "ldr r1, =fault_pc \n" + "ldr r2, [r0, #24] \n" /* stacked PC is at offset 24 */ + "str r2, [r1] \n" + "ldr r1, =fault_lr \n" + "ldr r2, [r0, #20] \n" /* stacked LR is at offset 20 */ + "str r2, [r1] \n" + "b HardFault_Decode \n"); +} + +void HardFault_Decode(void) { + fault_cfsr = *(volatile uint32_t*)0xE000ED28; + fault_hfsr = *(volatile uint32_t*)0xE000ED2C; + fault_bfar = *(volatile uint32_t*)0xE000ED38; + fault_mmfar = *(volatile uint32_t*)0xE000ED34; while (1) { - /* USER CODE BEGIN W1_HardFault_IRQn 0 */ - /* USER CODE END W1_HardFault_IRQn 0 */ } } - + /** * @brief This function handles Memory management fault. */ void MemManage_Handler(void) { /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - + /* USER CODE END MemoryManagement_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ /* USER CODE END W1_MemoryManagement_IRQn 0 */ } } - + /** * @brief This function handles Pre-fetch fault, memory access fault. */ void BusFault_Handler(void) { /* USER CODE BEGIN BusFault_IRQn 0 */ - + /* USER CODE END BusFault_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_BusFault_IRQn 0 */ /* USER CODE END W1_BusFault_IRQn 0 */ } } - + /** * @brief This function handles Undefined instruction or illegal state. */ void UsageFault_Handler(void) { /* USER CODE BEGIN UsageFault_IRQn 0 */ - + /* USER CODE END UsageFault_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ /* USER CODE END W1_UsageFault_IRQn 0 */ } } - + /** * @brief This function handles System service call via SWI instruction. */ void SVC_Handler(void) { /* USER CODE BEGIN SVCall_IRQn 0 */ - + /* USER CODE END SVCall_IRQn 0 */ /* USER CODE BEGIN SVCall_IRQn 1 */ - + /* USER CODE END SVCall_IRQn 1 */ } - + /** * @brief This function handles Debug monitor. */ void DebugMon_Handler(void) { /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - + /* USER CODE END DebugMonitor_IRQn 0 */ /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - + /* USER CODE END DebugMonitor_IRQn 1 */ } - + /** * @brief This function handles Pendable request for system service. */ void PendSV_Handler(void) { /* USER CODE BEGIN PendSV_IRQn 0 */ - + /* USER CODE END PendSV_IRQn 0 */ /* USER CODE BEGIN PendSV_IRQn 1 */ - + /* USER CODE END PendSV_IRQn 1 */ } - + /** * @brief This function handles System tick timer. */ void SysTick_Handler(void) { /* USER CODE BEGIN SysTick_IRQn 0 */ - + /* USER CODE END SysTick_IRQn 0 */ HAL_IncTick(); /* USER CODE BEGIN SysTick_IRQn 1 */ lv_tick_inc(1); /* USER CODE END SysTick_IRQn 1 */ } - + /******************************************************************************/ /* STM32F4xx Peripheral Interrupt Handlers */ /* Add here the Interrupt Handlers for the used peripherals. */ /* For the available peripheral interrupt handler names, */ /* please refer to the startup file (startup_stm32f4xx.s). */ /******************************************************************************/ - + /** * @brief This function handles CAN1 RX0 interrupts. */ void CAN1_RX0_IRQHandler(void) { /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ - can_irq_count++; + /* USER CODE END CAN1_RX0_IRQn 0 */ HAL_CAN_IRQHandler(&hcan1); /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ - + /* USER CODE END CAN1_RX0_IRQn 1 */ } - + /** * @brief This function handles DMA2 stream0 global interrupt. */ void DMA2_Stream0_IRQHandler(void) { /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ - + /* USER CODE END DMA2_Stream0_IRQn 0 */ HAL_DMA_IRQHandler(&hdma_memtomem_dma2_stream0); /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ - + /* USER CODE END DMA2_Stream0_IRQn 1 */ } - + /** * @brief This function handles LTDC global interrupt. */ void LTDC_IRQHandler(void) { /* USER CODE BEGIN LTDC_IRQn 0 */ - + /* USER CODE END LTDC_IRQn 0 */ HAL_LTDC_IRQHandler(&hltdc); /* USER CODE BEGIN LTDC_IRQn 1 */ - + /* USER CODE END LTDC_IRQn 1 */ } - + /** * @brief This function handles DMA2D global interrupt. */ void DMA2D_IRQHandler(void) { /* USER CODE BEGIN DMA2D_IRQn 0 */ - + /* USER CODE END DMA2D_IRQn 0 */ HAL_DMA2D_IRQHandler(&hdma2d); /* USER CODE BEGIN DMA2D_IRQn 1 */ - + /* USER CODE END DMA2D_IRQn 1 */ } - + /** * @brief This function handles DSI global interrupt. */ void DSI_IRQHandler(void) { /* USER CODE BEGIN DSI_IRQn 0 */ - + /* USER CODE END DSI_IRQn 0 */ HAL_DSI_IRQHandler(&hdsi); /* USER CODE BEGIN DSI_IRQn 1 */ - + /* USER CODE END DSI_IRQn 1 */ } - + /* USER CODE BEGIN 1 */ - + /* USER CODE END 1 */ + + \ No newline at end of file diff --git a/projects/veh.dbc b/projects/veh.dbc index c46fa3671..f450e42f9 100644 --- a/projects/veh.dbc +++ b/projects/veh.dbc @@ -134,7 +134,7 @@ BO_ 230 DashCommand: 5 FC SG_ Reset : 4|1@1+ (1,0) [0|1] "" DASH SG_ Errored : 5|1@1+ (1,0) [0|1] "" DASH SG_ HvPrechargePercent : 8|8@1+ (1,0) [0|100] "" DASH - SG_ Speed : 16|12@1+ (0.1,0) [0|100] "mph" DASH + SG_ Speed : 16|12@1+ (1,0) [0|100] "mph" DASH SG_ HvSocPercent : 32|8@1+ (1,0) [0|100] "" DASH BO_ 231 DashStatus: 3 DASH diff --git a/scripts/build/add_hardfloat.py b/scripts/build/add_hardfloat.py index a276205c7..99f7d4482 100644 --- a/scripts/build/add_hardfloat.py +++ b/scripts/build/add_hardfloat.py @@ -1,8 +1,8 @@ Import("env") - + flags = [ "-mfloat-abi=hard", - "-mfpu=fpv5-d16", + "-mfpu=fpv4-sp-d16", ] - + env.Append(CCFLAGS=flags, LINKFLAGS=flags) \ No newline at end of file From fa390fc53e04c6536b8797df0bf44e80de26851e Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 13 Jun 2026 13:12:47 -0400 Subject: [PATCH 12/16] Update UI --- projects/dashboard/include/DriveModeMenu.hpp | 119 ++-- projects/dashboard/include/StartingHV.hpp | 1 + projects/dashboard/src/Display.cpp | 2 +- projects/dashboard/src/DriveModeMenu.cpp | 517 ++++++++++-------- projects/dashboard/src/StartingHV.cpp | 3 +- .../platforms/stm32/Core/Inc/stm32f4xx_it.h | 2 +- .../platforms/stm32/Core/Src/stm32f4xx_it.c | 114 ++-- .../dashboard/src/platforms/stm32/lv_conf.h | 6 +- 8 files changed, 415 insertions(+), 349 deletions(-) diff --git a/projects/dashboard/include/DriveModeMenu.hpp b/projects/dashboard/include/DriveModeMenu.hpp index b114a44d8..456b6367f 100644 --- a/projects/dashboard/include/DriveModeMenu.hpp +++ b/projects/dashboard/include/DriveModeMenu.hpp @@ -5,58 +5,71 @@ #include "etl/vector.h" #include "lvgl.h" -class CurrentArcs { +// ── HV current arc ─────────────────────────────────────────────────────────── +class HVCurrentArc { public: static constexpr uint32_t kUpdateRateHz = 100; - static constexpr uint32_t kAvgWindowSamples = kUpdateRateHz; // 1s window - static constexpr float kHVCurrentMax = 500.0f; // A — tune - static constexpr float kLVCurrentMax = 50.0f; // A — tune - static constexpr float kArcResolution = 10.0f; // ticks per amp + static constexpr uint32_t kAvgWindowSamples = kUpdateRateHz; + static constexpr float kHVCurrentMax = 500.0f; + static constexpr float kArcResolution = 10.0f; - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); + void Draw(lv_obj_t* parent); + void PushSample(float hv_current); + +private: + lv_obj_t* arc_{nullptr}; + lv_obj_t* label_{nullptr}; + etl::circular_buffer buf_; - // Push one sample per Update() tick. - void PushSamples(float hv_current, float lv_current); + float ComputeAverage() const; + void Update(); +}; + +// ── HV / LV voltage ────────────────────────────────────────────────────────── +class HVVoltageDisplay { +public: + void Draw(lv_obj_t* parent); + void SetVoltage(float hv_voltage); private: - lv_obj_t* hv_arc_{nullptr}; - lv_obj_t* lv_arc_{nullptr}; - lv_obj_t* hv_label_{nullptr}; - lv_obj_t* lv_label_{nullptr}; + lv_obj_t* label_{nullptr}; +}; - etl::circular_buffer hv_buf_; - etl::circular_buffer lv_buf_; +class LVVoltageDisplay { +public: + void Draw(lv_obj_t* parent); + void SetVoltage(float lv_voltage); - float ComputeAverage( - const etl::circular_buffer& buf) const; - void UpdateArcs(); +private: + lv_obj_t* label_{nullptr}; }; -class VoltageDisplay { +// ── LV current (text) ──────────────────────────────────────────────────────── +class LVCurrentDisplay { public: - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetVoltages(float hv_voltage, float lv_voltage); + void Draw(lv_obj_t* parent); + void SetCurrent(float current); private: - lv_obj_t* container_{nullptr}; - lv_obj_t* hv_label_{nullptr}; - lv_obj_t* lv_label_{nullptr}; + lv_obj_t* label_{nullptr}; }; +// ── SOC ────────────────────────────────────────────────────────────────────── class Battery { public: void Draw(lv_obj_t* parent); void SetSOC(float soc); private: - lv_obj_t* row_{nullptr}; - lv_obj_t* soc_bar_{nullptr}; - lv_obj_t* soc_label_{nullptr}; + lv_obj_t* bar_{nullptr}; + lv_obj_t* label_{nullptr}; }; -class BatteryTemps { + +// ── Temperature card ───────────────────────────────────────────────────────── +class TempCard { public: - void Draw(lv_obj_t* parent); - void SetTemps(float min_temp, float max_temp); + void Draw(lv_obj_t* parent, const char* title, lv_color_t color); + void SetTemps(float min, float max); private: lv_obj_t* container_{nullptr}; @@ -64,26 +77,41 @@ class BatteryTemps { lv_obj_t* max_label_{nullptr}; }; -class MotorInverterTemps { +// ── CAN indicator ──────────────────────────────────────────────────────────── +class CANIndicator { public: - void Draw(lv_obj_t* parent); - void SetTemps(float motor_temp, float inverter_temp); + void Draw(lv_obj_t* parent, const char* label); + void SetActive(bool active); private: - lv_obj_t* container_{nullptr}; - lv_obj_t* motor_label_{nullptr}; - lv_obj_t* inv_label_{nullptr}; + lv_obj_t* dot_{nullptr}; + lv_obj_t* label_{nullptr}; }; +// ── FC status ──────────────────────────────────────────────────────────────── class FCStatusMessage { public: - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); + void Draw(lv_obj_t* parent); void SetStatus(const char* status); private: - lv_obj_t* label{nullptr}; + lv_obj_t* label_{nullptr}; +}; + +// ── Speedometer (compact) ──────────────────────────────────────────────────── +class Speedometer { +public: + static constexpr float kSpeedMax = 140.0f; // km/h, FSAE-realistic ceiling + + void Draw(lv_obj_t* parent); + void SetSpeed(float speed_kph); + +private: + lv_obj_t* arc_{nullptr}; + lv_obj_t* value_label_{nullptr}; }; +// ── Screen ─────────────────────────────────────────────────────────────────── class DriveModeMenu : public Screen { public: explicit DriveModeMenu(Display* display); @@ -91,12 +119,21 @@ class DriveModeMenu : public Screen { void Update() override; private: - CurrentArcs current_arcs_; - VoltageDisplay voltage_display_; + HVCurrentArc hv_arc_; + HVVoltageDisplay hv_voltage_; + LVVoltageDisplay lv_voltage_; + LVCurrentDisplay lv_current_; Battery battery_; - BatteryTemps battery_temps_; - MotorInverterTemps motor_inverter_temps_; + + TempCard battery_temp_; + TempCard motor_temp_; + TempCard inverter_temp_; + + CANIndicator pt_can_; + CANIndicator veh_can_; + FCStatusMessage fc_status_; + Speedometer speedo_; uint32_t last_warning_time_{0}; etl::vector active_warning_ids_; diff --git a/projects/dashboard/include/StartingHV.hpp b/projects/dashboard/include/StartingHV.hpp index 8023b54bf..6c594b510 100644 --- a/projects/dashboard/include/StartingHV.hpp +++ b/projects/dashboard/include/StartingHV.hpp @@ -11,5 +11,6 @@ class StartingHV : public Screen { void Update() override; private: + lv_obj_t* title_label; lv_obj_t* progress_bar_; }; \ No newline at end of file diff --git a/projects/dashboard/src/Display.cpp b/projects/dashboard/src/Display.cpp index 1873bc68c..e64fd21f1 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -4,7 +4,7 @@ Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh) : enter(enter), scroll(scroll), veh_bus(veh), - screen_(&profile_select), //! drive_mode profile_select + screen_(&drive_mode), //! drive_mode profile_select profile_select(this), confirm_menu(this), acknowledge_config(this), diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index 2445923a4..a93e981cb 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -3,310 +3,341 @@ #include "Display.hpp" #include "lvgl.h" -float CurrentArcs::ComputeAverage( - const etl::circular_buffer& buf) const { - if (buf.empty()) return 0.0f; - float sum = 0.0f; - for (const float v : buf) sum += v; - return sum / static_cast(buf.size()); +// ───────────────────────────────────────────────────────────── +// Layout constants & fonts +// ───────────────────────────────────────────────────────────── +// NOTE: enable LV_FONT_MONTSERRAT_20 / _30 / _36 / _40 / _48 in lv_conf.h + +namespace { + +constexpr lv_coord_t kColTop = 60; +constexpr lv_coord_t kColHeight = 380; +constexpr lv_coord_t kColWidth = 260; + +const lv_font_t* kFontCaption = &lv_font_montserrat_20; +const lv_font_t* kFontTitle = &lv_font_montserrat_30; +const lv_font_t* kFontLabel = &lv_font_montserrat_30; +const lv_font_t* kFontMid = &lv_font_montserrat_36; +const lv_font_t* kFontValue = &lv_font_montserrat_40; +const lv_font_t* kFontBig = &lv_font_montserrat_48; + +lv_obj_t* MakeColumn(lv_obj_t* parent, lv_coord_t x, const char* name) { + lv_obj_t* col = lv_obj_create(parent); + lv_obj_set_size(col, kColWidth, kColHeight); + lv_obj_align(col, LV_ALIGN_TOP_LEFT, x, kColTop); + lv_obj_set_style_bg_opa(col, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(col, 0, 0); + lv_obj_set_style_pad_all(col, 0, 0); + lv_obj_set_style_pad_row(col, 6, 0); + lv_obj_clear_flag(col, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_set_layout(col, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(col, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(col, LV_FLEX_ALIGN_SPACE_BETWEEN, + LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); + + lv_obj_t* title = lv_label_create(col); + lv_obj_set_style_text_font(title, kFontTitle, 0); + lv_label_set_text(title, name); + return col; } -void CurrentArcs::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, - lv_coord_t y) { - hv_arc_ = lv_arc_create(parent); - lv_obj_set_size(hv_arc_, 300, 300); - lv_arc_set_range(hv_arc_, 0, - static_cast(kHVCurrentMax * kArcResolution)); - lv_arc_set_value(hv_arc_, 0); - lv_obj_align(hv_arc_, align, x, y); - lv_obj_remove_style(hv_arc_, NULL, LV_PART_KNOB); - - lv_arc_ = lv_arc_create(parent); - lv_obj_set_size(lv_arc_, 180, 180); - lv_arc_set_range(lv_arc_, 0, - static_cast(kLVCurrentMax * kArcResolution)); - lv_arc_set_value(lv_arc_, 0); - lv_obj_align_to(lv_arc_, hv_arc_, LV_ALIGN_CENTER, 0, 0); - lv_obj_remove_style(lv_arc_, NULL, LV_PART_KNOB); - - hv_label_ = lv_label_create(parent); - lv_obj_set_style_text_font(hv_label_, &lv_font_montserrat_20, 0); - lv_label_set_text(hv_label_, "HV: -- A"); - lv_obj_align_to(hv_label_, hv_arc_, LV_ALIGN_CENTER, 0, -18); - - lv_label_ = lv_label_create(parent); - lv_obj_set_style_text_font(lv_label_, &lv_font_montserrat_20, 0); - lv_label_set_text(lv_label_, "LV: -- A"); - lv_obj_align_to(lv_label_, hv_arc_, LV_ALIGN_CENTER, 0, 18); - - lv_obj_t* desc_label = lv_label_create(parent); - lv_obj_set_style_text_font(desc_label, &lv_font_montserrat_14, 0); - lv_label_set_text(desc_label, "HV / LV Current"); - lv_obj_align_to(desc_label, hv_arc_, LV_ALIGN_BOTTOM_MID, 0, -4); +lv_obj_t* MakeRow(lv_obj_t* parent) { + lv_obj_t* row = lv_obj_create(parent); + lv_obj_set_size(row, LV_PCT(100), LV_SIZE_CONTENT); + lv_obj_set_style_bg_opa(row, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(row, 0, 0); + lv_obj_set_style_pad_all(row, 0, 0); + lv_obj_clear_flag(row, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_set_layout(row, LV_LAYOUT_FLEX); + lv_obj_set_flex_flow(row, LV_FLEX_FLOW_ROW); + lv_obj_set_flex_align(row, LV_FLEX_ALIGN_SPACE_EVENLY, LV_FLEX_ALIGN_CENTER, + LV_FLEX_ALIGN_CENTER); + return row; } -void CurrentArcs::PushSamples(float hv_current, float lv_current) { - hv_buf_.push(hv_current); - lv_buf_.push(lv_current); - UpdateArcs(); +} // namespace + +// ───────────────────────────────────────────────────────────── +// HV Arc +// ───────────────────────────────────────────────────────────── + +float HVCurrentArc::ComputeAverage() const { + if (buf_.empty()) return 0.0f; + float sum = 0; + for (auto v : buf_) sum += v; + return sum / buf_.size(); } -void CurrentArcs::UpdateArcs() { - const float hv_avg = ComputeAverage(hv_buf_); - const float lv_avg = ComputeAverage(lv_buf_); +void HVCurrentArc::Draw(lv_obj_t* parent) { + arc_ = lv_arc_create(parent); + lv_obj_set_size(arc_, 200, 200); + lv_arc_set_bg_angles(arc_, 135, 45); + lv_arc_set_range(arc_, 0, (int32_t)(kHVCurrentMax * kArcResolution)); + lv_arc_set_value(arc_, 0); + lv_obj_remove_style(arc_, NULL, LV_PART_KNOB); + lv_obj_clear_flag(arc_, LV_OBJ_FLAG_CLICKABLE); + lv_obj_set_style_arc_width(arc_, 16, LV_PART_MAIN); + lv_obj_set_style_arc_width(arc_, 16, LV_PART_INDICATOR); + + label_ = lv_label_create(arc_); + lv_obj_set_style_text_font(label_, kFontBig, 0); + lv_label_set_text(label_, "--"); + lv_obj_align(label_, LV_ALIGN_CENTER, 0, -10); + + lv_obj_t* unit = lv_label_create(arc_); + lv_obj_set_style_text_font(unit, kFontCaption, 0); + lv_label_set_text(unit, "HV AMPS"); + lv_obj_align(unit, LV_ALIGN_CENTER, 0, 30); +} - if (hv_arc_) { - lv_arc_set_value(hv_arc_, - static_cast(hv_avg * kArcResolution)); - lv_label_set_text_fmt(hv_label_, "HV: %d A", static_cast(hv_avg)); - } - if (lv_arc_) { - lv_arc_set_value(lv_arc_, - static_cast(lv_avg * kArcResolution)); - lv_label_set_text_fmt(lv_label_, "LV: %d A", static_cast(lv_avg)); - } +void HVCurrentArc::PushSample(float v) { + buf_.push(v); + Update(); } -void VoltageDisplay::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, - lv_coord_t y) { - container_ = lv_obj_create(parent); - lv_obj_set_size(container_, 200, LV_SIZE_CONTENT); - lv_obj_align(container_, align, x, y); - lv_obj_set_style_bg_opa(container_, LV_OPA_TRANSP, 0); - lv_obj_set_style_border_width(container_, 0, 0); - lv_obj_set_style_pad_all(container_, 0, 0); - lv_obj_set_style_pad_row(container_, 8, 0); - - lv_obj_set_layout(container_, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(container_, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_CENTER, - LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); +void HVCurrentArc::Update() { + float avg = ComputeAverage(); + lv_arc_set_value(arc_, (int32_t)(avg * kArcResolution)); + lv_label_set_text_fmt(label_, "%d", (int)avg); +} + +// ───────────────────────────────────────────────────────────── +// Voltage / Current +// ───────────────────────────────────────────────────────────── + +void HVVoltageDisplay::Draw(lv_obj_t* parent) { + label_ = lv_label_create(parent); + lv_obj_set_style_text_font(label_, kFontValue, 0); + lv_label_set_text(label_, "HV -- V"); +} - lv_obj_t* title = lv_label_create(container_); - lv_label_set_text(title, "Voltage"); - lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); +void HVVoltageDisplay::SetVoltage(float v) { + lv_label_set_text_fmt(label_, "HV %d V", (int)v); +} - hv_label_ = lv_label_create(container_); - lv_label_set_text(hv_label_, "HV: --- V"); - lv_obj_set_style_text_font(hv_label_, &lv_font_montserrat_36, 0); +void LVVoltageDisplay::Draw(lv_obj_t* parent) { + label_ = lv_label_create(parent); + lv_obj_set_style_text_font(label_, kFontValue, 0); + lv_label_set_text(label_, "LV -- V"); +} - lv_label_ = lv_label_create(container_); - lv_label_set_text(lv_label_, "LV: -- V"); - lv_obj_set_style_text_font(lv_label_, &lv_font_montserrat_36, 0); +void LVVoltageDisplay::SetVoltage(float v) { + lv_label_set_text_fmt(label_, "LV %d V", (int)v); } -void VoltageDisplay::SetVoltages(float hv_voltage, float lv_voltage) { - if (hv_label_) - lv_label_set_text_fmt(hv_label_, "HV: %d V", - static_cast(hv_voltage)); - if (lv_label_) - lv_label_set_text_fmt(lv_label_, "LV: %d V", - static_cast(lv_voltage)); +void LVCurrentDisplay::Draw(lv_obj_t* parent) { + label_ = lv_label_create(parent); + lv_obj_set_style_text_font(label_, kFontValue, 0); + lv_label_set_text(label_, "LV -- A"); } +void LVCurrentDisplay::SetCurrent(float v) { + lv_label_set_text_fmt(label_, "LV %d A", (int)v); +} + +// ───────────────────────────────────────────────────────────── +// Battery SOC +// ───────────────────────────────────────────────────────────── + void Battery::Draw(lv_obj_t* parent) { - lv_obj_t* wrapper = lv_obj_create(parent); - lv_obj_set_size(wrapper, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_bg_opa(wrapper, LV_OPA_TRANSP, 0); - lv_obj_set_style_border_width(wrapper, 0, 0); - lv_obj_set_style_pad_all(wrapper, 0, 0); - lv_obj_set_style_pad_row(wrapper, 6, 0); - - lv_obj_set_layout(wrapper, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(wrapper, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(wrapper, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, - LV_FLEX_ALIGN_END); - - lv_obj_t* title = lv_label_create(wrapper); - lv_label_set_text(title, "Battery"); - lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); - - row_ = lv_obj_create(wrapper); - lv_obj_set_size(row_, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_bg_opa(row_, LV_OPA_TRANSP, 0); - lv_obj_set_style_border_width(row_, 0, 0); - lv_obj_set_style_pad_all(row_, 0, 0); - lv_obj_set_style_pad_column(row_, 10, 0); - - lv_obj_set_layout(row_, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(row_, LV_FLEX_FLOW_ROW); - lv_obj_set_flex_align(row_, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER, + lv_obj_t* wrap = lv_obj_create(parent); + lv_obj_set_size(wrap, LV_PCT(100), LV_SIZE_CONTENT); + lv_obj_set_style_bg_opa(wrap, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(wrap, 0, 0); + lv_obj_set_style_pad_all(wrap, 0, 0); + lv_obj_set_style_pad_row(wrap, 4, 0); + lv_obj_clear_flag(wrap, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_set_flex_flow(wrap, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(wrap, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, LV_FLEX_ALIGN_CENTER); - soc_bar_ = lv_bar_create(row_); - lv_obj_set_size(soc_bar_, 20, 120); - lv_bar_set_range(soc_bar_, 0, 100); - lv_bar_set_value(soc_bar_, 0, LV_ANIM_OFF); - lv_bar_set_orientation(soc_bar_, LV_BAR_ORIENTATION_VERTICAL); + bar_ = lv_bar_create(wrap); + lv_bar_set_range(bar_, 0, 100); + lv_obj_set_size(bar_, LV_PCT(100), 26); - soc_label_ = lv_label_create(row_); - lv_label_set_text(soc_label_, "--%"); - lv_obj_set_style_text_font(soc_label_, &lv_font_montserrat_48, 0); + label_ = lv_label_create(wrap); + lv_obj_set_style_text_font(label_, kFontValue, 0); + lv_label_set_text(label_, "--%"); } void Battery::SetSOC(float soc) { - if (soc_label_) - lv_label_set_text_fmt(soc_label_, "%d%%", static_cast(soc)); - if (soc_bar_) - lv_bar_set_value(soc_bar_, static_cast(soc), LV_ANIM_ON); + lv_bar_set_value(bar_, (int)soc, LV_ANIM_OFF); + lv_label_set_text_fmt(label_, "%d%%", (int)soc); } -void BatteryTemps::Draw(lv_obj_t* parent) { +// ───────────────────────────────────────────────────────────── +// Temp Card +// ───────────────────────────────────────────────────────────── + +void TempCard::Draw(lv_obj_t* parent, const char* title, lv_color_t color) { container_ = lv_obj_create(parent); - lv_obj_set_size(container_, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_bg_opa(container_, LV_OPA_TRANSP, 0); - lv_obj_set_style_border_width(container_, 0, 0); - lv_obj_set_style_pad_all(container_, 0, 0); - lv_obj_set_style_pad_row(container_, 4, 0); + lv_obj_set_width(container_, LV_PCT(100)); + lv_obj_set_flex_grow(container_, 1); + + lv_obj_set_style_bg_color(container_, color, 0); + lv_obj_set_style_bg_opa(container_, LV_OPA_COVER, 0); + lv_obj_set_style_radius(container_, 8, 0); + lv_obj_set_style_pad_all(container_, 8, 0); + lv_obj_set_style_pad_row(container_, 2, 0); + lv_obj_clear_flag(container_, LV_OBJ_FLAG_SCROLLABLE); - lv_obj_set_layout(container_, LV_LAYOUT_FLEX); lv_obj_set_flex_flow(container_, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, - LV_FLEX_ALIGN_END); + lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_SPACE_EVENLY, + LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); - lv_obj_t* title = lv_label_create(container_); - lv_label_set_text(title, "Cell temps"); - lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); + lv_obj_t* t = lv_label_create(container_); + lv_obj_set_style_text_font(t, kFontCaption, 0); + lv_label_set_text(t, title); - min_label_ = lv_label_create(container_); - lv_label_set_text(min_label_, "Min: -- C"); - lv_obj_set_style_text_font(min_label_, &lv_font_montserrat_24, 0); + lv_obj_t* row = MakeRow(container_); + min_label_ = lv_label_create(row); + lv_obj_set_style_text_font(min_label_, kFontMid, 0); + lv_label_set_text(min_label_, "Min --"); - max_label_ = lv_label_create(container_); - lv_label_set_text(max_label_, "Max: -- C"); - lv_obj_set_style_text_font(max_label_, &lv_font_montserrat_24, 0); + max_label_ = lv_label_create(row); + lv_obj_set_style_text_font(max_label_, kFontMid, 0); + lv_label_set_text(max_label_, "Max --"); } -void BatteryTemps::SetTemps(float min_temp, float max_temp) { - if (min_label_) - lv_label_set_text_fmt(min_label_, "Min: %d C", - static_cast(min_temp)); - if (max_label_) - lv_label_set_text_fmt(max_label_, "Max: %d C", - static_cast(max_temp)); +void TempCard::SetTemps(float min, float max) { + lv_label_set_text_fmt(min_label_, "Min: %d C", (int)min); + lv_label_set_text_fmt(max_label_, "Max: %d C", (int)max); } -void MotorInverterTemps::Draw(lv_obj_t* parent) { - container_ = lv_obj_create(parent); - lv_obj_set_size(container_, LV_SIZE_CONTENT, LV_SIZE_CONTENT); - lv_obj_set_style_bg_opa(container_, LV_OPA_TRANSP, 0); - lv_obj_set_style_border_width(container_, 0, 0); - lv_obj_set_style_pad_all(container_, 0, 0); - lv_obj_set_style_pad_row(container_, 4, 0); +// ───────────────────────────────────────────────────────────── +// CAN Indicator +// ───────────────────────────────────────────────────────────── + +void CANIndicator::Draw(lv_obj_t* parent, const char* label) { + lv_obj_t* wrap = lv_obj_create(parent); + lv_obj_set_size(wrap, LV_SIZE_CONTENT, LV_SIZE_CONTENT); + lv_obj_set_style_bg_opa(wrap, LV_OPA_TRANSP, 0); + lv_obj_set_style_border_width(wrap, 0, 0); + lv_obj_set_style_pad_all(wrap, 0, 0); + lv_obj_set_style_pad_column(wrap, 8, 0); + lv_obj_clear_flag(wrap, LV_OBJ_FLAG_SCROLLABLE); + lv_obj_set_flex_flow(wrap, LV_FLEX_FLOW_ROW); + lv_obj_set_flex_align(wrap, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_CENTER, + LV_FLEX_ALIGN_CENTER); - lv_obj_set_layout(container_, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(container_, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_END, - LV_FLEX_ALIGN_END); + dot_ = lv_obj_create(wrap); + lv_obj_set_size(dot_, 18, 18); + lv_obj_set_style_radius(dot_, LV_RADIUS_CIRCLE, 0); + lv_obj_set_style_border_width(dot_, 0, 0); + lv_obj_set_style_bg_color(dot_, lv_color_hex(0x444444), 0); - lv_obj_t* title = lv_label_create(container_); - lv_label_set_text(title, "Drive temps"); - lv_obj_set_style_text_font(title, &lv_font_montserrat_20, 0); + label_ = lv_label_create(wrap); + lv_obj_set_style_text_font(label_, kFontLabel, 0); + lv_label_set_text(label_, label); +} + +void CANIndicator::SetActive(bool active) { + lv_obj_set_style_bg_color( + dot_, active ? lv_color_hex(0x00FF00) : lv_color_hex(0x444444), 0); +} - motor_label_ = lv_label_create(container_); - lv_label_set_text(motor_label_, "Motor: -- C"); - lv_obj_set_style_text_font(motor_label_, &lv_font_montserrat_24, 0); +// ───────────────────────────────────────────────────────────── +// FC Status +// ───────────────────────────────────────────────────────────── - inv_label_ = lv_label_create(container_); - lv_label_set_text(inv_label_, "Inv: -- C"); - lv_obj_set_style_text_font(inv_label_, &lv_font_montserrat_24, 0); +void FCStatusMessage::Draw(lv_obj_t* parent) { + label_ = lv_label_create(parent); + lv_obj_set_style_text_font(label_, kFontLabel, 0); + lv_label_set_text(label_, "FC: --"); } -void MotorInverterTemps::SetTemps(float motor_temp, float inverter_temp) { - if (motor_label_) - lv_label_set_text_fmt(motor_label_, "Motor: %d C", - static_cast(motor_temp)); - if (inv_label_) - lv_label_set_text_fmt(inv_label_, "Inv: %d C", - static_cast(inverter_temp)); +void FCStatusMessage::SetStatus(const char* s) { + lv_label_set_text_fmt(label_, "FC: %s", s); } -void FCStatusMessage::Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, - lv_coord_t y) { - label = lv_label_create(parent); - lv_obj_align(label, align, x, y); - lv_label_set_text(label, "FC: --"); - lv_obj_set_style_text_font(label, &lv_font_montserrat_20, 0); +// ───────────────────────────────────────────────────────────── +// Speedometer (compact, bottom of right column) +// ───────────────────────────────────────────────────────────── + +void Speedometer::Draw(lv_obj_t* parent) { + arc_ = lv_arc_create(parent); + lv_obj_set_size(arc_, 130, 130); + lv_arc_set_bg_angles(arc_, 135, 45); + lv_arc_set_range(arc_, 0, (int32_t)kSpeedMax); + lv_arc_set_value(arc_, 0); + lv_obj_remove_style(arc_, NULL, LV_PART_KNOB); + lv_obj_clear_flag(arc_, LV_OBJ_FLAG_CLICKABLE); + lv_obj_set_style_arc_width(arc_, 10, LV_PART_MAIN); + lv_obj_set_style_arc_width(arc_, 10, LV_PART_INDICATOR); + + value_label_ = lv_label_create(arc_); + lv_obj_set_style_text_font(value_label_, kFontMid, 0); + lv_label_set_text(value_label_, "--"); + lv_obj_align(value_label_, LV_ALIGN_CENTER, 0, -8); + + lv_obj_t* unit = lv_label_create(arc_); + lv_obj_set_style_text_font(unit, kFontCaption, 0); + lv_label_set_text(unit, "km/h"); + lv_obj_align(unit, LV_ALIGN_CENTER, 0, 22); } -void FCStatusMessage::SetStatus(const char* status) { - lv_label_set_text_fmt(label, "FC: %s", status); +void Speedometer::SetSpeed(float kph) { + if (kph < 0.0f) kph = 0.0f; + if (kph > kSpeedMax) kph = kSpeedMax; + lv_arc_set_value(arc_, (int32_t)kph); + lv_label_set_text_fmt(value_label_, "%d", (int)kph); } +// ───────────────────────────────────────────────────────────── +// DriveModeMenu +// ───────────────────────────────────────────────────────────── + DriveModeMenu::DriveModeMenu(Display* display) : Screen(display) {} void DriveModeMenu::CreateGUI() { - last_warning_time_ = lv_tick_get(); - warning_cycle_index_ = 0; - active_warning_ids_.clear(); - - current_arcs_.Draw(frame_, LV_ALIGN_TOP_LEFT, 10, 90); - - voltage_display_.Draw(frame_, LV_ALIGN_TOP_MID, 60, 80); - - lv_obj_t* right_col = lv_obj_create(frame_); - lv_obj_set_size(right_col, 180, 410); - - lv_obj_align(right_col, LV_ALIGN_TOP_RIGHT, -10, 50); - lv_obj_set_style_bg_opa(right_col, LV_OPA_TRANSP, 0); - lv_obj_set_style_border_width(right_col, 0, 0); - lv_obj_set_style_pad_all(right_col, 0, 0); - lv_obj_set_style_pad_row(right_col, 0, 0); - - lv_obj_set_layout(right_col, LV_LAYOUT_FLEX); - lv_obj_set_flex_flow(right_col, LV_FLEX_FLOW_COLUMN); - lv_obj_set_flex_align(right_col, LV_FLEX_ALIGN_SPACE_EVENLY, - LV_FLEX_ALIGN_END, LV_FLEX_ALIGN_END); - - battery_.Draw(right_col); - battery_temps_.Draw(right_col); - motor_inverter_temps_.Draw(right_col); - - fc_status_.Draw(frame_, LV_ALIGN_BOTTOM_MID, 0, -35); - - lv_obj_t* footer = lv_label_create(frame_); - lv_label_set_text(footer, "Hold ENTER to shutdown"); - lv_obj_align(footer, LV_ALIGN_BOTTOM_MID, 0, -10); - lv_obj_set_style_text_font(footer, &lv_font_montserrat_14, 0); + lv_obj_t* left = MakeColumn(frame_, 10, "HV"); + hv_arc_.Draw(left); // 200 px arc, 48 pt center value + hv_voltage_.Draw(left); // 40 pt + battery_.Draw(left); // full-width bar + 40 pt SOC + + lv_obj_t* mid = MakeColumn(frame_, 270, "THERMALS"); + battery_temp_.Draw(mid, "BATTERY", lv_color_hex(0xAA0000)); + motor_temp_.Draw(mid, "MOTOR", lv_color_hex(0x00AA00)); + inverter_temp_.Draw(mid, "INVERTER", lv_color_hex(0x0000AA)); + + lv_obj_t* right = MakeColumn(frame_, 530, "LV"); + lv_voltage_.Draw(right); + lv_current_.Draw(right); + fc_status_.Draw(right); + + lv_obj_t* can_row = MakeRow(right); + pt_can_.Draw(can_row, "PT"); + veh_can_.Draw(can_row, "VEH"); + + speedo_.Draw(right); } void DriveModeMenu::Update() { - if (display_->enter.GetHeldDuration() > 3000 && - display_->enter.IsPressed()) { - display_->ChangeState(State::SHUTDOWN); - } - - auto fc_msg = display_->veh_bus.GetRxDashCommand(); auto lv_msg = display_->veh_bus.GetRxLvDcdc(); auto acc_msg = display_->veh_bus.GetRxAccumulator_Soc(); auto bms_msg = display_->veh_bus.GetRxBmsBroadcast(); - if (fc_msg.has_value()) { - const float hv_current = 120.0f; //! no HVCurrent signal exists yet - const float lv_current = - lv_msg.has_value() ? lv_msg->BusCurrent() : 0.0f; - current_arcs_.PushSamples(hv_current, lv_current); + hv_arc_.PushSample(0.0f); - voltage_display_.SetVoltages( - acc_msg.has_value() ? acc_msg->PackVoltage() : 0.0f, - lv_msg.has_value() ? lv_msg->LvBatteryVoltage() : 0.0f); + lv_current_.SetCurrent(lv_msg ? lv_msg->BusCurrent() : 0.0f); - battery_.SetSOC(acc_msg.has_value() - ? static_cast(acc_msg->SocPercent()) - : 0.0f); + lv_voltage_.SetVoltage(lv_msg ? lv_msg->LvBatteryVoltage() : 0.0f); + hv_voltage_.SetVoltage(acc_msg ? acc_msg->PackVoltage() : 0.0f); - battery_temps_.SetTemps( - bms_msg.has_value() ? bms_msg->LowThermValue() : 0.0f, - bms_msg.has_value() ? bms_msg->HighThermValue() : 0.0f); + battery_.SetSOC(acc_msg ? acc_msg->SocPercent() : 0.0f); - motor_inverter_temps_.SetTemps( - 67.0f, 67.0f); //! no MotorTemp/InverterTemp yet + if (bms_msg) { + battery_temp_.SetTemps(bms_msg->LowThermValue(), + bms_msg->HighThermValue()); + } - fc_status_.SetStatus("Hi"); //! no FC status + motor_temp_.SetTemps(0.0f, 0.0f); + inverter_temp_.SetTemps(0.0f, 0.0f); - if (fc_msg->Errored()) { - display_->ChangeState(State::ERROR); - } - } - // ... warning cycling unchanged + fc_status_.SetStatus("OK"); + + speedo_.SetSpeed(0.0f); // TODO: wire to wheel speed / inverter RPM msg + + pt_can_.SetActive(false); + veh_can_.SetActive(true); } \ No newline at end of file diff --git a/projects/dashboard/src/StartingHV.cpp b/projects/dashboard/src/StartingHV.cpp index c3f3f9905..edf7c2590 100644 --- a/projects/dashboard/src/StartingHV.cpp +++ b/projects/dashboard/src/StartingHV.cpp @@ -6,7 +6,7 @@ StartingHV::StartingHV(Display* display) : Screen(display) {} void StartingHV::CreateGUI() { - lv_obj_t* title_label = lv_label_create(frame_); + title_label = lv_label_create(frame_); lv_label_set_text(title_label, "Precharging Accumulator"); lv_obj_align(title_label, LV_ALIGN_TOP_MID, 0, 50); lv_obj_set_style_text_font(title_label, &lv_font_montserrat_38, 0); @@ -20,7 +20,6 @@ void StartingHV::Update() { auto fc_msg = display_->veh_bus.GetRxDashCommand(); if (!fc_msg.has_value()) return; - lv_bar_set_value(progress_bar_, fc_msg->HvPrechargePercent(), LV_ANIM_OFF); if (fc_msg->HvStarted()) { diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h index d814dcfc5..9eb2b16e8 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h @@ -60,7 +60,7 @@ void DMA2_Stream0_IRQHandler(void); void LTDC_IRQHandler(void); void DMA2D_IRQHandler(void); void DSI_IRQHandler(void); -void HardFault_Decode(void); +void HardFault_Decode(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c index 7a0de4cae..27d45c90a 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c @@ -16,46 +16,46 @@ ****************************************************************************** */ /* USER CODE END Header */ - + /* Includes ------------------------------------------------------------------*/ #include "stm32f4xx_it.h" - + #include "main.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "lvgl.h" /* USER CODE END Includes */ - + /* Private typedef -----------------------------------------------------------*/ /* USER CODE BEGIN TD */ - + /* USER CODE END TD */ - + /* Private define ------------------------------------------------------------*/ /* USER CODE BEGIN PD */ - + /* USER CODE END PD */ - + /* Private macro -------------------------------------------------------------*/ /* USER CODE BEGIN PM */ - + /* USER CODE END PM */ - + /* Private variables ---------------------------------------------------------*/ /* USER CODE BEGIN PV */ - + /* USER CODE END PV */ - + /* Private function prototypes -----------------------------------------------*/ /* USER CODE BEGIN PFP */ - + /* USER CODE END PFP */ - + /* Private user code ---------------------------------------------------------*/ /* USER CODE BEGIN 0 */ - + /* USER CODE END 0 */ - + /* External variables --------------------------------------------------------*/ extern CAN_HandleTypeDef hcan1; extern DMA_HandleTypeDef hdma_memtomem_dma2_stream0; @@ -63,9 +63,9 @@ extern DMA2D_HandleTypeDef hdma2d; extern DSI_HandleTypeDef hdsi; extern LTDC_HandleTypeDef hltdc; /* USER CODE BEGIN EV */ - + /* USER CODE END EV */ - + /******************************************************************************/ /* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ @@ -74,14 +74,14 @@ extern LTDC_HandleTypeDef hltdc; */ void NMI_Handler(void) { /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - + /* USER CODE END NonMaskableInt_IRQn 0 */ /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ while (1) { } /* USER CODE END NonMaskableInt_IRQn 1 */ } - + /* Fault context captured here — inspect in debugger when HardFault fires */ volatile uint32_t fault_pc; volatile uint32_t fault_lr; @@ -90,7 +90,7 @@ volatile uint32_t fault_hfsr; /* HardFault Status: forced/debug */ volatile uint32_t fault_bfar; /* Bus Fault Address (valid if CFSR bit 7 set) */ volatile uint32_t fault_mmfar; /* MemManage Fault Address (valid if CFSR bit 23 set) */ - + /** * @brief This function handles Hard fault interrupt. */ @@ -108,7 +108,7 @@ __attribute__((naked)) void HardFault_Handler(void) { "str r2, [r1] \n" "b HardFault_Decode \n"); } - + void HardFault_Decode(void) { fault_cfsr = *(volatile uint32_t*)0xE000ED28; fault_hfsr = *(volatile uint32_t*)0xE000ED2C; @@ -117,169 +117,167 @@ void HardFault_Decode(void) { while (1) { } } - + /** * @brief This function handles Memory management fault. */ void MemManage_Handler(void) { /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - + /* USER CODE END MemoryManagement_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ /* USER CODE END W1_MemoryManagement_IRQn 0 */ } } - + /** * @brief This function handles Pre-fetch fault, memory access fault. */ void BusFault_Handler(void) { /* USER CODE BEGIN BusFault_IRQn 0 */ - + /* USER CODE END BusFault_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_BusFault_IRQn 0 */ /* USER CODE END W1_BusFault_IRQn 0 */ } } - + /** * @brief This function handles Undefined instruction or illegal state. */ void UsageFault_Handler(void) { /* USER CODE BEGIN UsageFault_IRQn 0 */ - + /* USER CODE END UsageFault_IRQn 0 */ while (1) { /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ /* USER CODE END W1_UsageFault_IRQn 0 */ } } - + /** * @brief This function handles System service call via SWI instruction. */ void SVC_Handler(void) { /* USER CODE BEGIN SVCall_IRQn 0 */ - + /* USER CODE END SVCall_IRQn 0 */ /* USER CODE BEGIN SVCall_IRQn 1 */ - + /* USER CODE END SVCall_IRQn 1 */ } - + /** * @brief This function handles Debug monitor. */ void DebugMon_Handler(void) { /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - + /* USER CODE END DebugMonitor_IRQn 0 */ /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - + /* USER CODE END DebugMonitor_IRQn 1 */ } - + /** * @brief This function handles Pendable request for system service. */ void PendSV_Handler(void) { /* USER CODE BEGIN PendSV_IRQn 0 */ - + /* USER CODE END PendSV_IRQn 0 */ /* USER CODE BEGIN PendSV_IRQn 1 */ - + /* USER CODE END PendSV_IRQn 1 */ } - + /** * @brief This function handles System tick timer. */ void SysTick_Handler(void) { /* USER CODE BEGIN SysTick_IRQn 0 */ - + /* USER CODE END SysTick_IRQn 0 */ HAL_IncTick(); /* USER CODE BEGIN SysTick_IRQn 1 */ lv_tick_inc(1); /* USER CODE END SysTick_IRQn 1 */ } - + /******************************************************************************/ /* STM32F4xx Peripheral Interrupt Handlers */ /* Add here the Interrupt Handlers for the used peripherals. */ /* For the available peripheral interrupt handler names, */ /* please refer to the startup file (startup_stm32f4xx.s). */ /******************************************************************************/ - + /** * @brief This function handles CAN1 RX0 interrupts. */ void CAN1_RX0_IRQHandler(void) { /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ - + /* USER CODE END CAN1_RX0_IRQn 0 */ HAL_CAN_IRQHandler(&hcan1); /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ - + /* USER CODE END CAN1_RX0_IRQn 1 */ } - + /** * @brief This function handles DMA2 stream0 global interrupt. */ void DMA2_Stream0_IRQHandler(void) { /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ - + /* USER CODE END DMA2_Stream0_IRQn 0 */ HAL_DMA_IRQHandler(&hdma_memtomem_dma2_stream0); /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ - + /* USER CODE END DMA2_Stream0_IRQn 1 */ } - + /** * @brief This function handles LTDC global interrupt. */ void LTDC_IRQHandler(void) { /* USER CODE BEGIN LTDC_IRQn 0 */ - + /* USER CODE END LTDC_IRQn 0 */ HAL_LTDC_IRQHandler(&hltdc); /* USER CODE BEGIN LTDC_IRQn 1 */ - + /* USER CODE END LTDC_IRQn 1 */ } - + /** * @brief This function handles DMA2D global interrupt. */ void DMA2D_IRQHandler(void) { /* USER CODE BEGIN DMA2D_IRQn 0 */ - + /* USER CODE END DMA2D_IRQn 0 */ HAL_DMA2D_IRQHandler(&hdma2d); /* USER CODE BEGIN DMA2D_IRQn 1 */ - + /* USER CODE END DMA2D_IRQn 1 */ } - + /** * @brief This function handles DSI global interrupt. */ void DSI_IRQHandler(void) { /* USER CODE BEGIN DSI_IRQn 0 */ - + /* USER CODE END DSI_IRQn 0 */ HAL_DSI_IRQHandler(&hdsi); /* USER CODE BEGIN DSI_IRQn 1 */ - + /* USER CODE END DSI_IRQn 1 */ } - + /* USER CODE BEGIN 1 */ - + /* USER CODE END 1 */ - - \ No newline at end of file diff --git a/projects/dashboard/src/platforms/stm32/lv_conf.h b/projects/dashboard/src/platforms/stm32/lv_conf.h index 2abbfb5b8..4c8811eca 100644 --- a/projects/dashboard/src/platforms/stm32/lv_conf.h +++ b/projects/dashboard/src/platforms/stm32/lv_conf.h @@ -593,13 +593,13 @@ #define LV_FONT_MONTSERRAT_22 0 #define LV_FONT_MONTSERRAT_24 1 #define LV_FONT_MONTSERRAT_26 0 -#define LV_FONT_MONTSERRAT_28 0 -#define LV_FONT_MONTSERRAT_30 0 +#define LV_FONT_MONTSERRAT_28 1 +#define LV_FONT_MONTSERRAT_30 1 #define LV_FONT_MONTSERRAT_32 0 #define LV_FONT_MONTSERRAT_34 0 #define LV_FONT_MONTSERRAT_36 1 #define LV_FONT_MONTSERRAT_38 1 -#define LV_FONT_MONTSERRAT_40 0 +#define LV_FONT_MONTSERRAT_40 1 #define LV_FONT_MONTSERRAT_42 0 #define LV_FONT_MONTSERRAT_44 0 #define LV_FONT_MONTSERRAT_46 0 From 44608a55d5649e3bc47d2a2fbe4ea4d802e9961a Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 13 Jun 2026 15:44:30 -0400 Subject: [PATCH 13/16] D a s h b o a r d --- projects/dashboard/config.yaml | 3 +++ projects/dashboard/include/Display.hpp | 3 ++- projects/dashboard/include/Screen.hpp | 3 +++ projects/dashboard/src/AcknowledgeConfig.cpp | 1 - projects/dashboard/src/ConfirmMenu.cpp | 1 + projects/dashboard/src/Display.cpp | 1 + projects/dashboard/src/DriveModeMenu.cpp | 18 ++++++++------ projects/dashboard/src/StatusBar.cpp | 2 +- projects/front_controller/src/main.cc | 2 ++ projects/pt.dbc | 2 +- projects/veh.dbc | 26 ++++++++++---------- 11 files changed, 38 insertions(+), 24 deletions(-) diff --git a/projects/dashboard/config.yaml b/projects/dashboard/config.yaml index d745b6c6c..f84654e01 100644 --- a/projects/dashboard/config.yaml +++ b/projects/dashboard/config.yaml @@ -4,3 +4,6 @@ canGen: - name: veh node: DASH dbcFile: "../veh.dbc" + - name: pt + node: DASH + dbcFile: "../pt.dbc" diff --git a/projects/dashboard/include/Display.hpp b/projects/dashboard/include/Display.hpp index c5ea48996..9f360f34c 100644 --- a/projects/dashboard/include/Display.hpp +++ b/projects/dashboard/include/Display.hpp @@ -14,9 +14,10 @@ #include "StartMotors.hpp" #include "StartingHV.hpp" #include "StartingMotors.hpp" +#include "generated/can/pt_bus.hpp" +#include "generated/can/pt_messages.hpp" #include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" - class Display { public: using State = generated::can::TxDashStatus::State_t; diff --git a/projects/dashboard/include/Screen.hpp b/projects/dashboard/include/Screen.hpp index 0466564b9..d0d0f9e40 100644 --- a/projects/dashboard/include/Screen.hpp +++ b/projects/dashboard/include/Screen.hpp @@ -1,6 +1,9 @@ #pragma once #include "StatusBar.hpp" +#include "generated/can/pt_bus.hpp" +#include "generated/can/pt_messages.hpp" +#include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" #include "lvgl.h" diff --git a/projects/dashboard/src/AcknowledgeConfig.cpp b/projects/dashboard/src/AcknowledgeConfig.cpp index c356d10bb..7c2979f3e 100644 --- a/projects/dashboard/src/AcknowledgeConfig.cpp +++ b/projects/dashboard/src/AcknowledgeConfig.cpp @@ -1,7 +1,6 @@ #include "AcknowledgeConfig.hpp" #include "Display.hpp" -#include "generated/can/veh_bus.hpp" #include "lvgl.h" AcknowledgeConfig::AcknowledgeConfig(Display* display) : Screen(display) {} diff --git a/projects/dashboard/src/ConfirmMenu.cpp b/projects/dashboard/src/ConfirmMenu.cpp index 5cf8b91f3..2a151be97 100644 --- a/projects/dashboard/src/ConfirmMenu.cpp +++ b/projects/dashboard/src/ConfirmMenu.cpp @@ -1,6 +1,7 @@ #include "ConfirmMenu.hpp" #include "Display.hpp" +#include "generated/can/veh_bus.hpp" ConfirmMenu::ConfirmMenu(Display* display) : Screen(display) {} diff --git a/projects/dashboard/src/Display.cpp b/projects/dashboard/src/Display.cpp index e64fd21f1..328af1023 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -1,5 +1,6 @@ #include "Display.hpp" +#include "generated/can/veh_bus.hpp" Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh) : enter(enter), scroll(scroll), diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index a93e981cb..7a0821d82 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -187,21 +187,24 @@ void TempCard::Draw(lv_obj_t* parent, const char* title, lv_color_t color) { lv_obj_t* t = lv_label_create(container_); lv_obj_set_style_text_font(t, kFontCaption, 0); + lv_obj_set_style_text_color(t, lv_color_white(), 0); lv_label_set_text(t, title); lv_obj_t* row = MakeRow(container_); min_label_ = lv_label_create(row); - lv_obj_set_style_text_font(min_label_, kFontMid, 0); - lv_label_set_text(min_label_, "Min --"); + lv_obj_set_style_text_font(min_label_, kFontTitle, 0); + lv_obj_set_style_text_color(min_label_, lv_color_white(), 0); + lv_label_set_text(min_label_, "Min -"); max_label_ = lv_label_create(row); - lv_obj_set_style_text_font(max_label_, kFontMid, 0); - lv_label_set_text(max_label_, "Max --"); + lv_obj_set_style_text_font(max_label_, kFontTitle, 0); + lv_obj_set_style_text_color(max_label_, lv_color_white(), 0); + lv_label_set_text(max_label_, "Max -"); } void TempCard::SetTemps(float min, float max) { - lv_label_set_text_fmt(min_label_, "Min: %d C", (int)min); - lv_label_set_text_fmt(max_label_, "Max: %d C", (int)max); + lv_label_set_text_fmt(min_label_, "Min: %d", (int)min); + lv_label_set_text_fmt(max_label_, "Max: %d", (int)max); } // ───────────────────────────────────────────────────────────── @@ -316,8 +319,9 @@ void DriveModeMenu::Update() { auto lv_msg = display_->veh_bus.GetRxLvDcdc(); auto acc_msg = display_->veh_bus.GetRxAccumulator_Soc(); auto bms_msg = display_->veh_bus.GetRxBmsBroadcast(); + auto pack_msg = display_->veh_bus.GetRxPack_State(); - hv_arc_.PushSample(0.0f); + hv_arc_.PushSample(bms_msg ? pack_msg->Pack_Current() : 0.0f); lv_current_.SetCurrent(lv_msg ? lv_msg->BusCurrent() : 0.0f); diff --git a/projects/dashboard/src/StatusBar.cpp b/projects/dashboard/src/StatusBar.cpp index aba48ef0e..e54db8083 100644 --- a/projects/dashboard/src/StatusBar.cpp +++ b/projects/dashboard/src/StatusBar.cpp @@ -15,7 +15,7 @@ void StatusBar::Create(lv_obj_t* parent) { lv_obj_align(bar_container_, LV_ALIGN_TOP_MID, 0, 0); // Style: Red/orange background - lv_obj_set_style_bg_color(bar_container_, lv_color_hex(0xFF4500), + lv_obj_set_style_bg_color(bar_container_, lv_color_hex(0x00008B), LV_PART_MAIN); // Orange-red lv_obj_set_style_bg_opa(bar_container_, LV_OPA_COVER, LV_PART_MAIN); lv_obj_set_style_border_width(bar_container_, 0, LV_PART_MAIN); diff --git a/projects/front_controller/src/main.cc b/projects/front_controller/src/main.cc index ef2ea1981..bb097c2b9 100644 --- a/projects/front_controller/src/main.cc +++ b/projects/front_controller/src/main.cc @@ -184,6 +184,8 @@ static void Update_100Hz(void) { if (dash.has_value() && (dash->State() == DashState::SHUTDOWN)) { new_state = SHUTDOWN; } + + auto inv } break; case SHUTDOWN: diff --git a/projects/pt.dbc b/projects/pt.dbc index 9d74735bf..e4d7f9249 100644 --- a/projects/pt.dbc +++ b/projects/pt.dbc @@ -33,7 +33,7 @@ NS_ : BS_: -BU_: INV1 INV2 FC +BU_: INV1 INV2 FC DASH BO_ 643 Inv1_ActualValues1: 8 INV1 SG_ bSystemReady : 8|1@1+ (1,0) [0|0] "" FC diff --git a/projects/veh.dbc b/projects/veh.dbc index f450e42f9..4dcd6f976 100644 --- a/projects/veh.dbc +++ b/projects/veh.dbc @@ -127,15 +127,15 @@ BO_ 214 LvDcdc: 6 LVC SG_ BusCurrent : 32|16@1+ (0.001,0) [0|15] "A" FC,RPI,DASH BO_ 230 DashCommand: 5 FC - SG_ ConfigReceived : 0|1@1+ (1,0) [0|1] "" DASH - SG_ HvStarted : 1|1@1+ (1,0) [0|1] "" DASH - SG_ MotorStarted : 2|1@1+ (1,0) [0|1] "" DASH - SG_ DriveStarted : 3|1@1+ (1,0) [0|1] "" DASH - SG_ Reset : 4|1@1+ (1,0) [0|1] "" DASH - SG_ Errored : 5|1@1+ (1,0) [0|1] "" DASH - SG_ HvPrechargePercent : 8|8@1+ (1,0) [0|100] "" DASH - SG_ Speed : 16|12@1+ (1,0) [0|100] "mph" DASH - SG_ HvSocPercent : 32|8@1+ (1,0) [0|100] "" DASH + SG_ ConfigReceived : 0|1@1+ (1.0,0) [0|1] "" DASH + SG_ HvStarted : 1|1@1+ (1.0,0) [0|1] "" DASH + SG_ MotorStarted : 2|1@1+ (1.0,0) [0|1] "" DASH + SG_ DriveStarted : 3|1@1+ (1.0,0) [0|1] "" DASH + SG_ Reset : 4|1@1+ (1.0,0) [0|1] "" DASH + SG_ Errored : 5|1@1+ (1.0,0) [0|1] "" DASH + SG_ HvPrechargePercent : 8|8@1+ (1.0,0) [0|100] "" DASH + SG_ Speed : 16|12@1+ (0.1,0) [0|100] "mph" DASH + SG_ HvSocPercent : 32|8@1+ (1.0,0) [0|100] "" DASH BO_ 231 DashStatus: 3 DASH SG_ Counter : 0|8@1+ (1,0) [0|255] "" FC @@ -261,10 +261,10 @@ BO_ 1570 ContactorCommand: 3 FC SG_ PackNegative : 16|8@1+ (1,0) [0|0] "" BMS BO_ 1572 Pack_State: 7 BMS - SG_ Pack_Current : 0|16@1+ (0.1,0) [0|0] "Amps" FC - SG_ Pack_Inst_Voltage : 16|16@1+ (0.1,0) [0|0] "Volts" FC - SG_ Avg_Cell_Voltage : 32|16@1+ (0.0001,0) [0|0] "Volts" FC - SG_ Populated_Cells : 48|8@1+ (1,0) [0|0] "Num" FC + SG_ Pack_Current : 0|16@1+ (0.1,0) [0|0] "Amps" FC, DASH + SG_ Pack_Inst_Voltage : 16|16@1+ (0.1,0) [0|0] "Volts" FC, DASH + SG_ Avg_Cell_Voltage : 32|16@1+ (0.0001,0) [0|0] "Volts" FC, DASH + SG_ Populated_Cells : 48|8@1+ (1,0) [0|0] "Num" FC, DASH BO_ 1571 Pack_Current_Limits: 4 BMS SG_ Pack_CCL : 0|16@1+ (1,0) [0|0] "Amps" FC From 6ea2fb679395d06554b345d7f7768b0e35bcbc1b Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 13 Jun 2026 16:34:34 -0400 Subject: [PATCH 14/16] Add pt CAN to dashboard --- projects/dashboard/include/Display.hpp | 5 +- projects/dashboard/include/bindings.hpp | 1 + projects/dashboard/src/Display.cpp | 5 +- projects/dashboard/src/DriveModeMenu.cpp | 11 +- projects/dashboard/src/main.cc | 6 +- .../dashboard/src/platforms/linux/bindings.cc | 3 + .../org.eclipse.core.resources.prefs | 2 + .../src/platforms/stm32/Core/Inc/can.h | 4 + .../src/platforms/stm32/Core/Inc/dma.h | 4 +- .../src/platforms/stm32/Core/Inc/dma2d.h | 1 + .../src/platforms/stm32/Core/Inc/dsihost.h | 1 + .../src/platforms/stm32/Core/Inc/fmc.h | 10 +- .../src/platforms/stm32/Core/Inc/gpio.h | 1 + .../src/platforms/stm32/Core/Inc/ltdc.h | 1 + .../stm32/Core/Inc/stm32f4xx_hal_conf.h | 453 ++++++------- .../platforms/stm32/Core/Inc/stm32f4xx_it.h | 1 - .../src/platforms/stm32/Core/Inc/usart.h | 1 + .../src/platforms/stm32/Core/Src/can.c | 236 +++++-- .../src/platforms/stm32/Core/Src/dma.c | 61 +- .../src/platforms/stm32/Core/Src/dma2d.c | 107 ++-- .../src/platforms/stm32/Core/Src/dsihost.c | 272 ++++---- .../src/platforms/stm32/Core/Src/fmc.c | 603 +++++++++--------- .../src/platforms/stm32/Core/Src/gpio.c | 230 +++---- .../src/platforms/stm32/Core/Src/ltdc.c | 180 +++--- .../src/platforms/stm32/Core/Src/main.c | 139 ++-- .../stm32/Core/Src/stm32f4xx_hal_msp.c | 22 +- .../platforms/stm32/Core/Src/stm32f4xx_it.c | 280 ++++---- .../src/platforms/stm32/Core/Src/usart.c | 132 ++-- .../dashboard/src/platforms/stm32/bindings.cc | 3 + .../src/platforms/stm32/dashboard.ioc | 198 +++--- 30 files changed, 1555 insertions(+), 1418 deletions(-) create mode 100644 projects/dashboard/src/platforms/stm32/.settings/org.eclipse.core.resources.prefs diff --git a/projects/dashboard/include/Display.hpp b/projects/dashboard/include/Display.hpp index 9f360f34c..ed0166270 100644 --- a/projects/dashboard/include/Display.hpp +++ b/projects/dashboard/include/Display.hpp @@ -23,13 +23,14 @@ class Display { using State = generated::can::TxDashStatus::State_t; using Profile = generated::can::TxDashStatus::Profile_t; - Display(Button& enter, Button& scroll, generated::can::VehBus& veh); + Display(Button& enter, Button& scroll, generated::can::VehBus& veh, + generated::can::PtBus& pt); // CAN and Buttons are public so the ScreenUpdate can access them Button enter; Button scroll; generated::can::VehBus& veh_bus; - + generated::can::PtBus& pt_bus; Profile selected_profile = Profile::Default; void Start(); diff --git a/projects/dashboard/include/bindings.hpp b/projects/dashboard/include/bindings.hpp index 5f439db1c..79fc3e7d8 100644 --- a/projects/dashboard/include/bindings.hpp +++ b/projects/dashboard/include/bindings.hpp @@ -6,6 +6,7 @@ namespace bindings { extern macfe::periph::CanBase& veh_can_base; +extern macfe::periph::CanBase& pt_can_base; extern macfe::periph::DigitalInput& button_scroll; extern macfe::periph::DigitalInput& button_enter; diff --git a/projects/dashboard/src/Display.cpp b/projects/dashboard/src/Display.cpp index 328af1023..6332d2310 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -1,10 +1,13 @@ #include "Display.hpp" +#include "generated/can/pt_bus.hpp" #include "generated/can/veh_bus.hpp" -Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh) +Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh, + generated::can::PtBus& pt) : enter(enter), scroll(scroll), veh_bus(veh), + pt_bus(pt), screen_(&drive_mode), //! drive_mode profile_select profile_select(this), confirm_menu(this), diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index 7a0821d82..e0777de76 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -316,10 +316,13 @@ void DriveModeMenu::CreateGUI() { } void DriveModeMenu::Update() { + auto fc_msg = display_->veh_bus.GetRxDashCommand(); auto lv_msg = display_->veh_bus.GetRxLvDcdc(); auto acc_msg = display_->veh_bus.GetRxAccumulator_Soc(); auto bms_msg = display_->veh_bus.GetRxBmsBroadcast(); auto pack_msg = display_->veh_bus.GetRxPack_State(); + auto inv1_msg = display_->pt_bus.GetRxInv1_ActualValues2(); + auto inv2_msg = display_->pt_bus.GetRxInv2_ActualValues2(); hv_arc_.PushSample(bms_msg ? pack_msg->Pack_Current() : 0.0f); @@ -335,12 +338,14 @@ void DriveModeMenu::Update() { bms_msg->HighThermValue()); } - motor_temp_.SetTemps(0.0f, 0.0f); - inverter_temp_.SetTemps(0.0f, 0.0f); + motor_temp_.SetTemps(inv1_msg ? inv1_msg->TempMotor() : 0.0f, + inv2_msg ? inv2_msg->TempMotor() : 0.0f); + inverter_temp_.SetTemps(inv1_msg ? inv1_msg->TempInverter() : 0.0f, + inv2_msg ? inv2_msg->TempInverter() : 0.0f); fc_status_.SetStatus("OK"); - speedo_.SetSpeed(0.0f); // TODO: wire to wheel speed / inverter RPM msg + speedo_.SetSpeed(fc_msg ? fc_msg->Speed() : 0.0f); pt_can_.SetActive(false); veh_can_.SetActive(true); diff --git a/projects/dashboard/src/main.cc b/projects/dashboard/src/main.cc index e60526868..4fda36e92 100644 --- a/projects/dashboard/src/main.cc +++ b/projects/dashboard/src/main.cc @@ -5,6 +5,8 @@ #include "Button.hpp" #include "Display.hpp" #include "bindings.hpp" +#include "generated/can/pt_bus.hpp" +#include "generated/can/pt_messages.hpp" #include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" #include "gpio.h" @@ -18,8 +20,8 @@ using namespace generated::can; Button btn_enter{bindings::button_enter}; Button btn_scroll{bindings::button_scroll}; VehBus veh_can{bindings::veh_can_base}; - -Display display{btn_enter, btn_scroll, veh_can}; +PtBus pt_can{bindings::pt_can_base}; +Display display{btn_enter, btn_scroll, veh_can, pt_can}; const int kUpdatePeriodMs = 20; static uint8_t tx_counter = 0; diff --git a/projects/dashboard/src/platforms/linux/bindings.cc b/projects/dashboard/src/platforms/linux/bindings.cc index d8f396ba3..3ea255979 100644 --- a/projects/dashboard/src/platforms/linux/bindings.cc +++ b/projects/dashboard/src/platforms/linux/bindings.cc @@ -68,6 +68,7 @@ namespace mcal { using namespace mcal::lnx; CanBase veh_can_base{"vcan0"}; +CanBase pt_can_base{"vcan1"}; KeyboardInput button_scroll{SDLK_TAB}; KeyboardInput button_select{SDLK_SPACE}; @@ -76,6 +77,7 @@ KeyboardInput button_select{SDLK_SPACE}; namespace bindings { macfe::periph::CanBase& veh_can_base = mcal::veh_can_base; +macfe::periph::CanBase& pt_can_base = mcal::pt_can_base; macfe::periph::DigitalInput& button_scroll = mcal::button_scroll; macfe::periph::DigitalInput& button_enter = mcal::button_select; @@ -99,6 +101,7 @@ void Initialize() { std::signal(SIGTERM, signal_handler); // Termination signal mcal::veh_can_base.Setup(); + mcal::pt_can_base.Setup(); /* Create SDL window with LVGL 9.3 native driver */ lv_display = lv_sdl_window_create(800, 480); diff --git a/projects/dashboard/src/platforms/stm32/.settings/org.eclipse.core.resources.prefs b/projects/dashboard/src/platforms/stm32/.settings/org.eclipse.core.resources.prefs new file mode 100644 index 000000000..99f26c020 --- /dev/null +++ b/projects/dashboard/src/platforms/stm32/.settings/org.eclipse.core.resources.prefs @@ -0,0 +1,2 @@ +eclipse.preferences.version=1 +encoding/=UTF-8 diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/can.h b/projects/dashboard/src/platforms/stm32/Core/Inc/can.h index 0d8b3db2b..a560d35b2 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/can.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/can.h @@ -34,11 +34,14 @@ extern "C" { extern CAN_HandleTypeDef hcan1; +extern CAN_HandleTypeDef hcan2; + /* USER CODE BEGIN Private defines */ /* USER CODE END Private defines */ void MX_CAN1_Init(void); +void MX_CAN2_Init(void); /* USER CODE BEGIN Prototypes */ @@ -49,3 +52,4 @@ void MX_CAN1_Init(void); #endif #endif /* __CAN_H__ */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/dma.h b/projects/dashboard/src/platforms/stm32/Core/Inc/dma.h index 5044e4b4e..12b16cb9b 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/dma.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/dma.h @@ -29,8 +29,7 @@ extern "C" { /* Includes ------------------------------------------------------------------*/ #include "main.h" -/* DMA memory to memory transfer handles - * -------------------------------------*/ +/* DMA memory to memory transfer handles -------------------------------------*/ extern DMA_HandleTypeDef hdma_memtomem_dma2_stream0; /* USER CODE BEGIN Includes */ @@ -52,3 +51,4 @@ void MX_DMA_Init(void); #endif #endif /* __DMA_H__ */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/dma2d.h b/projects/dashboard/src/platforms/stm32/Core/Inc/dma2d.h index 6bef30fa1..d3def9725 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/dma2d.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/dma2d.h @@ -49,3 +49,4 @@ void MX_DMA2D_Init(void); #endif #endif /* __DMA2D_H__ */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/dsihost.h b/projects/dashboard/src/platforms/stm32/Core/Inc/dsihost.h index 957ef0133..08b1345dd 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/dsihost.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/dsihost.h @@ -49,3 +49,4 @@ void MX_DSIHOST_DSI_Init(void); #endif #endif /* __DSIHOST_H__ */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/fmc.h b/projects/dashboard/src/platforms/stm32/Core/Inc/fmc.h index 2bcbbbe8e..721f762aa 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/fmc.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/fmc.h @@ -21,7 +21,7 @@ #ifndef __FMC_H #define __FMC_H #ifdef __cplusplus -extern "C" { + extern "C" { #endif /* Includes ------------------------------------------------------------------*/ @@ -51,9 +51,9 @@ void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* hsdram); #endif /*__FMC_H */ /** - * @} - */ + * @} + */ /** - * @} - */ + * @} + */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/gpio.h b/projects/dashboard/src/platforms/stm32/Core/Inc/gpio.h index 907d2a43f..c91d06e4b 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/gpio.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/gpio.h @@ -46,3 +46,4 @@ void MX_GPIO_Init(void); } #endif #endif /*__ GPIO_H__ */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/ltdc.h b/projects/dashboard/src/platforms/stm32/Core/Inc/ltdc.h index 3ba52dde7..446f6a30a 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/ltdc.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/ltdc.h @@ -49,3 +49,4 @@ void MX_LTDC_Init(void); #endif #endif /* __LTDC_H__ */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h index 791eb6755..311f5ac86 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_hal_conf.h @@ -25,7 +25,7 @@ #define __STM32F4xx_HAL_CONF_H #ifdef __cplusplus -extern "C" { + extern "C" { #endif /* Exported types ------------------------------------------------------------*/ @@ -33,11 +33,11 @@ extern "C" { /* ########################## Module Selection ############################## */ /** - * @brief This is the list of modules to be used in the HAL driver - */ + * @brief This is the list of modules to be used in the HAL driver + */ #define HAL_MODULE_ENABLED -/* #define HAL_CRYP_MODULE_ENABLED */ + /* #define HAL_CRYP_MODULE_ENABLED */ /* #define HAL_ADC_MODULE_ENABLED */ #define HAL_CAN_MODULE_ENABLED /* #define HAL_CRC_MODULE_ENABLED */ @@ -91,158 +91,114 @@ extern "C" { /* ########################## HSE/HSI Values adaptation ##################### */ /** - * @brief Adjust the value of External High Speed oscillator (HSE) used in your - * application. This value is used by the RCC HAL module to compute the system - * frequency (when HSE is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSE_VALUE) -#define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ -#endif /* HSE_VALUE */ - -#if !defined(HSE_STARTUP_TIMEOUT) -#define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ -#endif /* HSE_STARTUP_TIMEOUT */ + * @brief Adjust the value of External High Speed oscillator (HSE) used in your application. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSE is used as system clock source, directly or through the PLL). + */ +#if !defined (HSE_VALUE) + #define HSE_VALUE 8000000U /*!< Value of the External oscillator in Hz */ +#endif /* HSE_VALUE */ + +#if !defined (HSE_STARTUP_TIMEOUT) + #define HSE_STARTUP_TIMEOUT 100U /*!< Time out for HSE start up, in ms */ +#endif /* HSE_STARTUP_TIMEOUT */ /** - * @brief Internal High Speed oscillator (HSI) value. - * This value is used by the RCC HAL module to compute the system - * frequency (when HSI is used as system clock source, directly or through the - * PLL). - */ -#if !defined(HSI_VALUE) -#define HSI_VALUE \ - ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ -#endif /* HSI_VALUE */ + * @brief Internal High Speed oscillator (HSI) value. + * This value is used by the RCC HAL module to compute the system frequency + * (when HSI is used as system clock source, directly or through the PLL). + */ +#if !defined (HSI_VALUE) + #define HSI_VALUE ((uint32_t)16000000U) /*!< Value of the Internal oscillator in Hz*/ +#endif /* HSI_VALUE */ /** - * @brief Internal Low Speed oscillator (LSI) value. - */ -#if !defined(LSI_VALUE) -#define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ -#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz \ - The real value may vary depending on the variations \ - in voltage and temperature.*/ + * @brief Internal Low Speed oscillator (LSI) value. + */ +#if !defined (LSI_VALUE) + #define LSI_VALUE 32000U /*!< LSI Typical Value in Hz*/ +#endif /* LSI_VALUE */ /*!< Value of the Internal Low Speed oscillator in Hz + The real value may vary depending on the variations + in voltage and temperature.*/ /** - * @brief External Low Speed oscillator (LSE) value. - */ -#if !defined(LSE_VALUE) -#define LSE_VALUE \ - 32768U /*!< Value of the External Low Speed oscillator in Hz */ -#endif /* LSE_VALUE */ + * @brief External Low Speed oscillator (LSE) value. + */ +#if !defined (LSE_VALUE) + #define LSE_VALUE 32768U /*!< Value of the External Low Speed oscillator in Hz */ +#endif /* LSE_VALUE */ -#if !defined(LSE_STARTUP_TIMEOUT) -#define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ -#endif /* LSE_STARTUP_TIMEOUT */ +#if !defined (LSE_STARTUP_TIMEOUT) + #define LSE_STARTUP_TIMEOUT 5000U /*!< Time out for LSE start up, in ms */ +#endif /* LSE_STARTUP_TIMEOUT */ /** - * @brief External clock source for I2S peripheral - * This value is used by the I2S HAL module to compute the I2S clock - * source frequency, this source is inserted directly through I2S_CKIN pad. - */ -#if !defined(EXTERNAL_CLOCK_VALUE) -#define EXTERNAL_CLOCK_VALUE \ - 12288000U /*!< Value of the External audio frequency in Hz*/ -#endif /* EXTERNAL_CLOCK_VALUE */ + * @brief External clock source for I2S peripheral + * This value is used by the I2S HAL module to compute the I2S clock source + * frequency, this source is inserted directly through I2S_CKIN pad. + */ +#if !defined (EXTERNAL_CLOCK_VALUE) + #define EXTERNAL_CLOCK_VALUE 12288000U /*!< Value of the External audio frequency in Hz*/ +#endif /* EXTERNAL_CLOCK_VALUE */ /* Tip: To avoid modifying this file each time you need to use different HSE, === you can define the HSE value in your toolchain compiler preprocessor. */ /* ########################### System Configuration ######################### */ /** - * @brief This is the HAL system configuration section - */ -#define VDD_VALUE 3300U /*!< Value of VDD in mv */ -#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */ -#define USE_RTOS 0U -#define PREFETCH_ENABLE 1U -#define INSTRUCTION_CACHE_ENABLE 1U -#define DATA_CACHE_ENABLE 1U - -#define USE_HAL_ADC_REGISTER_CALLBACKS \ - 0U /* ADC register callback disabled */ -#define USE_HAL_CAN_REGISTER_CALLBACKS \ - 0U /* CAN register callback disabled */ -#define USE_HAL_CEC_REGISTER_CALLBACKS \ - 0U /* CEC register callback disabled */ -#define USE_HAL_CRYP_REGISTER_CALLBACKS \ - 0U /* CRYP register callback disabled */ -#define USE_HAL_DAC_REGISTER_CALLBACKS \ - 0U /* DAC register callback disabled */ -#define USE_HAL_DCMI_REGISTER_CALLBACKS \ - 0U /* DCMI register callback disabled */ -#define USE_HAL_DFSDM_REGISTER_CALLBACKS \ - 0U /* DFSDM register callback disabled */ -#define USE_HAL_DMA2D_REGISTER_CALLBACKS \ - 0U /* DMA2D register callback disabled */ -#define USE_HAL_DSI_REGISTER_CALLBACKS \ - 0U /* DSI register callback disabled */ -#define USE_HAL_ETH_REGISTER_CALLBACKS \ - 0U /* ETH register callback disabled */ -#define USE_HAL_HASH_REGISTER_CALLBACKS \ - 0U /* HASH register callback disabled */ -#define USE_HAL_HCD_REGISTER_CALLBACKS \ - 0U /* HCD register callback disabled */ -#define USE_HAL_I2C_REGISTER_CALLBACKS \ - 0U /* I2C register callback disabled */ -#define USE_HAL_FMPI2C_REGISTER_CALLBACKS \ - 0U /* FMPI2C register callback disabled */ -#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS \ - 0U /* FMPSMBUS register callback disabled */ -#define USE_HAL_I2S_REGISTER_CALLBACKS \ - 0U /* I2S register callback disabled */ -#define USE_HAL_IRDA_REGISTER_CALLBACKS \ - 0U /* IRDA register callback disabled */ -#define USE_HAL_LPTIM_REGISTER_CALLBACKS \ - 0U /* LPTIM register callback disabled */ -#define USE_HAL_LTDC_REGISTER_CALLBACKS \ - 1U /* LTDC register callback enabled */ -#define USE_HAL_MMC_REGISTER_CALLBACKS \ - 0U /* MMC register callback disabled */ -#define USE_HAL_NAND_REGISTER_CALLBACKS \ - 0U /* NAND register callback disabled */ -#define USE_HAL_NOR_REGISTER_CALLBACKS \ - 0U /* NOR register callback disabled */ -#define USE_HAL_PCCARD_REGISTER_CALLBACKS \ - 0U /* PCCARD register callback disabled */ -#define USE_HAL_PCD_REGISTER_CALLBACKS \ - 0U /* PCD register callback disabled */ -#define USE_HAL_QSPI_REGISTER_CALLBACKS \ - 0U /* QSPI register callback disabled */ -#define USE_HAL_RNG_REGISTER_CALLBACKS \ - 0U /* RNG register callback disabled */ -#define USE_HAL_RTC_REGISTER_CALLBACKS \ - 0U /* RTC register callback disabled */ -#define USE_HAL_SAI_REGISTER_CALLBACKS \ - 0U /* SAI register callback disabled */ -#define USE_HAL_SD_REGISTER_CALLBACKS \ - 0U /* SD register callback disabled */ -#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS \ - 0U /* SMARTCARD register callback disabled */ -#define USE_HAL_SDRAM_REGISTER_CALLBACKS \ - 0U /* SDRAM register callback disabled */ -#define USE_HAL_SRAM_REGISTER_CALLBACKS \ - 0U /* SRAM register callback disabled */ -#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS \ - 0U /* SPDIFRX register callback disabled */ -#define USE_HAL_SMBUS_REGISTER_CALLBACKS \ - 0U /* SMBUS register callback disabled */ -#define USE_HAL_SPI_REGISTER_CALLBACKS \ - 0U /* SPI register callback disabled */ -#define USE_HAL_TIM_REGISTER_CALLBACKS \ - 0U /* TIM register callback disabled */ -#define USE_HAL_UART_REGISTER_CALLBACKS \ - 0U /* UART register callback disabled */ -#define USE_HAL_USART_REGISTER_CALLBACKS \ - 0U /* USART register callback disabled */ -#define USE_HAL_WWDG_REGISTER_CALLBACKS \ - 0U /* WWDG register callback disabled */ + * @brief This is the HAL system configuration section + */ +#define VDD_VALUE 3300U /*!< Value of VDD in mv */ +#define TICK_INT_PRIORITY 0U /*!< tick interrupt priority */ +#define USE_RTOS 0U +#define PREFETCH_ENABLE 1U +#define INSTRUCTION_CACHE_ENABLE 1U +#define DATA_CACHE_ENABLE 1U + +#define USE_HAL_ADC_REGISTER_CALLBACKS 0U /* ADC register callback disabled */ +#define USE_HAL_CAN_REGISTER_CALLBACKS 0U /* CAN register callback disabled */ +#define USE_HAL_CEC_REGISTER_CALLBACKS 0U /* CEC register callback disabled */ +#define USE_HAL_CRYP_REGISTER_CALLBACKS 0U /* CRYP register callback disabled */ +#define USE_HAL_DAC_REGISTER_CALLBACKS 0U /* DAC register callback disabled */ +#define USE_HAL_DCMI_REGISTER_CALLBACKS 0U /* DCMI register callback disabled */ +#define USE_HAL_DFSDM_REGISTER_CALLBACKS 0U /* DFSDM register callback disabled */ +#define USE_HAL_DMA2D_REGISTER_CALLBACKS 0U /* DMA2D register callback disabled */ +#define USE_HAL_DSI_REGISTER_CALLBACKS 0U /* DSI register callback disabled */ +#define USE_HAL_ETH_REGISTER_CALLBACKS 0U /* ETH register callback disabled */ +#define USE_HAL_HASH_REGISTER_CALLBACKS 0U /* HASH register callback disabled */ +#define USE_HAL_HCD_REGISTER_CALLBACKS 0U /* HCD register callback disabled */ +#define USE_HAL_I2C_REGISTER_CALLBACKS 0U /* I2C register callback disabled */ +#define USE_HAL_FMPI2C_REGISTER_CALLBACKS 0U /* FMPI2C register callback disabled */ +#define USE_HAL_FMPSMBUS_REGISTER_CALLBACKS 0U /* FMPSMBUS register callback disabled */ +#define USE_HAL_I2S_REGISTER_CALLBACKS 0U /* I2S register callback disabled */ +#define USE_HAL_IRDA_REGISTER_CALLBACKS 0U /* IRDA register callback disabled */ +#define USE_HAL_LPTIM_REGISTER_CALLBACKS 0U /* LPTIM register callback disabled */ +#define USE_HAL_LTDC_REGISTER_CALLBACKS 1U /* LTDC register callback enabled */ +#define USE_HAL_MMC_REGISTER_CALLBACKS 0U /* MMC register callback disabled */ +#define USE_HAL_NAND_REGISTER_CALLBACKS 0U /* NAND register callback disabled */ +#define USE_HAL_NOR_REGISTER_CALLBACKS 0U /* NOR register callback disabled */ +#define USE_HAL_PCCARD_REGISTER_CALLBACKS 0U /* PCCARD register callback disabled */ +#define USE_HAL_PCD_REGISTER_CALLBACKS 0U /* PCD register callback disabled */ +#define USE_HAL_QSPI_REGISTER_CALLBACKS 0U /* QSPI register callback disabled */ +#define USE_HAL_RNG_REGISTER_CALLBACKS 0U /* RNG register callback disabled */ +#define USE_HAL_RTC_REGISTER_CALLBACKS 0U /* RTC register callback disabled */ +#define USE_HAL_SAI_REGISTER_CALLBACKS 0U /* SAI register callback disabled */ +#define USE_HAL_SD_REGISTER_CALLBACKS 0U /* SD register callback disabled */ +#define USE_HAL_SMARTCARD_REGISTER_CALLBACKS 0U /* SMARTCARD register callback disabled */ +#define USE_HAL_SDRAM_REGISTER_CALLBACKS 0U /* SDRAM register callback disabled */ +#define USE_HAL_SRAM_REGISTER_CALLBACKS 0U /* SRAM register callback disabled */ +#define USE_HAL_SPDIFRX_REGISTER_CALLBACKS 0U /* SPDIFRX register callback disabled */ +#define USE_HAL_SMBUS_REGISTER_CALLBACKS 0U /* SMBUS register callback disabled */ +#define USE_HAL_SPI_REGISTER_CALLBACKS 0U /* SPI register callback disabled */ +#define USE_HAL_TIM_REGISTER_CALLBACKS 0U /* TIM register callback disabled */ +#define USE_HAL_UART_REGISTER_CALLBACKS 0U /* UART register callback disabled */ +#define USE_HAL_USART_REGISTER_CALLBACKS 0U /* USART register callback disabled */ +#define USE_HAL_WWDG_REGISTER_CALLBACKS 0U /* WWDG register callback disabled */ /* ########################## Assert Selection ############################## */ /** - * @brief Uncomment the line below to expanse the "assert_param" macro in the - * HAL drivers code - */ + * @brief Uncomment the line below to expanse the "assert_param" macro in the + * HAL drivers code + */ /* #define USE_FULL_ASSERT 1U */ /* ################## Ethernet peripheral configuration ##################### */ @@ -250,303 +206,286 @@ extern "C" { /* Section 1 : Ethernet peripheral configuration */ /* MAC ADDRESS: MAC_ADDR0:MAC_ADDR1:MAC_ADDR2:MAC_ADDR3:MAC_ADDR4:MAC_ADDR5 */ -#define MAC_ADDR0 2U -#define MAC_ADDR1 0U -#define MAC_ADDR2 0U -#define MAC_ADDR3 0U -#define MAC_ADDR4 0U -#define MAC_ADDR5 0U +#define MAC_ADDR0 2U +#define MAC_ADDR1 0U +#define MAC_ADDR2 0U +#define MAC_ADDR3 0U +#define MAC_ADDR4 0U +#define MAC_ADDR5 0U /* Definition of the Ethernet driver buffers size and count */ -#define ETH_RX_BUF_SIZE \ - ETH_MAX_PACKET_SIZE /* buffer size for receive */ -#define ETH_TX_BUF_SIZE \ - ETH_MAX_PACKET_SIZE /* buffer size for transmit */ -#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ -#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ +#define ETH_RX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for receive */ +#define ETH_TX_BUF_SIZE ETH_MAX_PACKET_SIZE /* buffer size for transmit */ +#define ETH_RXBUFNB 4U /* 4 Rx buffers of size ETH_RX_BUF_SIZE */ +#define ETH_TXBUFNB 4U /* 4 Tx buffers of size ETH_TX_BUF_SIZE */ /* Section 2: PHY configuration section */ /* DP83848_PHY_ADDRESS Address*/ #define DP83848_PHY_ADDRESS /* PHY Reset delay these values are based on a 1 ms Systick interrupt*/ -#define PHY_RESET_DELAY 0x000000FFU +#define PHY_RESET_DELAY 0x000000FFU /* PHY Configuration delay */ -#define PHY_CONFIG_DELAY 0x00000FFFU +#define PHY_CONFIG_DELAY 0x00000FFFU -#define PHY_READ_TO 0x0000FFFFU -#define PHY_WRITE_TO 0x0000FFFFU +#define PHY_READ_TO 0x0000FFFFU +#define PHY_WRITE_TO 0x0000FFFFU /* Section 3: Common PHY Registers */ -#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ -#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ - -#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ -#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ -#define PHY_FULLDUPLEX_100M \ - ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ -#define PHY_HALFDUPLEX_100M \ - ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ -#define PHY_FULLDUPLEX_10M \ - ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ -#define PHY_HALFDUPLEX_10M \ - ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ -#define PHY_AUTONEGOTIATION \ - ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ -#define PHY_RESTART_AUTONEGOTIATION \ - ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ -#define PHY_POWERDOWN \ - ((uint16_t)0x0800U) /*!< Select the power down mode */ -#define PHY_ISOLATE \ - ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ - -#define PHY_AUTONEGO_COMPLETE \ - ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ -#define PHY_LINKED_STATUS \ - ((uint16_t)0x0004U) /*!< Valid link established */ -#define PHY_JABBER_DETECTION \ - ((uint16_t)0x0002U) /*!< Jabber condition detected */ +#define PHY_BCR ((uint16_t)0x0000U) /*!< Transceiver Basic Control Register */ +#define PHY_BSR ((uint16_t)0x0001U) /*!< Transceiver Basic Status Register */ + +#define PHY_RESET ((uint16_t)0x8000U) /*!< PHY Reset */ +#define PHY_LOOPBACK ((uint16_t)0x4000U) /*!< Select loop-back mode */ +#define PHY_FULLDUPLEX_100M ((uint16_t)0x2100U) /*!< Set the full-duplex mode at 100 Mb/s */ +#define PHY_HALFDUPLEX_100M ((uint16_t)0x2000U) /*!< Set the half-duplex mode at 100 Mb/s */ +#define PHY_FULLDUPLEX_10M ((uint16_t)0x0100U) /*!< Set the full-duplex mode at 10 Mb/s */ +#define PHY_HALFDUPLEX_10M ((uint16_t)0x0000U) /*!< Set the half-duplex mode at 10 Mb/s */ +#define PHY_AUTONEGOTIATION ((uint16_t)0x1000U) /*!< Enable auto-negotiation function */ +#define PHY_RESTART_AUTONEGOTIATION ((uint16_t)0x0200U) /*!< Restart auto-negotiation function */ +#define PHY_POWERDOWN ((uint16_t)0x0800U) /*!< Select the power down mode */ +#define PHY_ISOLATE ((uint16_t)0x0400U) /*!< Isolate PHY from MII */ + +#define PHY_AUTONEGO_COMPLETE ((uint16_t)0x0020U) /*!< Auto-Negotiation process completed */ +#define PHY_LINKED_STATUS ((uint16_t)0x0004U) /*!< Valid link established */ +#define PHY_JABBER_DETECTION ((uint16_t)0x0002U) /*!< Jabber condition detected */ /* Section 4: Extended PHY Registers */ -#define PHY_SR \ - ((uint16_t)) /*!< PHY status register Offset */ +#define PHY_SR ((uint16_t)) /*!< PHY status register Offset */ -#define PHY_SPEED_STATUS \ - ((uint16_t)) /*!< PHY Speed mask */ -#define PHY_DUPLEX_STATUS \ - ((uint16_t)) /*!< PHY Duplex mask */ +#define PHY_SPEED_STATUS ((uint16_t)) /*!< PHY Speed mask */ +#define PHY_DUPLEX_STATUS ((uint16_t)) /*!< PHY Duplex mask */ /* ################## SPI peripheral configuration ########################## */ /* CRC FEATURE: Use to activate CRC feature inside HAL SPI Driver - * Activated: CRC code is present inside driver - * Deactivated: CRC code cleaned from driver - */ +* Activated: CRC code is present inside driver +* Deactivated: CRC code cleaned from driver +*/ -#define USE_SPI_CRC 0U +#define USE_SPI_CRC 0U /* Includes ------------------------------------------------------------------*/ /** - * @brief Include module's header file - */ + * @brief Include module's header file + */ #ifdef HAL_RCC_MODULE_ENABLED -#include "stm32f4xx_hal_rcc.h" + #include "stm32f4xx_hal_rcc.h" #endif /* HAL_RCC_MODULE_ENABLED */ #ifdef HAL_GPIO_MODULE_ENABLED -#include "stm32f4xx_hal_gpio.h" + #include "stm32f4xx_hal_gpio.h" #endif /* HAL_GPIO_MODULE_ENABLED */ #ifdef HAL_EXTI_MODULE_ENABLED -#include "stm32f4xx_hal_exti.h" + #include "stm32f4xx_hal_exti.h" #endif /* HAL_EXTI_MODULE_ENABLED */ #ifdef HAL_DMA_MODULE_ENABLED -#include "stm32f4xx_hal_dma.h" + #include "stm32f4xx_hal_dma.h" #endif /* HAL_DMA_MODULE_ENABLED */ #ifdef HAL_CORTEX_MODULE_ENABLED -#include "stm32f4xx_hal_cortex.h" + #include "stm32f4xx_hal_cortex.h" #endif /* HAL_CORTEX_MODULE_ENABLED */ #ifdef HAL_ADC_MODULE_ENABLED -#include "stm32f4xx_hal_adc.h" + #include "stm32f4xx_hal_adc.h" #endif /* HAL_ADC_MODULE_ENABLED */ #ifdef HAL_CAN_MODULE_ENABLED -#include "stm32f4xx_hal_can.h" + #include "stm32f4xx_hal_can.h" #endif /* HAL_CAN_MODULE_ENABLED */ #ifdef HAL_CAN_LEGACY_MODULE_ENABLED -#include "stm32f4xx_hal_can_legacy.h" + #include "stm32f4xx_hal_can_legacy.h" #endif /* HAL_CAN_LEGACY_MODULE_ENABLED */ #ifdef HAL_CRC_MODULE_ENABLED -#include "stm32f4xx_hal_crc.h" + #include "stm32f4xx_hal_crc.h" #endif /* HAL_CRC_MODULE_ENABLED */ #ifdef HAL_CRYP_MODULE_ENABLED -#include "stm32f4xx_hal_cryp.h" + #include "stm32f4xx_hal_cryp.h" #endif /* HAL_CRYP_MODULE_ENABLED */ #ifdef HAL_DMA2D_MODULE_ENABLED -#include "stm32f4xx_hal_dma2d.h" + #include "stm32f4xx_hal_dma2d.h" #endif /* HAL_DMA2D_MODULE_ENABLED */ #ifdef HAL_DAC_MODULE_ENABLED -#include "stm32f4xx_hal_dac.h" + #include "stm32f4xx_hal_dac.h" #endif /* HAL_DAC_MODULE_ENABLED */ #ifdef HAL_DCMI_MODULE_ENABLED -#include "stm32f4xx_hal_dcmi.h" + #include "stm32f4xx_hal_dcmi.h" #endif /* HAL_DCMI_MODULE_ENABLED */ #ifdef HAL_ETH_MODULE_ENABLED -#include "stm32f4xx_hal_eth.h" + #include "stm32f4xx_hal_eth.h" #endif /* HAL_ETH_MODULE_ENABLED */ #ifdef HAL_ETH_LEGACY_MODULE_ENABLED -#include "stm32f4xx_hal_eth_legacy.h" + #include "stm32f4xx_hal_eth_legacy.h" #endif /* HAL_ETH_LEGACY_MODULE_ENABLED */ #ifdef HAL_FLASH_MODULE_ENABLED -#include "stm32f4xx_hal_flash.h" + #include "stm32f4xx_hal_flash.h" #endif /* HAL_FLASH_MODULE_ENABLED */ #ifdef HAL_SRAM_MODULE_ENABLED -#include "stm32f4xx_hal_sram.h" + #include "stm32f4xx_hal_sram.h" #endif /* HAL_SRAM_MODULE_ENABLED */ #ifdef HAL_NOR_MODULE_ENABLED -#include "stm32f4xx_hal_nor.h" + #include "stm32f4xx_hal_nor.h" #endif /* HAL_NOR_MODULE_ENABLED */ #ifdef HAL_NAND_MODULE_ENABLED -#include "stm32f4xx_hal_nand.h" + #include "stm32f4xx_hal_nand.h" #endif /* HAL_NAND_MODULE_ENABLED */ #ifdef HAL_PCCARD_MODULE_ENABLED -#include "stm32f4xx_hal_pccard.h" + #include "stm32f4xx_hal_pccard.h" #endif /* HAL_PCCARD_MODULE_ENABLED */ #ifdef HAL_SDRAM_MODULE_ENABLED -#include "stm32f4xx_hal_sdram.h" + #include "stm32f4xx_hal_sdram.h" #endif /* HAL_SDRAM_MODULE_ENABLED */ #ifdef HAL_HASH_MODULE_ENABLED -#include "stm32f4xx_hal_hash.h" + #include "stm32f4xx_hal_hash.h" #endif /* HAL_HASH_MODULE_ENABLED */ #ifdef HAL_I2C_MODULE_ENABLED -#include "stm32f4xx_hal_i2c.h" + #include "stm32f4xx_hal_i2c.h" #endif /* HAL_I2C_MODULE_ENABLED */ #ifdef HAL_SMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_smbus.h" + #include "stm32f4xx_hal_smbus.h" #endif /* HAL_SMBUS_MODULE_ENABLED */ #ifdef HAL_I2S_MODULE_ENABLED -#include "stm32f4xx_hal_i2s.h" + #include "stm32f4xx_hal_i2s.h" #endif /* HAL_I2S_MODULE_ENABLED */ #ifdef HAL_IWDG_MODULE_ENABLED -#include "stm32f4xx_hal_iwdg.h" + #include "stm32f4xx_hal_iwdg.h" #endif /* HAL_IWDG_MODULE_ENABLED */ #ifdef HAL_LTDC_MODULE_ENABLED -#include "stm32f4xx_hal_ltdc.h" + #include "stm32f4xx_hal_ltdc.h" #endif /* HAL_LTDC_MODULE_ENABLED */ #ifdef HAL_PWR_MODULE_ENABLED -#include "stm32f4xx_hal_pwr.h" + #include "stm32f4xx_hal_pwr.h" #endif /* HAL_PWR_MODULE_ENABLED */ #ifdef HAL_RNG_MODULE_ENABLED -#include "stm32f4xx_hal_rng.h" + #include "stm32f4xx_hal_rng.h" #endif /* HAL_RNG_MODULE_ENABLED */ #ifdef HAL_RTC_MODULE_ENABLED -#include "stm32f4xx_hal_rtc.h" + #include "stm32f4xx_hal_rtc.h" #endif /* HAL_RTC_MODULE_ENABLED */ #ifdef HAL_SAI_MODULE_ENABLED -#include "stm32f4xx_hal_sai.h" + #include "stm32f4xx_hal_sai.h" #endif /* HAL_SAI_MODULE_ENABLED */ #ifdef HAL_SD_MODULE_ENABLED -#include "stm32f4xx_hal_sd.h" + #include "stm32f4xx_hal_sd.h" #endif /* HAL_SD_MODULE_ENABLED */ #ifdef HAL_SPI_MODULE_ENABLED -#include "stm32f4xx_hal_spi.h" + #include "stm32f4xx_hal_spi.h" #endif /* HAL_SPI_MODULE_ENABLED */ #ifdef HAL_TIM_MODULE_ENABLED -#include "stm32f4xx_hal_tim.h" + #include "stm32f4xx_hal_tim.h" #endif /* HAL_TIM_MODULE_ENABLED */ #ifdef HAL_UART_MODULE_ENABLED -#include "stm32f4xx_hal_uart.h" + #include "stm32f4xx_hal_uart.h" #endif /* HAL_UART_MODULE_ENABLED */ #ifdef HAL_USART_MODULE_ENABLED -#include "stm32f4xx_hal_usart.h" + #include "stm32f4xx_hal_usart.h" #endif /* HAL_USART_MODULE_ENABLED */ #ifdef HAL_IRDA_MODULE_ENABLED -#include "stm32f4xx_hal_irda.h" + #include "stm32f4xx_hal_irda.h" #endif /* HAL_IRDA_MODULE_ENABLED */ #ifdef HAL_SMARTCARD_MODULE_ENABLED -#include "stm32f4xx_hal_smartcard.h" + #include "stm32f4xx_hal_smartcard.h" #endif /* HAL_SMARTCARD_MODULE_ENABLED */ #ifdef HAL_WWDG_MODULE_ENABLED -#include "stm32f4xx_hal_wwdg.h" + #include "stm32f4xx_hal_wwdg.h" #endif /* HAL_WWDG_MODULE_ENABLED */ #ifdef HAL_PCD_MODULE_ENABLED -#include "stm32f4xx_hal_pcd.h" + #include "stm32f4xx_hal_pcd.h" #endif /* HAL_PCD_MODULE_ENABLED */ #ifdef HAL_HCD_MODULE_ENABLED -#include "stm32f4xx_hal_hcd.h" + #include "stm32f4xx_hal_hcd.h" #endif /* HAL_HCD_MODULE_ENABLED */ #ifdef HAL_DSI_MODULE_ENABLED -#include "stm32f4xx_hal_dsi.h" + #include "stm32f4xx_hal_dsi.h" #endif /* HAL_DSI_MODULE_ENABLED */ #ifdef HAL_QSPI_MODULE_ENABLED -#include "stm32f4xx_hal_qspi.h" + #include "stm32f4xx_hal_qspi.h" #endif /* HAL_QSPI_MODULE_ENABLED */ #ifdef HAL_CEC_MODULE_ENABLED -#include "stm32f4xx_hal_cec.h" + #include "stm32f4xx_hal_cec.h" #endif /* HAL_CEC_MODULE_ENABLED */ #ifdef HAL_FMPI2C_MODULE_ENABLED -#include "stm32f4xx_hal_fmpi2c.h" + #include "stm32f4xx_hal_fmpi2c.h" #endif /* HAL_FMPI2C_MODULE_ENABLED */ #ifdef HAL_FMPSMBUS_MODULE_ENABLED -#include "stm32f4xx_hal_fmpsmbus.h" + #include "stm32f4xx_hal_fmpsmbus.h" #endif /* HAL_FMPSMBUS_MODULE_ENABLED */ #ifdef HAL_SPDIFRX_MODULE_ENABLED -#include "stm32f4xx_hal_spdifrx.h" + #include "stm32f4xx_hal_spdifrx.h" #endif /* HAL_SPDIFRX_MODULE_ENABLED */ #ifdef HAL_DFSDM_MODULE_ENABLED -#include "stm32f4xx_hal_dfsdm.h" + #include "stm32f4xx_hal_dfsdm.h" #endif /* HAL_DFSDM_MODULE_ENABLED */ #ifdef HAL_LPTIM_MODULE_ENABLED -#include "stm32f4xx_hal_lptim.h" + #include "stm32f4xx_hal_lptim.h" #endif /* HAL_LPTIM_MODULE_ENABLED */ #ifdef HAL_MMC_MODULE_ENABLED -#include "stm32f4xx_hal_mmc.h" + #include "stm32f4xx_hal_mmc.h" #endif /* HAL_MMC_MODULE_ENABLED */ /* Exported macro ------------------------------------------------------------*/ -#ifdef USE_FULL_ASSERT +#ifdef USE_FULL_ASSERT /** - * @brief The assert_param macro is used for function's parameters check. - * @param expr If expr is false, it calls assert_failed function - * which reports the name of the source file and the source - * line number of the call that failed. - * If expr is true, it returns no value. - * @retval None - */ -#define assert_param(expr) \ - ((expr) ? (void)0U : assert_failed((uint8_t*)__FILE__, __LINE__)) + * @brief The assert_param macro is used for function's parameters check. + * @param expr If expr is false, it calls assert_failed function + * which reports the name of the source file and the source + * line number of the call that failed. + * If expr is true, it returns no value. + * @retval None + */ + #define assert_param(expr) ((expr) ? (void)0U : assert_failed((uint8_t *)__FILE__, __LINE__)) /* Exported functions ------------------------------------------------------- */ -void assert_failed(uint8_t* file, uint32_t line); + void assert_failed(uint8_t* file, uint32_t line); #else -#define assert_param(expr) ((void)0U) + #define assert_param(expr) ((void)0U) #endif /* USE_FULL_ASSERT */ #ifdef __cplusplus diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h index 9eb2b16e8..2645fbd85 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/stm32f4xx_it.h @@ -60,7 +60,6 @@ void DMA2_Stream0_IRQHandler(void); void LTDC_IRQHandler(void); void DMA2D_IRQHandler(void); void DSI_IRQHandler(void); -void HardFault_Decode(void); /* USER CODE BEGIN EFP */ /* USER CODE END EFP */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/usart.h b/projects/dashboard/src/platforms/stm32/Core/Inc/usart.h index 27f3ce5eb..6e70f61a5 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/usart.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/usart.h @@ -49,3 +49,4 @@ void MX_USART3_UART_Init(void); #endif #endif /* __USART_H__ */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/can.c b/projects/dashboard/src/platforms/stm32/Core/Src/can.c index aed5695b6..ceb95210b 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/can.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/can.c @@ -25,88 +25,186 @@ /* USER CODE END 0 */ CAN_HandleTypeDef hcan1; +CAN_HandleTypeDef hcan2; /* CAN1 init function */ -void MX_CAN1_Init(void) { - /* USER CODE BEGIN CAN1_Init 0 */ - - /* USER CODE END CAN1_Init 0 */ - - /* USER CODE BEGIN CAN1_Init 1 */ - - /* USER CODE END CAN1_Init 1 */ - hcan1.Instance = CAN1; - hcan1.Init.Prescaler = 6; - hcan1.Init.Mode = CAN_MODE_NORMAL; - hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ; - hcan1.Init.TimeSeg1 = CAN_BS1_13TQ; - hcan1.Init.TimeSeg2 = CAN_BS2_1TQ; - hcan1.Init.TimeTriggeredMode = DISABLE; - hcan1.Init.AutoBusOff = DISABLE; - hcan1.Init.AutoWakeUp = DISABLE; - hcan1.Init.AutoRetransmission = DISABLE; - hcan1.Init.ReceiveFifoLocked = DISABLE; - hcan1.Init.TransmitFifoPriority = DISABLE; - if (HAL_CAN_Init(&hcan1) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN CAN1_Init 2 */ +void MX_CAN1_Init(void) +{ + + /* USER CODE BEGIN CAN1_Init 0 */ + + /* USER CODE END CAN1_Init 0 */ + + /* USER CODE BEGIN CAN1_Init 1 */ + + /* USER CODE END CAN1_Init 1 */ + hcan1.Instance = CAN1; + hcan1.Init.Prescaler = 6; + hcan1.Init.Mode = CAN_MODE_NORMAL; + hcan1.Init.SyncJumpWidth = CAN_SJW_1TQ; + hcan1.Init.TimeSeg1 = CAN_BS1_13TQ; + hcan1.Init.TimeSeg2 = CAN_BS2_1TQ; + hcan1.Init.TimeTriggeredMode = DISABLE; + hcan1.Init.AutoBusOff = DISABLE; + hcan1.Init.AutoWakeUp = DISABLE; + hcan1.Init.AutoRetransmission = DISABLE; + hcan1.Init.ReceiveFifoLocked = DISABLE; + hcan1.Init.TransmitFifoPriority = DISABLE; + if (HAL_CAN_Init(&hcan1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN CAN1_Init 2 */ + + /* USER CODE END CAN1_Init 2 */ - /* USER CODE END CAN1_Init 2 */ } +/* CAN2 init function */ +void MX_CAN2_Init(void) +{ + + /* USER CODE BEGIN CAN2_Init 0 */ + + /* USER CODE END CAN2_Init 0 */ + + /* USER CODE BEGIN CAN2_Init 1 */ + + /* USER CODE END CAN2_Init 1 */ + hcan2.Instance = CAN2; + hcan2.Init.Prescaler = 16; + hcan2.Init.Mode = CAN_MODE_NORMAL; + hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ; + hcan2.Init.TimeSeg1 = CAN_BS1_1TQ; + hcan2.Init.TimeSeg2 = CAN_BS2_1TQ; + hcan2.Init.TimeTriggeredMode = DISABLE; + hcan2.Init.AutoBusOff = DISABLE; + hcan2.Init.AutoWakeUp = DISABLE; + hcan2.Init.AutoRetransmission = DISABLE; + hcan2.Init.ReceiveFifoLocked = DISABLE; + hcan2.Init.TransmitFifoPriority = DISABLE; + if (HAL_CAN_Init(&hcan2) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN CAN2_Init 2 */ + + /* USER CODE END CAN2_Init 2 */ -void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle) { - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if (canHandle->Instance == CAN1) { - /* USER CODE BEGIN CAN1_MspInit 0 */ - - /* USER CODE END CAN1_MspInit 0 */ - /* CAN1 clock enable */ - __HAL_RCC_CAN1_CLK_ENABLE(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**CAN1 GPIO Configuration - PB8 ------> CAN1_RX - PB9 ------> CAN1_TX - */ - GPIO_InitStruct.Pin = GPIO_PIN_8 | GPIO_PIN_9; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF9_CAN1; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* CAN1 interrupt Init */ - HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 10, 0); - HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn); - /* USER CODE BEGIN CAN1_MspInit 1 */ - - /* USER CODE END CAN1_MspInit 1 */ - } } -void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle) { - if (canHandle->Instance == CAN1) { - /* USER CODE BEGIN CAN1_MspDeInit 0 */ +static uint32_t HAL_RCC_CAN1_CLK_ENABLED=0; + +void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle) +{ - /* USER CODE END CAN1_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CAN1_CLK_DISABLE(); + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(canHandle->Instance==CAN1) + { + /* USER CODE BEGIN CAN1_MspInit 0 */ + + /* USER CODE END CAN1_MspInit 0 */ + /* CAN1 clock enable */ + HAL_RCC_CAN1_CLK_ENABLED++; + if(HAL_RCC_CAN1_CLK_ENABLED==1){ + __HAL_RCC_CAN1_CLK_ENABLE(); + } - /**CAN1 GPIO Configuration - PB8 ------> CAN1_RX - PB9 ------> CAN1_TX - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8 | GPIO_PIN_9); + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**CAN1 GPIO Configuration + PB8 ------> CAN1_RX + PB9 ------> CAN1_TX + */ + GPIO_InitStruct.Pin = GPIO_PIN_8|GPIO_PIN_9; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_CAN1; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* CAN1 interrupt Init */ + HAL_NVIC_SetPriority(CAN1_RX0_IRQn, 15, 0); + HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn); + /* USER CODE BEGIN CAN1_MspInit 1 */ + + /* USER CODE END CAN1_MspInit 1 */ + } + else if(canHandle->Instance==CAN2) + { + /* USER CODE BEGIN CAN2_MspInit 0 */ + + /* USER CODE END CAN2_MspInit 0 */ + /* CAN2 clock enable */ + __HAL_RCC_CAN2_CLK_ENABLE(); + HAL_RCC_CAN1_CLK_ENABLED++; + if(HAL_RCC_CAN1_CLK_ENABLED==1){ + __HAL_RCC_CAN1_CLK_ENABLE(); + } - /* CAN1 interrupt Deinit */ - HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn); - /* USER CODE BEGIN CAN1_MspDeInit 1 */ + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**CAN2 GPIO Configuration + PB6 ------> CAN2_TX + PB12 ------> CAN2_RX + */ + GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_12; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF9_CAN2; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN CAN2_MspInit 1 */ + + /* USER CODE END CAN2_MspInit 1 */ + } +} - /* USER CODE END CAN1_MspDeInit 1 */ +void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle) +{ + + if(canHandle->Instance==CAN1) + { + /* USER CODE BEGIN CAN1_MspDeInit 0 */ + + /* USER CODE END CAN1_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_CAN1_CLK_DISABLE(); + + /**CAN1 GPIO Configuration + PB8 ------> CAN1_RX + PB9 ------> CAN1_TX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_8|GPIO_PIN_9); + + /* CAN1 interrupt Deinit */ + HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn); + /* USER CODE BEGIN CAN1_MspDeInit 1 */ + + /* USER CODE END CAN1_MspDeInit 1 */ + } + else if(canHandle->Instance==CAN2) + { + /* USER CODE BEGIN CAN2_MspDeInit 0 */ + + /* USER CODE END CAN2_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_CAN2_CLK_DISABLE(); + HAL_RCC_CAN1_CLK_ENABLED--; + if(HAL_RCC_CAN1_CLK_ENABLED==0){ + __HAL_RCC_CAN1_CLK_DISABLE(); } + + /**CAN2 GPIO Configuration + PB6 ------> CAN2_TX + PB12 ------> CAN2_RX + */ + HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_12); + + /* USER CODE BEGIN CAN2_MspDeInit 1 */ + + /* USER CODE END CAN2_MspDeInit 1 */ + } } /* USER CODE BEGIN 1 */ -/* USER CODE END 1 */ \ No newline at end of file +/* USER CODE END 1 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/dma.c b/projects/dashboard/src/platforms/stm32/Core/Src/dma.c index a77b3eb3e..4a597e4a9 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/dma.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/dma.c @@ -35,38 +35,43 @@ DMA_HandleTypeDef hdma_memtomem_dma2_stream0; /** - * Enable DMA controller clock - * Configure DMA for memory to memory transfers - * hdma_memtomem_dma2_stream0 - */ -void MX_DMA_Init(void) { - /* DMA controller clock enable */ - __HAL_RCC_DMA2_CLK_ENABLE(); + * Enable DMA controller clock + * Configure DMA for memory to memory transfers + * hdma_memtomem_dma2_stream0 + */ +void MX_DMA_Init(void) +{ + + /* DMA controller clock enable */ + __HAL_RCC_DMA2_CLK_ENABLE(); - /* Configure DMA request hdma_memtomem_dma2_stream0 on DMA2_Stream0 */ - hdma_memtomem_dma2_stream0.Instance = DMA2_Stream0; - hdma_memtomem_dma2_stream0.Init.Channel = DMA_CHANNEL_0; - hdma_memtomem_dma2_stream0.Init.Direction = DMA_MEMORY_TO_MEMORY; - hdma_memtomem_dma2_stream0.Init.PeriphInc = DMA_PINC_ENABLE; - hdma_memtomem_dma2_stream0.Init.MemInc = DMA_MINC_ENABLE; - hdma_memtomem_dma2_stream0.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; - hdma_memtomem_dma2_stream0.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; - hdma_memtomem_dma2_stream0.Init.Mode = DMA_NORMAL; - hdma_memtomem_dma2_stream0.Init.Priority = DMA_PRIORITY_LOW; - hdma_memtomem_dma2_stream0.Init.FIFOMode = DMA_FIFOMODE_ENABLE; - hdma_memtomem_dma2_stream0.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; - hdma_memtomem_dma2_stream0.Init.MemBurst = DMA_MBURST_SINGLE; - hdma_memtomem_dma2_stream0.Init.PeriphBurst = DMA_PBURST_SINGLE; - if (HAL_DMA_Init(&hdma_memtomem_dma2_stream0) != HAL_OK) { - Error_Handler(); - } + /* Configure DMA request hdma_memtomem_dma2_stream0 on DMA2_Stream0 */ + hdma_memtomem_dma2_stream0.Instance = DMA2_Stream0; + hdma_memtomem_dma2_stream0.Init.Channel = DMA_CHANNEL_0; + hdma_memtomem_dma2_stream0.Init.Direction = DMA_MEMORY_TO_MEMORY; + hdma_memtomem_dma2_stream0.Init.PeriphInc = DMA_PINC_ENABLE; + hdma_memtomem_dma2_stream0.Init.MemInc = DMA_MINC_ENABLE; + hdma_memtomem_dma2_stream0.Init.PeriphDataAlignment = DMA_PDATAALIGN_WORD; + hdma_memtomem_dma2_stream0.Init.MemDataAlignment = DMA_MDATAALIGN_WORD; + hdma_memtomem_dma2_stream0.Init.Mode = DMA_NORMAL; + hdma_memtomem_dma2_stream0.Init.Priority = DMA_PRIORITY_LOW; + hdma_memtomem_dma2_stream0.Init.FIFOMode = DMA_FIFOMODE_ENABLE; + hdma_memtomem_dma2_stream0.Init.FIFOThreshold = DMA_FIFO_THRESHOLD_FULL; + hdma_memtomem_dma2_stream0.Init.MemBurst = DMA_MBURST_SINGLE; + hdma_memtomem_dma2_stream0.Init.PeriphBurst = DMA_PBURST_SINGLE; + if (HAL_DMA_Init(&hdma_memtomem_dma2_stream0) != HAL_OK) + { + Error_Handler(); + } + + /* DMA interrupt init */ + /* DMA2_Stream0_IRQn interrupt configuration */ + HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); - /* DMA interrupt init */ - /* DMA2_Stream0_IRQn interrupt configuration */ - HAL_NVIC_SetPriority(DMA2_Stream0_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(DMA2_Stream0_IRQn); } /* USER CODE BEGIN 2 */ /* USER CODE END 2 */ + diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/dma2d.c b/projects/dashboard/src/platforms/stm32/Core/Src/dma2d.c index 7eed7e35c..cbede7302 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/dma2d.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/dma2d.c @@ -27,64 +27,75 @@ DMA2D_HandleTypeDef hdma2d; /* DMA2D init function */ -void MX_DMA2D_Init(void) { - /* USER CODE BEGIN DMA2D_Init 0 */ - - /* USER CODE END DMA2D_Init 0 */ - - /* USER CODE BEGIN DMA2D_Init 1 */ - - /* USER CODE END DMA2D_Init 1 */ - hdma2d.Instance = DMA2D; - hdma2d.Init.Mode = DMA2D_M2M; - hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB565; - hdma2d.Init.OutputOffset = 0; - hdma2d.LayerCfg[1].InputOffset = 0; - hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565; - hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; - hdma2d.LayerCfg[1].InputAlpha = 0; - if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) { - Error_Handler(); - } - if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN DMA2D_Init 2 */ - - /* USER CODE END DMA2D_Init 2 */ +void MX_DMA2D_Init(void) +{ + + /* USER CODE BEGIN DMA2D_Init 0 */ + + /* USER CODE END DMA2D_Init 0 */ + + /* USER CODE BEGIN DMA2D_Init 1 */ + + /* USER CODE END DMA2D_Init 1 */ + hdma2d.Instance = DMA2D; + hdma2d.Init.Mode = DMA2D_M2M; + hdma2d.Init.ColorMode = DMA2D_OUTPUT_RGB565; + hdma2d.Init.OutputOffset = 0; + hdma2d.LayerCfg[1].InputOffset = 0; + hdma2d.LayerCfg[1].InputColorMode = DMA2D_INPUT_RGB565; + hdma2d.LayerCfg[1].AlphaMode = DMA2D_NO_MODIF_ALPHA; + hdma2d.LayerCfg[1].InputAlpha = 0; + if (HAL_DMA2D_Init(&hdma2d) != HAL_OK) + { + Error_Handler(); + } + if (HAL_DMA2D_ConfigLayer(&hdma2d, 1) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN DMA2D_Init 2 */ + + /* USER CODE END DMA2D_Init 2 */ + } -void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* dma2dHandle) { - if (dma2dHandle->Instance == DMA2D) { - /* USER CODE BEGIN DMA2D_MspInit 0 */ +void HAL_DMA2D_MspInit(DMA2D_HandleTypeDef* dma2dHandle) +{ + + if(dma2dHandle->Instance==DMA2D) + { + /* USER CODE BEGIN DMA2D_MspInit 0 */ - /* USER CODE END DMA2D_MspInit 0 */ - /* DMA2D clock enable */ - __HAL_RCC_DMA2D_CLK_ENABLE(); + /* USER CODE END DMA2D_MspInit 0 */ + /* DMA2D clock enable */ + __HAL_RCC_DMA2D_CLK_ENABLE(); - /* DMA2D interrupt Init */ - HAL_NVIC_SetPriority(DMA2D_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(DMA2D_IRQn); - /* USER CODE BEGIN DMA2D_MspInit 1 */ + /* DMA2D interrupt Init */ + HAL_NVIC_SetPriority(DMA2D_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(DMA2D_IRQn); + /* USER CODE BEGIN DMA2D_MspInit 1 */ - /* USER CODE END DMA2D_MspInit 1 */ - } + /* USER CODE END DMA2D_MspInit 1 */ + } } -void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* dma2dHandle) { - if (dma2dHandle->Instance == DMA2D) { - /* USER CODE BEGIN DMA2D_MspDeInit 0 */ +void HAL_DMA2D_MspDeInit(DMA2D_HandleTypeDef* dma2dHandle) +{ + + if(dma2dHandle->Instance==DMA2D) + { + /* USER CODE BEGIN DMA2D_MspDeInit 0 */ - /* USER CODE END DMA2D_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_DMA2D_CLK_DISABLE(); + /* USER CODE END DMA2D_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_DMA2D_CLK_DISABLE(); - /* DMA2D interrupt Deinit */ - HAL_NVIC_DisableIRQ(DMA2D_IRQn); - /* USER CODE BEGIN DMA2D_MspDeInit 1 */ + /* DMA2D interrupt Deinit */ + HAL_NVIC_DisableIRQ(DMA2D_IRQn); + /* USER CODE BEGIN DMA2D_MspDeInit 1 */ - /* USER CODE END DMA2D_MspDeInit 1 */ - } + /* USER CODE END DMA2D_MspDeInit 1 */ + } } /* USER CODE BEGIN 1 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/dsihost.c b/projects/dashboard/src/platforms/stm32/Core/Src/dsihost.c index e241893dc..96d61a4fe 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/dsihost.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/dsihost.c @@ -28,142 +28,158 @@ DSI_HandleTypeDef hdsi; /* DSIHOST init function */ -void MX_DSIHOST_DSI_Init(void) { - /* USER CODE BEGIN DSIHOST_Init 0 */ - - /* USER CODE END DSIHOST_Init 0 */ - - DSI_PLLInitTypeDef PLLInit = {0}; - DSI_HOST_TimeoutTypeDef HostTimeouts = {0}; - DSI_PHY_TimerTypeDef PhyTimings = {0}; - DSI_VidCfgTypeDef VidCfg = {0}; - - /* USER CODE BEGIN DSIHOST_Init 1 */ - - /* USER CODE END DSIHOST_Init 1 */ - hdsi.Instance = DSI; - hdsi.Init.AutomaticClockLaneControl = DSI_AUTO_CLK_LANE_CTRL_DISABLE; - hdsi.Init.TXEscapeCkdiv = 4; - hdsi.Init.NumberOfLanes = DSI_TWO_DATA_LANES; - PLLInit.PLLNDIV = 125; - PLLInit.PLLIDF = DSI_PLL_IN_DIV2; - PLLInit.PLLODF = DSI_PLL_OUT_DIV1; - if (HAL_DSI_Init(&hdsi, &PLLInit) != HAL_OK) { - Error_Handler(); - } - HostTimeouts.TimeoutCkdiv = 1; - HostTimeouts.HighSpeedTransmissionTimeout = 0; - HostTimeouts.LowPowerReceptionTimeout = 0; - HostTimeouts.HighSpeedReadTimeout = 0; - HostTimeouts.LowPowerReadTimeout = 0; - HostTimeouts.HighSpeedWriteTimeout = 0; - HostTimeouts.HighSpeedWritePrespMode = DSI_HS_PM_DISABLE; - HostTimeouts.LowPowerWriteTimeout = 0; - HostTimeouts.BTATimeout = 0; - if (HAL_DSI_ConfigHostTimeouts(&hdsi, &HostTimeouts) != HAL_OK) { - Error_Handler(); - } - PhyTimings.ClockLaneHS2LPTime = 35; - PhyTimings.ClockLaneLP2HSTime = 35; - PhyTimings.DataLaneHS2LPTime = 35; - PhyTimings.DataLaneLP2HSTime = 35; - PhyTimings.DataLaneMaxReadTime = 0; - PhyTimings.StopWaitTime = 10; - if (HAL_DSI_ConfigPhyTimer(&hdsi, &PhyTimings) != HAL_OK) { - Error_Handler(); - } - if (HAL_DSI_SetLowPowerRXFilter(&hdsi, 10000) != HAL_OK) { - Error_Handler(); - } - if (HAL_DSI_ConfigErrorMonitor(&hdsi, HAL_DSI_ERROR_NONE) != HAL_OK) { - Error_Handler(); - } - VidCfg.VirtualChannelID = 0; - VidCfg.ColorCoding = DSI_RGB888; - VidCfg.LooselyPacked = DSI_LOOSELY_PACKED_DISABLE; - VidCfg.Mode = DSI_VID_MODE_BURST; - VidCfg.PacketSize = 800; - VidCfg.NumberOfChunks = 0; - VidCfg.NullPacketSize = 0; - VidCfg.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; - VidCfg.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; - VidCfg.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; - VidCfg.HorizontalSyncActive = 5; - VidCfg.HorizontalBackPorch = 77; - VidCfg.HorizontalLine = 1982; - VidCfg.VerticalSyncActive = 120; - VidCfg.VerticalBackPorch = 150; - VidCfg.VerticalFrontPorch = 150; - VidCfg.VerticalActive = 480; - VidCfg.LPCommandEnable = DSI_LP_COMMAND_ENABLE; - VidCfg.LPLargestPacketSize = 16; - VidCfg.LPVACTLargestPacketSize = 0; - VidCfg.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; - VidCfg.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; - VidCfg.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; - VidCfg.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; - VidCfg.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; - VidCfg.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; - VidCfg.FrameBTAAcknowledgeEnable = DSI_FBTAA_DISABLE; - if (HAL_DSI_ConfigVideoMode(&hdsi, &VidCfg) != HAL_OK) { - Error_Handler(); - } - if (HAL_DSI_SetGenericVCID(&hdsi, 0) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN DSIHOST_Init 2 */ - - /* USER CODE END DSIHOST_Init 2 */ +void MX_DSIHOST_DSI_Init(void) +{ + + /* USER CODE BEGIN DSIHOST_Init 0 */ + + /* USER CODE END DSIHOST_Init 0 */ + + DSI_PLLInitTypeDef PLLInit = {0}; + DSI_HOST_TimeoutTypeDef HostTimeouts = {0}; + DSI_PHY_TimerTypeDef PhyTimings = {0}; + DSI_VidCfgTypeDef VidCfg = {0}; + + /* USER CODE BEGIN DSIHOST_Init 1 */ + + /* USER CODE END DSIHOST_Init 1 */ + hdsi.Instance = DSI; + hdsi.Init.AutomaticClockLaneControl = DSI_AUTO_CLK_LANE_CTRL_DISABLE; + hdsi.Init.TXEscapeCkdiv = 4; + hdsi.Init.NumberOfLanes = DSI_TWO_DATA_LANES; + PLLInit.PLLNDIV = 125; + PLLInit.PLLIDF = DSI_PLL_IN_DIV2; + PLLInit.PLLODF = DSI_PLL_OUT_DIV1; + if (HAL_DSI_Init(&hdsi, &PLLInit) != HAL_OK) + { + Error_Handler(); + } + HostTimeouts.TimeoutCkdiv = 1; + HostTimeouts.HighSpeedTransmissionTimeout = 0; + HostTimeouts.LowPowerReceptionTimeout = 0; + HostTimeouts.HighSpeedReadTimeout = 0; + HostTimeouts.LowPowerReadTimeout = 0; + HostTimeouts.HighSpeedWriteTimeout = 0; + HostTimeouts.HighSpeedWritePrespMode = DSI_HS_PM_DISABLE; + HostTimeouts.LowPowerWriteTimeout = 0; + HostTimeouts.BTATimeout = 0; + if (HAL_DSI_ConfigHostTimeouts(&hdsi, &HostTimeouts) != HAL_OK) + { + Error_Handler(); + } + PhyTimings.ClockLaneHS2LPTime = 35; + PhyTimings.ClockLaneLP2HSTime = 35; + PhyTimings.DataLaneHS2LPTime = 35; + PhyTimings.DataLaneLP2HSTime = 35; + PhyTimings.DataLaneMaxReadTime = 0; + PhyTimings.StopWaitTime = 10; + if (HAL_DSI_ConfigPhyTimer(&hdsi, &PhyTimings) != HAL_OK) + { + Error_Handler(); + } + if (HAL_DSI_SetLowPowerRXFilter(&hdsi, 10000) != HAL_OK) + { + Error_Handler(); + } + if (HAL_DSI_ConfigErrorMonitor(&hdsi, HAL_DSI_ERROR_NONE) != HAL_OK) + { + Error_Handler(); + } + VidCfg.VirtualChannelID = 0; + VidCfg.ColorCoding = DSI_RGB888; + VidCfg.LooselyPacked = DSI_LOOSELY_PACKED_DISABLE; + VidCfg.Mode = DSI_VID_MODE_BURST; + VidCfg.PacketSize = 800; + VidCfg.NumberOfChunks = 0; + VidCfg.NullPacketSize = 0; + VidCfg.HSPolarity = DSI_HSYNC_ACTIVE_HIGH; + VidCfg.VSPolarity = DSI_VSYNC_ACTIVE_HIGH; + VidCfg.DEPolarity = DSI_DATA_ENABLE_ACTIVE_HIGH; + VidCfg.HorizontalSyncActive = 5; + VidCfg.HorizontalBackPorch = 77; + VidCfg.HorizontalLine = 1982; + VidCfg.VerticalSyncActive = 120; + VidCfg.VerticalBackPorch = 150; + VidCfg.VerticalFrontPorch = 150; + VidCfg.VerticalActive = 480; + VidCfg.LPCommandEnable = DSI_LP_COMMAND_ENABLE; + VidCfg.LPLargestPacketSize = 16; + VidCfg.LPVACTLargestPacketSize = 0; + VidCfg.LPHorizontalFrontPorchEnable = DSI_LP_HFP_ENABLE; + VidCfg.LPHorizontalBackPorchEnable = DSI_LP_HBP_ENABLE; + VidCfg.LPVerticalActiveEnable = DSI_LP_VACT_ENABLE; + VidCfg.LPVerticalFrontPorchEnable = DSI_LP_VFP_ENABLE; + VidCfg.LPVerticalBackPorchEnable = DSI_LP_VBP_ENABLE; + VidCfg.LPVerticalSyncActiveEnable = DSI_LP_VSYNC_ENABLE; + VidCfg.FrameBTAAcknowledgeEnable = DSI_FBTAA_DISABLE; + if (HAL_DSI_ConfigVideoMode(&hdsi, &VidCfg) != HAL_OK) + { + Error_Handler(); + } + if (HAL_DSI_SetGenericVCID(&hdsi, 0) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN DSIHOST_Init 2 */ + + /* USER CODE END DSIHOST_Init 2 */ + } -void HAL_DSI_MspInit(DSI_HandleTypeDef* dsiHandle) { - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if (dsiHandle->Instance == DSI) { - /* USER CODE BEGIN DSI_MspInit 0 */ - - /* USER CODE END DSI_MspInit 0 */ - /* DSI clock enable */ - __HAL_RCC_DSI_CLK_ENABLE(); - - __HAL_RCC_GPIOJ_CLK_ENABLE(); - /**DSIHOST GPIO Configuration - PJ2 ------> DSIHOST_TE - */ - GPIO_InitStruct.Pin = DSI_TE_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF13_DSI; - HAL_GPIO_Init(DSI_TE_GPIO_Port, &GPIO_InitStruct); - - /* DSI interrupt Init */ - HAL_NVIC_SetPriority(DSI_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(DSI_IRQn); - /* USER CODE BEGIN DSI_MspInit 1 */ - - /* USER CODE END DSI_MspInit 1 */ - } +void HAL_DSI_MspInit(DSI_HandleTypeDef* dsiHandle) +{ + + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(dsiHandle->Instance==DSI) + { + /* USER CODE BEGIN DSI_MspInit 0 */ + + /* USER CODE END DSI_MspInit 0 */ + /* DSI clock enable */ + __HAL_RCC_DSI_CLK_ENABLE(); + + __HAL_RCC_GPIOJ_CLK_ENABLE(); + /**DSIHOST GPIO Configuration + PJ2 ------> DSIHOST_TE + */ + GPIO_InitStruct.Pin = DSI_TE_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF13_DSI; + HAL_GPIO_Init(DSI_TE_GPIO_Port, &GPIO_InitStruct); + + /* DSI interrupt Init */ + HAL_NVIC_SetPriority(DSI_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(DSI_IRQn); + /* USER CODE BEGIN DSI_MspInit 1 */ + + /* USER CODE END DSI_MspInit 1 */ + } } -void HAL_DSI_MspDeInit(DSI_HandleTypeDef* dsiHandle) { - if (dsiHandle->Instance == DSI) { - /* USER CODE BEGIN DSI_MspDeInit 0 */ +void HAL_DSI_MspDeInit(DSI_HandleTypeDef* dsiHandle) +{ + + if(dsiHandle->Instance==DSI) + { + /* USER CODE BEGIN DSI_MspDeInit 0 */ - /* USER CODE END DSI_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_DSI_CLK_DISABLE(); + /* USER CODE END DSI_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_DSI_CLK_DISABLE(); - /**DSIHOST GPIO Configuration - PJ2 ------> DSIHOST_TE - */ - HAL_GPIO_DeInit(DSI_TE_GPIO_Port, DSI_TE_Pin); + /**DSIHOST GPIO Configuration + PJ2 ------> DSIHOST_TE + */ + HAL_GPIO_DeInit(DSI_TE_GPIO_Port, DSI_TE_Pin); - /* DSI interrupt Deinit */ - HAL_NVIC_DisableIRQ(DSI_IRQn); - /* USER CODE BEGIN DSI_MspDeInit 1 */ + /* DSI interrupt Deinit */ + HAL_NVIC_DisableIRQ(DSI_IRQn); + /* USER CODE BEGIN DSI_MspDeInit 1 */ - /* USER CODE END DSI_MspDeInit 1 */ - } + /* USER CODE END DSI_MspDeInit 1 */ + } } /* USER CODE BEGIN 1 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/fmc.c b/projects/dashboard/src/platforms/stm32/Core/Src/fmc.c index fe7bf0746..1ae603395 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/fmc.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/fmc.c @@ -28,323 +28,326 @@ SDRAM_HandleTypeDef hsdram1; /* FMC initialization function */ -void MX_FMC_Init(void) { - /* USER CODE BEGIN FMC_Init 0 */ - - /* USER CODE END FMC_Init 0 */ - - FMC_SDRAM_TimingTypeDef SdramTiming = {0}; - - /* USER CODE BEGIN FMC_Init 1 */ - - /* USER CODE END FMC_Init 1 */ - - /** Perform the SDRAM1 memory initialization sequence - */ - hsdram1.Instance = FMC_SDRAM_DEVICE; - /* hsdram1.Init */ - hsdram1.Init.SDBank = FMC_SDRAM_BANK1; - hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; - hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; - hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; - hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; - hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; - hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; - hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; - hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; - hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; - /* SdramTiming */ - SdramTiming.LoadToActiveDelay = 2; - SdramTiming.ExitSelfRefreshDelay = 7; - SdramTiming.SelfRefreshTime = 4; - SdramTiming.RowCycleDelay = 7; - SdramTiming.WriteRecoveryTime = 3; - SdramTiming.RPDelay = 2; - SdramTiming.RCDDelay = 2; - - if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) { - Error_Handler(); - } - - /* USER CODE BEGIN FMC_Init 2 */ - - /* USER CODE END FMC_Init 2 */ +void MX_FMC_Init(void) +{ + /* USER CODE BEGIN FMC_Init 0 */ + + /* USER CODE END FMC_Init 0 */ + + FMC_SDRAM_TimingTypeDef SdramTiming = {0}; + + /* USER CODE BEGIN FMC_Init 1 */ + + /* USER CODE END FMC_Init 1 */ + + /** Perform the SDRAM1 memory initialization sequence + */ + hsdram1.Instance = FMC_SDRAM_DEVICE; + /* hsdram1.Init */ + hsdram1.Init.SDBank = FMC_SDRAM_BANK1; + hsdram1.Init.ColumnBitsNumber = FMC_SDRAM_COLUMN_BITS_NUM_8; + hsdram1.Init.RowBitsNumber = FMC_SDRAM_ROW_BITS_NUM_12; + hsdram1.Init.MemoryDataWidth = FMC_SDRAM_MEM_BUS_WIDTH_32; + hsdram1.Init.InternalBankNumber = FMC_SDRAM_INTERN_BANKS_NUM_4; + hsdram1.Init.CASLatency = FMC_SDRAM_CAS_LATENCY_3; + hsdram1.Init.WriteProtection = FMC_SDRAM_WRITE_PROTECTION_DISABLE; + hsdram1.Init.SDClockPeriod = FMC_SDRAM_CLOCK_PERIOD_2; + hsdram1.Init.ReadBurst = FMC_SDRAM_RBURST_ENABLE; + hsdram1.Init.ReadPipeDelay = FMC_SDRAM_RPIPE_DELAY_0; + /* SdramTiming */ + SdramTiming.LoadToActiveDelay = 2; + SdramTiming.ExitSelfRefreshDelay = 7; + SdramTiming.SelfRefreshTime = 4; + SdramTiming.RowCycleDelay = 7; + SdramTiming.WriteRecoveryTime = 3; + SdramTiming.RPDelay = 2; + SdramTiming.RCDDelay = 2; + + if (HAL_SDRAM_Init(&hsdram1, &SdramTiming) != HAL_OK) + { + Error_Handler( ); + } + + /* USER CODE BEGIN FMC_Init 2 */ + + /* USER CODE END FMC_Init 2 */ } static uint32_t FMC_Initialized = 0; -static void HAL_FMC_MspInit(void) { - /* USER CODE BEGIN FMC_MspInit 0 */ - - /* USER CODE END FMC_MspInit 0 */ - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if (FMC_Initialized) { - return; - } - FMC_Initialized = 1; - - /* Peripheral clock enable */ - __HAL_RCC_FMC_CLK_ENABLE(); - - /** FMC GPIO Configuration - PE1 ------> FMC_NBL1 - PE0 ------> FMC_NBL0 - PG15 ------> FMC_SDNCAS - PD0 ------> FMC_D2 - PI4 ------> FMC_NBL2 - PD1 ------> FMC_D3 - PI3 ------> FMC_D27 - PI2 ------> FMC_D26 - PF0 ------> FMC_A0 - PI5 ------> FMC_NBL3 - PI7 ------> FMC_D29 - PI10 ------> FMC_D31 - PI6 ------> FMC_D28 - PH15 ------> FMC_D23 - PI1 ------> FMC_D25 - PF1 ------> FMC_A1 - PI9 ------> FMC_D30 - PH13 ------> FMC_D21 - PH14 ------> FMC_D22 - PI0 ------> FMC_D24 - PF2 ------> FMC_A2 - PF3 ------> FMC_A3 - PG8 ------> FMC_SDCLK - PF4 ------> FMC_A4 - PH3 ------> FMC_SDNE0 - PF5 ------> FMC_A5 - PH2 ------> FMC_SDCKE0 - PD15 ------> FMC_D1 - PD10 ------> FMC_D15 - PD14 ------> FMC_D0 - PD9 ------> FMC_D14 - PD8 ------> FMC_D13 - PC0 ------> FMC_SDNWE - PF12 ------> FMC_A6 - PG1 ------> FMC_A11 - PF15 ------> FMC_A9 - PH12 ------> FMC_D20 - PF13 ------> FMC_A7 - PG0 ------> FMC_A10 - PE8 ------> FMC_D5 - PG5 ------> FMC_BA1 - PG4 ------> FMC_BA0 - PH9 ------> FMC_D17 - PH11 ------> FMC_D19 - PF14 ------> FMC_A8 - PF11 ------> FMC_SDNRAS - PE9 ------> FMC_D6 - PE11 ------> FMC_D8 - PE14 ------> FMC_D11 - PH8 ------> FMC_D16 - PH10 ------> FMC_D18 - PE7 ------> FMC_D4 - PE10 ------> FMC_D7 - PE12 ------> FMC_D9 - PE15 ------> FMC_D12 - PE13 ------> FMC_D10 - */ - /* GPIO_InitStruct */ - GPIO_InitStruct.Pin = FMC_NBL1_Pin | FMC_NBL0_Pin | D5_Pin | D6_Pin | - D8_Pin | D11_Pin | D4_Pin | D7_Pin | D9_Pin | - D12_Pin | D10_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - - HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); - - /* GPIO_InitStruct */ - GPIO_InitStruct.Pin = - SDNCAS_Pin | SDCLK_Pin | A11_Pin | A10_Pin | GPIO_PIN_5 | GPIO_PIN_4; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - - HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); - - /* GPIO_InitStruct */ - GPIO_InitStruct.Pin = - D2_Pin | D3_Pin | D1_Pin | D15_Pin | D0_Pin | D14_Pin | D13_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /* GPIO_InitStruct */ - GPIO_InitStruct.Pin = FMC_NBL2_Pin | D27_Pin | D26_Pin | FMC_NBL3_Pin | - D29_Pin | D31_Pin | D28_Pin | D25_Pin | D30_Pin | - D24_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - - HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); - - /* GPIO_InitStruct */ - GPIO_InitStruct.Pin = A0_Pin | A1_Pin | A2_Pin | A3_Pin | A4_Pin | A5_Pin | - A6_Pin | A9_Pin | A7_Pin | A8_Pin | - SDNMT48LC4M32B2B5_6A_RAS_RAS___Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - - HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); - - /* GPIO_InitStruct */ - GPIO_InitStruct.Pin = D23_Pin | D21_Pin | D22_Pin | SDNE0_Pin | SDCKE0_Pin | - D20_Pin | D17_Pin | D19_Pin | D16_Pin | D18_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - - HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); - - /* GPIO_InitStruct */ - GPIO_InitStruct.Pin = SDNWE_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_FMC; - - HAL_GPIO_Init(SDNWE_GPIO_Port, &GPIO_InitStruct); - - /* USER CODE BEGIN FMC_MspInit 1 */ - - /* USER CODE END FMC_MspInit 1 */ +static void HAL_FMC_MspInit(void){ + /* USER CODE BEGIN FMC_MspInit 0 */ + + /* USER CODE END FMC_MspInit 0 */ + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if (FMC_Initialized) { + return; + } + FMC_Initialized = 1; + + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_ENABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI4 ------> FMC_NBL2 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PF0 ------> FMC_A0 + PI5 ------> FMC_NBL3 + PI7 ------> FMC_D29 + PI10 ------> FMC_D31 + PI6 ------> FMC_D28 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF1 ------> FMC_A1 + PI9 ------> FMC_D30 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PG8 ------> FMC_SDCLK + PF4 ------> FMC_A4 + PH3 ------> FMC_SDNE0 + PF5 ------> FMC_A5 + PH2 ------> FMC_SDCKE0 + PD15 ------> FMC_D1 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PC0 ------> FMC_SDNWE + PF12 ------> FMC_A6 + PG1 ------> FMC_A11 + PF15 ------> FMC_A9 + PH12 ------> FMC_D20 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE8 ------> FMC_D5 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH9 ------> FMC_D17 + PH11 ------> FMC_D19 + PF14 ------> FMC_A8 + PF11 ------> FMC_SDNRAS + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PH8 ------> FMC_D16 + PH10 ------> FMC_D18 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + PE13 ------> FMC_D10 + */ + /* GPIO_InitStruct */ + GPIO_InitStruct.Pin = FMC_NBL1_Pin|FMC_NBL0_Pin|D5_Pin|D6_Pin + |D8_Pin|D11_Pin|D4_Pin|D7_Pin + |D9_Pin|D12_Pin|D10_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + + HAL_GPIO_Init(GPIOE, &GPIO_InitStruct); + + /* GPIO_InitStruct */ + GPIO_InitStruct.Pin = SDNCAS_Pin|SDCLK_Pin|A11_Pin|A10_Pin + |GPIO_PIN_5|GPIO_PIN_4; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + + HAL_GPIO_Init(GPIOG, &GPIO_InitStruct); + + /* GPIO_InitStruct */ + GPIO_InitStruct.Pin = D2_Pin|D3_Pin|D1_Pin|D15_Pin + |D0_Pin|D14_Pin|D13_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /* GPIO_InitStruct */ + GPIO_InitStruct.Pin = FMC_NBL2_Pin|D27_Pin|D26_Pin|FMC_NBL3_Pin + |D29_Pin|D31_Pin|D28_Pin|D25_Pin + |D30_Pin|D24_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + + HAL_GPIO_Init(GPIOI, &GPIO_InitStruct); + + /* GPIO_InitStruct */ + GPIO_InitStruct.Pin = A0_Pin|A1_Pin|A2_Pin|A3_Pin + |A4_Pin|A5_Pin|A6_Pin|A9_Pin + |A7_Pin|A8_Pin|SDNMT48LC4M32B2B5_6A_RAS_RAS___Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + + HAL_GPIO_Init(GPIOF, &GPIO_InitStruct); + + /* GPIO_InitStruct */ + GPIO_InitStruct.Pin = D23_Pin|D21_Pin|D22_Pin|SDNE0_Pin + |SDCKE0_Pin|D20_Pin|D17_Pin|D19_Pin + |D16_Pin|D18_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + + /* GPIO_InitStruct */ + GPIO_InitStruct.Pin = SDNWE_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_FMC; + + HAL_GPIO_Init(SDNWE_GPIO_Port, &GPIO_InitStruct); + + /* USER CODE BEGIN FMC_MspInit 1 */ + + /* USER CODE END FMC_MspInit 1 */ } -void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* sdramHandle) { - /* USER CODE BEGIN SDRAM_MspInit 0 */ +void HAL_SDRAM_MspInit(SDRAM_HandleTypeDef* sdramHandle){ + /* USER CODE BEGIN SDRAM_MspInit 0 */ - /* USER CODE END SDRAM_MspInit 0 */ - HAL_FMC_MspInit(); - /* USER CODE BEGIN SDRAM_MspInit 1 */ + /* USER CODE END SDRAM_MspInit 0 */ + HAL_FMC_MspInit(); + /* USER CODE BEGIN SDRAM_MspInit 1 */ - /* USER CODE END SDRAM_MspInit 1 */ + /* USER CODE END SDRAM_MspInit 1 */ } static uint32_t FMC_DeInitialized = 0; -static void HAL_FMC_MspDeInit(void) { - /* USER CODE BEGIN FMC_MspDeInit 0 */ - - /* USER CODE END FMC_MspDeInit 0 */ - if (FMC_DeInitialized) { - return; - } - FMC_DeInitialized = 1; - /* Peripheral clock enable */ - __HAL_RCC_FMC_CLK_DISABLE(); - - /** FMC GPIO Configuration - PE1 ------> FMC_NBL1 - PE0 ------> FMC_NBL0 - PG15 ------> FMC_SDNCAS - PD0 ------> FMC_D2 - PI4 ------> FMC_NBL2 - PD1 ------> FMC_D3 - PI3 ------> FMC_D27 - PI2 ------> FMC_D26 - PF0 ------> FMC_A0 - PI5 ------> FMC_NBL3 - PI7 ------> FMC_D29 - PI10 ------> FMC_D31 - PI6 ------> FMC_D28 - PH15 ------> FMC_D23 - PI1 ------> FMC_D25 - PF1 ------> FMC_A1 - PI9 ------> FMC_D30 - PH13 ------> FMC_D21 - PH14 ------> FMC_D22 - PI0 ------> FMC_D24 - PF2 ------> FMC_A2 - PF3 ------> FMC_A3 - PG8 ------> FMC_SDCLK - PF4 ------> FMC_A4 - PH3 ------> FMC_SDNE0 - PF5 ------> FMC_A5 - PH2 ------> FMC_SDCKE0 - PD15 ------> FMC_D1 - PD10 ------> FMC_D15 - PD14 ------> FMC_D0 - PD9 ------> FMC_D14 - PD8 ------> FMC_D13 - PC0 ------> FMC_SDNWE - PF12 ------> FMC_A6 - PG1 ------> FMC_A11 - PF15 ------> FMC_A9 - PH12 ------> FMC_D20 - PF13 ------> FMC_A7 - PG0 ------> FMC_A10 - PE8 ------> FMC_D5 - PG5 ------> FMC_BA1 - PG4 ------> FMC_BA0 - PH9 ------> FMC_D17 - PH11 ------> FMC_D19 - PF14 ------> FMC_A8 - PF11 ------> FMC_SDNRAS - PE9 ------> FMC_D6 - PE11 ------> FMC_D8 - PE14 ------> FMC_D11 - PH8 ------> FMC_D16 - PH10 ------> FMC_D18 - PE7 ------> FMC_D4 - PE10 ------> FMC_D7 - PE12 ------> FMC_D9 - PE15 ------> FMC_D12 - PE13 ------> FMC_D10 - */ - - HAL_GPIO_DeInit(GPIOE, FMC_NBL1_Pin | FMC_NBL0_Pin | D5_Pin | D6_Pin | - D8_Pin | D11_Pin | D4_Pin | D7_Pin | D9_Pin | - D12_Pin | D10_Pin); - - HAL_GPIO_DeInit(GPIOG, SDNCAS_Pin | SDCLK_Pin | A11_Pin | A10_Pin | - GPIO_PIN_5 | GPIO_PIN_4); - - HAL_GPIO_DeInit( - GPIOD, D2_Pin | D3_Pin | D1_Pin | D15_Pin | D0_Pin | D14_Pin | D13_Pin); - - HAL_GPIO_DeInit(GPIOI, FMC_NBL2_Pin | D27_Pin | D26_Pin | FMC_NBL3_Pin | - D29_Pin | D31_Pin | D28_Pin | D25_Pin | D30_Pin | - D24_Pin); - - HAL_GPIO_DeInit(GPIOF, A0_Pin | A1_Pin | A2_Pin | A3_Pin | A4_Pin | A5_Pin | - A6_Pin | A9_Pin | A7_Pin | A8_Pin | - SDNMT48LC4M32B2B5_6A_RAS_RAS___Pin); - - HAL_GPIO_DeInit(GPIOH, D23_Pin | D21_Pin | D22_Pin | SDNE0_Pin | - SDCKE0_Pin | D20_Pin | D17_Pin | D19_Pin | - D16_Pin | D18_Pin); - - HAL_GPIO_DeInit(SDNWE_GPIO_Port, SDNWE_Pin); - - /* USER CODE BEGIN FMC_MspDeInit 1 */ - - /* USER CODE END FMC_MspDeInit 1 */ +static void HAL_FMC_MspDeInit(void){ + /* USER CODE BEGIN FMC_MspDeInit 0 */ + + /* USER CODE END FMC_MspDeInit 0 */ + if (FMC_DeInitialized) { + return; + } + FMC_DeInitialized = 1; + /* Peripheral clock enable */ + __HAL_RCC_FMC_CLK_DISABLE(); + + /** FMC GPIO Configuration + PE1 ------> FMC_NBL1 + PE0 ------> FMC_NBL0 + PG15 ------> FMC_SDNCAS + PD0 ------> FMC_D2 + PI4 ------> FMC_NBL2 + PD1 ------> FMC_D3 + PI3 ------> FMC_D27 + PI2 ------> FMC_D26 + PF0 ------> FMC_A0 + PI5 ------> FMC_NBL3 + PI7 ------> FMC_D29 + PI10 ------> FMC_D31 + PI6 ------> FMC_D28 + PH15 ------> FMC_D23 + PI1 ------> FMC_D25 + PF1 ------> FMC_A1 + PI9 ------> FMC_D30 + PH13 ------> FMC_D21 + PH14 ------> FMC_D22 + PI0 ------> FMC_D24 + PF2 ------> FMC_A2 + PF3 ------> FMC_A3 + PG8 ------> FMC_SDCLK + PF4 ------> FMC_A4 + PH3 ------> FMC_SDNE0 + PF5 ------> FMC_A5 + PH2 ------> FMC_SDCKE0 + PD15 ------> FMC_D1 + PD10 ------> FMC_D15 + PD14 ------> FMC_D0 + PD9 ------> FMC_D14 + PD8 ------> FMC_D13 + PC0 ------> FMC_SDNWE + PF12 ------> FMC_A6 + PG1 ------> FMC_A11 + PF15 ------> FMC_A9 + PH12 ------> FMC_D20 + PF13 ------> FMC_A7 + PG0 ------> FMC_A10 + PE8 ------> FMC_D5 + PG5 ------> FMC_BA1 + PG4 ------> FMC_BA0 + PH9 ------> FMC_D17 + PH11 ------> FMC_D19 + PF14 ------> FMC_A8 + PF11 ------> FMC_SDNRAS + PE9 ------> FMC_D6 + PE11 ------> FMC_D8 + PE14 ------> FMC_D11 + PH8 ------> FMC_D16 + PH10 ------> FMC_D18 + PE7 ------> FMC_D4 + PE10 ------> FMC_D7 + PE12 ------> FMC_D9 + PE15 ------> FMC_D12 + PE13 ------> FMC_D10 + */ + + HAL_GPIO_DeInit(GPIOE, FMC_NBL1_Pin|FMC_NBL0_Pin|D5_Pin|D6_Pin + |D8_Pin|D11_Pin|D4_Pin|D7_Pin + |D9_Pin|D12_Pin|D10_Pin); + + HAL_GPIO_DeInit(GPIOG, SDNCAS_Pin|SDCLK_Pin|A11_Pin|A10_Pin + |GPIO_PIN_5|GPIO_PIN_4); + + HAL_GPIO_DeInit(GPIOD, D2_Pin|D3_Pin|D1_Pin|D15_Pin + |D0_Pin|D14_Pin|D13_Pin); + + HAL_GPIO_DeInit(GPIOI, FMC_NBL2_Pin|D27_Pin|D26_Pin|FMC_NBL3_Pin + |D29_Pin|D31_Pin|D28_Pin|D25_Pin + |D30_Pin|D24_Pin); + + HAL_GPIO_DeInit(GPIOF, A0_Pin|A1_Pin|A2_Pin|A3_Pin + |A4_Pin|A5_Pin|A6_Pin|A9_Pin + |A7_Pin|A8_Pin|SDNMT48LC4M32B2B5_6A_RAS_RAS___Pin); + + HAL_GPIO_DeInit(GPIOH, D23_Pin|D21_Pin|D22_Pin|SDNE0_Pin + |SDCKE0_Pin|D20_Pin|D17_Pin|D19_Pin + |D16_Pin|D18_Pin); + + HAL_GPIO_DeInit(SDNWE_GPIO_Port, SDNWE_Pin); + + /* USER CODE BEGIN FMC_MspDeInit 1 */ + + /* USER CODE END FMC_MspDeInit 1 */ } -void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* sdramHandle) { - /* USER CODE BEGIN SDRAM_MspDeInit 0 */ +void HAL_SDRAM_MspDeInit(SDRAM_HandleTypeDef* sdramHandle){ + /* USER CODE BEGIN SDRAM_MspDeInit 0 */ - /* USER CODE END SDRAM_MspDeInit 0 */ - HAL_FMC_MspDeInit(); - /* USER CODE BEGIN SDRAM_MspDeInit 1 */ + /* USER CODE END SDRAM_MspDeInit 0 */ + HAL_FMC_MspDeInit(); + /* USER CODE BEGIN SDRAM_MspDeInit 1 */ - /* USER CODE END SDRAM_MspDeInit 1 */ + /* USER CODE END SDRAM_MspDeInit 1 */ } /** - * @} - */ + * @} + */ /** - * @} - */ + * @} + */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/gpio.c b/projects/dashboard/src/platforms/stm32/Core/Src/gpio.c index 8003d0d27..f8077b8b6 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/gpio.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/gpio.c @@ -37,120 +37,122 @@ PC12 ------> SDIO_CK PG9 ------> USART6_RX */ -void MX_GPIO_Init(void) { - GPIO_InitTypeDef GPIO_InitStruct = {0}; - - /* GPIO Ports Clock Enable */ - __HAL_RCC_GPIOE_CLK_ENABLE(); - __HAL_RCC_GPIOB_CLK_ENABLE(); - __HAL_RCC_GPIOC_CLK_ENABLE(); - __HAL_RCC_GPIOA_CLK_ENABLE(); - __HAL_RCC_GPIOG_CLK_ENABLE(); - __HAL_RCC_GPIOD_CLK_ENABLE(); - __HAL_RCC_GPIOI_CLK_ENABLE(); - __HAL_RCC_GPIOF_CLK_ENABLE(); - __HAL_RCC_GPIOK_CLK_ENABLE(); - __HAL_RCC_GPIOH_CLK_ENABLE(); - __HAL_RCC_GPIOJ_CLK_ENABLE(); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOD, LED3_Pin | LED2_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOB, OTG_FS1_PowerSwitchOn_Pin | EXT_RESET_Pin, - GPIO_PIN_RESET); - - /*Configure GPIO pin Output Level */ - HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET); - - /*Configure GPIO pin : I2S3_CK_Pin */ - GPIO_InitStruct.Pin = I2S3_CK_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; - HAL_GPIO_Init(I2S3_CK_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : uSD_CLK_Pin */ - GPIO_InitStruct.Pin = uSD_CLK_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; - HAL_GPIO_Init(uSD_CLK_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : OTG_FS1_OverCurrent_Pin */ - GPIO_InitStruct.Pin = OTG_FS1_OverCurrent_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(OTG_FS1_OverCurrent_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : LED3_Pin LED2_Pin */ - GPIO_InitStruct.Pin = LED3_Pin | LED2_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); - - /*Configure GPIO pin : LED4_Pin */ - GPIO_InitStruct.Pin = LED4_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED4_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : USART6_RX_Pin */ - GPIO_InitStruct.Pin = USART6_RX_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF8_USART6; - HAL_GPIO_Init(USART6_RX_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : LED1_Pin */ - GPIO_InitStruct.Pin = LED1_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pins : OTG_FS1_PowerSwitchOn_Pin EXT_RESET_Pin */ - GPIO_InitStruct.Pin = OTG_FS1_PowerSwitchOn_Pin | EXT_RESET_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /*Configure GPIO pin : LCD_INT_Pin */ - GPIO_InitStruct.Pin = LCD_INT_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; - GPIO_InitStruct.Pull = GPIO_NOPULL; - HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct); - - /*Configure GPIO pin : PA0 */ - GPIO_InitStruct.Pin = GPIO_PIN_0; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); - - /*Configure GPIO pins : BUTTON_SCROLL_Pin BUTTON_SELECT_Pin */ - GPIO_InitStruct.Pin = BUTTON_SCROLL_Pin | BUTTON_SELECT_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_INPUT; - GPIO_InitStruct.Pull = GPIO_PULLDOWN; - HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); - - /*Configure GPIO pin : PH7 */ - GPIO_InitStruct.Pin = GPIO_PIN_7; - GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; - HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); +void MX_GPIO_Init(void) +{ + + GPIO_InitTypeDef GPIO_InitStruct = {0}; + + /* GPIO Ports Clock Enable */ + __HAL_RCC_GPIOE_CLK_ENABLE(); + __HAL_RCC_GPIOB_CLK_ENABLE(); + __HAL_RCC_GPIOC_CLK_ENABLE(); + __HAL_RCC_GPIOA_CLK_ENABLE(); + __HAL_RCC_GPIOG_CLK_ENABLE(); + __HAL_RCC_GPIOD_CLK_ENABLE(); + __HAL_RCC_GPIOI_CLK_ENABLE(); + __HAL_RCC_GPIOF_CLK_ENABLE(); + __HAL_RCC_GPIOK_CLK_ENABLE(); + __HAL_RCC_GPIOH_CLK_ENABLE(); + __HAL_RCC_GPIOJ_CLK_ENABLE(); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOD, LED3_Pin|LED2_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(LED4_GPIO_Port, LED4_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(LED1_GPIO_Port, LED1_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOB, OTG_FS1_PowerSwitchOn_Pin|EXT_RESET_Pin, GPIO_PIN_RESET); + + /*Configure GPIO pin Output Level */ + HAL_GPIO_WritePin(GPIOH, GPIO_PIN_7, GPIO_PIN_RESET); + + /*Configure GPIO pin : I2S3_CK_Pin */ + GPIO_InitStruct.Pin = I2S3_CK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Alternate = GPIO_AF6_SPI3; + HAL_GPIO_Init(I2S3_CK_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : uSD_CLK_Pin */ + GPIO_InitStruct.Pin = uSD_CLK_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF12_SDIO; + HAL_GPIO_Init(uSD_CLK_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : OTG_FS1_OverCurrent_Pin */ + GPIO_InitStruct.Pin = OTG_FS1_OverCurrent_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(OTG_FS1_OverCurrent_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : LED3_Pin LED2_Pin */ + GPIO_InitStruct.Pin = LED3_Pin|LED2_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOD, &GPIO_InitStruct); + + /*Configure GPIO pin : LED4_Pin */ + GPIO_InitStruct.Pin = LED4_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED4_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : USART6_RX_Pin */ + GPIO_InitStruct.Pin = USART6_RX_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF8_USART6; + HAL_GPIO_Init(USART6_RX_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : LED1_Pin */ + GPIO_InitStruct.Pin = LED1_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_OD; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(LED1_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pins : OTG_FS1_PowerSwitchOn_Pin EXT_RESET_Pin */ + GPIO_InitStruct.Pin = OTG_FS1_PowerSwitchOn_Pin|EXT_RESET_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /*Configure GPIO pin : LCD_INT_Pin */ + GPIO_InitStruct.Pin = LCD_INT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_IT_RISING; + GPIO_InitStruct.Pull = GPIO_NOPULL; + HAL_GPIO_Init(LCD_INT_GPIO_Port, &GPIO_InitStruct); + + /*Configure GPIO pin : PA0 */ + GPIO_InitStruct.Pin = GPIO_PIN_0; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + HAL_GPIO_Init(GPIOA, &GPIO_InitStruct); + + /*Configure GPIO pins : BUTTON_SCROLL_Pin BUTTON_SELECT_Pin */ + GPIO_InitStruct.Pin = BUTTON_SCROLL_Pin|BUTTON_SELECT_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_INPUT; + GPIO_InitStruct.Pull = GPIO_PULLDOWN; + HAL_GPIO_Init(GPIOC, &GPIO_InitStruct); + + /*Configure GPIO pin : PH7 */ + GPIO_InitStruct.Pin = GPIO_PIN_7; + GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP; + GPIO_InitStruct.Pull = GPIO_NOPULL; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW; + HAL_GPIO_Init(GPIOH, &GPIO_InitStruct); + } /* USER CODE BEGIN 2 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/ltdc.c b/projects/dashboard/src/platforms/stm32/Core/Src/ltdc.c index c2ef6803e..62bf4b7b3 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/ltdc.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/ltdc.c @@ -27,101 +27,113 @@ LTDC_HandleTypeDef hltdc; /* LTDC init function */ -void MX_LTDC_Init(void) { - /* USER CODE BEGIN LTDC_Init 0 */ - - /* USER CODE END LTDC_Init 0 */ - - LTDC_LayerCfgTypeDef pLayerCfg = {0}; - - /* USER CODE BEGIN LTDC_Init 1 */ - - /* USER CODE END LTDC_Init 1 */ - hltdc.Instance = LTDC; - hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AH; - hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AH; - hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; - hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; - hltdc.Init.HorizontalSync = 1; - hltdc.Init.VerticalSync = 119; - hltdc.Init.AccumulatedHBP = 35; - hltdc.Init.AccumulatedVBP = 269; - hltdc.Init.AccumulatedActiveW = 835; - hltdc.Init.AccumulatedActiveH = 749; - hltdc.Init.TotalWidth = 869; - hltdc.Init.TotalHeigh = 899; - hltdc.Init.Backcolor.Blue = 0; - hltdc.Init.Backcolor.Green = 0; - hltdc.Init.Backcolor.Red = 0; - if (HAL_LTDC_Init(&hltdc) != HAL_OK) { - Error_Handler(); - } - pLayerCfg.WindowX0 = 0; - pLayerCfg.WindowX1 = 800; - pLayerCfg.WindowY0 = 0; - pLayerCfg.WindowY1 = 480; - pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; - pLayerCfg.Alpha = 255; - pLayerCfg.Alpha0 = 0; - pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; - pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; - pLayerCfg.FBStartAdress = 0xC0000000; - pLayerCfg.ImageWidth = 800; - pLayerCfg.ImageHeight = 480; - pLayerCfg.Backcolor.Blue = 0; - pLayerCfg.Backcolor.Green = 0; - pLayerCfg.Backcolor.Red = 0; - if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN LTDC_Init 2 */ +void MX_LTDC_Init(void) +{ + + /* USER CODE BEGIN LTDC_Init 0 */ + + /* USER CODE END LTDC_Init 0 */ + + LTDC_LayerCfgTypeDef pLayerCfg = {0}; + + /* USER CODE BEGIN LTDC_Init 1 */ + + /* USER CODE END LTDC_Init 1 */ + hltdc.Instance = LTDC; + hltdc.Init.HSPolarity = LTDC_HSPOLARITY_AH; + hltdc.Init.VSPolarity = LTDC_VSPOLARITY_AH; + hltdc.Init.DEPolarity = LTDC_DEPOLARITY_AL; + hltdc.Init.PCPolarity = LTDC_PCPOLARITY_IPC; + hltdc.Init.HorizontalSync = 1; + hltdc.Init.VerticalSync = 119; + hltdc.Init.AccumulatedHBP = 35; + hltdc.Init.AccumulatedVBP = 269; + hltdc.Init.AccumulatedActiveW = 835; + hltdc.Init.AccumulatedActiveH = 749; + hltdc.Init.TotalWidth = 869; + hltdc.Init.TotalHeigh = 899; + hltdc.Init.Backcolor.Blue = 0; + hltdc.Init.Backcolor.Green = 0; + hltdc.Init.Backcolor.Red = 0; + if (HAL_LTDC_Init(&hltdc) != HAL_OK) + { + Error_Handler(); + } + pLayerCfg.WindowX0 = 0; + pLayerCfg.WindowX1 = 800; + pLayerCfg.WindowY0 = 0; + pLayerCfg.WindowY1 = 480; + pLayerCfg.PixelFormat = LTDC_PIXEL_FORMAT_RGB565; + pLayerCfg.Alpha = 255; + pLayerCfg.Alpha0 = 0; + pLayerCfg.BlendingFactor1 = LTDC_BLENDING_FACTOR1_PAxCA; + pLayerCfg.BlendingFactor2 = LTDC_BLENDING_FACTOR2_PAxCA; + pLayerCfg.FBStartAdress = 0xC0000000; + pLayerCfg.ImageWidth = 800; + pLayerCfg.ImageHeight = 480; + pLayerCfg.Backcolor.Blue = 0; + pLayerCfg.Backcolor.Green = 0; + pLayerCfg.Backcolor.Red = 0; + if (HAL_LTDC_ConfigLayer(&hltdc, &pLayerCfg, 0) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN LTDC_Init 2 */ + + /* USER CODE END LTDC_Init 2 */ - /* USER CODE END LTDC_Init 2 */ } -void HAL_LTDC_MspInit(LTDC_HandleTypeDef* ltdcHandle) { - RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; - if (ltdcHandle->Instance == LTDC) { - /* USER CODE BEGIN LTDC_MspInit 0 */ - - /* USER CODE END LTDC_MspInit 0 */ - - /** Initializes the peripherals clock - */ - PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; - PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; - PeriphClkInitStruct.PLLSAI.PLLSAIR = 7; - PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; - if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) { - Error_Handler(); - } +void HAL_LTDC_MspInit(LTDC_HandleTypeDef* ltdcHandle) +{ + + RCC_PeriphCLKInitTypeDef PeriphClkInitStruct = {0}; + if(ltdcHandle->Instance==LTDC) + { + /* USER CODE BEGIN LTDC_MspInit 0 */ + + /* USER CODE END LTDC_MspInit 0 */ + + /** Initializes the peripherals clock + */ + PeriphClkInitStruct.PeriphClockSelection = RCC_PERIPHCLK_LTDC; + PeriphClkInitStruct.PLLSAI.PLLSAIN = 384; + PeriphClkInitStruct.PLLSAI.PLLSAIR = 7; + PeriphClkInitStruct.PLLSAIDivR = RCC_PLLSAIDIVR_2; + if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInitStruct) != HAL_OK) + { + Error_Handler(); + } - /* LTDC clock enable */ - __HAL_RCC_LTDC_CLK_ENABLE(); + /* LTDC clock enable */ + __HAL_RCC_LTDC_CLK_ENABLE(); - /* LTDC interrupt Init */ - HAL_NVIC_SetPriority(LTDC_IRQn, 0, 0); - HAL_NVIC_EnableIRQ(LTDC_IRQn); - /* USER CODE BEGIN LTDC_MspInit 1 */ + /* LTDC interrupt Init */ + HAL_NVIC_SetPriority(LTDC_IRQn, 0, 0); + HAL_NVIC_EnableIRQ(LTDC_IRQn); + /* USER CODE BEGIN LTDC_MspInit 1 */ - /* USER CODE END LTDC_MspInit 1 */ - } + /* USER CODE END LTDC_MspInit 1 */ + } } -void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* ltdcHandle) { - if (ltdcHandle->Instance == LTDC) { - /* USER CODE BEGIN LTDC_MspDeInit 0 */ +void HAL_LTDC_MspDeInit(LTDC_HandleTypeDef* ltdcHandle) +{ - /* USER CODE END LTDC_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_LTDC_CLK_DISABLE(); + if(ltdcHandle->Instance==LTDC) + { + /* USER CODE BEGIN LTDC_MspDeInit 0 */ - /* LTDC interrupt Deinit */ - HAL_NVIC_DisableIRQ(LTDC_IRQn); - /* USER CODE BEGIN LTDC_MspDeInit 1 */ + /* USER CODE END LTDC_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_LTDC_CLK_DISABLE(); - /* USER CODE END LTDC_MspDeInit 1 */ - } + /* LTDC interrupt Deinit */ + HAL_NVIC_DisableIRQ(LTDC_IRQn); + /* USER CODE BEGIN LTDC_MspDeInit 1 */ + + /* USER CODE END LTDC_MspDeInit 1 */ + } } /* USER CODE BEGIN 1 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/main.c b/projects/dashboard/src/platforms/stm32/Core/Src/main.c index 4eee8b2f6..a9e92428c 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/main.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/main.c @@ -18,15 +18,14 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ #include "main.h" - #include "can.h" #include "dma.h" #include "dma2d.h" #include "dsihost.h" -#include "fmc.h" -#include "gpio.h" #include "ltdc.h" #include "usart.h" +#include "gpio.h" +#include "fmc.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ @@ -66,57 +65,61 @@ void SystemClock_Config(void); /* USER CODE END 0 */ /** - * @brief The application entry point. - * @retval int - */ + * @brief The application entry point. + * @retval int + */ /** - * @brief System Clock Configuration - * @retval None - */ -void SystemClock_Config(void) { - RCC_OscInitTypeDef RCC_OscInitStruct = {0}; - RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; - - /** Configure the main internal regulator output voltage - */ - __HAL_RCC_PWR_CLK_ENABLE(); - __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); - - /** Initializes the RCC Oscillators according to the specified parameters - * in the RCC_OscInitTypeDef structure. - */ - RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; - RCC_OscInitStruct.HSEState = RCC_HSE_ON; - RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; - RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; - RCC_OscInitStruct.PLL.PLLM = 8; - RCC_OscInitStruct.PLL.PLLN = 360; - RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; - RCC_OscInitStruct.PLL.PLLQ = 6; - RCC_OscInitStruct.PLL.PLLR = 6; - if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) { - Error_Handler(); - } - - /** Activate the Over-Drive mode - */ - if (HAL_PWREx_EnableOverDrive() != HAL_OK) { - Error_Handler(); - } - - /** Initializes the CPU, AHB and APB buses clocks - */ - RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK | - RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2; - RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; - RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; - RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; - RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; - - if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) { - Error_Handler(); - } + * @brief System Clock Configuration + * @retval None + */ +void SystemClock_Config(void) +{ + RCC_OscInitTypeDef RCC_OscInitStruct = {0}; + RCC_ClkInitTypeDef RCC_ClkInitStruct = {0}; + + /** Configure the main internal regulator output voltage + */ + __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_PWR_VOLTAGESCALING_CONFIG(PWR_REGULATOR_VOLTAGE_SCALE1); + + /** Initializes the RCC Oscillators according to the specified parameters + * in the RCC_OscInitTypeDef structure. + */ + RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE; + RCC_OscInitStruct.HSEState = RCC_HSE_ON; + RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON; + RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE; + RCC_OscInitStruct.PLL.PLLM = 8; + RCC_OscInitStruct.PLL.PLLN = 360; + RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2; + RCC_OscInitStruct.PLL.PLLQ = 6; + RCC_OscInitStruct.PLL.PLLR = 6; + if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) + { + Error_Handler(); + } + + /** Activate the Over-Drive mode + */ + if (HAL_PWREx_EnableOverDrive() != HAL_OK) + { + Error_Handler(); + } + + /** Initializes the CPU, AHB and APB buses clocks + */ + RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK + |RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2; + RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK; + RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1; + RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV4; + RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV2; + + if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_5) != HAL_OK) + { + Error_Handler(); + } } /* USER CODE BEGIN 4 */ @@ -124,31 +127,33 @@ void SystemClock_Config(void) { /* USER CODE END 4 */ /** - * @brief This function is executed in case of error occurrence. - * @retval None - */ -void Error_Handler(void) { - /* USER CODE BEGIN Error_Handler_Debug */ + * @brief This function is executed in case of error occurrence. + * @retval None + */ +void Error_Handler(void) +{ + /* USER CODE BEGIN Error_Handler_Debug */ /* User can add his own implementation to report the HAL error return state */ __disable_irq(); while (1) { } - /* USER CODE END Error_Handler_Debug */ + /* USER CODE END Error_Handler_Debug */ } #ifdef USE_FULL_ASSERT /** - * @brief Reports the name of the source file and the source line number - * where the assert_param error has occurred. - * @param file: pointer to the source file name - * @param line: assert_param error line source number - * @retval None - */ -void assert_failed(uint8_t* file, uint32_t line) { - /* USER CODE BEGIN 6 */ + * @brief Reports the name of the source file and the source line number + * where the assert_param error has occurred. + * @param file: pointer to the source file name + * @param line: assert_param error line source number + * @retval None + */ +void assert_failed(uint8_t *file, uint32_t line) +{ + /* USER CODE BEGIN 6 */ /* User can add his own implementation to report the file name and line number, ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */ - /* USER CODE END 6 */ + /* USER CODE END 6 */ } #endif /* USE_FULL_ASSERT */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_hal_msp.c b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_hal_msp.c index 111022975..a3004fd49 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_hal_msp.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_hal_msp.c @@ -58,21 +58,23 @@ /* USER CODE END 0 */ /** - * Initializes the Global MSP. - */ -void HAL_MspInit(void) { - /* USER CODE BEGIN MspInit 0 */ + * Initializes the Global MSP. + */ +void HAL_MspInit(void) +{ + + /* USER CODE BEGIN MspInit 0 */ - /* USER CODE END MspInit 0 */ + /* USER CODE END MspInit 0 */ - __HAL_RCC_SYSCFG_CLK_ENABLE(); - __HAL_RCC_PWR_CLK_ENABLE(); + __HAL_RCC_SYSCFG_CLK_ENABLE(); + __HAL_RCC_PWR_CLK_ENABLE(); - /* System interrupt init*/ + /* System interrupt init*/ - /* USER CODE BEGIN MspInit 1 */ + /* USER CODE BEGIN MspInit 1 */ - /* USER CODE END MspInit 1 */ + /* USER CODE END MspInit 1 */ } /* USER CODE BEGIN 1 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c index 27d45c90a..56f286db1 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/stm32f4xx_it.c @@ -18,9 +18,8 @@ /* USER CODE END Header */ /* Includes ------------------------------------------------------------------*/ -#include "stm32f4xx_it.h" - #include "main.h" +#include "stm32f4xx_it.h" /* Private includes ----------------------------------------------------------*/ /* USER CODE BEGIN Includes */ #include "lvgl.h" @@ -70,140 +69,130 @@ extern LTDC_HandleTypeDef hltdc; /* Cortex-M4 Processor Interruption and Exception Handlers */ /******************************************************************************/ /** - * @brief This function handles Non maskable interrupt. - */ -void NMI_Handler(void) { - /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ - - /* USER CODE END NonMaskableInt_IRQn 0 */ - /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ + * @brief This function handles Non maskable interrupt. + */ +void NMI_Handler(void) +{ + /* USER CODE BEGIN NonMaskableInt_IRQn 0 */ + + /* USER CODE END NonMaskableInt_IRQn 0 */ + /* USER CODE BEGIN NonMaskableInt_IRQn 1 */ while (1) { } - /* USER CODE END NonMaskableInt_IRQn 1 */ + /* USER CODE END NonMaskableInt_IRQn 1 */ } -/* Fault context captured here — inspect in debugger when HardFault fires */ -volatile uint32_t fault_pc; -volatile uint32_t fault_lr; -volatile uint32_t fault_cfsr; /* Configurable Fault Status: which fault type */ -volatile uint32_t fault_hfsr; /* HardFault Status: forced/debug */ -volatile uint32_t fault_bfar; /* Bus Fault Address (valid if CFSR bit 7 set) */ -volatile uint32_t - fault_mmfar; /* MemManage Fault Address (valid if CFSR bit 23 set) */ - /** - * @brief This function handles Hard fault interrupt. - */ -__attribute__((naked)) void HardFault_Handler(void) { - __asm volatile( - "tst lr, #4 \n" /* check EXC_RETURN[2]: 0=MSP, 1=PSP */ - "ite eq \n" - "mrseq r0, msp \n" - "mrsne r0, psp \n" - "ldr r1, =fault_pc \n" - "ldr r2, [r0, #24] \n" /* stacked PC is at offset 24 */ - "str r2, [r1] \n" - "ldr r1, =fault_lr \n" - "ldr r2, [r0, #20] \n" /* stacked LR is at offset 20 */ - "str r2, [r1] \n" - "b HardFault_Decode \n"); -} - -void HardFault_Decode(void) { - fault_cfsr = *(volatile uint32_t*)0xE000ED28; - fault_hfsr = *(volatile uint32_t*)0xE000ED2C; - fault_bfar = *(volatile uint32_t*)0xE000ED38; - fault_mmfar = *(volatile uint32_t*)0xE000ED34; - while (1) { - } + * @brief This function handles Hard fault interrupt. + */ +void HardFault_Handler(void) +{ + /* USER CODE BEGIN HardFault_IRQn 0 */ + + /* USER CODE END HardFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_HardFault_IRQn 0 */ + /* USER CODE END W1_HardFault_IRQn 0 */ + } } /** - * @brief This function handles Memory management fault. - */ -void MemManage_Handler(void) { - /* USER CODE BEGIN MemoryManagement_IRQn 0 */ - - /* USER CODE END MemoryManagement_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ - /* USER CODE END W1_MemoryManagement_IRQn 0 */ - } + * @brief This function handles Memory management fault. + */ +void MemManage_Handler(void) +{ + /* USER CODE BEGIN MemoryManagement_IRQn 0 */ + + /* USER CODE END MemoryManagement_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_MemoryManagement_IRQn 0 */ + /* USER CODE END W1_MemoryManagement_IRQn 0 */ + } } /** - * @brief This function handles Pre-fetch fault, memory access fault. - */ -void BusFault_Handler(void) { - /* USER CODE BEGIN BusFault_IRQn 0 */ - - /* USER CODE END BusFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_BusFault_IRQn 0 */ - /* USER CODE END W1_BusFault_IRQn 0 */ - } + * @brief This function handles Pre-fetch fault, memory access fault. + */ +void BusFault_Handler(void) +{ + /* USER CODE BEGIN BusFault_IRQn 0 */ + + /* USER CODE END BusFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_BusFault_IRQn 0 */ + /* USER CODE END W1_BusFault_IRQn 0 */ + } } /** - * @brief This function handles Undefined instruction or illegal state. - */ -void UsageFault_Handler(void) { - /* USER CODE BEGIN UsageFault_IRQn 0 */ - - /* USER CODE END UsageFault_IRQn 0 */ - while (1) { - /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ - /* USER CODE END W1_UsageFault_IRQn 0 */ - } + * @brief This function handles Undefined instruction or illegal state. + */ +void UsageFault_Handler(void) +{ + /* USER CODE BEGIN UsageFault_IRQn 0 */ + + /* USER CODE END UsageFault_IRQn 0 */ + while (1) + { + /* USER CODE BEGIN W1_UsageFault_IRQn 0 */ + /* USER CODE END W1_UsageFault_IRQn 0 */ + } } /** - * @brief This function handles System service call via SWI instruction. - */ -void SVC_Handler(void) { - /* USER CODE BEGIN SVCall_IRQn 0 */ + * @brief This function handles System service call via SWI instruction. + */ +void SVC_Handler(void) +{ + /* USER CODE BEGIN SVCall_IRQn 0 */ - /* USER CODE END SVCall_IRQn 0 */ - /* USER CODE BEGIN SVCall_IRQn 1 */ + /* USER CODE END SVCall_IRQn 0 */ + /* USER CODE BEGIN SVCall_IRQn 1 */ - /* USER CODE END SVCall_IRQn 1 */ + /* USER CODE END SVCall_IRQn 1 */ } /** - * @brief This function handles Debug monitor. - */ -void DebugMon_Handler(void) { - /* USER CODE BEGIN DebugMonitor_IRQn 0 */ + * @brief This function handles Debug monitor. + */ +void DebugMon_Handler(void) +{ + /* USER CODE BEGIN DebugMonitor_IRQn 0 */ - /* USER CODE END DebugMonitor_IRQn 0 */ - /* USER CODE BEGIN DebugMonitor_IRQn 1 */ + /* USER CODE END DebugMonitor_IRQn 0 */ + /* USER CODE BEGIN DebugMonitor_IRQn 1 */ - /* USER CODE END DebugMonitor_IRQn 1 */ + /* USER CODE END DebugMonitor_IRQn 1 */ } /** - * @brief This function handles Pendable request for system service. - */ -void PendSV_Handler(void) { - /* USER CODE BEGIN PendSV_IRQn 0 */ + * @brief This function handles Pendable request for system service. + */ +void PendSV_Handler(void) +{ + /* USER CODE BEGIN PendSV_IRQn 0 */ - /* USER CODE END PendSV_IRQn 0 */ - /* USER CODE BEGIN PendSV_IRQn 1 */ + /* USER CODE END PendSV_IRQn 0 */ + /* USER CODE BEGIN PendSV_IRQn 1 */ - /* USER CODE END PendSV_IRQn 1 */ + /* USER CODE END PendSV_IRQn 1 */ } /** - * @brief This function handles System tick timer. - */ -void SysTick_Handler(void) { - /* USER CODE BEGIN SysTick_IRQn 0 */ - - /* USER CODE END SysTick_IRQn 0 */ - HAL_IncTick(); - /* USER CODE BEGIN SysTick_IRQn 1 */ + * @brief This function handles System tick timer. + */ +void SysTick_Handler(void) +{ + /* USER CODE BEGIN SysTick_IRQn 0 */ + + /* USER CODE END SysTick_IRQn 0 */ + HAL_IncTick(); + /* USER CODE BEGIN SysTick_IRQn 1 */ lv_tick_inc(1); - /* USER CODE END SysTick_IRQn 1 */ + /* USER CODE END SysTick_IRQn 1 */ } /******************************************************************************/ @@ -214,68 +203,73 @@ void SysTick_Handler(void) { /******************************************************************************/ /** - * @brief This function handles CAN1 RX0 interrupts. - */ -void CAN1_RX0_IRQHandler(void) { - /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ + * @brief This function handles CAN1 RX0 interrupts. + */ +void CAN1_RX0_IRQHandler(void) +{ + /* USER CODE BEGIN CAN1_RX0_IRQn 0 */ - /* USER CODE END CAN1_RX0_IRQn 0 */ - HAL_CAN_IRQHandler(&hcan1); - /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ + /* USER CODE END CAN1_RX0_IRQn 0 */ + HAL_CAN_IRQHandler(&hcan1); + /* USER CODE BEGIN CAN1_RX0_IRQn 1 */ - /* USER CODE END CAN1_RX0_IRQn 1 */ + /* USER CODE END CAN1_RX0_IRQn 1 */ } /** - * @brief This function handles DMA2 stream0 global interrupt. - */ -void DMA2_Stream0_IRQHandler(void) { - /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ + * @brief This function handles DMA2 stream0 global interrupt. + */ +void DMA2_Stream0_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2_Stream0_IRQn 0 */ - /* USER CODE END DMA2_Stream0_IRQn 0 */ - HAL_DMA_IRQHandler(&hdma_memtomem_dma2_stream0); - /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ + /* USER CODE END DMA2_Stream0_IRQn 0 */ + HAL_DMA_IRQHandler(&hdma_memtomem_dma2_stream0); + /* USER CODE BEGIN DMA2_Stream0_IRQn 1 */ - /* USER CODE END DMA2_Stream0_IRQn 1 */ + /* USER CODE END DMA2_Stream0_IRQn 1 */ } /** - * @brief This function handles LTDC global interrupt. - */ -void LTDC_IRQHandler(void) { - /* USER CODE BEGIN LTDC_IRQn 0 */ + * @brief This function handles LTDC global interrupt. + */ +void LTDC_IRQHandler(void) +{ + /* USER CODE BEGIN LTDC_IRQn 0 */ - /* USER CODE END LTDC_IRQn 0 */ - HAL_LTDC_IRQHandler(&hltdc); - /* USER CODE BEGIN LTDC_IRQn 1 */ + /* USER CODE END LTDC_IRQn 0 */ + HAL_LTDC_IRQHandler(&hltdc); + /* USER CODE BEGIN LTDC_IRQn 1 */ - /* USER CODE END LTDC_IRQn 1 */ + /* USER CODE END LTDC_IRQn 1 */ } /** - * @brief This function handles DMA2D global interrupt. - */ -void DMA2D_IRQHandler(void) { - /* USER CODE BEGIN DMA2D_IRQn 0 */ + * @brief This function handles DMA2D global interrupt. + */ +void DMA2D_IRQHandler(void) +{ + /* USER CODE BEGIN DMA2D_IRQn 0 */ - /* USER CODE END DMA2D_IRQn 0 */ - HAL_DMA2D_IRQHandler(&hdma2d); - /* USER CODE BEGIN DMA2D_IRQn 1 */ + /* USER CODE END DMA2D_IRQn 0 */ + HAL_DMA2D_IRQHandler(&hdma2d); + /* USER CODE BEGIN DMA2D_IRQn 1 */ - /* USER CODE END DMA2D_IRQn 1 */ + /* USER CODE END DMA2D_IRQn 1 */ } /** - * @brief This function handles DSI global interrupt. - */ -void DSI_IRQHandler(void) { - /* USER CODE BEGIN DSI_IRQn 0 */ + * @brief This function handles DSI global interrupt. + */ +void DSI_IRQHandler(void) +{ + /* USER CODE BEGIN DSI_IRQn 0 */ - /* USER CODE END DSI_IRQn 0 */ - HAL_DSI_IRQHandler(&hdsi); - /* USER CODE BEGIN DSI_IRQn 1 */ + /* USER CODE END DSI_IRQn 0 */ + HAL_DSI_IRQHandler(&hdsi); + /* USER CODE BEGIN DSI_IRQn 1 */ - /* USER CODE END DSI_IRQn 1 */ + /* USER CODE END DSI_IRQn 1 */ } /* USER CODE BEGIN 1 */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/usart.c b/projects/dashboard/src/platforms/stm32/Core/Src/usart.c index 14cac7ab2..03af4eed0 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/usart.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/usart.c @@ -28,75 +28,85 @@ UART_HandleTypeDef huart3; /* USART3 init function */ -void MX_USART3_UART_Init(void) { - /* USER CODE BEGIN USART3_Init 0 */ - - /* USER CODE END USART3_Init 0 */ - - /* USER CODE BEGIN USART3_Init 1 */ - - /* USER CODE END USART3_Init 1 */ - huart3.Instance = USART3; - huart3.Init.BaudRate = 115200; - huart3.Init.WordLength = UART_WORDLENGTH_8B; - huart3.Init.StopBits = UART_STOPBITS_1; - huart3.Init.Parity = UART_PARITY_NONE; - huart3.Init.Mode = UART_MODE_TX_RX; - huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; - huart3.Init.OverSampling = UART_OVERSAMPLING_16; - if (HAL_UART_Init(&huart3) != HAL_OK) { - Error_Handler(); - } - /* USER CODE BEGIN USART3_Init 2 */ - - /* USER CODE END USART3_Init 2 */ +void MX_USART3_UART_Init(void) +{ + + /* USER CODE BEGIN USART3_Init 0 */ + + /* USER CODE END USART3_Init 0 */ + + /* USER CODE BEGIN USART3_Init 1 */ + + /* USER CODE END USART3_Init 1 */ + huart3.Instance = USART3; + huart3.Init.BaudRate = 115200; + huart3.Init.WordLength = UART_WORDLENGTH_8B; + huart3.Init.StopBits = UART_STOPBITS_1; + huart3.Init.Parity = UART_PARITY_NONE; + huart3.Init.Mode = UART_MODE_TX_RX; + huart3.Init.HwFlowCtl = UART_HWCONTROL_NONE; + huart3.Init.OverSampling = UART_OVERSAMPLING_16; + if (HAL_UART_Init(&huart3) != HAL_OK) + { + Error_Handler(); + } + /* USER CODE BEGIN USART3_Init 2 */ + + /* USER CODE END USART3_Init 2 */ + } -void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) { - GPIO_InitTypeDef GPIO_InitStruct = {0}; - if (uartHandle->Instance == USART3) { - /* USER CODE BEGIN USART3_MspInit 0 */ - - /* USER CODE END USART3_MspInit 0 */ - /* USART3 clock enable */ - __HAL_RCC_USART3_CLK_ENABLE(); - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**USART3 GPIO Configuration - PB10 ------> USART3_TX - PB11 ------> USART3_RX - */ - GPIO_InitStruct.Pin = STLK_RX_Pin | STLK_TX_Pin; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_PULLUP; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF7_USART3; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN USART3_MspInit 1 */ - - /* USER CODE END USART3_MspInit 1 */ - } +void HAL_UART_MspInit(UART_HandleTypeDef* uartHandle) +{ + + GPIO_InitTypeDef GPIO_InitStruct = {0}; + if(uartHandle->Instance==USART3) + { + /* USER CODE BEGIN USART3_MspInit 0 */ + + /* USER CODE END USART3_MspInit 0 */ + /* USART3 clock enable */ + __HAL_RCC_USART3_CLK_ENABLE(); + + __HAL_RCC_GPIOB_CLK_ENABLE(); + /**USART3 GPIO Configuration + PB10 ------> USART3_TX + PB11 ------> USART3_RX + */ + GPIO_InitStruct.Pin = STLK_RX_Pin|STLK_TX_Pin; + GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; + GPIO_InitStruct.Pull = GPIO_PULLUP; + GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; + GPIO_InitStruct.Alternate = GPIO_AF7_USART3; + HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); + + /* USER CODE BEGIN USART3_MspInit 1 */ + + /* USER CODE END USART3_MspInit 1 */ + } } -void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) { - if (uartHandle->Instance == USART3) { - /* USER CODE BEGIN USART3_MspDeInit 0 */ +void HAL_UART_MspDeInit(UART_HandleTypeDef* uartHandle) +{ + + if(uartHandle->Instance==USART3) + { + /* USER CODE BEGIN USART3_MspDeInit 0 */ - /* USER CODE END USART3_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_USART3_CLK_DISABLE(); + /* USER CODE END USART3_MspDeInit 0 */ + /* Peripheral clock disable */ + __HAL_RCC_USART3_CLK_DISABLE(); - /**USART3 GPIO Configuration - PB10 ------> USART3_TX - PB11 ------> USART3_RX - */ - HAL_GPIO_DeInit(GPIOB, STLK_RX_Pin | STLK_TX_Pin); + /**USART3 GPIO Configuration + PB10 ------> USART3_TX + PB11 ------> USART3_RX + */ + HAL_GPIO_DeInit(GPIOB, STLK_RX_Pin|STLK_TX_Pin); - /* USER CODE BEGIN USART3_MspDeInit 1 */ + /* USER CODE BEGIN USART3_MspDeInit 1 */ - /* USER CODE END USART3_MspDeInit 1 */ - } + /* USER CODE END USART3_MspDeInit 1 */ + } } /* USER CODE BEGIN 1 */ diff --git a/projects/dashboard/src/platforms/stm32/bindings.cc b/projects/dashboard/src/platforms/stm32/bindings.cc index 1ebefe81f..34a7e9631 100644 --- a/projects/dashboard/src/platforms/stm32/bindings.cc +++ b/projects/dashboard/src/platforms/stm32/bindings.cc @@ -56,6 +56,7 @@ namespace mcal { using namespace stm32f; CanBase veh_can_base{&hcan1}; +CanBase pt_can_base{&hcan2}; DigitalInput button_scroll_n{BUTTON_SCROLL_GPIO_Port, BUTTON_SCROLL_Pin}; DigitalInput button_enter_n{BUTTON_SELECT_GPIO_Port, BUTTON_SELECT_Pin}; macfe::periph::InvertedDigitalInput button_scroll{button_scroll_n}; @@ -66,6 +67,7 @@ macfe::periph::InvertedDigitalInput button_enter{button_enter_n}; namespace bindings { macfe::periph::CanBase& veh_can_base = mcal::veh_can_base; +macfe::periph::CanBase& pt_can_base = mcal::pt_can_base; macfe::periph::DigitalInput& button_scroll = mcal::button_scroll; macfe::periph::DigitalInput& button_enter = mcal::button_enter; @@ -98,6 +100,7 @@ void Initialize() { uint32_t can_prio = NVIC_GetPriority(CAN1_RX0_IRQn); MX_CAN1_Init(); mcal::veh_can_base.Setup(); + mcal::pt_can_base.Setup(); //! USEFUL // init display advance_leds(); diff --git a/projects/dashboard/src/platforms/stm32/dashboard.ioc b/projects/dashboard/src/platforms/stm32/dashboard.ioc index dd461f50c..d7ba6e1ff 100644 --- a/projects/dashboard/src/platforms/stm32/dashboard.ioc +++ b/projects/dashboard/src/platforms/stm32/dashboard.ioc @@ -8,6 +8,10 @@ CAN1.CalculateTimeBit=2000 CAN1.CalculateTimeQuantum=133.33333333333331 CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1 CAN1.Prescaler=6 +CAN2.CalculateBaudRate=937500 +CAN2.CalculateTimeBit=1066 +CAN2.CalculateTimeQuantum=355.55555555555554 +CAN2.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate DMA2D.ColorMode=DMA2D_OUTPUT_RGB565 DMA2D.IPParameters=ColorMode DSIHOST.BTA_FlowControl=__NULL @@ -116,110 +120,113 @@ LTDC.WindowY1_L0=480 Mcu.CPN=STM32F469NIH6 Mcu.Family=STM32F4 Mcu.IP0=CAN1 -Mcu.IP1=DMA -Mcu.IP2=DMA2D -Mcu.IP3=DSIHOST -Mcu.IP4=FMC -Mcu.IP5=LTDC -Mcu.IP6=NVIC -Mcu.IP7=RCC -Mcu.IP8=SYS -Mcu.IP9=USART3 -Mcu.IPNb=10 +Mcu.IP1=CAN2 +Mcu.IP10=USART3 +Mcu.IP2=DMA +Mcu.IP3=DMA2D +Mcu.IP4=DSIHOST +Mcu.IP5=FMC +Mcu.IP6=LTDC +Mcu.IP7=NVIC +Mcu.IP8=RCC +Mcu.IP9=SYS +Mcu.IPNb=11 Mcu.Name=STM32F469NIHx Mcu.Package=TFBGA216 Mcu.Pin0=PE1 Mcu.Pin1=PE0 -Mcu.Pin10=PD0 -Mcu.Pin11=PI4 -Mcu.Pin12=PD5 -Mcu.Pin13=PD1 -Mcu.Pin14=PI3 -Mcu.Pin15=PI2 -Mcu.Pin16=PF0 -Mcu.Pin17=PI5 -Mcu.Pin18=PI7 -Mcu.Pin19=PI10 +Mcu.Pin10=PG15 +Mcu.Pin11=PD0 +Mcu.Pin12=PI4 +Mcu.Pin13=PD5 +Mcu.Pin14=PD1 +Mcu.Pin15=PI3 +Mcu.Pin16=PI2 +Mcu.Pin17=PF0 +Mcu.Pin18=PI5 +Mcu.Pin19=PI7 Mcu.Pin2=PB8 -Mcu.Pin20=PI6 -Mcu.Pin21=PK3 -Mcu.Pin22=PG9 -Mcu.Pin23=PD4 -Mcu.Pin24=PH15 -Mcu.Pin25=PI1 -Mcu.Pin26=PC14/OSC32_IN -Mcu.Pin27=PF1 -Mcu.Pin28=PI9 -Mcu.Pin29=PH13 +Mcu.Pin20=PI10 +Mcu.Pin21=PI6 +Mcu.Pin22=PK3 +Mcu.Pin23=PG9 +Mcu.Pin24=PD4 +Mcu.Pin25=PH15 +Mcu.Pin26=PI1 +Mcu.Pin27=PC14/OSC32_IN +Mcu.Pin28=PF1 +Mcu.Pin29=PI9 Mcu.Pin3=PB3 -Mcu.Pin30=PH14 -Mcu.Pin31=PI0 -Mcu.Pin32=PC15/OSC32_OUT -Mcu.Pin33=DSIHOST_D1P -Mcu.Pin34=DSIHOST_D1N -Mcu.Pin35=PH0/OSC_IN -Mcu.Pin36=PF2 -Mcu.Pin37=PH1/OSC_OUT -Mcu.Pin38=PF3 -Mcu.Pin39=DSIHOST_CKP +Mcu.Pin30=PH13 +Mcu.Pin31=PH14 +Mcu.Pin32=PI0 +Mcu.Pin33=PC15/OSC32_OUT +Mcu.Pin34=DSIHOST_D1P +Mcu.Pin35=DSIHOST_D1N +Mcu.Pin36=PH0/OSC_IN +Mcu.Pin37=PF2 +Mcu.Pin38=PH1/OSC_OUT +Mcu.Pin39=PF3 Mcu.Pin4=PC12 -Mcu.Pin40=DSIHOST_CKN -Mcu.Pin41=PG8 -Mcu.Pin42=PF4 -Mcu.Pin43=PH3 -Mcu.Pin44=DSIHOST_D0P -Mcu.Pin45=DSIHOST_D0N -Mcu.Pin46=PG6 -Mcu.Pin47=PF5 -Mcu.Pin48=PH2 -Mcu.Pin49=PD15 +Mcu.Pin40=DSIHOST_CKP +Mcu.Pin41=DSIHOST_CKN +Mcu.Pin42=PG8 +Mcu.Pin43=PF4 +Mcu.Pin44=PH3 +Mcu.Pin45=DSIHOST_D0P +Mcu.Pin46=DSIHOST_D0N +Mcu.Pin47=PG6 +Mcu.Pin48=PF5 +Mcu.Pin49=PH2 Mcu.Pin5=PA14 -Mcu.Pin50=PD10 -Mcu.Pin51=PD14 -Mcu.Pin52=PD9 -Mcu.Pin53=PD8 -Mcu.Pin54=PC0 -Mcu.Pin55=PB2/BOOT1 -Mcu.Pin56=PF12 -Mcu.Pin57=PG1 -Mcu.Pin58=PF15 -Mcu.Pin59=PJ5 +Mcu.Pin50=PD15 +Mcu.Pin51=PD10 +Mcu.Pin52=PD14 +Mcu.Pin53=PB12 +Mcu.Pin54=PD9 +Mcu.Pin55=PD8 +Mcu.Pin56=PC0 +Mcu.Pin57=PB2/BOOT1 +Mcu.Pin58=PF12 +Mcu.Pin59=PG1 Mcu.Pin6=PA13 -Mcu.Pin60=PH12 -Mcu.Pin61=PA0/WKUP -Mcu.Pin62=PC4 -Mcu.Pin63=PF13 -Mcu.Pin64=PG0 -Mcu.Pin65=PE8 -Mcu.Pin66=PG5 -Mcu.Pin67=PG4 -Mcu.Pin68=PH7 -Mcu.Pin69=PH9 +Mcu.Pin60=PF15 +Mcu.Pin61=PJ5 +Mcu.Pin62=PH12 +Mcu.Pin63=PA0/WKUP +Mcu.Pin64=PC4 +Mcu.Pin65=PF13 +Mcu.Pin66=PG0 +Mcu.Pin67=PE8 +Mcu.Pin68=PG5 +Mcu.Pin69=PG4 Mcu.Pin7=PB9 -Mcu.Pin70=PH11 -Mcu.Pin71=PC5 -Mcu.Pin72=PF14 -Mcu.Pin73=PJ2 -Mcu.Pin74=PF11 -Mcu.Pin75=PE9 -Mcu.Pin76=PE11 -Mcu.Pin77=PE14 -Mcu.Pin78=PB10 -Mcu.Pin79=PH8 +Mcu.Pin70=PH7 +Mcu.Pin71=PH9 +Mcu.Pin72=PH11 +Mcu.Pin73=PC5 +Mcu.Pin74=PF14 +Mcu.Pin75=PJ2 +Mcu.Pin76=PF11 +Mcu.Pin77=PE9 +Mcu.Pin78=PE11 +Mcu.Pin79=PE14 Mcu.Pin8=PB7 -Mcu.Pin80=PH10 -Mcu.Pin81=PB0 -Mcu.Pin82=PE7 -Mcu.Pin83=PE10 -Mcu.Pin84=PE12 -Mcu.Pin85=PE15 -Mcu.Pin86=PE13 -Mcu.Pin87=PB11 -Mcu.Pin88=VP_DMA2D_VS_DMA2D -Mcu.Pin89=VP_LTDC_DSIMode -Mcu.Pin9=PG15 -Mcu.Pin90=VP_SYS_VS_Systick -Mcu.PinsNb=91 +Mcu.Pin80=PB10 +Mcu.Pin81=PH8 +Mcu.Pin82=PH10 +Mcu.Pin83=PB0 +Mcu.Pin84=PE7 +Mcu.Pin85=PE10 +Mcu.Pin86=PE12 +Mcu.Pin87=PE15 +Mcu.Pin88=PE13 +Mcu.Pin89=PB11 +Mcu.Pin9=PB6 +Mcu.Pin90=VP_DMA2D_VS_DMA2D +Mcu.Pin91=VP_LTDC_DSIMode +Mcu.Pin92=VP_SYS_VS_Systick +Mcu.PinsNb=93 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F469NIHx @@ -278,6 +285,9 @@ PB11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PB11.Locked=true PB11.Mode=Asynchronous PB11.Signal=USART3_RX +PB12.Locked=true +PB12.Mode=CAN_Activate +PB12.Signal=CAN2_RX PB2/BOOT1.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP PB2/BOOT1.GPIO_Label=OTG_FS1_PowerSwitchOn [STMPS2151STR_En] PB2/BOOT1.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP @@ -292,6 +302,8 @@ PB3.GPIO_PuPd=GPIO_NOPULL PB3.GPIO_Speed=GPIO_SPEED_FREQ_LOW PB3.Locked=true PB3.Signal=I2S3_CK +PB6.Mode=CAN_Activate +PB6.Signal=CAN2_TX PB7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI PB7.GPIO_Label=OTG_FS1_OverCurrent [STMPS2151STR_FAULT] PB7.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING From 552fafea21b8022307d53b430d507214c90ee5ae Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 13 Jun 2026 18:02:11 -0400 Subject: [PATCH 15/16] Forward signals --- projects/front_controller/config.yaml | 6 +++--- projects/front_controller/src/main.cc | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/projects/front_controller/config.yaml b/projects/front_controller/config.yaml index 8681b85c3..5be22e3a8 100644 --- a/projects/front_controller/config.yaml +++ b/projects/front_controller/config.yaml @@ -2,8 +2,8 @@ canGen: outputPath: include/generated/can busses: - name: veh - node: fc + node: FC dbcFile: "../veh.dbc" - name: pt - node: fc - dbcFile: "../pt.dbc" + node: FC + dbcFile: "../pt.dbc" \ No newline at end of file diff --git a/projects/front_controller/src/main.cc b/projects/front_controller/src/main.cc index bb097c2b9..d52a30b54 100644 --- a/projects/front_controller/src/main.cc +++ b/projects/front_controller/src/main.cc @@ -184,8 +184,14 @@ static void Update_100Hz(void) { if (dash.has_value() && (dash->State() == DashState::SHUTDOWN)) { new_state = SHUTDOWN; } - - auto inv + auto inv1_2 = pt_can_bus.GetRxInv1_ActualValues2(); + auto inv2_2 = pt_can_bus.GetRxInv2_ActualValues2(); + veh_can_bus.Send(TxInverterStatus{ + .temp_motor_inv1 = inv1_2->TempMotor(), + .temp_inverter_inv1 = inv1_2->TempInverter(), + .temp_motor_inv2 = inv2_2->TempMotor(), + .temp_inverter_inv2 = inv2_2->TempInverter(), + }); } break; case SHUTDOWN: From bd57b35bd456f04aa1d7ba7241ebe3ad0c6f3074 Mon Sep 17 00:00:00 2001 From: Noah Jaye Date: Sat, 13 Jun 2026 18:58:18 -0400 Subject: [PATCH 16/16] Rip ptcan --- projects/dashboard/include/Display.hpp | 6 +- projects/dashboard/include/DriveModeMenu.hpp | 1 - projects/dashboard/include/Screen.hpp | 2 - projects/dashboard/include/bindings.hpp | 1 - projects/dashboard/src/ConfirmMenu.cpp | 2 +- projects/dashboard/src/Display.cpp | 6 +- projects/dashboard/src/DriveModeMenu.cpp | 13 +- projects/dashboard/src/main.cc | 5 +- .../dashboard/src/platforms/linux/bindings.cc | 3 - .../src/platforms/stm32/Core/Inc/can.h | 3 - .../src/platforms/stm32/Core/Src/can.c | 90 +------- .../dashboard/src/platforms/stm32/bindings.cc | 3 - .../src/platforms/stm32/dashboard.ioc | 200 ++++++++---------- projects/veh.dbc | 6 + 14 files changed, 111 insertions(+), 230 deletions(-) diff --git a/projects/dashboard/include/Display.hpp b/projects/dashboard/include/Display.hpp index ed0166270..59c8de70b 100644 --- a/projects/dashboard/include/Display.hpp +++ b/projects/dashboard/include/Display.hpp @@ -14,8 +14,6 @@ #include "StartMotors.hpp" #include "StartingHV.hpp" #include "StartingMotors.hpp" -#include "generated/can/pt_bus.hpp" -#include "generated/can/pt_messages.hpp" #include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" class Display { @@ -23,14 +21,12 @@ class Display { using State = generated::can::TxDashStatus::State_t; using Profile = generated::can::TxDashStatus::Profile_t; - Display(Button& enter, Button& scroll, generated::can::VehBus& veh, - generated::can::PtBus& pt); + Display(Button& enter, Button& scroll, generated::can::VehBus& veh); // CAN and Buttons are public so the ScreenUpdate can access them Button enter; Button scroll; generated::can::VehBus& veh_bus; - generated::can::PtBus& pt_bus; Profile selected_profile = Profile::Default; void Start(); diff --git a/projects/dashboard/include/DriveModeMenu.hpp b/projects/dashboard/include/DriveModeMenu.hpp index 456b6367f..4b16450ab 100644 --- a/projects/dashboard/include/DriveModeMenu.hpp +++ b/projects/dashboard/include/DriveModeMenu.hpp @@ -129,7 +129,6 @@ class DriveModeMenu : public Screen { TempCard motor_temp_; TempCard inverter_temp_; - CANIndicator pt_can_; CANIndicator veh_can_; FCStatusMessage fc_status_; diff --git a/projects/dashboard/include/Screen.hpp b/projects/dashboard/include/Screen.hpp index d0d0f9e40..b77cbccd4 100644 --- a/projects/dashboard/include/Screen.hpp +++ b/projects/dashboard/include/Screen.hpp @@ -1,8 +1,6 @@ #pragma once #include "StatusBar.hpp" -#include "generated/can/pt_bus.hpp" -#include "generated/can/pt_messages.hpp" #include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" #include "lvgl.h" diff --git a/projects/dashboard/include/bindings.hpp b/projects/dashboard/include/bindings.hpp index 79fc3e7d8..5f439db1c 100644 --- a/projects/dashboard/include/bindings.hpp +++ b/projects/dashboard/include/bindings.hpp @@ -6,7 +6,6 @@ namespace bindings { extern macfe::periph::CanBase& veh_can_base; -extern macfe::periph::CanBase& pt_can_base; extern macfe::periph::DigitalInput& button_scroll; extern macfe::periph::DigitalInput& button_enter; diff --git a/projects/dashboard/src/ConfirmMenu.cpp b/projects/dashboard/src/ConfirmMenu.cpp index 2a151be97..b27483328 100644 --- a/projects/dashboard/src/ConfirmMenu.cpp +++ b/projects/dashboard/src/ConfirmMenu.cpp @@ -33,4 +33,4 @@ void ConfirmMenu::Update() { } else if (display_->scroll.PosEdge()) { lv_roller_set_selected(roller, !sel, LV_ANIM_ON); } -} +} \ No newline at end of file diff --git a/projects/dashboard/src/Display.cpp b/projects/dashboard/src/Display.cpp index 6332d2310..599e6729e 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -2,13 +2,11 @@ #include "generated/can/pt_bus.hpp" #include "generated/can/veh_bus.hpp" -Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh, - generated::can::PtBus& pt) +Display::Display(Button& enter, Button& scroll, generated::can::VehBus& veh) : enter(enter), scroll(scroll), veh_bus(veh), - pt_bus(pt), - screen_(&drive_mode), //! drive_mode profile_select + screen_(&profile_select), //! Useful: drive_mode profile_select profile_select(this), confirm_menu(this), acknowledge_config(this), diff --git a/projects/dashboard/src/DriveModeMenu.cpp b/projects/dashboard/src/DriveModeMenu.cpp index e0777de76..840220731 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -309,7 +309,6 @@ void DriveModeMenu::CreateGUI() { fc_status_.Draw(right); lv_obj_t* can_row = MakeRow(right); - pt_can_.Draw(can_row, "PT"); veh_can_.Draw(can_row, "VEH"); speedo_.Draw(right); @@ -321,8 +320,7 @@ void DriveModeMenu::Update() { auto acc_msg = display_->veh_bus.GetRxAccumulator_Soc(); auto bms_msg = display_->veh_bus.GetRxBmsBroadcast(); auto pack_msg = display_->veh_bus.GetRxPack_State(); - auto inv1_msg = display_->pt_bus.GetRxInv1_ActualValues2(); - auto inv2_msg = display_->pt_bus.GetRxInv2_ActualValues2(); + auto inv_msg = display_->veh_bus.GetRxInverterStatus(); hv_arc_.PushSample(bms_msg ? pack_msg->Pack_Current() : 0.0f); @@ -338,15 +336,14 @@ void DriveModeMenu::Update() { bms_msg->HighThermValue()); } - motor_temp_.SetTemps(inv1_msg ? inv1_msg->TempMotor() : 0.0f, - inv2_msg ? inv2_msg->TempMotor() : 0.0f); - inverter_temp_.SetTemps(inv1_msg ? inv1_msg->TempInverter() : 0.0f, - inv2_msg ? inv2_msg->TempInverter() : 0.0f); + motor_temp_.SetTemps(inv_msg ? inv_msg->TempMotorInv1() : 0.0f, + inv_msg ? inv_msg->TempMotorInv2() : 0.0f); + inverter_temp_.SetTemps(inv_msg ? inv_msg->TempInverterInv1() : 0.0f, + inv_msg ? inv_msg->TempInverterInv2() : 0.0f); fc_status_.SetStatus("OK"); speedo_.SetSpeed(fc_msg ? fc_msg->Speed() : 0.0f); - pt_can_.SetActive(false); veh_can_.SetActive(true); } \ No newline at end of file diff --git a/projects/dashboard/src/main.cc b/projects/dashboard/src/main.cc index 4fda36e92..41a24bf9c 100644 --- a/projects/dashboard/src/main.cc +++ b/projects/dashboard/src/main.cc @@ -5,8 +5,6 @@ #include "Button.hpp" #include "Display.hpp" #include "bindings.hpp" -#include "generated/can/pt_bus.hpp" -#include "generated/can/pt_messages.hpp" #include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" #include "gpio.h" @@ -20,8 +18,7 @@ using namespace generated::can; Button btn_enter{bindings::button_enter}; Button btn_scroll{bindings::button_scroll}; VehBus veh_can{bindings::veh_can_base}; -PtBus pt_can{bindings::pt_can_base}; -Display display{btn_enter, btn_scroll, veh_can, pt_can}; +Display display{btn_enter, btn_scroll, veh_can}; const int kUpdatePeriodMs = 20; static uint8_t tx_counter = 0; diff --git a/projects/dashboard/src/platforms/linux/bindings.cc b/projects/dashboard/src/platforms/linux/bindings.cc index 3ea255979..d8f396ba3 100644 --- a/projects/dashboard/src/platforms/linux/bindings.cc +++ b/projects/dashboard/src/platforms/linux/bindings.cc @@ -68,7 +68,6 @@ namespace mcal { using namespace mcal::lnx; CanBase veh_can_base{"vcan0"}; -CanBase pt_can_base{"vcan1"}; KeyboardInput button_scroll{SDLK_TAB}; KeyboardInput button_select{SDLK_SPACE}; @@ -77,7 +76,6 @@ KeyboardInput button_select{SDLK_SPACE}; namespace bindings { macfe::periph::CanBase& veh_can_base = mcal::veh_can_base; -macfe::periph::CanBase& pt_can_base = mcal::pt_can_base; macfe::periph::DigitalInput& button_scroll = mcal::button_scroll; macfe::periph::DigitalInput& button_enter = mcal::button_select; @@ -101,7 +99,6 @@ void Initialize() { std::signal(SIGTERM, signal_handler); // Termination signal mcal::veh_can_base.Setup(); - mcal::pt_can_base.Setup(); /* Create SDL window with LVGL 9.3 native driver */ lv_display = lv_sdl_window_create(800, 480); diff --git a/projects/dashboard/src/platforms/stm32/Core/Inc/can.h b/projects/dashboard/src/platforms/stm32/Core/Inc/can.h index a560d35b2..2ebe3df4c 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/can.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/can.h @@ -34,14 +34,11 @@ extern "C" { extern CAN_HandleTypeDef hcan1; -extern CAN_HandleTypeDef hcan2; - /* USER CODE BEGIN Private defines */ /* USER CODE END Private defines */ void MX_CAN1_Init(void); -void MX_CAN2_Init(void); /* USER CODE BEGIN Prototypes */ diff --git a/projects/dashboard/src/platforms/stm32/Core/Src/can.c b/projects/dashboard/src/platforms/stm32/Core/Src/can.c index ceb95210b..efabeda52 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/can.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/can.c @@ -25,7 +25,6 @@ /* USER CODE END 0 */ CAN_HandleTypeDef hcan1; -CAN_HandleTypeDef hcan2; /* CAN1 init function */ void MX_CAN1_Init(void) @@ -59,40 +58,6 @@ void MX_CAN1_Init(void) /* USER CODE END CAN1_Init 2 */ } -/* CAN2 init function */ -void MX_CAN2_Init(void) -{ - - /* USER CODE BEGIN CAN2_Init 0 */ - - /* USER CODE END CAN2_Init 0 */ - - /* USER CODE BEGIN CAN2_Init 1 */ - - /* USER CODE END CAN2_Init 1 */ - hcan2.Instance = CAN2; - hcan2.Init.Prescaler = 16; - hcan2.Init.Mode = CAN_MODE_NORMAL; - hcan2.Init.SyncJumpWidth = CAN_SJW_1TQ; - hcan2.Init.TimeSeg1 = CAN_BS1_1TQ; - hcan2.Init.TimeSeg2 = CAN_BS2_1TQ; - hcan2.Init.TimeTriggeredMode = DISABLE; - hcan2.Init.AutoBusOff = DISABLE; - hcan2.Init.AutoWakeUp = DISABLE; - hcan2.Init.AutoRetransmission = DISABLE; - hcan2.Init.ReceiveFifoLocked = DISABLE; - hcan2.Init.TransmitFifoPriority = DISABLE; - if (HAL_CAN_Init(&hcan2) != HAL_OK) - { - Error_Handler(); - } - /* USER CODE BEGIN CAN2_Init 2 */ - - /* USER CODE END CAN2_Init 2 */ - -} - -static uint32_t HAL_RCC_CAN1_CLK_ENABLED=0; void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle) { @@ -104,10 +69,7 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle) /* USER CODE END CAN1_MspInit 0 */ /* CAN1 clock enable */ - HAL_RCC_CAN1_CLK_ENABLED++; - if(HAL_RCC_CAN1_CLK_ENABLED==1){ - __HAL_RCC_CAN1_CLK_ENABLE(); - } + __HAL_RCC_CAN1_CLK_ENABLE(); __HAL_RCC_GPIOB_CLK_ENABLE(); /**CAN1 GPIO Configuration @@ -128,34 +90,6 @@ void HAL_CAN_MspInit(CAN_HandleTypeDef* canHandle) /* USER CODE END CAN1_MspInit 1 */ } - else if(canHandle->Instance==CAN2) - { - /* USER CODE BEGIN CAN2_MspInit 0 */ - - /* USER CODE END CAN2_MspInit 0 */ - /* CAN2 clock enable */ - __HAL_RCC_CAN2_CLK_ENABLE(); - HAL_RCC_CAN1_CLK_ENABLED++; - if(HAL_RCC_CAN1_CLK_ENABLED==1){ - __HAL_RCC_CAN1_CLK_ENABLE(); - } - - __HAL_RCC_GPIOB_CLK_ENABLE(); - /**CAN2 GPIO Configuration - PB6 ------> CAN2_TX - PB12 ------> CAN2_RX - */ - GPIO_InitStruct.Pin = GPIO_PIN_6|GPIO_PIN_12; - GPIO_InitStruct.Mode = GPIO_MODE_AF_PP; - GPIO_InitStruct.Pull = GPIO_NOPULL; - GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH; - GPIO_InitStruct.Alternate = GPIO_AF9_CAN2; - HAL_GPIO_Init(GPIOB, &GPIO_InitStruct); - - /* USER CODE BEGIN CAN2_MspInit 1 */ - - /* USER CODE END CAN2_MspInit 1 */ - } } void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle) @@ -181,28 +115,6 @@ void HAL_CAN_MspDeInit(CAN_HandleTypeDef* canHandle) /* USER CODE END CAN1_MspDeInit 1 */ } - else if(canHandle->Instance==CAN2) - { - /* USER CODE BEGIN CAN2_MspDeInit 0 */ - - /* USER CODE END CAN2_MspDeInit 0 */ - /* Peripheral clock disable */ - __HAL_RCC_CAN2_CLK_DISABLE(); - HAL_RCC_CAN1_CLK_ENABLED--; - if(HAL_RCC_CAN1_CLK_ENABLED==0){ - __HAL_RCC_CAN1_CLK_DISABLE(); - } - - /**CAN2 GPIO Configuration - PB6 ------> CAN2_TX - PB12 ------> CAN2_RX - */ - HAL_GPIO_DeInit(GPIOB, GPIO_PIN_6|GPIO_PIN_12); - - /* USER CODE BEGIN CAN2_MspDeInit 1 */ - - /* USER CODE END CAN2_MspDeInit 1 */ - } } /* USER CODE BEGIN 1 */ diff --git a/projects/dashboard/src/platforms/stm32/bindings.cc b/projects/dashboard/src/platforms/stm32/bindings.cc index 34a7e9631..1ebefe81f 100644 --- a/projects/dashboard/src/platforms/stm32/bindings.cc +++ b/projects/dashboard/src/platforms/stm32/bindings.cc @@ -56,7 +56,6 @@ namespace mcal { using namespace stm32f; CanBase veh_can_base{&hcan1}; -CanBase pt_can_base{&hcan2}; DigitalInput button_scroll_n{BUTTON_SCROLL_GPIO_Port, BUTTON_SCROLL_Pin}; DigitalInput button_enter_n{BUTTON_SELECT_GPIO_Port, BUTTON_SELECT_Pin}; macfe::periph::InvertedDigitalInput button_scroll{button_scroll_n}; @@ -67,7 +66,6 @@ macfe::periph::InvertedDigitalInput button_enter{button_enter_n}; namespace bindings { macfe::periph::CanBase& veh_can_base = mcal::veh_can_base; -macfe::periph::CanBase& pt_can_base = mcal::pt_can_base; macfe::periph::DigitalInput& button_scroll = mcal::button_scroll; macfe::periph::DigitalInput& button_enter = mcal::button_enter; @@ -100,7 +98,6 @@ void Initialize() { uint32_t can_prio = NVIC_GetPriority(CAN1_RX0_IRQn); MX_CAN1_Init(); mcal::veh_can_base.Setup(); - mcal::pt_can_base.Setup(); //! USEFUL // init display advance_leds(); diff --git a/projects/dashboard/src/platforms/stm32/dashboard.ioc b/projects/dashboard/src/platforms/stm32/dashboard.ioc index d7ba6e1ff..7226e4649 100644 --- a/projects/dashboard/src/platforms/stm32/dashboard.ioc +++ b/projects/dashboard/src/platforms/stm32/dashboard.ioc @@ -8,10 +8,6 @@ CAN1.CalculateTimeBit=2000 CAN1.CalculateTimeQuantum=133.33333333333331 CAN1.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate,Prescaler,BS1 CAN1.Prescaler=6 -CAN2.CalculateBaudRate=937500 -CAN2.CalculateTimeBit=1066 -CAN2.CalculateTimeQuantum=355.55555555555554 -CAN2.IPParameters=CalculateTimeQuantum,CalculateTimeBit,CalculateBaudRate DMA2D.ColorMode=DMA2D_OUTPUT_RGB565 DMA2D.IPParameters=ColorMode DSIHOST.BTA_FlowControl=__NULL @@ -120,113 +116,110 @@ LTDC.WindowY1_L0=480 Mcu.CPN=STM32F469NIH6 Mcu.Family=STM32F4 Mcu.IP0=CAN1 -Mcu.IP1=CAN2 -Mcu.IP10=USART3 -Mcu.IP2=DMA -Mcu.IP3=DMA2D -Mcu.IP4=DSIHOST -Mcu.IP5=FMC -Mcu.IP6=LTDC -Mcu.IP7=NVIC -Mcu.IP8=RCC -Mcu.IP9=SYS -Mcu.IPNb=11 +Mcu.IP1=DMA +Mcu.IP2=DMA2D +Mcu.IP3=DSIHOST +Mcu.IP4=FMC +Mcu.IP5=LTDC +Mcu.IP6=NVIC +Mcu.IP7=RCC +Mcu.IP8=SYS +Mcu.IP9=USART3 +Mcu.IPNb=10 Mcu.Name=STM32F469NIHx Mcu.Package=TFBGA216 Mcu.Pin0=PE1 Mcu.Pin1=PE0 -Mcu.Pin10=PG15 -Mcu.Pin11=PD0 -Mcu.Pin12=PI4 -Mcu.Pin13=PD5 -Mcu.Pin14=PD1 -Mcu.Pin15=PI3 -Mcu.Pin16=PI2 -Mcu.Pin17=PF0 -Mcu.Pin18=PI5 -Mcu.Pin19=PI7 +Mcu.Pin10=PD0 +Mcu.Pin11=PI4 +Mcu.Pin12=PD5 +Mcu.Pin13=PD1 +Mcu.Pin14=PI3 +Mcu.Pin15=PI2 +Mcu.Pin16=PF0 +Mcu.Pin17=PI5 +Mcu.Pin18=PI7 +Mcu.Pin19=PI10 Mcu.Pin2=PB8 -Mcu.Pin20=PI10 -Mcu.Pin21=PI6 -Mcu.Pin22=PK3 -Mcu.Pin23=PG9 -Mcu.Pin24=PD4 -Mcu.Pin25=PH15 -Mcu.Pin26=PI1 -Mcu.Pin27=PC14/OSC32_IN -Mcu.Pin28=PF1 -Mcu.Pin29=PI9 +Mcu.Pin20=PI6 +Mcu.Pin21=PK3 +Mcu.Pin22=PG9 +Mcu.Pin23=PD4 +Mcu.Pin24=PH15 +Mcu.Pin25=PI1 +Mcu.Pin26=PC14/OSC32_IN +Mcu.Pin27=PF1 +Mcu.Pin28=PI9 +Mcu.Pin29=PH13 Mcu.Pin3=PB3 -Mcu.Pin30=PH13 -Mcu.Pin31=PH14 -Mcu.Pin32=PI0 -Mcu.Pin33=PC15/OSC32_OUT -Mcu.Pin34=DSIHOST_D1P -Mcu.Pin35=DSIHOST_D1N -Mcu.Pin36=PH0/OSC_IN -Mcu.Pin37=PF2 -Mcu.Pin38=PH1/OSC_OUT -Mcu.Pin39=PF3 +Mcu.Pin30=PH14 +Mcu.Pin31=PI0 +Mcu.Pin32=PC15/OSC32_OUT +Mcu.Pin33=DSIHOST_D1P +Mcu.Pin34=DSIHOST_D1N +Mcu.Pin35=PH0/OSC_IN +Mcu.Pin36=PF2 +Mcu.Pin37=PH1/OSC_OUT +Mcu.Pin38=PF3 +Mcu.Pin39=DSIHOST_CKP Mcu.Pin4=PC12 -Mcu.Pin40=DSIHOST_CKP -Mcu.Pin41=DSIHOST_CKN -Mcu.Pin42=PG8 -Mcu.Pin43=PF4 -Mcu.Pin44=PH3 -Mcu.Pin45=DSIHOST_D0P -Mcu.Pin46=DSIHOST_D0N -Mcu.Pin47=PG6 -Mcu.Pin48=PF5 -Mcu.Pin49=PH2 +Mcu.Pin40=DSIHOST_CKN +Mcu.Pin41=PG8 +Mcu.Pin42=PF4 +Mcu.Pin43=PH3 +Mcu.Pin44=DSIHOST_D0P +Mcu.Pin45=DSIHOST_D0N +Mcu.Pin46=PG6 +Mcu.Pin47=PF5 +Mcu.Pin48=PH2 +Mcu.Pin49=PD15 Mcu.Pin5=PA14 -Mcu.Pin50=PD15 -Mcu.Pin51=PD10 -Mcu.Pin52=PD14 -Mcu.Pin53=PB12 -Mcu.Pin54=PD9 -Mcu.Pin55=PD8 -Mcu.Pin56=PC0 -Mcu.Pin57=PB2/BOOT1 -Mcu.Pin58=PF12 -Mcu.Pin59=PG1 +Mcu.Pin50=PD10 +Mcu.Pin51=PD14 +Mcu.Pin52=PD9 +Mcu.Pin53=PD8 +Mcu.Pin54=PC0 +Mcu.Pin55=PB2/BOOT1 +Mcu.Pin56=PF12 +Mcu.Pin57=PG1 +Mcu.Pin58=PF15 +Mcu.Pin59=PJ5 Mcu.Pin6=PA13 -Mcu.Pin60=PF15 -Mcu.Pin61=PJ5 -Mcu.Pin62=PH12 -Mcu.Pin63=PA0/WKUP -Mcu.Pin64=PC4 -Mcu.Pin65=PF13 -Mcu.Pin66=PG0 -Mcu.Pin67=PE8 -Mcu.Pin68=PG5 -Mcu.Pin69=PG4 +Mcu.Pin60=PH12 +Mcu.Pin61=PA0/WKUP +Mcu.Pin62=PC4 +Mcu.Pin63=PF13 +Mcu.Pin64=PG0 +Mcu.Pin65=PE8 +Mcu.Pin66=PG5 +Mcu.Pin67=PG4 +Mcu.Pin68=PH7 +Mcu.Pin69=PH9 Mcu.Pin7=PB9 -Mcu.Pin70=PH7 -Mcu.Pin71=PH9 -Mcu.Pin72=PH11 -Mcu.Pin73=PC5 -Mcu.Pin74=PF14 -Mcu.Pin75=PJ2 -Mcu.Pin76=PF11 -Mcu.Pin77=PE9 -Mcu.Pin78=PE11 -Mcu.Pin79=PE14 +Mcu.Pin70=PH11 +Mcu.Pin71=PC5 +Mcu.Pin72=PF14 +Mcu.Pin73=PJ2 +Mcu.Pin74=PF11 +Mcu.Pin75=PE9 +Mcu.Pin76=PE11 +Mcu.Pin77=PE14 +Mcu.Pin78=PB10 +Mcu.Pin79=PH8 Mcu.Pin8=PB7 -Mcu.Pin80=PB10 -Mcu.Pin81=PH8 -Mcu.Pin82=PH10 -Mcu.Pin83=PB0 -Mcu.Pin84=PE7 -Mcu.Pin85=PE10 -Mcu.Pin86=PE12 -Mcu.Pin87=PE15 -Mcu.Pin88=PE13 -Mcu.Pin89=PB11 -Mcu.Pin9=PB6 -Mcu.Pin90=VP_DMA2D_VS_DMA2D -Mcu.Pin91=VP_LTDC_DSIMode -Mcu.Pin92=VP_SYS_VS_Systick -Mcu.PinsNb=93 +Mcu.Pin80=PH10 +Mcu.Pin81=PB0 +Mcu.Pin82=PE7 +Mcu.Pin83=PE10 +Mcu.Pin84=PE12 +Mcu.Pin85=PE15 +Mcu.Pin86=PE13 +Mcu.Pin87=PB11 +Mcu.Pin88=VP_DMA2D_VS_DMA2D +Mcu.Pin89=VP_LTDC_DSIMode +Mcu.Pin9=PG15 +Mcu.Pin90=VP_SYS_VS_Systick +Mcu.PinsNb=91 Mcu.ThirdPartyNb=0 Mcu.UserConstants= Mcu.UserName=STM32F469NIHx @@ -285,9 +278,6 @@ PB11.GPIO_Speed=GPIO_SPEED_FREQ_VERY_HIGH PB11.Locked=true PB11.Mode=Asynchronous PB11.Signal=USART3_RX -PB12.Locked=true -PB12.Mode=CAN_Activate -PB12.Signal=CAN2_RX PB2/BOOT1.GPIOParameters=GPIO_Speed,GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultOutputPP PB2/BOOT1.GPIO_Label=OTG_FS1_PowerSwitchOn [STMPS2151STR_En] PB2/BOOT1.GPIO_ModeDefaultOutputPP=GPIO_MODE_OUTPUT_PP @@ -302,8 +292,6 @@ PB3.GPIO_PuPd=GPIO_NOPULL PB3.GPIO_Speed=GPIO_SPEED_FREQ_LOW PB3.Locked=true PB3.Signal=I2S3_CK -PB6.Mode=CAN_Activate -PB6.Signal=CAN2_TX PB7.GPIOParameters=GPIO_PuPd,GPIO_Label,GPIO_ModeDefaultEXTI PB7.GPIO_Label=OTG_FS1_OverCurrent [STMPS2151STR_FAULT] PB7.GPIO_ModeDefaultEXTI=GPIO_MODE_IT_RISING @@ -820,7 +808,7 @@ ProjectManager.ToolChainLocation= ProjectManager.UAScriptAfterPath= ProjectManager.UAScriptBeforePath= ProjectManager.UnderRoot=true -ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_DMA2D_Init-DMA2D-false-HAL-true,5-MX_DSIHOST_DSI_Init-DSIHOST-false-HAL-true,6-MX_FMC_Init-FMC-false-HAL-true,7-MX_LTDC_Init-LTDC-false-HAL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true,9-MX_CAN1_Init-CAN1-false-HAL-true +ProjectManager.functionlistsort=1-SystemClock_Config-RCC-false-HAL-false,2-MX_GPIO_Init-GPIO-false-HAL-true,3-MX_DMA_Init-DMA-false-HAL-true,4-MX_DMA2D_Init-DMA2D-false-HAL-true,5-MX_DSIHOST_DSI_Init-DSIHOST-false-HAL-true,6-MX_FMC_Init-FMC-false-HAL-true,7-MX_LTDC_Init-LTDC-false-HAL-true,8-MX_USART3_UART_Init-USART3-false-HAL-true,9-MX_CAN1_Init-CAN1-false-HAL-true,10-MX_CAN2_Init-CAN2-false-HAL-true RCC.AHBFreq_Value=180000000 RCC.APB1CLKDivider=RCC_HCLK_DIV4 RCC.APB1Freq_Value=45000000 diff --git a/projects/veh.dbc b/projects/veh.dbc index 4dcd6f976..4a89e62d4 100644 --- a/projects/veh.dbc +++ b/projects/veh.dbc @@ -142,6 +142,12 @@ BO_ 231 DashStatus: 3 DASH SG_ State : 8|8@1+ (1,0) [0|1] "" FC SG_ Profile : 16|8@1+ (1,0) [0|15] "" FC +BO_ 241 InverterStatus: 8 FC + SG_ TempMotorInv1 : 0|16@1- (0.1,0) [0|0] "degC" DASH + SG_ TempInverterInv1: 16|16@1- (0.1,0) [0|0] "degC" DASH + SG_ TempMotorInv2 : 32|16@1- (0.1,0) [0|0] "degC" DASH + SG_ TempInverterInv2 : 48|16@1- (0.1,0) [0|0] "degC" DASH + VAL_ 231 State 0 "LOGO" 1 "SELECT_PROFILE" 2 "CONFIRM_SELECTION" 3 "WAIT_SELECTION_ACK" 4 "PRESS_FOR_HV" 5 "STARTING_HV" 6 "PRESS_FOR_MOTOR" 7 "STARTING_MOTORS" 8 "BRAKE_TO_START" 9 "RUNNING" 10 "SHUTDOWN" 11 "ERROR"; VAL_ 231 Profile 0 "Default" 1 "Launch" 2 "Skidpad" 3 "Endurance" 4 "Tuning" 5 "_ENUM_TAIL_";