diff --git a/firmware/projects/EV5/TMS/bindings.h b/firmware/projects/EV5/TMS/bindings.h new file mode 100644 index 000000000..fcf0fbe7e --- /dev/null +++ b/firmware/projects/EV5/TMS/bindings.h @@ -0,0 +1,24 @@ +#pragma once + +#include "shared/periph/adc.h" +#include "shared/periph/can.h" +#include "shared/periph/gpio.h" +#include "shared/periph/pwm.h" + +namespace bindings { +extern shared::periph::ADCInput& temp_sensor_adc_1; +extern shared::periph::ADCInput& temp_sensor_adc_2; +extern shared::periph::ADCInput& temp_sensor_adc_3; +extern shared::periph::ADCInput& temp_sensor_adc_4; +extern shared::periph::ADCInput& temp_sensor_adc_5; +extern shared::periph::ADCInput& temp_sensor_adc_6; + +extern shared::periph::PWMOutput& fan_controller_pwm; + +extern shared::periph::DigitalOutput& debug_led_green; +extern shared::periph::DigitalOutput& debug_led_red; + +extern shared::periph::CanBase& veh_can_base; + +extern void Initialize(); +} // namespace bindings diff --git a/firmware/projects/EV5/TMS/main.cc b/firmware/projects/EV5/TMS/main.cc index 18d3c2f56..648b4b633 100644 --- a/firmware/projects/EV5/TMS/main.cc +++ b/firmware/projects/EV5/TMS/main.cc @@ -5,6 +5,7 @@ #include #include "app.h" +#include "bindings.h" #include "shared/comms/can/can_bus.h" #include "shared/os/tick.h" #include "shared/periph/adc.h" @@ -16,25 +17,6 @@ #include "veh_can_messages.h" #include "veh_msg_registry.h" -namespace bindings { -extern shared::periph::ADCInput& temp_sensor_adc_1; -extern shared::periph::ADCInput& temp_sensor_adc_2; -extern shared::periph::ADCInput& temp_sensor_adc_3; -extern shared::periph::ADCInput& temp_sensor_adc_4; -extern shared::periph::ADCInput& temp_sensor_adc_5; -extern shared::periph::ADCInput& temp_sensor_adc_6; - -extern shared::periph::PWMOutput& fan_controller_pwm; - -extern shared::periph::DigitalOutput& debug_do_blue; -extern shared::periph::DigitalOutput& debug_do_red; - -extern shared::periph::CanBase& veh_can_base; - -extern void Initialize(); -extern void Log(std::string); -} // namespace bindings - namespace os { extern void Tick(uint32_t ticks); extern void InitializeKernel(); @@ -84,11 +66,9 @@ const float temp_lut_data[][2] = { }; const float fan_lut_data[][2] = { - // clang-format off - {-1, 0}, - { 0, 30}, - {50, 100} - // clang-format on + {-1, 0}, + {0, 30}, + {50, 100}, }; constexpr int temp_lut_length = @@ -115,8 +95,8 @@ shared::can::CanBus veh_can_bus{ ***************************************************************/ FanContoller fan_controller{bindings::fan_controller_pwm, fan_temp_lut, 2.0f}; -DebugIndicator debug_blue{bindings::debug_do_blue}; -DebugIndicator debug_red{bindings::debug_do_red}; +DebugIndicator debug_green{bindings::debug_led_green}; +DebugIndicator debug_red{bindings::debug_led_red}; TempSensor temp_sensors[] = { TempSensor{bindings::temp_sensor_adc_1, temp_adc_lut}, @@ -141,6 +121,9 @@ void Update() { static uint8_t low_thermistor_idx; static uint8_t high_thermistor_idx; + debug_green.Toggle(); + debug_red.Toggle(); + veh_can_bus.Update(); ts_manager.Update(); ts_manager.GetTemperatures(temperature_buffer); @@ -168,7 +151,6 @@ void UpdateTask(void* argument) { while (true) { uint32_t start_time_ms = os::GetTickCount(); Update(); - debug_blue.Toggle(); // toggling indicates the loop is running os::TickUntil(start_time_ms + kTaskPeriodMs); } } diff --git a/firmware/projects/EV5/TMS/platforms/cli/CMakeLists.txt b/firmware/projects/EV5/TMS/platforms/cli/CMakeLists.txt deleted file mode 100644 index 7a94cd78b..000000000 --- a/firmware/projects/EV5/TMS/platforms/cli/CMakeLists.txt +++ /dev/null @@ -1,2 +0,0 @@ -target_sources(bindings PRIVATE bindings.cc) -target_link_libraries(bindings PUBLIC mcal-cli) \ No newline at end of file diff --git a/firmware/projects/EV5/TMS/platforms/cli/bindings.cc b/firmware/projects/EV5/TMS/platforms/cli/bindings.cc deleted file mode 100644 index be5c2ddfb..000000000 --- a/firmware/projects/EV5/TMS/platforms/cli/bindings.cc +++ /dev/null @@ -1,50 +0,0 @@ -/// @author Blake Freer -/// @date 2023-12-25 - -#include -#include - -#include "mcal/cli/periph/adc.h" -#include "mcal/cli/periph/gpio.h" -#include "mcal/cli/periph/pwm.h" -#include "shared/periph/adc.h" -#include "shared/periph/gpio.h" -#include "shared/periph/pwm.h" - -namespace mcal { -using namespace cli::periph; - -ADCInput temp_sensor_adc_1{"Temperature Sensor 1"}; -ADCInput temp_sensor_adc_2{"Temperature Sensor 2"}; -ADCInput temp_sensor_adc_3{"Temperature Sensor 3"}; -ADCInput temp_sensor_adc_4{"Temperature Sensor 4"}; -ADCInput temp_sensor_adc_5{"Temperature Sensor 5"}; -ADCInput temp_sensor_adc_6{"Temperature Sensor 6"}; - -PWMOutput fan_controller_pwm{"Fan Controller"}; -DigitalOutput debug_do_blue{"Debug: Blue"}; -DigitalOutput debug_do_red{"Debug: Red"}; - -} // namespace mcal - -namespace bindings { - -const shared::periph::ADCInput& temp_sensor_adc_1 = mcal::temp_sensor_adc_1; -const shared::periph::ADCInput& temp_sensor_adc_2 = mcal::temp_sensor_adc_2; -const shared::periph::ADCInput& temp_sensor_adc_3 = mcal::temp_sensor_adc_3; -const shared::periph::ADCInput& temp_sensor_adc_4 = mcal::temp_sensor_adc_4; -const shared::periph::ADCInput& temp_sensor_adc_5 = mcal::temp_sensor_adc_5; -const shared::periph::ADCInput& temp_sensor_adc_6 = mcal::temp_sensor_adc_6; -const shared::periph::PWMOutput& fan_controller_pwm = mcal::fan_controller_pwm; -const shared::periph::DigitalOutput& debug_do_blue = mcal::debug_do_blue; -const shared::periph::DigitalOutput& debug_do_red = mcal::debug_do_red; - -void Initialize() { - std::cout << "Initializing CLI..." << std::endl; -} - -void Log(std::string message) { - std::cout << "(Log) " << message << std::endl; -} - -} // namespace bindings diff --git a/firmware/projects/EV5/TMS/platforms/cli/mcal_conf.cmake b/firmware/projects/EV5/TMS/platforms/cli/mcal_conf.cmake deleted file mode 100644 index 1fb1df289..000000000 --- a/firmware/projects/EV5/TMS/platforms/cli/mcal_conf.cmake +++ /dev/null @@ -1,3 +0,0 @@ -# This file determines which mcal folder is included so that the mcal library -# can be linked to `bindings`. -set(MCAL cli) \ No newline at end of file diff --git a/firmware/projects/EV5/TMS/platforms/stm32f767/CMakeLists.txt b/firmware/projects/EV5/TMS/platforms/stm32f767/CMakeLists.txt index d67bc8fa3..3f38732c8 100644 --- a/firmware/projects/EV5/TMS/platforms/stm32f767/CMakeLists.txt +++ b/firmware/projects/EV5/TMS/platforms/stm32f767/CMakeLists.txt @@ -3,7 +3,8 @@ add_subdirectory(cubemx) -target_sources(bindings PUBLIC bindings.cc os.cc) +target_sources(bindings PUBLIC bindings.cc) +target_include_directories(bindings PUBLIC ${DIR_PROJECT}) target_link_libraries(bindings PUBLIC driver mcal-stm32f767) add_library(os) diff --git a/firmware/projects/EV5/TMS/platforms/stm32f767/bindings.cc b/firmware/projects/EV5/TMS/platforms/stm32f767/bindings.cc index 5c11bb28b..6dbd41b3c 100644 --- a/firmware/projects/EV5/TMS/platforms/stm32f767/bindings.cc +++ b/firmware/projects/EV5/TMS/platforms/stm32f767/bindings.cc @@ -13,6 +13,7 @@ #include "tim.h" // fw imports +#include "bindings.h" #include "mcal/stm32f767/periph/adc.h" #include "mcal/stm32f767/periph/gpio.h" #include "mcal/stm32f767/periph/pwm.h" @@ -39,26 +40,28 @@ ADCInput temp_sensor_adc_5{&hadc1, SENS_5_UC_IN_CHANNEL}; ADCInput temp_sensor_adc_6{&hadc1, SENS_6_UC_IN_CHANNEL}; PWMOutput fan_controller_pwm{&htim4, TIM_CHANNEL_1}; -DigitalOutput debug_do_blue{NUCLEO_BLUE_LED_GPIO_Port, NUCLEO_BLUE_LED_Pin}; -DigitalOutput debug_do_red{NUCLEO_RED_LED_GPIO_Port, NUCLEO_RED_LED_Pin}; +DigitalOutput debug_led_green{DEBUG_LED1_GPIO_Port, DEBUG_LED1_Pin}; +DigitalOutput debug_led_red{DEBUG_LED2_GPIO_Port, DEBUG_LED2_Pin}; +DigitalOutput debug_led_nucleo{NUCLEO_RED_LED_GPIO_Port, NUCLEO_RED_LED_Pin}; CanBase veh_can_base{&hcan2}; } // namespace mcal namespace bindings { -const shared::periph::ADCInput& temp_sensor_adc_1 = mcal::temp_sensor_adc_1; -const shared::periph::ADCInput& temp_sensor_adc_2 = mcal::temp_sensor_adc_2; -const shared::periph::ADCInput& temp_sensor_adc_3 = mcal::temp_sensor_adc_3; -const shared::periph::ADCInput& temp_sensor_adc_4 = mcal::temp_sensor_adc_4; -const shared::periph::ADCInput& temp_sensor_adc_5 = mcal::temp_sensor_adc_5; -const shared::periph::ADCInput& temp_sensor_adc_6 = mcal::temp_sensor_adc_6; +shared::periph::ADCInput& temp_sensor_adc_1 = mcal::temp_sensor_adc_1; +shared::periph::ADCInput& temp_sensor_adc_2 = mcal::temp_sensor_adc_2; +shared::periph::ADCInput& temp_sensor_adc_3 = mcal::temp_sensor_adc_3; +shared::periph::ADCInput& temp_sensor_adc_4 = mcal::temp_sensor_adc_4; +shared::periph::ADCInput& temp_sensor_adc_5 = mcal::temp_sensor_adc_5; +shared::periph::ADCInput& temp_sensor_adc_6 = mcal::temp_sensor_adc_6; -const shared::periph::PWMOutput& fan_controller_pwm = mcal::fan_controller_pwm; -const shared::periph::DigitalOutput& debug_do_blue = mcal::debug_do_blue; -const shared::periph::DigitalOutput& debug_do_red = mcal::debug_do_red; +shared::periph::PWMOutput& fan_controller_pwm = mcal::fan_controller_pwm; +shared::periph::DigitalOutput& debug_led_green = mcal::debug_led_green; +shared::periph::DigitalOutput& debug_led_red = mcal::debug_led_red; +// shared::periph::DigitalOutput& debug_led_red = mcal::debug_led_nucleo; -const shared::periph::CanBase& veh_can_base = mcal::veh_can_base; +shared::periph::CanBase& veh_can_base = mcal::veh_can_base; void Initialize() { SystemClock_Config(); @@ -69,8 +72,4 @@ void Initialize() { MX_CAN2_Init(); } -void Log(std::string s) { - return; -} - } // namespace bindings diff --git a/firmware/projects/EV5/TMS/platforms/stm32f767/cubemx/board_config.ioc b/firmware/projects/EV5/TMS/platforms/stm32f767/cubemx/board_config.ioc index 147b69e7c..0d1a7569b 100644 --- a/firmware/projects/EV5/TMS/platforms/stm32f767/cubemx/board_config.ioc +++ b/firmware/projects/EV5/TMS/platforms/stm32f767/cubemx/board_config.ioc @@ -17,8 +17,9 @@ CAN2.CalculateTimeQuantum=125.0 CAN2.IPParameters=CalculateTimeQuantum,CalculateBaudRate,Prescaler,CalculateTimeBit,BS1,BS2,ABOM CAN2.Prescaler=6 FREERTOS.FootprintOK=true -FREERTOS.IPParameters=Tasks01,FootprintOK -FREERTOS.Tasks01=Update,24,128,UpdateTask,As weak,NULL,Static,UpdateBuffer,UpdateControlBlock +FREERTOS.IPParameters=Tasks01,FootprintOK,configTOTAL_HEAP_SIZE +FREERTOS.Tasks01=Update,24,4096,UpdateTask,As weak,NULL,Static,UpdateBuffer,UpdateControlBlock +FREERTOS.configTOTAL_HEAP_SIZE=102400 File.Version=6 GPIO.groupedBy=Group By Peripherals KeepUserPlacement=false @@ -35,21 +36,23 @@ Mcu.IP7=TIM4 Mcu.IPNb=8 Mcu.Name=STM32F767ZITx Mcu.Package=LQFP144 -Mcu.Pin0=PC0 -Mcu.Pin1=PC1 -Mcu.Pin10=PB7 -Mcu.Pin11=VP_FREERTOS_VS_CMSIS_V2 -Mcu.Pin12=VP_SYS_VS_tim3 -Mcu.Pin13=VP_TIM4_VS_ClockSourceINT -Mcu.Pin2=PC2 -Mcu.Pin3=PC3 -Mcu.Pin4=PC4 -Mcu.Pin5=PC5 -Mcu.Pin6=PB13 -Mcu.Pin7=PB14 -Mcu.Pin8=PB5 -Mcu.Pin9=PB6 -Mcu.PinsNb=14 +Mcu.Pin0=PE2 +Mcu.Pin1=PC0 +Mcu.Pin10=PB5 +Mcu.Pin11=PB6 +Mcu.Pin12=PB7 +Mcu.Pin13=VP_FREERTOS_VS_CMSIS_V2 +Mcu.Pin14=VP_SYS_VS_tim3 +Mcu.Pin15=VP_TIM4_VS_ClockSourceINT +Mcu.Pin2=PC1 +Mcu.Pin3=PC2 +Mcu.Pin4=PC3 +Mcu.Pin5=PA3 +Mcu.Pin6=PC4 +Mcu.Pin7=PC5 +Mcu.Pin8=PB13 +Mcu.Pin9=PB14 +Mcu.PinsNb=16 Mcu.ThirdPartyNb=0 Mcu.UserConstants=SENS_2_UC_IN_CHANNEL,ADC_CHANNEL_11;SENS_6_UC_IN_CHANNEL,ADC_CHANNEL_15;SENS_3_UC_IN_CHANNEL,ADC_CHANNEL_12;SENS_1_UC_IN_CHANNEL,ADC_CHANNEL_10;SENS_4_UC_IN_CHANNEL,ADC_CHANNEL_13;SENS_5_UC_IN_CHANNEL,ADC_CHANNEL_14 Mcu.UserName=STM32F767ZITx @@ -73,6 +76,10 @@ NVIC.TIM3_IRQn=true\:15\:0\:false\:false\:true\:false\:false\:true\:true NVIC.TimeBase=TIM3_IRQn NVIC.TimeBaseIP=TIM3 NVIC.UsageFault_IRQn=true\:0\:0\:false\:false\:true\:false\:true\:false\:false +PA3.GPIOParameters=GPIO_Label +PA3.GPIO_Label=DEBUG_LED2 +PA3.Locked=true +PA3.Signal=GPIO_Output PB13.Locked=true PB13.Mode=CAN_Activate PB13.Signal=CAN2_TX @@ -115,6 +122,10 @@ PC5.GPIOParameters=GPIO_Label PC5.GPIO_Label=SENS_6_UC_IN PC5.Locked=true PC5.Signal=ADCx_IN15 +PE2.GPIOParameters=GPIO_Label +PE2.GPIO_Label=DEBUG_LED1 +PE2.Locked=true +PE2.Signal=GPIO_Output PinOutPanel.RotationAngle=0 ProjectManager.AskForMigrate=true ProjectManager.BackupPrevious=false