Ported from https://github.com/google/periph/issues/231. See https://pkg.go.dev/periph.io/x/conn/v3/gpio/gpiostream.