Known working minimized setup
This commit is contained in:
@@ -12,5 +12,5 @@ DEFINE_TIMER_IRQ(Timer_Key::S_TIM15, TIM15_IRQHandler)
|
|||||||
DEFINE_TIMER_IRQ(Timer_Key::S_TIM16, TIM16_IRQHandler)
|
DEFINE_TIMER_IRQ(Timer_Key::S_TIM16, TIM16_IRQHandler)
|
||||||
|
|
||||||
void registerTimerCallback(Timer_Key key, TimerCallback callback){
|
void registerTimerCallback(Timer_Key key, TimerCallback callback){
|
||||||
timer_callbacks[static_cast<int>(key)] = callback;
|
timer_callbacks[static_cast<uint32_t>(key)] = callback;
|
||||||
}
|
}
|
||||||
@@ -1,50 +1,29 @@
|
|||||||
#include "SHAL.h"
|
#include "SHAL.h"
|
||||||
|
|
||||||
#include <cstdlib>
|
|
||||||
#include <cstdio>
|
|
||||||
|
|
||||||
void togglePin() {
|
|
||||||
|
|
||||||
//PIN(B4).toggle();
|
|
||||||
//SHAL_UART2.sendString("Test\r\n");
|
|
||||||
}
|
|
||||||
|
|
||||||
void timer2callback(){
|
void timer2callback(){
|
||||||
auto val = PIN(A5).analogRead();
|
uint16_t val = PIN(A5).analogRead(SHAL_ADC_SampleTime::C4);
|
||||||
|
|
||||||
char buf [6];
|
if(val <= 600){
|
||||||
sprintf (buf, "%d\r\n", val);
|
PIN(B3).setHigh();
|
||||||
|
}
|
||||||
SHAL_UART2.sendString(buf);
|
else{
|
||||||
|
PIN(B3).setLow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int main() {
|
int main() {
|
||||||
|
|
||||||
SHAL_init();
|
SHAL_init();
|
||||||
|
|
||||||
PIN(B4).setPinMode(PinMode::OUTPUT_MODE);
|
|
||||||
PIN(B4).setLow();
|
|
||||||
|
|
||||||
PIN(B3).setPinMode(PinMode::OUTPUT_MODE);
|
PIN(B3).setPinMode(PinMode::OUTPUT_MODE);
|
||||||
|
|
||||||
PIN(A5).setPinMode(PinMode::ANALOG_MODE);
|
PIN(A5).setPinMode(PinMode::ANALOG_MODE);
|
||||||
|
|
||||||
SHAL_UART2.init(UART_Pair_Key::Tx2A2_Rx2A3);
|
SHAL_TIM2.init(4000000,50);
|
||||||
|
|
||||||
SHAL_UART2.begin(115200);
|
|
||||||
|
|
||||||
|
|
||||||
SHAL_UART2.sendString("Hello\r\n");
|
|
||||||
|
|
||||||
|
|
||||||
SHAL_TIM2.init(8000000,1000);
|
|
||||||
|
|
||||||
SHAL_TIM2.setCallbackFunc(timer2callback);
|
SHAL_TIM2.setCallbackFunc(timer2callback);
|
||||||
SHAL_TIM2.enableInterrupt();
|
SHAL_TIM2.enableInterrupt();
|
||||||
SHAL_TIM2.start();
|
SHAL_TIM2.start();
|
||||||
|
|
||||||
//End setup
|
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user