Merged branch UART and changed get function

This commit is contained in:
2025-09-08 00:42:54 -07:00
parent 368eac7616
commit a02ec044ce
3 changed files with 7 additions and 7 deletions

View File

@@ -37,7 +37,7 @@ private:
};
#define initUART(uart_pair) UARTManager::get(uart_pair)
#define getUART(uart_pair) UARTManager::get(uart_pair)
class UARTManager{

View File

@@ -31,7 +31,7 @@ UART::UART(const UART_Pair pair) : m_UARTPair(pair){
* The AFR register for GPIO_Typedef* is actually two registers - a low reg and high reg.
* The low reg handles pins 0-7, and the high reg handles 8-15.
* Each pin gets 4 bits in the register for AFR0 - AFR7. Hence 8 * 4 = 32 bits.
* Each AFR is a different function, look at the DATASHEET (not reference manual) to find these alternate functions
* Each AFR is a different function, look at the DATASHEET (not reference manual) to find these alternate function mappings
*/
getGPIORegister(Tx_Key).reg->AFR[TxAFR] |= getAFMask(uart_pair.TxMask) << (4 * (Tx_Pin % 8));
getGPIORegister(Rx_Key).reg->AFR[RxAFR] |= getAFMask(uart_pair.RxMask) << (4 * (Rx_Pin % 8));
@@ -72,11 +72,11 @@ void UART::sendChar(char c) {
UART& UARTManager::get(UART_Pair pair) {
//Always reassign since we could be changing to different pins for some reason
m_UARTs[getUARTChannel(pair)] = UART(pair);
//Reassign if pair doesn't match
if(m_UARTs[getUARTChannel(pair)].m_UARTPair != pair) {
m_UARTs[getUARTChannel(pair)] = UART(pair);
}
return m_UARTs[getUARTChannel(pair)];
}

View File

@@ -18,7 +18,7 @@ void tim2Handler(){
int main() {
UART uart2 = initUART(UART_Pair::Tx2A2_Rx2A3);
UART uart2 = getUART(UART_Pair::Tx2A2_Rx2A3);
uart2.begin(115200);