From 0b4a6ef5840a788e6a75b0ba746c0e73391d4285 Mon Sep 17 00:00:00 2001 From: Ea-r-th <39779954+Ea-r-th@users.noreply.github.com> Date: Thu, 23 Oct 2025 20:52:04 -0700 Subject: [PATCH] Known working minimized setup --- .../Peripheral/Timer/SHAL_TIM_CALLBACK.cpp | 2 +- SHAL/Src/main.cpp | 39 +++++-------------- 2 files changed, 10 insertions(+), 31 deletions(-) diff --git a/SHAL/Src/STM32L4XX/Peripheral/Timer/SHAL_TIM_CALLBACK.cpp b/SHAL/Src/STM32L4XX/Peripheral/Timer/SHAL_TIM_CALLBACK.cpp index 4ad8484..6a212b8 100644 --- a/SHAL/Src/STM32L4XX/Peripheral/Timer/SHAL_TIM_CALLBACK.cpp +++ b/SHAL/Src/STM32L4XX/Peripheral/Timer/SHAL_TIM_CALLBACK.cpp @@ -12,5 +12,5 @@ DEFINE_TIMER_IRQ(Timer_Key::S_TIM15, TIM15_IRQHandler) DEFINE_TIMER_IRQ(Timer_Key::S_TIM16, TIM16_IRQHandler) void registerTimerCallback(Timer_Key key, TimerCallback callback){ - timer_callbacks[static_cast(key)] = callback; + timer_callbacks[static_cast(key)] = callback; } \ No newline at end of file diff --git a/SHAL/Src/main.cpp b/SHAL/Src/main.cpp index c87e29d..9a5381d 100644 --- a/SHAL/Src/main.cpp +++ b/SHAL/Src/main.cpp @@ -1,51 +1,30 @@ #include "SHAL.h" -#include -#include - -void togglePin() { - - //PIN(B4).toggle(); - //SHAL_UART2.sendString("Test\r\n"); -} - void timer2callback(){ - auto val = PIN(A5).analogRead(); + uint16_t val = PIN(A5).analogRead(SHAL_ADC_SampleTime::C4); - char buf [6]; - sprintf (buf, "%d\r\n", val); - - SHAL_UART2.sendString(buf); + if(val <= 600){ + PIN(B3).setHigh(); + } + else{ + PIN(B3).setLow(); + } } int main() { SHAL_init(); - PIN(B4).setPinMode(PinMode::OUTPUT_MODE); - PIN(B4).setLow(); - PIN(B3).setPinMode(PinMode::OUTPUT_MODE); - PIN(A5).setPinMode(PinMode::ANALOG_MODE); - SHAL_UART2.init(UART_Pair_Key::Tx2A2_Rx2A3); - - SHAL_UART2.begin(115200); - - - SHAL_UART2.sendString("Hello\r\n"); - - - SHAL_TIM2.init(8000000,1000); + SHAL_TIM2.init(4000000,50); SHAL_TIM2.setCallbackFunc(timer2callback); SHAL_TIM2.enableInterrupt(); SHAL_TIM2.start(); - //End setup - while (true) { } -} +} \ No newline at end of file