tinygo.org/x/drivers@v0.27.1-0.20240509133757-7dbca2a54349/ssd1289/rp2040bus.go (about) 1 //go:build rp2040 2 3 package ssd1289 4 5 import ( 6 "device/rp" 7 "machine" 8 ) 9 10 type rp2040Bus struct { 11 firstPin machine.Pin 12 } 13 14 func NewRP2040Bus(firstPin machine.Pin) rp2040Bus { 15 16 for i := uint8(0); i < 16; i++ { 17 pin := machine.Pin(i + uint8(firstPin)) 18 pin.Configure(machine.PinConfig{Mode: machine.PinOutput}) 19 } 20 21 return rp2040Bus{ 22 firstPin: firstPin, 23 } 24 25 } 26 27 func (b rp2040Bus) Set(data uint16) { 28 data32 := uint32(data) 29 rp.SIO.GPIO_OUT_CLR.Set(0xFFFF << b.firstPin) 30 rp.SIO.GPIO_OUT_SET.Set(data32 << b.firstPin) 31 }