tinygo/src/machine/board_hifive1b.go
Ayke van Laethem 96e863f0f3 all: add a flag to the command line to select the serial implementation
This can be very useful for some purposes:

  * It makes it possible to disable the UART in cases where it is not
    needed or needs to be disabled to conserve power.
  * It makes it possible to disable the serial output to reduce code
    size, which may be important for some chips. Sometimes, a few kB can
    be saved this way.
  * It makes it possible to override the default, for example you might
    want to use an actual UART to debug the USB-CDC implementation.

It also lowers the dependency on having machine.Serial defined, which is
often not defined when targeting a chip. Eventually, we might want to
make it possible to write `-target=nrf52` or `-target=atmega328p` for
example to target the chip itself with no board specific assumptions.

The defaults don't change. I checked this by running `make smoketest`
before and after and comparing the results.
2021-06-25 17:58:39 +02:00

61 строка
1,1 КиБ
Go

// +build hifive1b
package machine
const (
D0 = P16
D1 = P17
D2 = P18
D3 = P19 // Green LED/PWM (PWM1_PWM1)
D4 = P20 // PWM (PWM1_PWM0)
D5 = P21 // Blue LED/PWM (PWM1_PWM2)
D6 = P22 // Red LED/PWM (PWM1_PWM3)
D7 = P16
D8 = NoPin // PWM?
D9 = P01
D10 = P02 // SPI1_CS0
D11 = P03 // SPI1_DQ0
D12 = P04 // SPI1_DQ1
D13 = P05 // SPI1_SCK
D14 = NoPin // not connected
D15 = P09 // does not seem to work?
D16 = P10 // PWM (PWM2_PWM0)
D17 = P11 // PWM (PWM2_PWM1)
D18 = P12 // SDA (I2C0_SDA)/PWM (PWM2_PWM2)
D19 = P13 // SDL (I2C0_SCL)/PWM (PWM2_PWM3)
)
const (
LED = LED1
LED1 = LED_RED
LED2 = LED_GREEN
LED3 = LED_BLUE
LED_RED = P22
LED_GREEN = P19
LED_BLUE = P21
)
var DefaultUART = UART0
const (
// TODO: figure out the pin numbers for these.
UART_TX_PIN = D1
UART_RX_PIN = D0
)
// SPI pins
const (
SPI0_SCK_PIN = NoPin
SPI0_SDO_PIN = NoPin
SPI0_SDI_PIN = NoPin
SPI1_SCK_PIN = D13
SPI1_SDO_PIN = D11
SPI1_SDI_PIN = D12
)
// I2C pins
const (
I2C0_SDA_PIN = D18
I2C0_SCL_PIN = D19
)