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:
2020-06-03 04:51:19 +00:00
parent 0f0cb73fa5
commit cdf0f4ffc9
22 changed files with 649 additions and 57 deletions

View File

@@ -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
}