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