初始化串口代码,一直放不上去,补放在这里。。。
void uart_init(void)
{
md_gpio_init_t x;
md_uart_init_t h_uart;
/* Initialize tx pin */
x.mode = MD_GPIO_MODE_OUTPUT;
x.odos = MD_GPIO_PUSH_PULL;
x.pupd = MD_GPIO_PUSH_UP;
x.podrv = MD_GPIO_OUT_DRIVE_1;
x.nodrv = MD_GPIO_OUT_DRIVE_0_1;
x.flt = MD_GPIO_FILTER_DISABLE;
x.type = MD_GPIO_TYPE_TTL;
x.func = MD_GPIO_FUNC_3;
md_gpio_init(UART0_TX_PORT, UART0_TX_PIN, &x);
/* Initialize rx pin */
x.mode = MD_GPIO_MODE_INPUT;
x.odos = MD_GPIO_PUSH_PULL;
x.pupd = MD_GPIO_PUSH_UP;
x.podrv = MD_GPIO_OUT_DRIVE_1;
x.nodrv = MD_GPIO_OUT_DRIVE_0_1;
x.flt = MD_GPIO_FILTER_DISABLE;
x.type = MD_GPIO_TYPE_TTL;
x.func = MD_GPIO_FUNC_3;
md_gpio_init(UART0_RX_PORT, UART0_RX_PIN, &x);
h_uart.baud = 115200;
h_uart.word_length = MD_UART_WORD_LENGTH_8B;
h_uart.stop_bits = MD_UART_STOP_BITS_1;
h_uart.parity = MD_UART_PARITY_NONE;
h_uart.fctl = MD_UART_FLOW_CTL_DISABLE;
h_uart.mode = MD_UART_MODE;
// md_uart_init_struct(&h_uart);
md_uart_init(UART0, &h_uart);
}
|