I2C bus upgrade (#432)
This commit is contained in:
parent
d100f42b1f
commit
b83c2629b9
56 changed files with 909 additions and 804 deletions
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
#include <i2c/i2c.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
|
@ -22,7 +23,7 @@ extern "C"
|
|||
* Init device
|
||||
* @param addr Device address
|
||||
*/
|
||||
void pca9685_init(uint8_t addr);
|
||||
void pca9685_init(i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* Setup device subaddress (see section 7.3.6 if the datasheet)
|
||||
|
@ -32,62 +33,62 @@ void pca9685_init(uint8_t addr);
|
|||
* @param enable True to enable subaddress, false to disable
|
||||
* @return False if error occured
|
||||
*/
|
||||
bool pca9685_set_subaddr(uint8_t addr, uint8_t num, uint8_t subaddr, bool enable);
|
||||
bool pca9685_set_subaddr(i2c_dev_t* dev, uint8_t num, uint8_t subaddr, bool enable);
|
||||
|
||||
/**
|
||||
* Restart device (see section 7.3.1.1 of the datasheet)
|
||||
* @param addr Device address
|
||||
*/
|
||||
void pca9685_restart(uint8_t addr);
|
||||
void pca9685_restart(i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* Check if device is in sleep mode
|
||||
* @param addr Device address
|
||||
* @return True if device is sleeping
|
||||
*/
|
||||
bool pca9685_is_sleeping(uint8_t addr);
|
||||
bool pca9685_is_sleeping(i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* Switch device to low-power mode or wake it up.
|
||||
* @param addr Device address
|
||||
* @param sleep True for sleep mode, false for wake up
|
||||
*/
|
||||
void pca9685_sleep(uint8_t addr, bool sleep);
|
||||
void pca9685_sleep(i2c_dev_t* dev, bool sleep);
|
||||
|
||||
/**
|
||||
* Get logic inversion of the outputs
|
||||
* @param addr Device address
|
||||
* @return True if outputs are inverted, false otherwise
|
||||
*/
|
||||
bool pca9685_is_output_inverted(uint8_t addr);
|
||||
bool pca9685_is_output_inverted(i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* Logically invert outputs (see section 7.7 of the datasheet)
|
||||
* @param addr Device address
|
||||
* @param inverted True for inverted outputs
|
||||
*/
|
||||
void pca9685_set_output_inverted(uint8_t addr, bool inverted);
|
||||
void pca9685_set_output_inverted(i2c_dev_t* dev, bool inverted);
|
||||
|
||||
/**
|
||||
* Get outputs mode
|
||||
* @param addr Device address
|
||||
* @return True if outputs are in open drain mode
|
||||
*/
|
||||
bool pca9685_get_output_open_drain(uint8_t addr);
|
||||
bool pca9685_get_output_open_drain(i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* Set outputs mode
|
||||
* @param addr Device address
|
||||
* @param open_drain True to set open drain mode, false to normal mode
|
||||
*/
|
||||
void pca9685_set_output_open_drain(uint8_t addr, bool open_drain);
|
||||
void pca9685_set_output_open_drain(i2c_dev_t* dev, bool open_drain);
|
||||
|
||||
/**
|
||||
* Get current PWM frequency prescaler.
|
||||
* @param addr Device address
|
||||
* @return Frequency prescaler
|
||||
*/
|
||||
uint8_t pca9685_get_prescaler(uint8_t addr);
|
||||
uint8_t pca9685_get_prescaler(i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* Set PWM frequency prescaler.
|
||||
|
@ -95,14 +96,14 @@ uint8_t pca9685_get_prescaler(uint8_t addr);
|
|||
* @param prescaler Prescaler value
|
||||
* @return False if error occured
|
||||
*/
|
||||
bool pca9685_set_prescaler(uint8_t addr, uint8_t prescaler);
|
||||
bool pca9685_set_prescaler(i2c_dev_t* dev, uint8_t prescaler);
|
||||
|
||||
/**
|
||||
* Get current PWM frequency
|
||||
* @param addr Device address
|
||||
* @return PWM frequency, Hz
|
||||
*/
|
||||
uint16_t pca9685_get_pwm_frequency(uint8_t addr);
|
||||
uint16_t pca9685_get_pwm_frequency(i2c_dev_t* dev);
|
||||
|
||||
/**
|
||||
* Set PWM frequency
|
||||
|
@ -110,7 +111,7 @@ uint16_t pca9685_get_pwm_frequency(uint8_t addr);
|
|||
* @param freq PWM frequency, Hz
|
||||
* @return False if error occured
|
||||
*/
|
||||
bool pca9685_set_pwm_frequency(uint8_t addr, uint16_t freq);
|
||||
bool pca9685_set_pwm_frequency(i2c_dev_t* dev, uint16_t freq);
|
||||
|
||||
/**
|
||||
* Set PWM value on output channel
|
||||
|
@ -118,7 +119,7 @@ bool pca9685_set_pwm_frequency(uint8_t addr, uint16_t freq);
|
|||
* @param channel Channel number, 0..15 or >15 for all channels
|
||||
* @param val PWM value, 0..4096
|
||||
*/
|
||||
void pca9685_set_pwm_value(uint8_t addr, uint8_t channel, uint16_t val);
|
||||
void pca9685_set_pwm_value(i2c_dev_t* dev, uint8_t channel, uint16_t val);
|
||||
|
||||
/**
|
||||
* Set PWM values on output channels
|
||||
|
@ -128,7 +129,7 @@ void pca9685_set_pwm_value(uint8_t addr, uint8_t channel, uint16_t val);
|
|||
* @param values Array of the channel values, each 0..4096
|
||||
* @return False if error occured
|
||||
*/
|
||||
bool pca9685_set_pwm_values(uint8_t addr, uint8_t first_ch, uint8_t channels, const uint16_t *values);
|
||||
bool pca9685_set_pwm_values(i2c_dev_t* dev, uint8_t first_ch, uint8_t channels, const uint16_t *values);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue