Nucleo f722ze (#1526)

machine/nucleo-f722ze: Add support for ST Micro NUCLEO-F722ZE
This commit is contained in:
kenbell
2020-12-14 21:51:35 -08:00
committed by GitHub
parent ae92ea149c
commit 43a31467d3
14 changed files with 668 additions and 5 deletions
+44
View File
@@ -0,0 +1,44 @@
// +build stm32f7x2
package machine
// Peripheral abstraction layer for the stm32f407
import (
"device/stm32"
"runtime/interrupt"
)
func CPUFrequency() uint32 {
return 216000000
}
//---------- UART related types and code
// UART representation
type UART struct {
Buffer *RingBuffer
Bus *stm32.USART_Type
Interrupt interrupt.Interrupt
AltFuncSelector stm32.AltFunc
}
// Configure the UART.
func (uart UART) configurePins(config UARTConfig) {
// enable the alternate functions on the TX and RX pins
config.TX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTTX}, uart.AltFuncSelector)
config.RX.ConfigureAltFunc(PinConfig{Mode: PinModeUARTRX}, uart.AltFuncSelector)
}
// UART baudrate calc based on the bus and clockspeed
// NOTE: keep this in sync with the runtime/runtime_stm32f7x2.go clock init code
func (uart UART) getBaudRateDivisor(baudRate uint32) uint32 {
var clock uint32
switch uart.Bus {
case stm32.USART1, stm32.USART6:
clock = CPUFrequency() / 2 // APB2 Frequency
case stm32.USART2, stm32.USART3, stm32.UART4, stm32.UART5:
clock = CPUFrequency() / 8 // APB1 Frequency
}
return clock / baudRate
}