
This makes it possible to assign I2C objects (machine.I2C0, machine.I2C1, etc.) without needing to take a pointer. This is important especially in the future when I2C may be driven using DMA and the machine.I2C type needs to store some state.
43 строки
642 Б
Go
43 строки
642 Б
Go
// +build sam,atsamd51,feather_m4
|
|
|
|
package machine
|
|
|
|
import (
|
|
"device/sam"
|
|
"runtime/interrupt"
|
|
)
|
|
|
|
var (
|
|
UART1 = UART{
|
|
Buffer: NewRingBuffer(),
|
|
Bus: sam.SERCOM5_USART_INT,
|
|
SERCOM: 5,
|
|
}
|
|
|
|
UART2 = UART{
|
|
Buffer: NewRingBuffer(),
|
|
Bus: sam.SERCOM0_USART_INT,
|
|
SERCOM: 0,
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM5_2, UART1.handleInterrupt)
|
|
UART2.Interrupt = interrupt.New(sam.IRQ_SERCOM0_2, UART2.handleInterrupt)
|
|
}
|
|
|
|
// I2C on the Feather M4.
|
|
var (
|
|
I2C0 = &I2C{
|
|
Bus: sam.SERCOM2_I2CM,
|
|
SERCOM: 2,
|
|
}
|
|
)
|
|
|
|
// SPI on the Feather M4.
|
|
var (
|
|
SPI0 = SPI{
|
|
Bus: sam.SERCOM1_SPIM,
|
|
SERCOM: 1,
|
|
}
|
|
)
|