working receive
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include <stm32f1xx_hal.h>
|
||||
#include <stm32f1xx_hal_uart.h>
|
||||
|
||||
#include "logging.hpp"
|
||||
#include "spi.hpp"
|
||||
@@ -27,6 +28,22 @@ void SysTick_Handler(void) {
|
||||
HAL_IncTick();
|
||||
HAL_SYSTICK_IRQHandler();
|
||||
}
|
||||
|
||||
void USART1_IRQHandler(void) {
|
||||
HAL_UART_IRQHandler(&uart_interface::s_UARTHandle);
|
||||
HAL_UART_Receive_IT(&uart_interface::s_UARTHandle, uart_interface::get_buf(),
|
||||
1);
|
||||
}
|
||||
|
||||
void HAL_UART_RxCpltCallback(UART_HandleTypeDef *huart) {
|
||||
const char value = *reinterpret_cast<const char *>(uart_interface::get_buf());
|
||||
|
||||
if (value == '\r') {
|
||||
HAL_GPIO_TogglePin(LED_PORT, LED2_PIN);
|
||||
}
|
||||
|
||||
log::debug({&value, 1});
|
||||
}
|
||||
}
|
||||
|
||||
void initGPIO() {
|
||||
@@ -105,11 +122,9 @@ int main(void) {
|
||||
while (1) {
|
||||
// RF95_setModeRx_Continuous();
|
||||
HAL_GPIO_WritePin(LED_PORT, LED1_PIN, GPIO_PIN_RESET);
|
||||
HAL_GPIO_WritePin(LED_PORT, LED2_PIN, GPIO_PIN_RESET);
|
||||
// RF95_receive(LoRa_buff);
|
||||
HAL_Delay(500);
|
||||
HAL_GPIO_WritePin(LED_PORT, LED1_PIN, GPIO_PIN_SET);
|
||||
HAL_GPIO_WritePin(LED_PORT, LED2_PIN, GPIO_PIN_SET);
|
||||
HAL_Delay(500);
|
||||
|
||||
// std::string_view msg{reinterpret_cast<char *>(LoRa_buff)};
|
||||
|
||||
Reference in New Issue
Block a user