Update such that tests pass for v1.2
This includes minor updates for the th different MCU variant, and bugfixes. Resolves #7
This commit is contained in:
@@ -36,8 +36,6 @@ UsartDriver::UsartDriver(USART_TypeDef *usart, TaskScheduler &scheduler)
|
||||
|
||||
void UsartDriver::init()
|
||||
{
|
||||
// TODO: This is all hardcoded for USART1 (doesn't exist on STM32L031)
|
||||
|
||||
#if defined(STM32L0XX)
|
||||
if (m_usart == USART2) {
|
||||
RCC->APB1ENR |= RCC_APB1ENR_USART2EN;
|
||||
@@ -54,14 +52,9 @@ void UsartDriver::init()
|
||||
#error "Unknown device family"
|
||||
#endif
|
||||
|
||||
// Set TX (PA9) to output, push/pull
|
||||
SET_TO(GPIOA->AFR[1], GPIO_AFRH_AFSEL9, 7u << GPIO_AFRH_AFSEL9_Pos); //AF7 (USART1_TX)
|
||||
SET_TO(GPIOA->MODER, GPIO_MODER_MODE9, 2u << GPIO_MODER_MODE9_Pos); // Alternate Function
|
||||
GPIOA->OTYPER &= ~GPIO_OTYPER_OT_9; // push/pull
|
||||
GPIOA->PUPDR &= ~GPIO_PUPDR_PUPD9; // no pullup, no pulldown
|
||||
|
||||
m_usart->BRR = (4100000) /115200L; // set baudrate (APBCLK / baud)
|
||||
m_usart->CR1 |= (USART_CR1_RE | USART_CR1_TE); // RX, TX enable
|
||||
// TODO: Don't hardcode the main clock value here
|
||||
m_usart->BRR = (4100000) / 115200L; // set baudrate (APBCLK / baud)
|
||||
m_usart->CR1 |= (USART_CR1_TE); // TX enable
|
||||
m_usart->CR1 |= USART_CR1_UE; // USART enable
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user