| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152 |
- /*
- * Copyright (c) 2006-2021, RT-Thread Development Team
- *
- * SPDX-License-Identifier: Apache-2.0
- *
- * Change Logs:
- * Date Author Notes
- * 2023-03-03 ZZ the first version
- */
- #ifndef APPLICATIONS_USART_USART_H_
- #define APPLICATIONS_USART_USART_H_
- #include "stm32g0xx_hal.h"
- #include "stm32g0xx_hal_usart.h"
- #ifdef __cplusplus
- extern "C" {
- #endif
- extern UART_HandleTypeDef UartHandle;
- #define USART1_BUFF_LANGTH 1048
- uint8_t uart1_buff[4];
- typedef struct {
- uint32_t len;
- uint16_t ind;
- uint8_t buf[USART1_BUFF_LANGTH];
- }SerialBuffType; //发送暂存区
- #define TX_TIMEOUT ((uint32_t)1000)
- #define RX_TIMEOUT HAL_MAX_DELAY
- /* Exported macro ------------------------------------------------------------*/
- #define IS_CAP_LETTER(c) (((c) >= 'A') && ((c) <= 'F'))
- #define IS_LC_LETTER(c) (((c) >= 'a') && ((c) <= 'f'))
- #define IS_09(c) (((c) >= '0') && ((c) <= '9'))
- #define ISVALIDHEX(c) (IS_CAP_LETTER(c) || IS_LC_LETTER(c) || IS_09(c))
- #define ISVALIDDEC(c) IS_09(c)
- #define CONVERTDEC(c) (c - '0')
- #define CONVERTHEX_ALPHA(c) (IS_CAP_LETTER(c) ? ((c) - 'A'+10) : ((c) - 'a'+10))
- #define CONVERTHEX(c) (IS_09(c) ? ((c) - '0') : CONVERTHEX_ALPHA(c))
- void MX_USART1_UART_Init(void);
- //void HAL_UART1_MspInit(void);
- //void HAL_UART1_MspDeInit(void);
- //void USART1_IRQHandler(void);
- void Int2Str(uint8_t *p_str, uint32_t intnum);
- uint32_t Str2Int(uint8_t *inputstr, uint32_t *intnum);
- void Serial_PutString(uint8_t *p_string,uint8_t p_len);
- HAL_StatusTypeDef Serial_PutByte(uint8_t param);
- #endif /* APPLICATIONS_USART_USART_H_ */
|