stm32: separate altfunc selection for UART Tx/Rx
This is needed for stm32l432 nucleo with different altfun for tx and rx
Этот коммит содержится в:
родитель
c522569378
коммит
dc981ce509
9 изменённых файлов: 37 добавлений и 30 удалений
|
@ -120,19 +120,22 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
UART1 = UART{
|
UART1 = UART{
|
||||||
Buffer: NewRingBuffer(),
|
Buffer: NewRingBuffer(),
|
||||||
Bus: stm32.USART3,
|
Bus: stm32.USART3,
|
||||||
AltFuncSelector: AF7_USART1_2_3,
|
TxAltFuncSelector: AF7_USART1_2_3,
|
||||||
|
RxAltFuncSelector: AF7_USART1_2_3,
|
||||||
}
|
}
|
||||||
UART2 = UART{
|
UART2 = UART{
|
||||||
Buffer: NewRingBuffer(),
|
Buffer: NewRingBuffer(),
|
||||||
Bus: stm32.USART6,
|
Bus: stm32.USART6,
|
||||||
AltFuncSelector: AF8_USART4_5_6,
|
TxAltFuncSelector: AF8_USART4_5_6,
|
||||||
|
RxAltFuncSelector: AF8_USART4_5_6,
|
||||||
}
|
}
|
||||||
UART3 = UART{
|
UART3 = UART{
|
||||||
Buffer: NewRingBuffer(),
|
Buffer: NewRingBuffer(),
|
||||||
Bus: stm32.USART1,
|
Bus: stm32.USART1,
|
||||||
AltFuncSelector: AF7_USART1_2_3,
|
TxAltFuncSelector: AF7_USART1_2_3,
|
||||||
|
RxAltFuncSelector: AF7_USART1_2_3,
|
||||||
}
|
}
|
||||||
UART0 = UART1
|
UART0 = UART1
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,9 +33,10 @@ var (
|
||||||
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
|
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
|
||||||
// Both UART0 and UART1 refer to USART2.
|
// Both UART0 and UART1 refer to USART2.
|
||||||
UART0 = UART{
|
UART0 = UART{
|
||||||
Buffer: NewRingBuffer(),
|
Buffer: NewRingBuffer(),
|
||||||
Bus: stm32.USART3,
|
Bus: stm32.USART3,
|
||||||
AltFuncSelector: UART_ALT_FN,
|
TxAltFuncSelector: UART_ALT_FN,
|
||||||
|
RxAltFuncSelector: UART_ALT_FN,
|
||||||
}
|
}
|
||||||
UART1 = &UART0
|
UART1 = &UART0
|
||||||
)
|
)
|
||||||
|
|
|
@ -33,9 +33,10 @@ var (
|
||||||
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
|
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
|
||||||
// Both UART0 and UART1 refer to LPUART1.
|
// Both UART0 and UART1 refer to LPUART1.
|
||||||
UART0 = UART{
|
UART0 = UART{
|
||||||
Buffer: NewRingBuffer(),
|
Buffer: NewRingBuffer(),
|
||||||
Bus: stm32.LPUART1,
|
Bus: stm32.LPUART1,
|
||||||
AltFuncSelector: UART_ALT_FN,
|
TxAltFuncSelector: UART_ALT_FN,
|
||||||
|
RxAltFuncSelector: UART_ALT_FN,
|
||||||
}
|
}
|
||||||
UART1 = &UART0
|
UART1 = &UART0
|
||||||
)
|
)
|
||||||
|
|
|
@ -28,9 +28,10 @@ const (
|
||||||
|
|
||||||
var (
|
var (
|
||||||
UART0 = UART{
|
UART0 = UART{
|
||||||
Buffer: NewRingBuffer(),
|
Buffer: NewRingBuffer(),
|
||||||
Bus: stm32.USART2,
|
Bus: stm32.USART2,
|
||||||
AltFuncSelector: AF7_USART1_2_3,
|
TxAltFuncSelector: AF7_USART1_2_3,
|
||||||
|
RxAltFuncSelector: AF7_USART1_2_3,
|
||||||
}
|
}
|
||||||
UART1 = &UART0
|
UART1 = &UART0
|
||||||
)
|
)
|
||||||
|
|
|
@ -13,10 +13,11 @@ import (
|
||||||
|
|
||||||
// UART representation
|
// UART representation
|
||||||
type UART struct {
|
type UART struct {
|
||||||
Buffer *RingBuffer
|
Buffer *RingBuffer
|
||||||
Bus *stm32.USART_Type
|
Bus *stm32.USART_Type
|
||||||
Interrupt interrupt.Interrupt
|
Interrupt interrupt.Interrupt
|
||||||
AltFuncSelector uint8
|
TxAltFuncSelector uint8
|
||||||
|
RxAltFuncSelector uint8
|
||||||
|
|
||||||
// Registers specific to the chip
|
// Registers specific to the chip
|
||||||
rxReg *volatile.Register32
|
rxReg *volatile.Register32
|
||||||
|
|
|
@ -37,8 +37,8 @@ const (
|
||||||
|
|
||||||
func (uart *UART) configurePins(config UARTConfig) {
|
func (uart *UART) configurePins(config UARTConfig) {
|
||||||
// enable the alternate functions on the TX and RX pins
|
// enable the alternate functions on the TX and RX pins
|
||||||
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.AltFuncSelector)
|
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.TxAltFuncSelector)
|
||||||
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.AltFuncSelector)
|
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.RxAltFuncSelector)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (uart *UART) getBaudRateDivisor(baudRate uint32) uint32 {
|
func (uart *UART) getBaudRateDivisor(baudRate uint32) uint32 {
|
||||||
|
|
|
@ -37,8 +37,8 @@ const (
|
||||||
// Configure the UART.
|
// Configure the UART.
|
||||||
func (uart *UART) configurePins(config UARTConfig) {
|
func (uart *UART) configurePins(config UARTConfig) {
|
||||||
// enable the alternate functions on the TX and RX pins
|
// enable the alternate functions on the TX and RX pins
|
||||||
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.AltFuncSelector)
|
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.TxAltFuncSelector)
|
||||||
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.AltFuncSelector)
|
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.RxAltFuncSelector)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UART baudrate calc based on the bus and clockspeed
|
// UART baudrate calc based on the bus and clockspeed
|
||||||
|
|
|
@ -17,8 +17,8 @@ func CPUFrequency() uint32 {
|
||||||
// Configure the UART.
|
// Configure the UART.
|
||||||
func (uart *UART) configurePins(config UARTConfig) {
|
func (uart *UART) configurePins(config UARTConfig) {
|
||||||
// enable the alternate functions on the TX and RX pins
|
// enable the alternate functions on the TX and RX pins
|
||||||
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.AltFuncSelector)
|
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.TxAltFuncSelector)
|
||||||
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.AltFuncSelector)
|
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.RxAltFuncSelector)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UART baudrate calc based on the bus and clockspeed
|
// UART baudrate calc based on the bus and clockspeed
|
||||||
|
|
|
@ -22,8 +22,8 @@ func (uart *UART) configurePins(config UARTConfig) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// enable the alternate functions on the TX and RX pins
|
// enable the alternate functions on the TX and RX pins
|
||||||
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.AltFuncSelector)
|
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.TxAltFuncSelector)
|
||||||
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.AltFuncSelector)
|
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.RxAltFuncSelector)
|
||||||
}
|
}
|
||||||
|
|
||||||
// UART baudrate calc based on the bus and clockspeed
|
// UART baudrate calc based on the bus and clockspeed
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче