30 lines
612 B
C
30 lines
612 B
C
#include "uart.h"
|
|
#include <reflow-controller/periph-config/shell-uart-config.h>
|
|
#include <stm32/stm32f4xx.h>
|
|
#include <string.h>
|
|
|
|
void uart_init(void)
|
|
{
|
|
SHELL_UART_RCC_REG |= SHELL_UART_RCC_MASK;
|
|
SHELL_UART_PERIPH->BRR = SHELL_UART_BRR_REG_VALUE;
|
|
SHELL_UART_PERIPH->CR2 = 0;
|
|
SHELL_UART_PERIPH->CR3 = 0;
|
|
SHELL_UART_PERIPH->CR1 = USART_CR1_TE | USART_CR1_UE;
|
|
}
|
|
|
|
void uart_send_char(char c)
|
|
{
|
|
while (!(SHELL_UART_PERIPH->SR & USART_SR_TXE));
|
|
SHELL_UART_PERIPH->DR = c;
|
|
}
|
|
|
|
void uart_send_string(const char *str)
|
|
{
|
|
int len, i;
|
|
|
|
len = strlen(str);
|
|
for (i = 0; i < len; i++) {
|
|
uart_send_char(str[i]);
|
|
}
|
|
}
|