25 lines
855 B
C
25 lines
855 B
C
#include "DrvUart.h"
|
|
|
|
#include "BSPUart.h"
|
|
#include "BspGPIO.h"
|
|
|
|
// 初始化RS485通信接口,特用UART1
|
|
void DrvRS485Init(uint8_t uart_id, uint32_t baudrate, uint32_t gpioPort, uint8_t gpioPins) {
|
|
if (uart_id == USR_UART1) {
|
|
BspGPIOInit(GPIO_PORTK_BASE, GPIO_PIN_4, GPIO_DIR_MODE_OUT, GPIO_PIN_TYPE_STD);
|
|
BspGPIOSetOutput(GPIO_PORTK_BASE, GPIO_PIN_4, USR_GPIO_OUT_LOW);
|
|
}
|
|
|
|
BspUartInit(uart_id, baudrate, USR_UART_DATABIT_8, USR_UART_STOPBIT_ONE, USR_UART_CHECKBIT_NONE);
|
|
BspGPIOInit(gpioPort, gpioPins, GPIO_DIR_MODE_OUT, GPIO_PIN_TYPE_STD);
|
|
BspGPIOSetOutput(gpioPort, gpioPins, USR_GPIO_OUT_LOW);
|
|
}
|
|
|
|
|
|
// 初始化用于printf操作的UART接口。
|
|
void DrvUartPrintfInit(uint8_t uart_id, uint32_t baudrate) {
|
|
BspUartInit(uart_id, baudrate, USR_UART_DATABIT_8, USR_UART_STOPBIT_ONE, USR_UART_CHECKBIT_NONE);
|
|
}
|
|
|
|
|