PCA9685 library

Dependents:   s-rov-firmware DISCO-F746NG_rtos_test

Revision:
2:5c8802f876f8
Parent:
1:7e071acc57b1
--- a/pca9685.cpp	Mon Jan 16 13:00:49 2017 +0000
+++ b/pca9685.cpp	Thu Jan 26 17:04:46 2017 +0000
@@ -1,7 +1,7 @@
 #include "mbed.h"
 #include "pca9685.h"
 
-PCA9685::PCA9685(uint8_t i2c_addr, I2C i2c_object, float freq):
+PCA9685::PCA9685(uint8_t i2c_addr, I2C* i2c_object, float freq):
     PCA9685_ADDR(i2c_addr << 1),
     frequency(freq),
     i2c(i2c_object)
@@ -51,7 +51,7 @@
     cmd[2] = on / 256;
     cmd[3] = off % 256;
     cmd[4] = off / 256;    
-    i2c.write(PCA9685_ADDR, cmd, 5);   
+    i2c->write(PCA9685_ADDR, cmd, 5);   
 }
 
 void PCA9685::set_pwm_duty(uint8_t num, float duty){
@@ -68,12 +68,12 @@
     char cmd[2];
     cmd[0] = reg;
     cmd[1] = msg;
-    i2c.write(PCA9685_ADDR, cmd, 2);
+    i2c->write(PCA9685_ADDR, cmd, 2);
 }
 
 char PCA9685::read_8(uint8_t reg){
     char cmd = reg;
-    i2c.write(PCA9685_ADDR, &cmd, 1);
-    i2c.read(PCA9685_ADDR, &cmd, 1);
+    i2c->write(PCA9685_ADDR, &cmd, 1);
+    i2c->read(PCA9685_ADDR, &cmd, 1);
     return cmd;    
 }
\ No newline at end of file