os, runtime: enable os.Stdin for baremetal target

This commit is contained in:
sago35
2022-03-29 08:25:04 +09:00
committed by Ron Evans
parent 97842b367c
commit 39805bca45
26 changed files with 327 additions and 2 deletions
+12
View File
@@ -66,6 +66,18 @@ 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()
}
func sleepTicks(d timeUnit) {
for d != 0 {
ticks := uint32(d) & 0x7fffff // 23 bits (to be on the safe side)