machine: split board definitions in separate files
Этот коммит содержится в:
родитель
2c21925f4c
коммит
8f5bd81bf5
6 изменённых файлов: 45 добавлений и 35 удалений
16
src/machine/board_arduino.go
Обычный файл
16
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
|
||||
)
|
8
src/machine/board_bluepill.go
Обычный файл
8
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
|
||||
)
|
21
src/machine/board_pca10040.go
Обычный файл
21
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
|
||||
)
|
|
@ -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.
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -25,10 +25,6 @@ const (
|
|||
portG
|
||||
)
|
||||
|
||||
const (
|
||||
LED = portC + 13
|
||||
)
|
||||
|
||||
func (p GPIO) getPort() *stm32.GPIO_Type {
|
||||
switch p.Pin / 16 {
|
||||
case 0:
|
||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче