You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
33 lines
535 B
33 lines
535 B
#include"usart.h"
|
|
#include"pin.h"
|
|
|
|
|
|
|
|
#define USART2_EN (1U << 17)
|
|
USART_TypeDef usart;
|
|
|
|
|
|
void usartInit()
|
|
{
|
|
/* COnfiguring teh pins for the uart*/
|
|
pinConfig(pinA2, alternate, none, none, normal);
|
|
pinConfig(pinA15, alternate, none, none, normal);
|
|
pinSetAlternate(pinA2, 1);
|
|
RCC->APB1ENR |= USART2_EN;
|
|
}
|
|
|
|
static uint16_t usartComputeBaudRate(uint32_t clk, uint32_t baud)
|
|
{
|
|
return((clk + (baud/2U))/baud);
|
|
}
|
|
|
|
void usartSetBaudRate(uint32_t baud)
|
|
{
|
|
usartComputeBaudRate(baud, 8000000);
|
|
}
|
|
|
|
void usartSendChar(uint8_t ch)
|
|
{
|
|
|
|
}
|