machine: define Serial as the default output

Previously, the machine.UART0 object had two meanings:

  - it was the first UART on the chip
  - it was the default output for println

These two meanings conflict, and resulted in workarounds like:

  - Defining UART0 to refer to the USB-CDC interface (atsamd21,
    atsamd51, nrf52840), even though that clearly isn't an UART.
  - Defining NRF_UART0 to avoid a conflict with UART0 (which was
    redefined as a USB-CDC interface).
  - Defining aliases like UART0 = UART1, which refer to the same
    hardware peripheral (stm32).

This commit changes this to use a new machine.Serial object for the
default serial port. It might refer to the first or second UART
depending on the board, or even to the USB-CDC interface. Also, UART0
now really refers to the first UART on the chip, no longer to a USB-CDC
interface.

The changes in the runtime package are all just search+replace. The
changes in the machine package are a mixture of search+replace and
manual modifications.

This commit does not affect binary size, in fact it doesn't affect the
resulting binary at all.
This commit is contained in:
Ayke van Laethem
2021-05-13 14:07:22 +02:00
committed by Ron Evans
parent aa5b8d0df7
commit b67351babe
82 changed files with 171 additions and 156 deletions
+2
View File
@@ -349,6 +349,8 @@ smoketest:
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=feather-m4-can examples/caninterrupt
@$(MD5SUM) test.hex
$(TINYGO) build -size short -o test.hex -target=arduino-nano33 examples/blinky1
@$(MD5SUM) test.hex
# test pwm
$(TINYGO) build -size short -o test.hex -target=itsybitsy-m0 examples/pwm
@$(MD5SUM) test.hex
+1 -1
View File
@@ -9,7 +9,7 @@ import (
// change these to test a different UART or pins if available
var (
uart = machine.UART0
uart = machine.Serial
tx = machine.UART_TX_PIN
rx = machine.UART_RX_PIN
)
+3 -1
View File
@@ -47,7 +47,9 @@ const (
LED = D6
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN Pin = PA24
USBCDC_DP_PIN Pin = PA25
+1 -1
View File
@@ -46,7 +46,7 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN Pin = PA24
USBCDC_DP_PIN Pin = PA25
+2
View File
@@ -35,6 +35,8 @@ const (
LED3 Pin = PB03 // RX LED
)
var Serial = USB
// ADC pins
const (
AREF Pin = PA03
+2
View File
@@ -74,3 +74,5 @@ const (
PB30 Pin = 62
PB31 Pin = 63
)
var Serial = USB
+3 -1
View File
@@ -15,6 +15,8 @@ const (
BUTTON = PB31
)
var Serial = USB
const (
// https://ww1.microchip.com/downloads/en/DeviceDoc/70005321A.pdf
@@ -152,7 +154,7 @@ const (
PIN_USB_ID = PC19
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+8 -7
View File
@@ -50,6 +50,8 @@ const (
LED = PC13
)
var Serial = UART1
// UART pins
const (
UART_TX_PIN = PA9
@@ -60,22 +62,21 @@ const (
var (
// USART1 is the first hardware serial port on the STM32.
// Both UART0 and UART1 refer to USART1.
UART0 = &_UART0
_UART0 = UART{
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART1,
}
UART1 = &_UART1
_UART1 = UART{
UART2 = &_UART2
_UART2 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART2,
}
)
func init() {
UART0.Interrupt = interrupt.New(stm32.IRQ_USART1, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART1.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART1, _UART1.handleInterrupt)
UART2.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART2.handleInterrupt)
}
// SPI pins
+1 -4
View File
@@ -56,10 +56,7 @@ const (
UART_RX_PIN = P0_30 // PORTB
)
// UART0 is the USB device
var (
UART0 = USB
)
var Serial = USB
// I2C pins
const (
+2 -2
View File
@@ -103,9 +103,9 @@ const (
UART_TX_PIN = D1
)
// UART0 is the USB device
// Serial is the USB device
var (
UART0 = USB
Serial = USB
)
// I2C pins
+2
View File
@@ -68,6 +68,8 @@ const (
ADC3 Pin = IO39
)
var Serial = UART0
// UART0 pins
const (
UART_TX_PIN = IO1
+1 -1
View File
@@ -42,7 +42,7 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+3 -1
View File
@@ -46,7 +46,9 @@ const (
NEOPIXELS = D8
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+3 -1
View File
@@ -39,7 +39,9 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+2 -2
View File
@@ -75,9 +75,9 @@ const (
UART_TX_PIN = D1
)
// UART0 is the USB device
// Serial is the USB device
var (
UART0 = USB
Serial = USB
)
// I2C pins
+1 -1
View File
@@ -140,7 +140,7 @@ var (
TxAltFuncSelector: AF7_USART1_2_3,
RxAltFuncSelector: AF7_USART1_2_3,
}
UART0 = UART1
Serial = UART1
)
func initUART() {
+2
View File
@@ -141,6 +141,8 @@ const (
NEOPIXEL = NEOPIXEL_PIN
)
var Serial = USB
// UART pins
const (
UART1_RX_PIN = D0 // (PB25)
+2
View File
@@ -35,6 +35,8 @@ const (
LED_BLUE = P21
)
var Serial = UART0
const (
// TODO: figure out the pin numbers for these.
UART_TX_PIN = D1
+1 -1
View File
@@ -42,7 +42,7 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+3 -1
View File
@@ -37,7 +37,9 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+2 -2
View File
@@ -70,9 +70,9 @@ const (
UART_TX_PIN = D1
)
// UART0 is the USB device
// Serial is the USB device
var (
UART0 = USB
Serial = USB
)
// I2C pins
+2
View File
@@ -54,6 +54,8 @@ const (
I2C0_SDA_PIN = PA10
)
var Serial = UART0
var (
// Console UART (LPUSART1)
+2
View File
@@ -52,6 +52,8 @@ const (
LED_BLUE = D14
)
var Serial = UART0
// Default pins for UARTHS.
const (
UART_TX_PIN = D5
+3 -1
View File
@@ -40,7 +40,9 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+2
View File
@@ -12,6 +12,8 @@ const (
BUTTONB Pin = P11
)
var Serial = UART0
// UART pins
const (
UART_TX_PIN Pin = P34
+2
View File
@@ -12,6 +12,8 @@ const (
BUTTONB Pin = 26
)
var Serial = UART0
// UART pins
const (
UART_TX_PIN Pin = 24
+2 -2
View File
@@ -54,9 +54,9 @@ const (
UART_TX_PIN = P0_08
)
// UART0 is the USB device
// Serial is the USB device
var (
UART0 = USB
Serial = USB
)
// I2C pins
+2
View File
@@ -20,6 +20,8 @@ const (
// Onboard blue LED (on the AI-Thinker module).
const LED = D4
var Serial = UART0
// SPI pins
const (
SPI0_SCK_PIN = D5
+2 -4
View File
@@ -23,10 +23,8 @@ const (
UART_RX_PIN Pin = NoPin
)
// UART0 is the USB device
var (
UART0 = USB
)
// Serial is the USB device
var Serial = USB
// I2C pins (unused)
const (
+2 -4
View File
@@ -18,10 +18,8 @@ const (
UART_RX_PIN Pin = 19
)
// UART0 is the USB device
var (
UART0 = USB
)
// Serial is the USB device
var Serial = USB
// I2C pins (unused)
const (
+4 -5
View File
@@ -99,17 +99,16 @@ const (
var (
// USART2 is the hardware serial port connected to the onboard ST-LINK
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
// Both UART0 and UART1 refer to USART2.
UART0 = &_UART0
_UART0 = UART{
UART2 = &_UART2
_UART2 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART2,
}
UART2 = UART0
Serial = UART2
)
func init() {
UART0.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART0.handleInterrupt)
UART2.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART2.handleInterrupt)
}
// SPI pins
+4 -5
View File
@@ -31,19 +31,18 @@ const (
var (
// USART3 is the hardware serial port connected to the onboard ST-LINK
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
// Both UART0 and UART1 refer to USART2.
UART0 = &_UART0
_UART0 = UART{
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART3,
TxAltFuncSelector: UART_ALT_FN,
RxAltFuncSelector: UART_ALT_FN,
}
UART1 = UART0
Serial = UART1
)
func init() {
UART0.Interrupt = interrupt.New(stm32.IRQ_USART3, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART3, _UART1.handleInterrupt)
}
// SPI pins
+4 -5
View File
@@ -63,15 +63,14 @@ const (
var (
// USART2 is the hardware serial port connected to the onboard ST-LINK
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
// Both UART0 and UART1 refer to USART2.
UART0 = &_UART0
_UART0 = UART{
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART2,
TxAltFuncSelector: 4,
RxAltFuncSelector: 4,
}
UART1 = UART0
Serial = UART1
// I2C1 is documented, alias to I2C0 as well
I2C1 = &I2C{
@@ -89,5 +88,5 @@ var (
)
func init() {
UART0.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART1.handleInterrupt)
}
+4 -5
View File
@@ -65,15 +65,14 @@ const (
var (
// USART2 is the hardware serial port connected to the onboard ST-LINK
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
// Both UART0 and UART1 refer to USART2.
UART0 = &_UART0
_UART0 = UART{
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART2,
TxAltFuncSelector: 7,
RxAltFuncSelector: 3,
}
UART1 = UART0
Serial = UART1
// I2C1 is documented, alias to I2C0 as well
I2C1 = &I2C{
@@ -91,5 +90,5 @@ var (
)
func init() {
UART0.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART1.handleInterrupt)
}
+4 -5
View File
@@ -31,15 +31,14 @@ const (
var (
// LPUART1 is the hardware serial port connected to the onboard ST-LINK
// debugger to be exposed as virtual COM port over USB on Nucleo boards.
// Both UART0 and UART1 refer to LPUART1.
UART0 = &_UART0
_UART0 = UART{
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.LPUART1,
TxAltFuncSelector: UART_ALT_FN,
RxAltFuncSelector: UART_ALT_FN,
}
UART1 = UART0
Serial = UART1
)
const (
@@ -57,5 +56,5 @@ var (
)
func init() {
UART0.Interrupt = interrupt.New(stm32.IRQ_LPUART1, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_LPUART1, _UART1.handleInterrupt)
}
+1 -1
View File
@@ -66,7 +66,7 @@ const (
BASE_ENABLE_PIN Pin = PB09
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN Pin = PA24
USBCDC_DP_PIN Pin = PA25
+1 -2
View File
@@ -41,8 +41,7 @@ const (
// UART
var (
Serial = USB
UART0 = NRF_UART0
Serial = UART0
)
const (
+1 -2
View File
@@ -41,8 +41,7 @@ const (
// UART
var (
Serial = USB
UART0 = NRF_UART0
Serial = UART0
)
const (
+1 -2
View File
@@ -41,8 +41,7 @@ const (
// UART
var (
Serial = USB
UART0 = NRF_UART0
Serial = UART0
)
const (
+2
View File
@@ -19,6 +19,8 @@ const (
LED_BLUE Pin = 23
)
var Serial = UART0
// UART pins
const (
UART_TX_PIN Pin = 9
+2
View File
@@ -23,6 +23,8 @@ const (
BUTTON4 Pin = 16
)
var Serial = UART0
// UART pins for NRF52840-DK
const (
UART_TX_PIN Pin = 6
+2
View File
@@ -22,6 +22,8 @@ const (
BUTTON4 Pin = 25
)
var Serial = UART0
// UART pins
const (
UART_TX_PIN Pin = 6
-8
View File
@@ -1,8 +0,0 @@
// +build nrf52840,pca10056
package machine
// UART0 is the NRF UART
var (
UART0 = NRF_UART0
)
+2 -2
View File
@@ -34,9 +34,9 @@ const (
UART_RX_PIN Pin = NoPin
)
// UART0 is the USB device
// Serial is the USB device
var (
UART0 = USB
Serial = USB
)
// I2C pins (unused)
+2
View File
@@ -17,6 +17,8 @@ const (
LED3 = LCD_BACKLIGHT_LOW
)
var Serial = UART0
// UART pins for PineTime. Note that RX is set to NoPin as RXD is not listed in
// the PineTime schematic 1.0:
// http://files.pine64.org/doc/PineTime/PineTime%20Port%20Assignment%20rev1.0.pdf
+3 -1
View File
@@ -66,7 +66,9 @@ const (
BUTTON_B_MASK = 128
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+3 -1
View File
@@ -69,7 +69,9 @@ const (
BUTTON_B_MASK = 128
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+3 -1
View File
@@ -94,7 +94,9 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+1 -1
View File
@@ -45,7 +45,7 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+2
View File
@@ -29,6 +29,8 @@ const (
BUTTON Pin = 7
)
var Serial = UART0
// UART pins
const (
UART_TX_PIN Pin = 6
-8
View File
@@ -1,8 +0,0 @@
// +build nrf52840,reelboard
package machine
// UART0 is the NRF UART
var (
UART0 = NRF_UART0
)
+4 -4
View File
@@ -27,19 +27,19 @@ const (
)
var (
UART0 = &_UART0
_UART0 = UART{
UART1 = &_UART1
_UART1 = UART{
Buffer: NewRingBuffer(),
Bus: stm32.USART2,
TxAltFuncSelector: AF7_USART1_2_3,
RxAltFuncSelector: AF7_USART1_2_3,
}
UART1 = UART0
Serial = UART1
)
// set up RX IRQ handler. Follow similar pattern for other UARTx instances
func init() {
UART0.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART0.handleInterrupt)
UART1.Interrupt = interrupt.New(stm32.IRQ_USART2, _UART1.handleInterrupt)
}
// SPI pins
+1 -1
View File
@@ -136,7 +136,7 @@ const (
)
var (
UART0 = UART1 // alias UART0 to UART1
Serial = UART1
UART1 = &_UART1
_UART1 = UART{
Bus: nxp.LPUART6,
+1 -1
View File
@@ -33,7 +33,7 @@ const (
LED = D13
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+3 -1
View File
@@ -325,7 +325,9 @@ const (
OUTPUT_CTR_3V3 = PC15
)
// UART0 aka USBCDC pins
var Serial = USB
// USBCDC pins
const (
USBCDC_DM_PIN = PIN_USB_DM
USBCDC_DP_PIN = PIN_USB_DP
+2
View File
@@ -26,3 +26,5 @@ const (
)
const HasLowFrequencyCrystal = true
var Serial = UART0
+1 -1
View File
@@ -48,7 +48,7 @@ const (
LED3 = LED_TXL
)
// UART0 aka USBCDC pins
// USBCDC pins
const (
USBCDC_DM_PIN = PA24
USBCDC_DP_PIN = PA25
+3
View File
@@ -121,6 +121,9 @@ func (i2c *I2C) readByte() byte {
return byte(avr.TWDR.Get())
}
// Always use UART0 as the serial output.
var Serial = UART0
// UART
var (
// UART0 is the hardware serial port on the AVR.
+4 -5
View File
@@ -505,8 +505,7 @@ type UART struct {
}
var (
// UART0 is actually a USB CDC interface.
UART0 = &USBCDC{Buffer: NewRingBuffer()}
USB = &USBCDC{Buffer: NewRingBuffer()}
)
const (
@@ -1985,7 +1984,7 @@ func handleUSB(intr interrupt.Interrupt) {
// Start of frame
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
UART0.Flush()
USB.Flush()
// if you want to blink LED showing traffic, this would be the place...
}
@@ -2045,7 +2044,7 @@ func handleUSB(intr interrupt.Interrupt) {
setEPINTFLAG(i, sam.USB_DEVICE_EPINTFLAG_TRCPT1)
if i == usb_CDC_ENDPOINT_IN {
UART0.waitTxc = false
USB.waitTxc = false
}
}
}
@@ -2359,7 +2358,7 @@ func handleEndpoint(ep uint32) {
// move to ring buffer
for i := 0; i < count; i++ {
UART0.Receive(byte((udd_ep_out_cache_buffer[ep][i] & 0xFF)))
USB.Receive(byte((udd_ep_out_cache_buffer[ep][i] & 0xFF)))
}
// set byte count to zero
+5 -5
View File
@@ -951,8 +951,8 @@ type UART struct {
}
var (
// UART0 is actually a USB CDC interface.
UART0 = &USBCDC{Buffer: NewRingBuffer()}
// USB is a USB CDC interface.
USB = &USBCDC{Buffer: NewRingBuffer()}
)
const (
@@ -2193,7 +2193,7 @@ func handleUSBIRQ(interrupt.Interrupt) {
// Start of frame
if (flags & sam.USB_DEVICE_INTFLAG_SOF) > 0 {
UART0.Flush()
USB.Flush()
// if you want to blink LED showing traffic, this would be the place...
}
@@ -2253,7 +2253,7 @@ func handleUSBIRQ(interrupt.Interrupt) {
setEPINTFLAG(i, sam.USB_DEVICE_ENDPOINT_EPINTFLAG_TRCPT1)
if i == usb_CDC_ENDPOINT_IN {
UART0.waitTxc = false
USB.waitTxc = false
}
}
}
@@ -2567,7 +2567,7 @@ func handleEndpoint(ep uint32) {
// move to ring buffer
for i := 0; i < count; i++ {
UART0.Receive(byte((udd_ep_out_cache_buffer[ep][i] & 0xFF)))
USB.Receive(byte((udd_ep_out_cache_buffer[ep][i] & 0xFF)))
}
// set byte count to zero
+1
View File
@@ -8,6 +8,7 @@ var (
SPI0 = SPI{0}
I2C0 = &I2C{0}
UART0 = &UART{0}
USB = &UART{100}
)
const (
+3 -3
View File
@@ -138,8 +138,8 @@ type UART struct {
// UART
var (
// UART0 is the hardware UART on the NRF SoC.
_NRF_UART0 = UART{Buffer: NewRingBuffer()}
NRF_UART0 = &_NRF_UART0
_UART0 = UART{Buffer: NewRingBuffer()}
UART0 = &_UART0
)
// Configure the UART.
@@ -165,7 +165,7 @@ func (uart *UART) Configure(config UARTConfig) {
nrf.UART0.INTENSET.Set(nrf.UART_INTENSET_RXDRDY_Msk)
// Enable RX IRQ.
intr := interrupt.New(nrf.IRQ_UART0, _NRF_UART0.handleInterrupt)
intr := interrupt.New(nrf.IRQ_UART0, _UART0.handleInterrupt)
intr.SetPriority(0xc0) // low priority
intr.Enable()
}
-4
View File
@@ -6,10 +6,6 @@ import (
"device/nrf"
)
var (
UART0 = NRF_UART0
)
func CPUFrequency() uint32 {
return 16000000
}
-4
View File
@@ -42,10 +42,6 @@ const (
P0_31 Pin = 31
)
var (
UART0 = NRF_UART0
)
// Get peripheral and pin number for this GPIO pin.
func (p Pin) getPortPin() (*nrf.GPIO_Type, uint32) {
return nrf.P0, uint32(p)
-4
View File
@@ -58,10 +58,6 @@ const (
P1_15 Pin = 47
)
var (
UART0 = NRF_UART0
)
// Get peripheral and pin number for this GPIO pin.
func (p Pin) getPortPin() (*nrf.GPIO_Type, uint32) {
if p >= 32 {
+2 -2
View File
@@ -8,11 +8,11 @@ import (
)
func initUART() {
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
// Sleep for a given period. The period is defined by the WDT peripheral, and is
+2 -2
View File
@@ -30,11 +30,11 @@ func init() {
initADCClock()
// connect to USB CDC interface
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func initClocks() {
+2 -2
View File
@@ -30,11 +30,11 @@ func init() {
initADCClock()
// connect to USB CDC interface
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func initClocks() {
+2 -2
View File
@@ -14,7 +14,7 @@ type timeUnit int64
var currentTime timeUnit
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func postinit() {}
@@ -53,7 +53,7 @@ func main() {
preinit()
// Initialize UART.
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
// Configure timer 0 in timer group 0, for timekeeping.
// EN: Enable the timer.
+2 -2
View File
@@ -14,7 +14,7 @@ type timeUnit int64
var currentTime timeUnit = 0
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
// Write to the internal control bus (using I2C?).
@@ -37,7 +37,7 @@ func main() {
rom_i2c_writeReg(103, 4, 2, 145)
// Initialize UART.
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
// Initialize timer. Bits:
// ENABLE: timer enable
+2 -2
View File
@@ -93,11 +93,11 @@ func initPeripherals() {
sifive.RTC.RTCCFG.Set(sifive.RTC_RTCCFG_ENALWAYS)
// Configure the UART.
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
var timerWakeup volatile.Register8
+2 -2
View File
@@ -105,11 +105,11 @@ func initPeripherals() {
// Enable FPIOA peripheral.
kendryte.SYSCTL.CLK_EN_PERI.SetBits(kendryte.SYSCTL_CLK_EN_PERI_FPIOA_CLK_EN)
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
var timerWakeup volatile.Register8
+2 -2
View File
@@ -29,7 +29,7 @@ func main() {
}
func init() {
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initLFCLK()
initRTC()
}
@@ -64,7 +64,7 @@ func initRTC() {
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func sleepTicks(d timeUnit) {
+2 -2
View File
@@ -33,7 +33,7 @@ func init() {
Device: stm32.TIM3,
})
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB1ENR,
@@ -43,7 +43,7 @@ func init() {
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
// initCLK sets clock to 72MHz using HSE 8MHz crystal w/ PLL X 9 (8MHz x 9 = 72MHz).
+2 -2
View File
@@ -181,10 +181,10 @@ func initCLK() {
func initCOM() {
if machine.NUM_UART_INTERFACES > 0 {
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
}
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
+2 -2
View File
@@ -51,7 +51,7 @@ func init() {
Device: stm32.TIM3,
})
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB1ENR,
@@ -61,7 +61,7 @@ func init() {
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func initCLK() {
+2 -2
View File
@@ -50,7 +50,7 @@ func init() {
Device: stm32.TIM3,
})
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB1ENR,
@@ -60,7 +60,7 @@ func init() {
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func initCLK() {
+1 -1
View File
@@ -14,7 +14,7 @@ const (
type arrtype = uint16
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func initCLK() {
+1 -1
View File
@@ -34,7 +34,7 @@ func init() {
Device: stm32.TIM22,
})
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB2ENR,
+1 -1
View File
@@ -34,7 +34,7 @@ func init() {
Device: stm32.TIM3,
})
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB1ENR,
+2 -2
View File
@@ -75,7 +75,7 @@ func init() {
Device: stm32.TIM15,
})
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB2ENR,
@@ -85,7 +85,7 @@ func init() {
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func initCLK() {
+2 -2
View File
@@ -51,7 +51,7 @@ func init() {
Device: stm32.TIM15,
})
machine.UART0.Configure(machine.UARTConfig{})
machine.Serial.Configure(machine.UARTConfig{})
initTickTimer(&timerInfo{
EnableRegister: &stm32.RCC.APB2ENR,
@@ -61,7 +61,7 @@ func init() {
}
func putchar(c byte) {
machine.UART0.WriteByte(c)
machine.Serial.WriteByte(c)
}
func initCLK() {