void Long_Uart2_Init(void) { uint32_t ui32_SystemClock; RINGBUF_Init(&long_Uart2_TxRingBuf, long_Uart2_TxBuf, sizeof(long_Uart2_TxBuf)); RINGBUF_Init(&long_Uart2_RxRingBuf, long_Uart2_RxBuf, sizeof(long_Uart2_RxBuf)); ui32_SystemClock = u32_UsrSystemClockGet(); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART2); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD); GPIOPinConfigure(GPIO_PD6_U2RX); GPIOPinConfigure(GPIO_PD7_U2TX); IntDisable(INT_UART2); GPIOPinTypeUART(GPIO_PORTD_BASE, GPIO_PIN_6 | GPIO_PIN_7); UARTConfigSetExpClk(UART2_BASE, ui32_SystemClock, 19200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTIntRegister(UART2_BASE, &UART2_RxTxHandler); UARTIntClear(UART2_BASE, UART_INT_RX | UART_INT_TX); UARTIntEnable(UART2_BASE, UART_INT_RX | UART_INT_RT); UARTTxIntModeSet(UART2_BASE, UART_TXINT_MODE_EOT); IntEnable(INT_UART2); }
void bluetooth_init(uint32_t baudrate) { uint32_t ui32_SystemClock; ui32_SystemClock = u32_UsrSystemClockGet(); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART0_BASE, ui32_SystemClock, baudrate, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); // UARTFIFOEnable(UART0_BASE); // UARTFIFOLevelSet(UART0_BASE, UART_FIFO_TX7_8, UART_FIFO_RX1_8); UARTIntRegister(UART0_BASE, &Bluetooth_RxTxHandler); IntEnable(INT_UART0); UARTIntEnable(UART0_BASE, UART_INT_RX | UART_INT_RT | UART_INT_TX); UARTTxIntModeSet(UART0_BASE, UART_TXINT_MODE_EOT); HC05_ClearEvtQueue(); }