72 lines
1.6 KiB
C++
72 lines
1.6 KiB
C++
#include "Start.hpp"
|
|
#include "SerialDebug.hpp"
|
|
#include "ESP8266.hpp"
|
|
#include <cstring>
|
|
|
|
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);
|
|
ESP8266 esp0(&huart1);
|
|
|
|
//Temporary variables begin
|
|
char buf[64];
|
|
//Temporary Variables end
|
|
|
|
void HAL_TIM_PeriodElapsedCallback(TIM_HandleTypeDef *htim){
|
|
if(htim==&htim4){
|
|
|
|
}
|
|
}
|
|
|
|
void HAL_UART_TxCpltCallback(UART_HandleTypeDef *huart) {
|
|
if(huart == &huart2){
|
|
debug.serialTxCpltCallback();
|
|
}
|
|
}
|
|
|
|
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
|
|
|
|
}
|
|
|
|
void start(){
|
|
debug.setLevel(SerialDebug::DEBUG_LEVEL_DEBUG);
|
|
debug.info("-----Init-----");
|
|
debug.info("Init timers begin");
|
|
//HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_1);
|
|
HAL_TIM_Encoder_Start(&htim1, TIM_CHANNEL_ALL);
|
|
//HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_1);
|
|
HAL_TIM_Encoder_Start(&htim3, TIM_CHANNEL_ALL);
|
|
HAL_TIM_PWM_Start(&htim2, TIM_CHANNEL_ALL);
|
|
HAL_TIM_Base_Start(&htim4);
|
|
debug.info("Init timers end");
|
|
debug.info("Init ESP8266 begin");
|
|
HAL_Delay(1000);
|
|
switch(esp0.command("ATE1\r\n")){
|
|
case ESP8266::STATUS_OK:
|
|
debug.debug("ATE0 OK");
|
|
break;
|
|
case ESP8266::STATUS_ERROR:
|
|
debug.debug("ATE0 ERROR");
|
|
break;
|
|
case ESP8266::STATUS_TIMEOUT:
|
|
debug.debug("ATE0 TIMEOUT");
|
|
break;
|
|
}
|
|
esp0.init();
|
|
//+IPD,0,14:Hello World 01\r\n
|
|
debug.info("Init ESP8266 end");
|
|
while(true){
|
|
esp0.send_uint32("TIM1->CNT", TIM1->CNT);
|
|
esp0.receive_uint32();
|
|
/*sprintf(buf, "TIM1->CNT: %lu", TIM1->CNT);
|
|
debug.debug(buf);*/
|
|
//HAL_Delay(10);
|
|
}
|
|
}
|
|
|