108 lines
3.2 KiB
C
108 lines
3.2 KiB
C
/***
|
|
* @Author: mbw
|
|
* @Date: 2024-08-20 15:51:16
|
|
* @LastEditors: mbw && 1600520629@qq.com
|
|
* @LastEditTime: 2024-09-04 11:54:28
|
|
* @FilePath: \USART1_Interrupt - RT-Thread\drivers\inc\drv_uart.h
|
|
* @Description:
|
|
* @
|
|
* @Copyright (c) 2024 by ${git_name_email}, All Rights Reserved.
|
|
*/
|
|
/************************************************************************************************/
|
|
/**
|
|
* @file usart_bsp.h
|
|
* @author MCU Ecosystem Development Team
|
|
* @brief USART BSP头文件。
|
|
*
|
|
*
|
|
**************************************************************************************************
|
|
* @attention
|
|
* Copyright (c) CEC Huada Electronic Design Co.,Ltd. All rights reserved.
|
|
*
|
|
**************************************************************************************************
|
|
*/
|
|
|
|
/* 避免头文件重复引用 */
|
|
#ifndef USART_BSP_H
|
|
#define USART_BSP_H
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/*------------------------------------------includes--------------------------------------------*/
|
|
#include <rtthread.h>
|
|
#include <rthw.h>
|
|
#include "lwrb.h"
|
|
typedef enum
|
|
{
|
|
kCheck0Stop1 = 0U,
|
|
kCheck0Stop2,
|
|
kCheckOdd,
|
|
kCheckEven
|
|
} TeUsartParityMode;
|
|
|
|
|
|
/*------------------------------------------defines---------------------------------------------*/
|
|
/***********************UART1**************************** */
|
|
#define UART1_DMA_RX_THREAD_STACK_SIZE (2024)
|
|
#define UART1_DMA_RX_THREAD_PRIORITY (20)
|
|
#define UART1_DMA_RX_THREAD_TIMESLICE (5)
|
|
|
|
#define UART1_TX_GPIO_PIN GPIO_PIN_11
|
|
#define UART1_TX_GPIO_PORT GPIOA
|
|
|
|
#define UART1_RX_GPIO_PIN GPIO_PIN_12
|
|
#define UART1_RX_GPIO_PORT GPIOA
|
|
|
|
#define UART1_RX_BUFFER_LENGTH (128U)
|
|
#define UART1_RX_RB_LENGTH (128U)
|
|
#define UART1_TX_RB_LENGTH (512U)
|
|
|
|
#define UART1_DMA_RX_CHANNEL DMA_CHANNEL_0
|
|
#define UART1_DMA_TX_CHANNEL DMA_CHANNEL_1
|
|
|
|
#define UART1_DMA_RX_IRQ_CHANNEL DMA_Channel0_IRQn
|
|
#define UART1_DMA_TX_IRQ_CHANNEL DMA_Channel1_IRQn
|
|
|
|
rt_uint32_t UART1_Write(const void* data, size_t len);
|
|
rt_uint32_t UART1_SendString(const char* str);
|
|
|
|
/*-------------------------------------------LPUART1-------------------------------------------------*/
|
|
#define LPUART1_RX_THREAD_STACK_SIZE (1024)
|
|
#define LPUART1_RX_THREAD_PRIORITY (10)
|
|
#define LPUART1_RX_THREAD_TIMESLICE (5)
|
|
|
|
/* LPUART1 GPIO引脚配置
|
|
PB11 ------> LPUART1发送引脚
|
|
PB10 ------> LPUART1接收引脚
|
|
*/
|
|
#define LPUART1_TX_GPIO_PIN GPIO_PIN_11
|
|
#define LPUART1_TX_GPIO_PORT GPIOB
|
|
|
|
#define LPUART1_RX_GPIO_PIN GPIO_PIN_10
|
|
#define LPUART1_RX_GPIO_PORT GPIOB
|
|
|
|
#define LPUART1_RX_BUFFER_LENGTH (16U)
|
|
#define LPUART1_RX_RB_LENGTH (16U)
|
|
#define LPUART1_TX_RB_LENGTH (128U)
|
|
|
|
extern lwrb_t lpuart1_rx_rb;
|
|
extern lwrb_t uart1_rx_rb;
|
|
#ifdef DEBUG_OUTPUT_SELECT
|
|
extern rt_sem_t uart1_rx_ok_sem;
|
|
#endif
|
|
|
|
rt_uint32_t LPUART1_Write(const void* data, size_t len);
|
|
rt_uint32_t LPUART1_SendString(const char* str);
|
|
|
|
/*-------------------------------------------functions------------------------------------------*/
|
|
|
|
int rt_hw_usart_init(void);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif /* USART_BSP_H */
|