Driver for a CD22M3494 cross point switcher

Library description

The CD22M3494 is a 16x8 crosspoint switch matrix, it can be used in any configuration i.e. 16 ins' 8 outs' or 16 outs' and 8 ins'. Control of the chip is pretty simple there are two parallel address buses a 4 byte address controls the X axis (16 IO pins) and a 3 byte address controls the Y axis (8 IO pins). A data bus says whether to open or close the switch and a 'strobe' bus actually performs the switch. This library provides a simple interface to control the CD22M3494 and provides a mechanism to associate source and destinations in pairs and switch the pairs via their names.

Revision:
2:25049dc7da13
Parent:
1:bc9ca1d1d7a6
Child:
3:fa46a8badc92
--- a/CD22M3494.h	Tue Sep 10 21:34:24 2013 +0000
+++ b/CD22M3494.h	Wed Sep 11 08:54:24 2013 +0000
@@ -2,11 +2,8 @@
 #define CD22M3494_H
 
 #include <mbed.h>
-
 #include <map>
-//using std::map;
 #include <string>
-//using std::string;
 
 /*
 X ADDRESS 
@@ -92,6 +89,8 @@
         delete data;
         delete strobe;
         delete reset;
+        associationTable.clear();
+        delete &associationTable;
     }
     
     bool crossPointConnect(unsigned short x, unsigned short y) {
@@ -127,7 +126,7 @@
     }
     
     void associate(string name, unsigned short xp1, unsigned short xp2) {
-        unsigned short xps[2];
+        unsigned short *xps = new unsigned short[2];
         xps[0] = xp1;
         xps[1] = xp2;
         associationTable[name] = xps;
@@ -135,8 +134,8 @@
     
     bool routeAssociations(string src, string dst) {
         if (associationTable.count(src) && associationTable.count(dst)) {
-            crossPointConnect(associationTable[src][0], associationTable[dst][1]);
-            crossPointConnect(associationTable[src][0], associationTable[dst][1]);
+            crossPointConnect(associationTable[src][0], associationTable[dst][0]);
+            crossPointConnect(associationTable[src][1], associationTable[dst][1]);
             return true;
         }
         return false;    
@@ -144,19 +143,19 @@
     
     bool unRouteAssociations(string src, string dst) {
         if (associationTable.count(src) && associationTable.count(dst)) {
-            crossPointDisconnect(associationTable[src][0], associationTable[dst][1]);
-            crossPointDisconnect(associationTable[src][0], associationTable[dst][1]);
+            crossPointDisconnect(associationTable[src][0], associationTable[dst][0]);
+            crossPointDisconnect(associationTable[src][1], associationTable[dst][1]);
             return true;
         }
         return false;            
     }
     
 private:
-    BusOut* xbus;
-    BusOut* ybus;
-    DigitalOut* data;
-    DigitalOut* strobe;
-    DigitalOut* reset;      
+    BusOut *xbus;
+    BusOut *ybus;
+    DigitalOut *data;
+    DigitalOut *strobe;
+    DigitalOut *reset;      
     map<string, unsigned short*> associationTable; 
 };