diff --git a/src/machine/board_arduino.go b/src/machine/board_arduino.go new file mode 100644 index 00000000..f6a4659a --- /dev/null +++ b/src/machine/board_arduino.go @@ -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 +) diff --git a/src/machine/board_bluepill.go b/src/machine/board_bluepill.go new file mode 100644 index 00000000..4d547809 --- /dev/null +++ b/src/machine/board_bluepill.go @@ -0,0 +1,8 @@ +// +build stm32,bluepill + +package machine + +// https://wiki.stm32duino.com/index.php?title=File:Bluepillpinout.gif +const ( + LED = portC + 13 +) diff --git a/src/machine/board_pca10040.go b/src/machine/board_pca10040.go new file mode 100644 index 00000000..b5ddaa34 --- /dev/null +++ b/src/machine/board_pca10040.go @@ -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 +) diff --git a/src/machine/machine_avr.go b/src/machine/machine_avr.go index 1c5e19a2..8fd1a4e8 100644 --- a/src/machine/machine_avr.go +++ b/src/machine/machine_avr.go @@ -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. diff --git a/src/machine/machine_nrf.go b/src/machine/machine_nrf.go index 9b75f1ce..81511d0a 100644 --- a/src/machine/machine_nrf.go +++ b/src/machine/machine_nrf.go @@ -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 diff --git a/src/machine/machine_stm32.go b/src/machine/machine_stm32.go index 9fe9a7b5..2489dffe 100644 --- a/src/machine/machine_stm32.go +++ b/src/machine/machine_stm32.go @@ -25,10 +25,6 @@ const ( portG ) -const ( - LED = portC + 13 -) - func (p GPIO) getPort() *stm32.GPIO_Type { switch p.Pin / 16 { case 0: