mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-16 10:43:29 +00:00
machine/nrf: refactor to use volatile package/API
Signed-off-by: Ron Evans <ron@hybridgroup.com>
This commit is contained in:
@@ -14,8 +14,8 @@ func (p GPIO) getPortPin() (*nrf.GPIO_Type, uint8) {
|
||||
}
|
||||
|
||||
func (uart UART) setPins(tx, rx uint32) {
|
||||
nrf.UART0.PSELTXD = nrf.RegValue(tx)
|
||||
nrf.UART0.PSELRXD = nrf.RegValue(rx)
|
||||
nrf.UART0.PSELTXD.Set(tx)
|
||||
nrf.UART0.PSELRXD.Set(rx)
|
||||
}
|
||||
|
||||
//go:export UART0_IRQHandler
|
||||
@@ -24,8 +24,8 @@ func handleUART0() {
|
||||
}
|
||||
|
||||
func (i2c I2C) setPins(scl, sda uint8) {
|
||||
i2c.Bus.PSELSCL = nrf.RegValue(scl)
|
||||
i2c.Bus.PSELSDA = nrf.RegValue(sda)
|
||||
i2c.Bus.PSELSCL.Set(uint32(scl))
|
||||
i2c.Bus.PSELSDA.Set(uint32(sda))
|
||||
}
|
||||
|
||||
// SPI
|
||||
@@ -39,7 +39,7 @@ func (spi SPI) setPins(sck, mosi, miso uint8) {
|
||||
if miso == 0 {
|
||||
miso = SPI0_MISO_PIN
|
||||
}
|
||||
spi.Bus.PSELSCK = nrf.RegValue(sck)
|
||||
spi.Bus.PSELMOSI = nrf.RegValue(mosi)
|
||||
spi.Bus.PSELMISO = nrf.RegValue(miso)
|
||||
spi.Bus.PSELSCK.Set(uint32(sck))
|
||||
spi.Bus.PSELMOSI.Set(uint32(mosi))
|
||||
spi.Bus.PSELMISO.Set(uint32(miso))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user