machine: split board definitions in separate files

This commit is contained in:
Ayke van Laethem
2018-09-22 15:41:52 +02:00
parent 2c21925f4c
commit 8f5bd81bf5
6 changed files with 45 additions and 35 deletions
+16
View File
@@ -0,0 +1,16 @@
// +build avr,arduino
package machine
// LED on the Arduino
const LED = 13
// ADC on the Arduino
const (
ADC0 = 0
ADC1 = 1
ADC2 = 2
ADC3 = 3
ADC4 = 4
ADC5 = 5
)
+8
View File
@@ -0,0 +1,8 @@
// +build stm32,bluepill
package machine
// https://wiki.stm32duino.com/index.php?title=File:Bluepillpinout.gif
const (
LED = portC + 13
)
+21
View File
@@ -0,0 +1,21 @@
// +build nrf,pca10040
package machine
// LEDs on the PCA10040 (nRF52832 dev board)
const (
LED = LED1
LED1 = 17
LED2 = 18
LED3 = 19
LED4 = 20
)
// Buttons on the PCA10040 (nRF52832 dev board)
const (
BUTTON = BUTTON1
BUTTON1 = 13
BUTTON2 = 14
BUTTON3 = 15
BUTTON4 = 16
)
-13
View File
@@ -13,9 +13,6 @@ const (
GPIO_OUTPUT
)
// LED on the Arduino
const LED = 13
func (p GPIO) Configure(config GPIOConfig) {
if config.Mode == GPIO_OUTPUT { // set output bit
if p.Pin < 8 {
@@ -125,16 +122,6 @@ func (pwm PWM) Set(value uint16) {
}
}
// ADC on the Arduino
const (
ADC0 = 0
ADC1 = 1
ADC2 = 2
ADC3 = 3
ADC4 = 4
ADC5 = 5
)
// InitADC initializes the registers needed for ADC.
func InitADC() {
// set a2d prescaler so we are inside the desired 50-200 KHz range at 16MHz.
-18
View File
@@ -15,24 +15,6 @@ const (
GPIO_OUTPUT = (nrf.GPIO_PIN_CNF_DIR_Output << nrf.GPIO_PIN_CNF_DIR_Pos) | (nrf.GPIO_PIN_CNF_INPUT_Disconnect << nrf.GPIO_PIN_CNF_INPUT_Pos)
)
// LEDs on the PCA10040 (nRF52832 dev board)
const (
LED = LED1
LED1 = 17
LED2 = 18
LED3 = 19
LED4 = 20
)
// Buttons on the PCA10040 (nRF52832 dev board)
const (
BUTTON = BUTTON1
BUTTON1 = 13
BUTTON2 = 14
BUTTON3 = 15
BUTTON4 = 16
)
// Configure this pin with the given configuration.
func (p GPIO) Configure(config GPIOConfig) {
cfg := config.Mode | nrf.GPIO_PIN_CNF_DRIVE_S0S1 | nrf.GPIO_PIN_CNF_SENSE_Disabled
-4
View File
@@ -25,10 +25,6 @@ const (
portG
)
const (
LED = portC + 13
)
func (p GPIO) getPort() *stm32.GPIO_Type {
switch p.Pin / 16 {
case 0: