tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/ws2812/ws2812_tinygoriscv.go (about)

     1  //go:build tinygo.riscv32
     2  
     3  package ws2812
     4  
     5  import "machine"
     6  
     7  // Send a single byte using the WS2812 protocol.
     8  func (d Device) WriteByte(c byte) error {
     9  	switch machine.CPUFrequency() {
    10  	case 160_000_000: // 160MHz, e.g. esp32c3
    11  		d.writeByte160(c)
    12  		return nil
    13  	case 320_000_000: // 320MHz, e.g. fe310
    14  		d.writeByte320(c)
    15  		return nil
    16  	default:
    17  		return errUnknownClockSpeed
    18  	}
    19  }