machine/esp32c3: implement USB_SERIAL for USBCDC communication

Signed-off-by: deadprogram <ron@hybridgroup.com>
This commit is contained in:
deadprogram
2023-11-27 15:25:58 +01:00
committed by Ron Evans
parent f51029484a
commit d7c77b6761
5 changed files with 117 additions and 19 deletions
+5
View File
@@ -5,6 +5,7 @@ package runtime
import (
"device/esp"
"device/riscv"
"machine"
"runtime/volatile"
"unsafe"
)
@@ -53,6 +54,10 @@ func main() {
// Configure interrupt handler
interruptInit()
// Initialize UART.
machine.USBCDC.Configure(machine.UARTConfig{})
machine.InitSerial()
// Initialize main system timer used for time.Now.
initTimer()
+16 -16
View File
@@ -10,22 +10,6 @@ import (
type timeUnit int64
func putchar(c byte) {
machine.Serial.WriteByte(c)
}
func getchar() byte {
for machine.Serial.Buffered() == 0 {
Gosched()
}
v, _ := machine.Serial.ReadByte()
return v
}
func buffered() int {
return machine.Serial.Buffered()
}
// Initialize .bss: zero-initialized global variables.
// The .data section has already been loaded by the ROM bootloader.
func clearbss() {
@@ -84,3 +68,19 @@ func sleepTicks(d timeUnit) {
func exit(code int) {
abort()
}
func putchar(c byte) {
machine.Serial.WriteByte(c)
}
func getchar() byte {
for machine.Serial.Buffered() == 0 {
Gosched()
}
v, _ := machine.Serial.ReadByte()
return v
}
func buffered() int {
return machine.Serial.Buffered()
}