code: func SetDutyCycle(pin Pin, dutyLen, cycleLen uint32) {
  	const pwmCtlReg = 0
  	var (
  		pwmDatReg uint
  		pwmRngReg uint
  		shift     uint // offset inside ctlReg
  	)
  
  	switch pin {
  	case 12, 18, 40: // channel pwm0
  		pwmRngReg = 4
  		pwmDatReg = 5
  		shift = 0
  	case 13, 19, 41, 45: // channel pwm1
  		pwmRngReg = 8
  		pwmDatReg = 9
  		shift = 8
  	default:
  		return
  	}
  
  	const ctlMask = 255 // ctl setting has 8 bits for each channel
  	const pwen = 1 << 0 // enable pwm
  	const msen = 1 << 7 // use M/S transition instead of pwm algorithm
  
  	// reset settings
  	pwmMem[pwmCtlReg] = pwmMem[pwmCtlReg]&^(ctlMask<<shift) | msen<<shift | pwen<<shift
  	// set duty cycle
  	pwmMem[pwmDatReg] = dutyLen
  	pwmMem[pwmRngReg] = cycleLen
  	time.Sleep(time.Microsecond * 10)
  
  	// NOTE without root permission this changes will simply do nothing successfully
  }
docs: // SetDutyCycle: Set cycle length (range) and duty length (data) for Pwm pin in M/S mode
  //
  //   |<- duty ->|
  //    __________
  //  _/          \_____________/
  //   |<------- cycle -------->|
  //
  // Output frequency is computed as pwm clock frequency divided by cycle length.
  // So, to set Pwm pin to freqency 38kHz with duty cycle 1/4, use this combination:
  //
  //  pin.Pwm()
  //  pin.DutyCycle(1, 4)
  //  pin.Freq(38000*4)
  //
  // Note that some pins share common pwm channel,
  // so calling this function will set same duty cycle for all pins belonging to channel.
  // The channels are:
  //   channel 1 (pwm0) for pins 12, 18, 40
  //   channel 2 (pwm1) for pins 13, 19, 41, 45.