//*********************************************************************************************************************//
// Change UART baud rate from 9600 to 115200 after we set bluetooth frequency to 115200
void set_uart_baud_rate(unsigned int uart_base)
{
    /* Make sure the UART is disabled before trying to configure it */
    REG(uart_base + UART_CTL) = UART_CTL_VALUE;

    /* Baud Rate Generation */
    REG(uart_base + UART_IBRD) = BAUD2IBRD(115200);
    REG(uart_base + UART_FBRD) = BAUD2FBRD(115200);

    /* UART Control: 8N1 with FIFOs */
    REG(uart_base + UART_LCRH) = UART_LCRH_WLEN_8 | UART_LCRH_FEN;

    /* UART Enable */
    REG(uart_base + UART_CTL) |= UART_CTL_UARTEN;
}
示例#2
0
文件: uart.c 项目: 200018171/contiki
  uart_pad_t rx;
  uart_pad_t tx;
  uart_pad_t cts;
  uart_pad_t rts;
  uint8_t nvic_int;
} uart_regs_t;
/*---------------------------------------------------------------------------*/
static const uart_regs_t uart_regs[UART_INSTANCE_COUNT] = {
  {
    .sys_ctrl_rcgcuart_uart = SYS_CTRL_RCGCUART_UART0,
    .sys_ctrl_scgcuart_uart = SYS_CTRL_SCGCUART_UART0,
    .sys_ctrl_dcgcuart_uart = SYS_CTRL_DCGCUART_UART0,
    .base = UART_0_BASE,
    .ioc_uartrxd_uart = IOC_UARTRXD_UART0,
    .ioc_pxx_sel_uart_txd = IOC_PXX_SEL_UART0_TXD,
    .ibrd = BAUD2IBRD(UART0_CONF_BAUD_RATE),
    .fbrd = BAUD2FBRD(UART0_CONF_BAUD_RATE),
    .rx = {UART0_RX_PORT, UART0_RX_PIN},
    .tx = {UART0_TX_PORT, UART0_TX_PIN},
    .cts = {-1, -1},
    .rts = {-1, -1},
    .nvic_int = NVIC_INT_UART0
  }, {
    .sys_ctrl_rcgcuart_uart = SYS_CTRL_RCGCUART_UART1,
    .sys_ctrl_scgcuart_uart = SYS_CTRL_SCGCUART_UART1,
    .sys_ctrl_dcgcuart_uart = SYS_CTRL_DCGCUART_UART1,
    .base = UART_1_BASE,
    .ioc_uartrxd_uart = IOC_UARTRXD_UART1,
    .ioc_pxx_sel_uart_txd = IOC_PXX_SEL_UART1_TXD,
    .ibrd = BAUD2IBRD(UART1_CONF_BAUD_RATE),
    .fbrd = BAUD2FBRD(UART1_CONF_BAUD_RATE),