/*-
* Copyright (c) 2018 Jason R. Thorpe
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* 1. Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
* ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
/*
* The PCA9685 has 6 address select pins, which must be
* pulled up or down to select the device's address. The
* selected slave address is:
*
* 1 A5 A4 A3 A2 A1 A0
*
* There are some addresses, however, that cannot be selected
* even if they fall into the selectable range:
*
* - Default all-call address (0x70)
* - 10-bit slave address prefix (0x78)
* - Reserved for future purposes address (0x7c)
*
* Use of sub-addresses to control groups of devices also limits
* the available individual slave addresses.
*/
#define PCA9685_I2CADDR_MIN 0x40
#define PCA9685_I2CADDR_MAX 0x7f
#define PCA9685_I2CADDR_BLACKLIST { 0x78, 0x7c }
/*
* PCA9685 has an internal 25MHz oscillator. The maximum external
* reference clock frequency is 50MHz.
*/
#define PCA9685_INTERNAL_FREQ 25000000
#define PCA9685_EXTERNAL_FREQ_MAX 50000000
/*
* Data sheet sez:
*
* Maximum PWM frequency is 1526Hz -- prescale == 0x03.
* Minimum PWM frequency is 24Hz -- prescale == 0xff.
*/
#define PCA9685_FREQ_MIN 24
#define PCA9685_FREQ_MAX 1526