serial: use common initialization for serial
Этот коммит содержится в:
родитель
7eaad62568
коммит
ff7c71c99c
22 изменённых файлов: 31 добавлений и 19 удалений
|
@ -5,3 +5,7 @@ package machine
|
||||||
|
|
||||||
// Serial is a null device: writes to it are ignored.
|
// Serial is a null device: writes to it are ignored.
|
||||||
var Serial = NullSerial{}
|
var Serial = NullSerial{}
|
||||||
|
|
||||||
|
func InitSerial() {
|
||||||
|
Serial.Configure(UARTConfig{})
|
||||||
|
}
|
||||||
|
|
|
@ -5,3 +5,7 @@ package machine
|
||||||
|
|
||||||
// Serial is implemented via the default (usually the first) UART on the chip.
|
// Serial is implemented via the default (usually the first) UART on the chip.
|
||||||
var Serial = DefaultUART
|
var Serial = DefaultUART
|
||||||
|
|
||||||
|
func InitSerial() {
|
||||||
|
Serial.Configure(UARTConfig{})
|
||||||
|
}
|
||||||
|
|
|
@ -5,3 +5,7 @@ package machine
|
||||||
|
|
||||||
// Serial is implemented via USB (USB-CDC).
|
// Serial is implemented via USB (USB-CDC).
|
||||||
var Serial = USB
|
var Serial = USB
|
||||||
|
|
||||||
|
func InitSerial() {
|
||||||
|
Serial.Configure(UARTConfig{})
|
||||||
|
}
|
||||||
|
|
|
@ -9,7 +9,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
func initUART() {
|
func initUART() {
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
|
|
|
@ -29,7 +29,7 @@ func init() {
|
||||||
initADCClock()
|
initADCClock()
|
||||||
|
|
||||||
// connect to USB CDC interface
|
// connect to USB CDC interface
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
if !machine.USB.Configured() {
|
if !machine.USB.Configured() {
|
||||||
machine.USB.Configure(machine.UARTConfig{})
|
machine.USB.Configure(machine.UARTConfig{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,7 @@ func init() {
|
||||||
initADCClock()
|
initADCClock()
|
||||||
|
|
||||||
// connect to USB CDC interface
|
// connect to USB CDC interface
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
if !machine.USB.Configured() {
|
if !machine.USB.Configured() {
|
||||||
machine.USB.Configure(machine.UARTConfig{})
|
machine.USB.Configure(machine.UARTConfig{})
|
||||||
}
|
}
|
||||||
|
|
|
@ -43,7 +43,7 @@ func main() {
|
||||||
clearbss()
|
clearbss()
|
||||||
|
|
||||||
// Initialize UART.
|
// Initialize UART.
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
// Initialize main system timer used for time.Now.
|
// Initialize main system timer used for time.Now.
|
||||||
initTimer()
|
initTimer()
|
||||||
|
|
|
@ -48,7 +48,7 @@ func main() {
|
||||||
rom_i2c_writeReg(103, 4, 2, 145)
|
rom_i2c_writeReg(103, 4, 2, 145)
|
||||||
|
|
||||||
// Initialize UART.
|
// Initialize UART.
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
// Initialize timer. Bits:
|
// Initialize timer. Bits:
|
||||||
// ENABLE: timer enable
|
// ENABLE: timer enable
|
||||||
|
|
|
@ -92,7 +92,7 @@ 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.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
|
|
|
@ -104,7 +104,7 @@ 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.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
|
|
|
@ -119,7 +119,7 @@ func initPins() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func initUART() {
|
func initUART() {
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
}
|
}
|
||||||
|
|
||||||
func putchar(c byte) {
|
func putchar(c byte) {
|
||||||
|
|
|
@ -28,7 +28,7 @@ func main() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
initLFCLK()
|
initLFCLK()
|
||||||
initRTC()
|
initRTC()
|
||||||
}
|
}
|
||||||
|
|
|
@ -76,7 +76,7 @@ func machineInit()
|
||||||
func init() {
|
func init() {
|
||||||
machineInit()
|
machineInit()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
}
|
}
|
||||||
|
|
||||||
//export Reset_Handler
|
//export Reset_Handler
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
initTickTimer(&machine.TIM4)
|
initTickTimer(&machine.TIM4)
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
func init() {
|
func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
initTickTimer(&machine.TIM2)
|
initTickTimer(&machine.TIM2)
|
||||||
}
|
}
|
||||||
|
|
|
@ -156,7 +156,7 @@ func initCLK() {
|
||||||
|
|
||||||
func initCOM() {
|
func initCOM() {
|
||||||
if machine.NUM_UART_INTERFACES > 0 {
|
if machine.NUM_UART_INTERFACES > 0 {
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
initTickTimer(&machine.TIM3)
|
initTickTimer(&machine.TIM3)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
initTickTimer(&machine.TIM21)
|
initTickTimer(&machine.TIM21)
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,7 +15,7 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
initTickTimer(&machine.TIM3)
|
initTickTimer(&machine.TIM3)
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,7 +38,7 @@ type arrtype = uint32
|
||||||
func init() {
|
func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
initTickTimer(&machine.TIM15)
|
initTickTimer(&machine.TIM15)
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,7 @@ const (
|
||||||
func init() {
|
func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
initTickTimer(&machine.TIM16)
|
initTickTimer(&machine.TIM16)
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,7 +23,7 @@ func init() {
|
||||||
initCLK()
|
initCLK()
|
||||||
|
|
||||||
// UART init
|
// UART init
|
||||||
machine.Serial.Configure(machine.UARTConfig{})
|
machine.InitSerial()
|
||||||
|
|
||||||
// Timers init
|
// Timers init
|
||||||
initTickTimer(&machine.TIM1)
|
initTickTimer(&machine.TIM1)
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче