code: func (a *AdafruitMotorHatDriver) setPWMFreq(conn Connection, freq float64) (err error) {
  	// 25MHz
  	preScaleVal := 25000000.0
  	// 12-bit
  	preScaleVal /= 4096.0
  	preScaleVal /= freq
  	preScaleVal -= 1.0
  	preScale := math.Floor(preScaleVal + 0.5)
  	if adafruitDebug {
  		log.Printf("Setting PWM frequency to:	%.2f Hz", freq)
  		log.Printf("Estimated pre-scale: 		%.2f", preScaleVal)
  		log.Printf("Final pre-scale: 			%.2f", preScale)
  	}
  	// default (and only) reads register 0
  	oldMode := []byte{0}
  	_, err = conn.Read(oldMode)
  	if err != nil {
  		return
  	}
  	// sleep?
  	if len(oldMode) > 0 {
  		newMode := (oldMode[0] & 0x7F) | 0x10
  		reg := byte(_Mode1)
  		if _, err = conn.Write([]byte{reg, newMode}); err != nil {
  			return
  		}
  		reg = byte(_Prescale)
  		val := byte(math.Floor(preScale))
  		if _, err = conn.Write([]byte{reg, val}); err != nil {
  			return
  		}
  		reg = byte(_Mode1)
  		if _, err = conn.Write([]byte{reg, oldMode[0]}); err != nil {
  			return
  		}
  		time.Sleep(5 * time.Millisecond)
  		if _, err = conn.Write([]byte{reg, (oldMode[0] | 0x80)}); err != nil {
  			return
  		}
  	}
  	return
  }
docs: // setPWMFreq adjusts the PWM frequency which determines how many full
  // pulses per second are generated by the integrated circuit.  The frequency
  // determines how "long" each pulse is in duration from start to finish,
  // taking into account the high and low segments of the pulse.