aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/machine/machine_atsamd51.go
diff options
context:
space:
mode:
Diffstat (limited to 'src/machine/machine_atsamd51.go')
-rw-r--r--src/machine/machine_atsamd51.go36
1 files changed, 18 insertions, 18 deletions
diff --git a/src/machine/machine_atsamd51.go b/src/machine/machine_atsamd51.go
index 5351f5f56..90064776a 100644
--- a/src/machine/machine_atsamd51.go
+++ b/src/machine/machine_atsamd51.go
@@ -1111,7 +1111,7 @@ func (i2c I2C) Configure(config I2CConfig) error {
i2c.Bus.SYNCBUSY.HasBits(sam.SERCOM_I2CM_SYNCBUSY_SWRST) {
}
- // Set i2c master mode
+ // Set i2c controller mode
//SERCOM_I2CM_CTRLA_MODE( I2C_MASTER_OPERATION )
// sam.SERCOM_I2CM_CTRLA_MODE_I2C_MASTER = 5?
i2c.Bus.CTRLA.Set(5 << sam.SERCOM_I2CM_CTRLA_MODE_Pos) // |
@@ -1186,7 +1186,7 @@ func (i2c I2C) Tx(addr uint16, w, r []byte) error {
// wait transmission complete
for !i2c.Bus.INTFLAG.HasBits(sam.SERCOM_I2CM_INTFLAG_SB) {
- // If the slave NACKS the address, the MB bit will be set.
+ // If the peripheral NACKS the address, the MB bit will be set.
// In that case, send a stop condition and return error.
if i2c.Bus.INTFLAG.HasBits(sam.SERCOM_I2CM_INTFLAG_MB) {
i2c.Bus.CTRLB.SetBits(wireCmdStop << sam.SERCOM_I2CM_CTRLB_CMD_Pos) // Stop condition
@@ -1309,8 +1309,8 @@ type SPI struct {
type SPIConfig struct {
Frequency uint32
SCK Pin
- MOSI Pin
- MISO Pin
+ SDO Pin
+ SDI Pin
LSBFirst bool
Mode uint8
}
@@ -1318,10 +1318,10 @@ type SPIConfig struct {
// Configure is intended to setup the SPI interface.
func (spi SPI) Configure(config SPIConfig) error {
// Use default pins if not set.
- if config.SCK == 0 && config.MOSI == 0 && config.MISO == 0 {
+ if config.SCK == 0 && config.SDO == 0 && config.SDI == 0 {
config.SCK = SPI0_SCK_PIN
- config.MOSI = SPI0_MOSI_PIN
- config.MISO = SPI0_MISO_PIN
+ config.SDO = SPI0_SDO_PIN
+ config.SDI = SPI0_SDI_PIN
}
// set default frequency
@@ -1329,17 +1329,17 @@ func (spi SPI) Configure(config SPIConfig) error {
config.Frequency = 4000000
}
- // Determine the input pinout (for MISO).
+ // Determine the input pinout (for SDI).
var dataInPinout uint32
- misoPinMode, misoPad, ok := findPinPadMapping(spi.SERCOM, config.MISO)
- if config.MISO != NoPin {
+ SDIPinMode, SDIPad, ok := findPinPadMapping(spi.SERCOM, config.SDI)
+ if config.SDI != NoPin {
if !ok {
return ErrInvalidInputPin
}
- dataInPinout = misoPad // mapped directly
+ dataInPinout = SDIPad // mapped directly
}
- // Determine the output pinout (for MOSI/SCK).
+ // Determine the output pinout (for SDO/SCK).
// See DOPO field in the CTRLA register on page 986 of the datasheet.
var dataOutPinout uint32
sckPinMode, sckPad, ok := findPinPadMapping(spi.SERCOM, config.SCK)
@@ -1347,11 +1347,11 @@ func (spi SPI) Configure(config SPIConfig) error {
// SCK pad must always be 1
return ErrInvalidOutputPin
}
- mosiPinMode, mosiPad, ok := findPinPadMapping(spi.SERCOM, config.MOSI)
+ SDOPinMode, SDOPad, ok := findPinPadMapping(spi.SERCOM, config.SDO)
if !ok {
return ErrInvalidOutputPin
}
- switch mosiPad {
+ switch SDOPad {
case 0:
dataOutPinout = 0x0
case 3:
@@ -1367,9 +1367,9 @@ func (spi SPI) Configure(config SPIConfig) error {
// enable pins
config.SCK.Configure(PinConfig{Mode: sckPinMode})
- config.MOSI.Configure(PinConfig{Mode: mosiPinMode})
- if config.MISO != NoPin {
- config.MISO.Configure(PinConfig{Mode: misoPinMode})
+ config.SDO.Configure(PinConfig{Mode: SDOPinMode})
+ if config.SDI != NoPin {
+ config.SDI.Configure(PinConfig{Mode: SDIPinMode})
}
// reset SERCOM
@@ -1384,7 +1384,7 @@ func (spi SPI) Configure(config SPIConfig) error {
dataOrder = 1
}
- // Set SPI master
+ // Set SPI controller
// SERCOM_SPIM_CTRLA_MODE_SPI_MASTER = 3
spi.Bus.CTRLA.Set((3 << sam.SERCOM_SPIM_CTRLA_MODE_Pos) |
(dataOutPinout << sam.SERCOM_SPIM_CTRLA_DOPO_Pos) |