mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-08 04:53:42 +00:00
usb/cdc: Better ring buffer implementation (#5209)
* begin adding ring512 implementation * refactor to make operation driven fuzz test * refactor USBCDC.Read to use ring512 * try txhandler separate to flush * working USBCDC with large packets * fix binary size * remove comment * documentation improvements
This commit is contained in:
committed by
deadprogram
parent
6bb6ea2432
commit
86cc3b6c12
@@ -0,0 +1,29 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"machine"
|
||||
"strconv"
|
||||
"time"
|
||||
)
|
||||
|
||||
func main() {
|
||||
time.Sleep(2 * time.Second) // connect via serial
|
||||
buf1 := makeBuffer('|', 600)
|
||||
buf2 := makeBuffer('/', 600)
|
||||
println("start")
|
||||
serialWrite(buf1)
|
||||
serialWrite(buf2)
|
||||
}
|
||||
|
||||
func makeBuffer(sep byte, size int) []byte {
|
||||
buf := make([]byte, size)
|
||||
for i := 0; i < size-5; i += 5 {
|
||||
buf[i] = sep
|
||||
strconv.AppendInt(buf[i+1:i+1:i+5], int64(i), 10)
|
||||
}
|
||||
return buf
|
||||
}
|
||||
|
||||
func serialWrite(b []byte) {
|
||||
machine.Serial.Write(b)
|
||||
}
|
||||
Reference in New Issue
Block a user