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..59c8de70b 100644 --- a/projects/dashboard/include/Display.hpp +++ b/projects/dashboard/include/Display.hpp @@ -16,7 +16,6 @@ #include "StartingMotors.hpp" #include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" - class Display { public: using State = generated::can::TxDashStatus::State_t; @@ -28,7 +27,6 @@ class Display { Button enter; Button scroll; generated::can::VehBus& veh_bus; - Profile selected_profile = Profile::Default; void Start(); diff --git a/projects/dashboard/include/DriveModeMenu.hpp b/projects/dashboard/include/DriveModeMenu.hpp index dad128e0e..4b16450ab 100644 --- a/projects/dashboard/include/DriveModeMenu.hpp +++ b/projects/dashboard/include/DriveModeMenu.hpp @@ -1,47 +1,140 @@ #pragma once #include "Screen.hpp" +#include "etl/circular_buffer.h" #include "etl/vector.h" #include "lvgl.h" -class Speedometer { +// ── HV current arc ─────────────────────────────────────────────────────────── +class HVCurrentArc { +public: + static constexpr uint32_t kUpdateRateHz = 100; + static constexpr uint32_t kAvgWindowSamples = kUpdateRateHz; + static constexpr float kHVCurrentMax = 500.0f; + static constexpr float kArcResolution = 10.0f; + + 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_; + + 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* label_{nullptr}; +}; + +class LVVoltageDisplay { public: - void Draw(lv_obj_t* parent, lv_align_t align, lv_coord_t x, lv_coord_t y); - void SetSpeed(float speed); + void Draw(lv_obj_t* parent); + void SetVoltage(float lv_voltage); private: - const float kArcMaxSpeed = 120; - const float kArcSpeedResolution = 10; + lv_obj_t* label_{nullptr}; +}; - lv_obj_t* arc; - lv_obj_t* label; +// ── LV current (text) ──────────────────────────────────────────────────────── +class LVCurrentDisplay { +public: + void Draw(lv_obj_t* parent); + void SetCurrent(float current); + +private: + lv_obj_t* label_{nullptr}; }; +// ── SOC ────────────────────────────────────────────────────────────────────── 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 Draw(lv_obj_t* parent); + void SetSOC(float soc); private: - const int kVoltMax = 600.f; - const int kVoltMin = 250.f; // display this as "empty" + lv_obj_t* bar_{nullptr}; + lv_obj_t* label_{nullptr}; +}; + +// ── Temperature card ───────────────────────────────────────────────────────── +class TempCard { +public: + void Draw(lv_obj_t* parent, const char* title, lv_color_t color); + void SetTemps(float min, float max); - lv_obj_t* label; +private: + lv_obj_t* container_{nullptr}; + lv_obj_t* min_label_{nullptr}; + lv_obj_t* max_label_{nullptr}; }; -class DriveModeMenu : public Screen { +// ── CAN indicator ──────────────────────────────────────────────────────────── +class CANIndicator { public: - DriveModeMenu(Display* display); + void Draw(lv_obj_t* parent, const char* label); + void SetActive(bool active); +private: + lv_obj_t* dot_{nullptr}; + lv_obj_t* label_{nullptr}; +}; + +// ── FC status ──────────────────────────────────────────────────────────────── +class FCStatusMessage { +public: + void Draw(lv_obj_t* parent); + void SetStatus(const char* status); + +private: + 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); void CreateGUI() override; void Update() override; private: + HVCurrentArc hv_arc_; + HVVoltageDisplay hv_voltage_; + LVVoltageDisplay lv_voltage_; + LVCurrentDisplay lv_current_; Battery battery_; - Speedometer speedometer_; - // Demo: cycling warnings - uint32_t last_warning_time_; + TempCard battery_temp_; + TempCard motor_temp_; + TempCard inverter_temp_; + + CANIndicator veh_can_; + + FCStatusMessage fc_status_; + Speedometer speedo_; + + 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/include/Screen.hpp b/projects/dashboard/include/Screen.hpp index 0466564b9..b77cbccd4 100644 --- a/projects/dashboard/include/Screen.hpp +++ b/projects/dashboard/include/Screen.hpp @@ -1,6 +1,7 @@ #pragma once #include "StatusBar.hpp" +#include "generated/can/veh_bus.hpp" #include "generated/can/veh_messages.hpp" #include "lvgl.h" 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/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/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..b27483328 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) {} @@ -32,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 7a3e93880..599e6729e 100644 --- a/projects/dashboard/src/Display.cpp +++ b/projects/dashboard/src/Display.cpp @@ -1,10 +1,12 @@ #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) : enter(enter), scroll(scroll), veh_bus(veh), - screen_(&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 76f91c735..840220731 100644 --- a/projects/dashboard/src/DriveModeMenu.cpp +++ b/projects/dashboard/src/DriveModeMenu.cpp @@ -3,107 +3,347 @@ #include "Display.hpp" #include "lvgl.h" -void Speedometer::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); +// ───────────────────────────────────────────────────────────── +// Layout constants & fonts +// ───────────────────────────────────────────────────────────── +// NOTE: enable LV_FONT_MONTSERRAT_20 / _30 / _36 / _40 / _48 in lv_conf.h - 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); +namespace { - 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); +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; +} + +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; +} + +} // 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 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); +} + +void HVCurrentArc::PushSample(float v) { + buf_.push(v); + Update(); +} + +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"); +} + +void HVVoltageDisplay::SetVoltage(float v) { + lv_label_set_text_fmt(label_, "HV %d V", (int)v); +} + +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"); +} + +void LVVoltageDisplay::SetVoltage(float v) { + lv_label_set_text_fmt(label_, "LV %d V", (int)v); +} + +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* 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); + + bar_ = lv_bar_create(wrap); + lv_bar_set_range(bar_, 0, 100); + lv_obj_set_size(bar_, LV_PCT(100), 26); + + label_ = lv_label_create(wrap); + lv_obj_set_style_text_font(label_, kFontValue, 0); + lv_label_set_text(label_, "--%"); +} + +void Battery::SetSOC(float soc) { + lv_bar_set_value(bar_, (int)soc, LV_ANIM_OFF); + lv_label_set_text_fmt(label_, "%d%%", (int)soc); +} + +// ───────────────────────────────────────────────────────────── +// Temp Card +// ───────────────────────────────────────────────────────────── + +void TempCard::Draw(lv_obj_t* parent, const char* title, lv_color_t color) { + container_ = lv_obj_create(parent); + 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_flex_flow(container_, LV_FLEX_FLOW_COLUMN); + lv_obj_set_flex_align(container_, LV_FLEX_ALIGN_SPACE_EVENLY, + LV_FLEX_ALIGN_START, LV_FLEX_ALIGN_START); + + 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_, 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_, 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", (int)min); + lv_label_set_text_fmt(max_label_, "Max: %d", (int)max); +} + +// ───────────────────────────────────────────────────────────── +// 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); + + 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); + + label_ = lv_label_create(wrap); + lv_obj_set_style_text_font(label_, kFontLabel, 0); + lv_label_set_text(label_, label); } -void Speedometer::SetSpeed(float speed) { - lv_arc_set_value(arc, speed * kArcSpeedResolution); - lv_label_set_text_fmt(label, "%d", static_cast(speed)); +void CANIndicator::SetActive(bool active) { + lv_obj_set_style_bg_color( + dot_, active ? lv_color_hex(0x00FF00) : lv_color_hex(0x444444), 0); } -// 12.9 16" +// ───────────────────────────────────────────────────────────── +// FC Status +// ───────────────────────────────────────────────────────────── + +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 FCStatusMessage::SetStatus(const char* s) { + lv_label_set_text_fmt(label_, "FC: %s", s); +} -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); +// ───────────────────────────────────────────────────────────── +// Speedometer (compact, bottom of right column) +// ───────────────────────────────────────────────────────────── - 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); +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); - SetPercent(0); + 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 Battery::SetPercent(float soc) { - lv_label_set_text_fmt(label, "%d %%", static_cast(soc)); +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(Display* display) - : Screen(display), last_warning_time_(0), warning_cycle_index_(0) {} +// ───────────────────────────────────────────────────────────── +// DriveModeMenu +// ───────────────────────────────────────────────────────────── + +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(); + 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); - // Status bar is always visible - speedometer_.Draw(frame_, LV_ALIGN_LEFT_MID, 100, 0); - battery_.Draw(frame_, LV_ALIGN_RIGHT_MID, -100, 0); + lv_obj_t* can_row = MakeRow(right); + veh_can_.Draw(can_row, "VEH"); - 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); + 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(); + auto pack_msg = display_->veh_bus.GetRxPack_State(); + auto inv_msg = display_->veh_bus.GetRxInverterStatus(); - if (fc_msg.has_value()) { - speedometer_.SetSpeed(fc_msg->Speed()); - battery_.SetPercent(fc_msg->HvSocPercent()); + hv_arc_.PushSample(bms_msg ? pack_msg->Pack_Current() : 0.0f); - if (fc_msg->Errored()) { - display_->ChangeState(State::ERROR); - } - } + lv_current_.SetCurrent(lv_msg ? lv_msg->BusCurrent() : 0.0f); + + lv_voltage_.SetVoltage(lv_msg ? lv_msg->LvBatteryVoltage() : 0.0f); + hv_voltage_.SetVoltage(acc_msg ? acc_msg->PackVoltage() : 0.0f); - // Demo: Cycle warnings every 4 seconds - uint32_t current_time = lv_tick_get(); + battery_.SetSOC(acc_msg ? 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(); + if (bms_msg) { + battery_temp_.SetTemps(bms_msg->LowThermValue(), + bms_msg->HighThermValue()); + } - // 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_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); - int warning_id = status_bar_.AddWarning(warnings[warning_cycle_index_]); - active_warning_ids_.push_back(warning_id); + fc_status_.SetStatus("OK"); - // Cycle to next warning - warning_cycle_index_ = (warning_cycle_index_ + 1) % 6; - last_warning_time_ = current_time; - } -} + speedo_.SetSpeed(fc_msg ? fc_msg->Speed() : 0.0f); + + 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/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/dashboard/src/main.cc b/projects/dashboard/src/main.cc index 586049018..41a24bf9c 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; } @@ -18,22 +18,20 @@ 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}; 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 { #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/.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/BSP/stm32469i_discovery_lcd.c b/projects/dashboard/src/platforms/stm32/BSP/stm32469i_discovery_lcd.c index 646cc8dfb..157b2227a 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,10 +222,14 @@ 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 + 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 @@ -217,7 +238,15 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { * - NVIC IRQ related to IP blocks enabled */ BSP_LCD_MspInit(); - + 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***********************************/ @@ -226,7 +255,8 @@ uint8_t BSP_LCD_InitEx(LCD_OrientationTypeDef orientation) { hdsi_eval.Instance = DSI; HAL_DSI_DeInit(&(hdsi_eval)); - + led_counter = 3; + advance_leds(); // 4 #if !defined(USE_STM32469I_DISCO_REVA) dsiPllInit.PLLNDIV = 125; dsiPllInit.PLLIDF = DSI_PLL_IN_DIV2; @@ -253,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 @@ -451,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; @@ -467,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/can.h b/projects/dashboard/src/platforms/stm32/Core/Inc/can.h index 0d8b3db2b..2ebe3df4c 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Inc/can.h +++ b/projects/dashboard/src/platforms/stm32/Core/Inc/can.h @@ -49,3 +49,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 ac8c2f177..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 15U /*!< 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/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 73dcc589e..efabeda52 100644 --- a/projects/dashboard/src/platforms/stm32/Core/Src/can.c +++ b/projects/dashboard/src/platforms/stm32/Core/Src/can.c @@ -27,84 +27,94 @@ CAN_HandleTypeDef hcan1; /* 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 */ - - /* USER CODE END 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 */ + } -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, 0, 0); - HAL_NVIC_EnableIRQ(CAN1_RX0_IRQn); - /* USER CODE BEGIN CAN1_MspInit 1 */ - - /* USER CODE END CAN1_MspInit 1 */ - } +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, 15, 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 */ +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(); + /* 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 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 */ + /* CAN1 interrupt Deinit */ + HAL_NVIC_DisableIRQ(CAN1_RX0_IRQn); + /* USER CODE BEGIN CAN1_MspDeInit 1 */ - /* USER CODE END CAN1_MspDeInit 1 */ - } + /* USER CODE END CAN1_MspDeInit 1 */ + } } /* USER CODE BEGIN 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 a9faa1cf8..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,117 +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 */ } /** - * @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 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 */ } /******************************************************************************/ @@ -191,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 f936cd3fe..1ebefe81f 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; + 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); + + 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,6 +71,8 @@ macfe::periph::DigitalInput& button_enter = mcal::button_enter; void Initialize() { HAL_Init(); + uwTickPrio = 0; + HAL_NVIC_SetPriority(SysTick_IRQn, 0, 0); SystemClock_Config(); /* Initialize all configured peripherals */ @@ -57,7 +80,6 @@ void Initialize() { MX_DMA_Init(); MX_DMA2D_Init(); MX_DSIHOST_DSI_Init(); - MX_CAN1_Init(); // Don't call MX_FMC_Init() - it is replaced by BSP_SDRAM...() BSP_SDRAM_Init(); @@ -66,35 +88,43 @@ void Initialize() { MX_LTDC_Init(); MX_USART3_UART_Init(); - mcal::veh_can_base.Setup(); - - BSP_LCD_Init(); + BSP_LCD_Init(); //! Breaks BSP_LCD_LayerDefaultInit(0, (uint32_t)SDRAM_DEVICE_ADDR); - BSP_LCD_Clear(LCD_COLOR_BLACK); - + 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 - 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(); + 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..7226e4649 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 @@ -808,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/dashboard/src/platforms/stm32/lv_conf.h b/projects/dashboard/src/platforms/stm32/lv_conf.h index fe26a44e6..4c8811eca 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 @@ -589,17 +589,17 @@ #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 -#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 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 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 4d3d619a8..e364957e7 100644 --- a/projects/front_controller/src/main.cc +++ b/projects/front_controller/src/main.cc @@ -189,6 +189,14 @@ static void Update_100Hz(void) { if (dash.has_value() && (dash->State() == DashState::SHUTDOWN)) { new_state = SHUTDOWN; } + 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: 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/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 22e1cea9f..858200ec8 100644 --- a/projects/veh.dbc +++ b/projects/veh.dbc @@ -128,21 +128,27 @@ 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_ 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|100] "" 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 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_"; @@ -262,10 +268,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 @@ -281,14 +287,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 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