nrf: add nrf52840-mdk board

With the help of Chillance on GitHub.
This commit is contained in:
Ayke van Laethem
2018-10-06 13:53:58 +02:00
parent f9edf7cc5c
commit daf92226d8
8 changed files with 121 additions and 11 deletions
+31
View File
@@ -0,0 +1,31 @@
// +build nrf52840
package machine
import (
"device/nrf"
)
// Get peripheral and pin number for this GPIO pin.
func (p GPIO) getPortPin() (*nrf.GPIO_Type, uint8) {
if p.Pin >= 32 {
return nrf.P1, p.Pin - 32
} else {
return nrf.P0, p.Pin
}
}
func (uart UART) setPins(tx, rx uint32) {
nrf.UART0.PSEL.TXD = nrf.RegValue(tx)
nrf.UART0.PSEL.RXD = nrf.RegValue(rx)
}
//go:export UARTE0_UART0_IRQHandler
func handleUART0() {
UART0.handleInterrupt()
}
func (i2c I2C) setPins(scl, sda uint8) {
i2c.Bus.PSEL.SCL = nrf.RegValue(scl)
i2c.Bus.PSEL.SDA = nrf.RegValue(sda)
}