Library for interfacing with the NXP PCA9685 PWM controller over an I2C connection. Designed with the Adafruit breakout board (of the same name) in mind.

Committer:
el13cj
Date:
Tue Apr 05 21:20:15 2016 +0000
Revision:
0:aa965d6b1f8f
Child:
3:a3410f2f061d
BASIC LIBRARY FUNCTIONS ALL WORKING

Who changed what in which revision?

UserRevisionLine numberNew contents of line
el13cj 0:aa965d6b1f8f 1 #ifndef PCA9685_LIBRARY_H
el13cj 0:aa965d6b1f8f 2 #define PCA9685_LIBRARY_H
el13cj 0:aa965d6b1f8f 3
el13cj 0:aa965d6b1f8f 4 #include "mbed.h"
el13cj 0:aa965d6b1f8f 5 #include "definitions.h"
el13cj 0:aa965d6b1f8f 6
el13cj 0:aa965d6b1f8f 7
el13cj 0:aa965d6b1f8f 8 class PCA9685 {
el13cj 0:aa965d6b1f8f 9
el13cj 0:aa965d6b1f8f 10 public:
el13cj 0:aa965d6b1f8f 11 PCA9685(uint8_t i2c_addr, I2C i2c_object, float frequency);
el13cj 0:aa965d6b1f8f 12 void init(void);
el13cj 0:aa965d6b1f8f 13 void set_pwm_output(int pwm_output, uint16_t count_on, uint16_t count_off);
el13cj 0:aa965d6b1f8f 14 void set_pwm_duty(int pwm_output, float duty_cycle);
el13cj 0:aa965d6b1f8f 15 void set_pwm_pw(int pwm_output, float pulse_width_us);
el13cj 0:aa965d6b1f8f 16 void update(void);
el13cj 0:aa965d6b1f8f 17
el13cj 0:aa965d6b1f8f 18 private:
el13cj 0:aa965d6b1f8f 19 void reset(void);
el13cj 0:aa965d6b1f8f 20 void write_8(uint8_t reg, uint8_t msg);
el13cj 0:aa965d6b1f8f 21 uint8_t read_8(uint8_t reg);
el13cj 0:aa965d6b1f8f 22 void set_prescale(uint8_t prescale);
el13cj 0:aa965d6b1f8f 23 int convert_pwm_value(float pulse_width_us, float period_us);
el13cj 0:aa965d6b1f8f 24
el13cj 0:aa965d6b1f8f 25 private:
el13cj 0:aa965d6b1f8f 26 int i2c_addr;
el13cj 0:aa965d6b1f8f 27 float freq;
el13cj 0:aa965d6b1f8f 28 I2C i2c;
el13cj 0:aa965d6b1f8f 29 };
el13cj 0:aa965d6b1f8f 30
el13cj 0:aa965d6b1f8f 31 #endif