Files
PFC/Code/STM32/Core/Src/Components/Start.cpp
2023-07-29 12:06:45 -03:00

59 lines
1.2 KiB
C++

#include "Start.hpp"
#include "SerialDebug.hpp"
#include "Robot.hpp"
extern UART_HandleTypeDef huart1;
extern UART_HandleTypeDef huart2;
extern TIM_HandleTypeDef htim1;
extern TIM_HandleTypeDef htim2;
extern TIM_HandleTypeDef htim3;
extern TIM_HandleTypeDef htim4;
SerialDebug debug(&huart2, 32);
Robot robot;
//Temporary variables begin
//Temporary Variables end
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
if(htim==&htim4){
robot.controlCallback();
}
}
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
if(huart == &huart2){
debug.serialTxCpltCallback();
}
}
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
switch(GPIO_Pin){
case GPIO_PIN_8:
//encoder0
robot.encoder0.callback(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_9));
break;
case GPIO_PIN_6:
//encoder1
robot.encoder1.callback(HAL_GPIO_ReadPin(GPIOA, GPIO_PIN_7));
break;
}
}
void HAL_UARTEx_RxEventCallback(UART_HandleTypeDef *huart, uint16_t Size){
if(huart == &huart1){
robot.uartCallback();
}
}
void start(){
debug.setLevel(SerialDebug::DEBUG_LEVEL_INFO);
debug.info("-----Init-----");
robot.init();
while(true){
}
}