Added more enums handling UART/USART functionality
This commit is contained in:
@@ -8,7 +8,7 @@
|
||||
#include <stm32f072xb.h>
|
||||
#include <cassert>
|
||||
|
||||
#include "SHAL_GPIO_REG.h"
|
||||
#include "SHAL_GPIO_TYPES.h"
|
||||
|
||||
#define AVAILABLE_PORTS 3
|
||||
#define PINS_PER_PORT 16
|
||||
@@ -49,6 +49,13 @@ enum class UART_Pair : uint8_t{
|
||||
Tx4C10_Rx4C11
|
||||
};
|
||||
|
||||
enum class USART {
|
||||
USART_1,
|
||||
USART_2,
|
||||
USART_3,
|
||||
USART_4
|
||||
};
|
||||
|
||||
constexpr SHAL_UART_Pair getUARTPair(const UART_Pair pair){
|
||||
switch(pair){
|
||||
case UART_Pair::Tx1A9_Rx1A10: return {9,10,&GPIOA->AFR[1],&GPIOA->AFR[1],AF_Mask::AF1,AF_Mask::AF1};
|
||||
@@ -63,6 +70,24 @@ constexpr SHAL_UART_Pair getUARTPair(const UART_Pair pair){
|
||||
}
|
||||
}
|
||||
|
||||
constexpr USART getUSARTReg(const UART_Pair pair){
|
||||
switch(pair){
|
||||
case UART_Pair::Tx1A9_Rx1A10:
|
||||
case UART_Pair::Tx1B6_Rx1B7:
|
||||
return USART::USART_1;
|
||||
case UART_Pair::Tx2A2_Rx2A3:
|
||||
case UART_Pair::Tx2A14_Rx2A15:
|
||||
return USART::USART_2;
|
||||
case UART_Pair::Tx3B10_Rx3B11:
|
||||
case UART_Pair::Tx3C4_Rx3C5:
|
||||
case UART_Pair::Tx3C10_Rx3C11:
|
||||
return USART::USART_3;
|
||||
case UART_Pair::Tx4A0_Rx4A1:
|
||||
case UART_Pair::Tx4C10_Rx4C11:
|
||||
return USART::USART_4;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
constexpr SHAL_Peripheral getGPIORegister(const GPIO_Key g){
|
||||
switch(g) {
|
||||
|
||||
Reference in New Issue
Block a user