From f677bbecc88e3e311d1330c635ff069b88179758 Mon Sep 17 00:00:00 2001 From: "lxbpxylps@126.com" Date: Wed, 6 Oct 2021 00:36:37 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=20HC-12=20=E5=BA=93?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Hardware/hc12/hc12.c | 20 ++++++++++++++++++++ Hardware/hc12/hc12.h | 19 +++++++++++++++++++ System/usart/uart.c | 1 + System/usart/uart.h | 4 ++-- 4 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 Hardware/hc12/hc12.c create mode 100644 Hardware/hc12/hc12.h diff --git a/Hardware/hc12/hc12.c b/Hardware/hc12/hc12.c new file mode 100644 index 0000000..5bfa0ff --- /dev/null +++ b/Hardware/hc12/hc12.c @@ -0,0 +1,20 @@ +//HC12 库 + +#include "string.h" + +#include "systick.h" + +#include "hc25.h" + +/**************************************** 私有变量 ****************************************/ + +/*****************************************************************************************/ + +/**************************************** 私有函数 ****************************************/ + +/*****************************************************************************************/ + +void HC12_Init(void) +{ + +} diff --git a/Hardware/hc12/hc12.h b/Hardware/hc12/hc12.h new file mode 100644 index 0000000..2433ab7 --- /dev/null +++ b/Hardware/hc12/hc12.h @@ -0,0 +1,19 @@ +//HC12 库 + +#ifndef __HC12_H +#define __HC12_H + +#include "uart.h" + +#define HC12_COM COM3 + +#define HC12_SendBuff(__pdata__, __data_len__) Uart_SendBuf(HC12_COM, __pdata__, __data_len__) +#define HC12_Receive(__pdata__) Uart_GetChar(HC12_COM, __pdata__) +#define HC12_ReceiveBuffUntil(__pdata__, __end_byte__, __timeout__) Uart_GetBuffUntil(HC12_COM, __pdata__, __end_byte__, __timeout__) +#define HC12_ClearSend Uart_ClearTxFifo(HC12_COM) +#define HC12_ClearReceive Uart_ClearRxFifo(HC12_COM) +#define HC12_BindReceiveHandle(__receive__) Uart_BindReceiveHandle(HC12_COM, __receive__) + +void HC12_Init(void); + +#endif diff --git a/System/usart/uart.c b/System/usart/uart.c index fe7e89a..6f6e618 100644 --- a/System/usart/uart.c +++ b/System/usart/uart.c @@ -407,6 +407,7 @@ uint8_t Uart_GetBuffUntil(COM_PORT_E _ucPort, uint8_t *_pBuf, uint8_t _endByte, if (ch == _endByte) { _pBuf[i] = '\0'; + return 1; } diff --git a/System/usart/uart.h b/System/usart/uart.h index a7516bd..fd039cc 100644 --- a/System/usart/uart.h +++ b/System/usart/uart.h @@ -5,7 +5,7 @@ #define UART1_FIFO_EN 1 //调试用串口 #define UART2_FIFO_EN 1 //WiFi 透传 -#define UART3_FIFO_EN 0 +#define UART3_FIFO_EN 1 //HC-12 #define UART4_FIFO_EN 0 #define UART5_FIFO_EN 0 #define UART6_FIFO_EN 0 @@ -39,7 +39,7 @@ typedef enum #endif #if UART3_FIFO_EN == 1 -#define UART3_BAUD 115200 +#define UART3_BAUD 9600 #define UART3_TX_BUF_SIZE 1 * 1024 #define UART3_RX_BUF_SIZE 1 * 1024 #endif