mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
90b42799a2
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.
38 lines
486 B
Go
38 lines
486 B
Go
// +build sam,atsamd51,pyportal
|
|
|
|
package machine
|
|
|
|
import (
|
|
"device/sam"
|
|
"runtime/interrupt"
|
|
)
|
|
|
|
var (
|
|
UART1 = UART{
|
|
Buffer: NewRingBuffer(),
|
|
Bus: sam.SERCOM4_USART_INT,
|
|
SERCOM: 4,
|
|
}
|
|
)
|
|
|
|
func init() {
|
|
UART1.Interrupt = interrupt.New(sam.IRQ_SERCOM4_2, UART1.handleInterrupt)
|
|
}
|
|
|
|
// I2C on the PyPortal.
|
|
var (
|
|
I2C0 = &I2C{
|
|
Bus: sam.SERCOM5_I2CM,
|
|
SERCOM: 5,
|
|
}
|
|
)
|
|
|
|
// SPI on the PyPortal.
|
|
var (
|
|
SPI0 = SPI{
|
|
Bus: sam.SERCOM2_SPIM,
|
|
SERCOM: 2,
|
|
}
|
|
NINA_SPI = SPI0
|
|
)
|