66 lines
1.4 KiB
C
Raw Normal View History

2021-10-12 14:23:45 +08:00
/**
* @file main.c
* @author Myth
* @version 0.8
* @date 2021.10.15
2021-10-12 14:23:45 +08:00
* @brief
* @details
* @note
* PC13 LED
*
2021-10-12 23:38:04 +08:00
* JTAG 使 SWD
2021-10-12 14:23:45 +08:00
*/
#include "sys.h"
#include "systick.h"
#include "uart.h"
#include "led.h"
#include "lora.h"
2021-10-12 14:23:45 +08:00
void Echo(uint8_t byte);
int main(void)
{
if (HAL_Init() != HAL_OK) //初始化 HAL 库
{
Error_Handler(__FILE__, __LINE__); //错误处理
}
SystemClock_Config(); //初始化系统时钟为 72MHz
2021-10-12 23:38:04 +08:00
DisableJTAG(); //禁用 JTAG
2021-10-12 14:23:45 +08:00
SysTick_Init(); //初始化 SysTick 和软件定时器
UART_Init(); //初始化串口
LED_Init(); //初始化 LED
LoRa_Init(); //初始化 LoRa 模块
2021-10-12 14:23:45 +08:00
UART_BindReceiveHandle(COM1, Echo); //绑定 COM1 串口接收中断至 Echo 函数
uint8_t buffer[255];
uint8_t size;
2021-10-14 00:48:38 +08:00
2021-10-12 14:23:45 +08:00
while (1)
{
//程序主循环
size = LoRa_Receive(buffer); //接收
if (size == 0)
continue;
printf("Receive %d bytes: %s\n", size, buffer);
LED1_Toggle;
2021-10-12 14:23:45 +08:00
}
return 1;
}
/**
* @brief
* @param byte:
*/
2021-10-12 14:23:45 +08:00
void Echo(uint8_t byte)
{
LED1_Slow_Toggle;
UART_SendChar(COM1, byte);
}