This is a driver to control the SD20 20 Channel I2C to Servo Driver Chip from www.robot-electronics.co.uk (http://www.robot-electronics.co.uk/htm/sd20tech.htm). This driver will allow a servo channel to be started up, stopped and the duty cycle altered in standard mode. No attempt to include the extended mode is included.

Revision:
0:870a29ad1074
Child:
1:6557cf755742
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SD20.cpp	Sun Jan 24 14:39:33 2016 +0000
@@ -0,0 +1,57 @@
+#include "mbed.h"
+#include "SD20.h"
+      
+SD20::SD20(I2C *bus,int I2CAddress, int BusHz)
+{
+    _bus = bus;
+    deviceAddress = I2CAddress;
+    BusHz = BusHz;
+    _bus -> frequency(BusHz);
+}
+
+int SD20::UpdatePWM(char *DataOutput)
+{
+        if(_bus -> write(deviceAddress,(char*)DataOutput,OUT_BUF_LEN))
+        {
+            printf("I2C Failed to write\r\n");
+            return 1;
+        }
+        else
+        {
+            printf("0x%02x sent to Reg: 0x%02x\r\n",*(DataOutput+1),*DataOutput);
+            return 0;
+        }
+}
+
+int SD20::StartStopPWM(int Channel,bool Start)
+{
+        if(Start == CHANNEL_START)
+        {
+            int DataOutput[] = {Channel,0x01};
+            if(_bus -> write(deviceAddress,(char*)DataOutput,OUT_BUF_LEN))
+            {
+                printf("I2C Failed to write\r\n");
+                return 1;
+            }
+            else
+            {
+                printf("0x%02x sent to Reg: 0x%02x\r\n",*(DataOutput+1),*DataOutput);
+                return 0;
+            }
+        }
+        else
+        {
+           int DataOutput[] = {Channel,0x00};
+            if(_bus -> write(deviceAddress,(char*)DataOutput,OUT_BUF_LEN))
+            {
+                printf("I2C Failed to write\r\n");
+                return 1;
+            }
+            else
+            {
+                printf("0x%02x sent to Reg: 0x%02x\r\n",*(DataOutput+1),*DataOutput);
+                return 0;
+            }
+        }
+}
+