mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-04 19:17:47 +00:00
targets,runtime,machine: add support for the stm32f469-disco board
The LEDs and button work; I haven't tested the SPI and I2C configuration.
This commit is contained in:
@@ -0,0 +1,79 @@
|
||||
// +build stm32f469disco
|
||||
|
||||
package machine
|
||||
|
||||
import (
|
||||
"device/stm32"
|
||||
"runtime/interrupt"
|
||||
)
|
||||
|
||||
const (
|
||||
LED = LED_BUILTIN
|
||||
LED1 = LED_GREEN
|
||||
LED2 = LED_ORANGE
|
||||
LED3 = LED_RED
|
||||
LED4 = LED_BLUE
|
||||
LED_BUILTIN = LED_GREEN
|
||||
LED_GREEN = PG6
|
||||
LED_ORANGE = PD4
|
||||
LED_RED = PD5
|
||||
LED_BLUE = PK3
|
||||
)
|
||||
|
||||
const (
|
||||
BUTTON = PA0
|
||||
)
|
||||
|
||||
// UART pins
|
||||
const (
|
||||
UART_TX_PIN = PB10
|
||||
UART_RX_PIN = PB11
|
||||
)
|
||||
|
||||
var (
|
||||
UART3 = &_UART3
|
||||
_UART3 = UART{
|
||||
Buffer: NewRingBuffer(),
|
||||
Bus: stm32.USART3,
|
||||
TxAltFuncSelector: AF7_USART1_2_3,
|
||||
RxAltFuncSelector: AF7_USART1_2_3,
|
||||
}
|
||||
DefaultUART = UART3
|
||||
)
|
||||
|
||||
// set up RX IRQ handler. Follow similar pattern for other UARTx instances
|
||||
func init() {
|
||||
UART3.Interrupt = interrupt.New(stm32.IRQ_USART3, _UART3.handleInterrupt)
|
||||
}
|
||||
|
||||
// SPI pins
|
||||
const (
|
||||
SPI1_SCK_PIN = PA5
|
||||
SPI1_SDI_PIN = PA6
|
||||
SPI1_SDO_PIN = PA7
|
||||
SPI0_SCK_PIN = SPI1_SCK_PIN
|
||||
SPI0_SDI_PIN = SPI1_SDI_PIN
|
||||
SPI0_SDO_PIN = SPI1_SDO_PIN
|
||||
)
|
||||
|
||||
// Since the first interface is named SPI1, both SPI0 and SPI1 refer to SPI1.
|
||||
// TODO: implement SPI2 and SPI3.
|
||||
var (
|
||||
SPI0 = SPI{
|
||||
Bus: stm32.SPI1,
|
||||
AltFuncSelector: AF5_SPI1_SPI2,
|
||||
}
|
||||
SPI1 = &SPI0
|
||||
)
|
||||
|
||||
const (
|
||||
I2C0_SCL_PIN = PB6
|
||||
I2C0_SDA_PIN = PB9
|
||||
)
|
||||
|
||||
var (
|
||||
I2C0 = &I2C{
|
||||
Bus: stm32.I2C1,
|
||||
AltFuncSelector: AF4_I2C1_2_3,
|
||||
}
|
||||
)
|
||||
@@ -616,16 +616,6 @@ func initRNG() {
|
||||
stm32.RNG.CR.SetBits(stm32.RNG_CR_RNGEN)
|
||||
}
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 168000000
|
||||
}
|
||||
|
||||
// Internal use: configured speed of the APB1 and APB2 timers, this should be kept
|
||||
// in sync with any changes to runtime package which configures the oscillators
|
||||
// and clock frequencies
|
||||
const APB1_TIM_FREQ = 42000000 * 2
|
||||
const APB2_TIM_FREQ = 84000000 * 2
|
||||
|
||||
// Alternative peripheral pin functions
|
||||
const (
|
||||
AF0_SYSTEM = 0
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
//go:build stm32f4 && (stm32f405 || stm32f407)
|
||||
// +build stm32f4
|
||||
// +build stm32f405 stm32f407
|
||||
|
||||
package machine
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 168000000
|
||||
}
|
||||
|
||||
// Internal use: configured speed of the APB1 and APB2 timers, this should be kept
|
||||
// in sync with any changes to runtime package which configures the oscillators
|
||||
// and clock frequencies
|
||||
const APB1_TIM_FREQ = 42000000 * 2
|
||||
const APB2_TIM_FREQ = 84000000 * 2
|
||||
@@ -0,0 +1,14 @@
|
||||
//go:build stm32f4 && stm32f469
|
||||
// +build stm32f4,stm32f469
|
||||
|
||||
package machine
|
||||
|
||||
func CPUFrequency() uint32 {
|
||||
return 180000000
|
||||
}
|
||||
|
||||
// Internal use: configured speed of the APB1 and APB2 timers, this should be kept
|
||||
// in sync with any changes to runtime package which configures the oscillators
|
||||
// and clock frequencies
|
||||
const APB1_TIM_FREQ = 45000000 * 2
|
||||
const APB2_TIM_FREQ = 90000000 * 2
|
||||
Reference in New Issue
Block a user