Projet-Voilier-3/driver/Driver_UART.c
2023-03-27 16:35:57 +02:00

37 lines
No EOL
1 KiB
C

#include "Driver_UART.h"
/*
void MyUart_Init(UartConfig config) {
// Enable the clock for GPIO Port and USART
RCC->APB2ENR |= RCC_APB2ENR_IOPAEN | RCC_APB2ENR_USART1EN;
// Configure GPIO pins for USART TX/RX pins
GPIOA->CRH |= GPIO_CRH_MODE9_1 | GPIO_CRH_CNF9_1 | GPIO_CRH_CNF10_0;
// Configure the USART using the provided configuration values
USART1->CR1 = config.USART_CR1;
USART1->CR2 = config.USART_CR2;
USART1->BRR = config.USART_BRR;
USART1->CR3 = config.USART_CR3;
// Enable the USART
USART1->CR1 |= USART_CR1_UE;
}
void MyUART_SendByte() {
// Wait for the USART TX buffer to be empty
while(!(usart->SR & USART_SR_TXE));
// Send the byte of data
usart->DR = data;
}
uint8_t MyUart_ReceiveByte(MyUART_Struct_TypeDef *usart) {
// Wait for the USART RX buffer to be non-empty
while(!(usart->SR & USART_SR_RXNE));
// Read the received byte from the USART's data register (DR)
uint8_t received_byte = usart->DR;
// Return the received byte
return received_byte;
}*/