mirror of
https://github.com/UpsilonNumworks/Upsilon.git
synced 2026-03-22 15:20:39 +01:00
[ion/device] Use the USART3 port for the console
Change-Id: I995984b94d6a2cc8a6e234cbecafc9be4c461327
This commit is contained in:
@@ -27,7 +27,7 @@ namespace Console {
|
||||
namespace Device {
|
||||
|
||||
void init() {
|
||||
RCC.APB2ENR()->setUSART1EN(true);
|
||||
RCC.APB1ENR()->setUSART3EN(true);
|
||||
|
||||
for(const GPIOPin & g : Pins) {
|
||||
g.group().MODER()->setMode(g.pin(), GPIO::MODER::Mode::AlternateFunction);
|
||||
@@ -39,17 +39,17 @@ void init() {
|
||||
UARTPort.CR1()->setRE(true);
|
||||
|
||||
/* We need to set the baud rate of the UART port.
|
||||
* This is set relative to the APB2 clock, which runs at 96 MHz.
|
||||
* This is set relative to the APB1 clock, which runs at 48 MHz.
|
||||
*
|
||||
* The baud rate is set by the following equation:
|
||||
* BaudRate = fAPB2/(16*USARTDIV), where USARTDIV is a divider.
|
||||
* In other words, USARDFIV = fAPB2/(16*BaudRate). All frequencies in Hz.
|
||||
* BaudRate = fAPB1/(16*USARTDIV), where USARTDIV is a divider.
|
||||
* In other words, USARDFIV = fAPB1/(16*BaudRate). All frequencies in Hz.
|
||||
*
|
||||
* In our case, fAPB2 = 96 MHz, so USARTDIV = 52.08333
|
||||
* DIV_MANTISSA = 52
|
||||
* DIV_FRAC = 16*0.083333 = 1.33 = 1
|
||||
* In our case, fAPB1 = 48 MHz, so USARTDIV = 26.0416667
|
||||
* DIV_MANTISSA = 26
|
||||
* DIV_FRAC = 16*0.0416667 = 1
|
||||
*/
|
||||
UARTPort.BRR()->setDIV_MANTISSA(52);
|
||||
UARTPort.BRR()->setDIV_MANTISSA(26);
|
||||
UARTPort.BRR()->setDIV_FRAC(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -10,18 +10,15 @@ namespace Device {
|
||||
|
||||
/* Pin | Role | Mode
|
||||
* -----+-------------------+--------------------
|
||||
* PC11 | UART1 RX | Alternate Function
|
||||
* PD8 | UART1 TX | Alternate Function
|
||||
* PC11 | UART3 RX | Alternate Function
|
||||
* PD8 | UART3 TX | Alternate Function
|
||||
*/
|
||||
|
||||
void init();
|
||||
void shutdown();
|
||||
|
||||
//constexpr USART UARTPort = USART(3);
|
||||
//constexpr static GPIOPin Pins[] = { GPIOPin(GPIOC, 11), GPIOPin(GPIOD, 8) };
|
||||
|
||||
constexpr USART UARTPort = USART(1);
|
||||
constexpr static GPIOPin Pins[] = { GPIOPin(GPIOB, 3), GPIOPin(GPIOB, 6) };
|
||||
constexpr USART UARTPort = USART(3);
|
||||
constexpr static GPIOPin Pins[] = { GPIOPin(GPIOC, 11), GPIOPin(GPIOD, 8) };
|
||||
|
||||
void sendChar(char c);
|
||||
char recvChar();
|
||||
|
||||
@@ -75,6 +75,7 @@ public:
|
||||
public:
|
||||
REGS_BOOL_FIELD(TIM3EN, 1);
|
||||
REGS_BOOL_FIELD(SPI3EN, 15);
|
||||
REGS_BOOL_FIELD(USART3EN, 18);
|
||||
REGS_BOOL_FIELD(PWREN, 28);
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user