github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/usb/descriptor/configuration.go (about) 1 package descriptor 2 3 import ( 4 "encoding/binary" 5 ) 6 7 const ( 8 configurationTypeLen = 9 9 ) 10 11 type ConfigurationType struct { 12 data []byte 13 } 14 15 func (d ConfigurationType) Bytes() []byte { 16 return d.data 17 } 18 19 func (d ConfigurationType) Length(v uint8) { 20 d.data[0] = byte(v) 21 } 22 23 func (d ConfigurationType) Type(v uint8) { 24 d.data[1] = byte(v) 25 } 26 27 func (d ConfigurationType) TotalLength(v uint16) { 28 binary.LittleEndian.PutUint16(d.data[2:4], v) 29 } 30 31 func (d ConfigurationType) NumInterfaces(v uint8) { 32 d.data[4] = byte(v) 33 } 34 35 func (d ConfigurationType) ConfigurationValue(v uint8) { 36 d.data[5] = byte(v) 37 } 38 39 func (d ConfigurationType) Configuration(v uint8) { 40 d.data[6] = byte(v) 41 } 42 43 func (d ConfigurationType) Attributes(v uint8) { 44 d.data[7] = byte(v) 45 } 46 47 func (d ConfigurationType) MaxPower(v uint8) { 48 d.data[8] = byte(v) 49 }