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
@@ -16,6 +16,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()
}
// Sleep for a given period. The period is defined by the WDT peripheral, and is
// on most chips (at least) 3 bits wide, in powers of two from 16ms to 2s
// (0=16ms, 1=32ms, 2=64ms...). Note that the WDT is not very accurate: it can