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.

Committer:
ollie8
Date:
Tue Sep 03 12:49:43 2013 +0000
Revision:
0:5ef90cd25c10
Child:
1:bc9ca1d1d7a6
Driver for a CD22M3494 cross point switcher

Who changed what in which revision?

UserRevisionLine numberNew contents of line
ollie8 0:5ef90cd25c10 1 #ifndef CD22M3494_H
ollie8 0:5ef90cd25c10 2 #define CD22M3494_H
ollie8 0:5ef90cd25c10 3
ollie8 0:5ef90cd25c10 4 #include <mbed.h>
ollie8 0:5ef90cd25c10 5 /*
ollie8 0:5ef90cd25c10 6 X ADDRESS
ollie8 0:5ef90cd25c10 7 AX3 AX2 AX1 AX0 X SWITCH
ollie8 0:5ef90cd25c10 8 0 0 0 0 X0
ollie8 0:5ef90cd25c10 9 0 0 0 1 X1
ollie8 0:5ef90cd25c10 10 0 0 1 0 X2
ollie8 0:5ef90cd25c10 11 0 0 1 1 X3
ollie8 0:5ef90cd25c10 12 0 1 0 0 X4
ollie8 0:5ef90cd25c10 13 0 1 0 1 X5
ollie8 0:5ef90cd25c10 14 0 1 1 0 X12
ollie8 0:5ef90cd25c10 15 0 1 1 1 X13
ollie8 0:5ef90cd25c10 16 1 0 0 0 X6
ollie8 0:5ef90cd25c10 17 1 0 0 1 X7
ollie8 0:5ef90cd25c10 18 1 0 1 0 X8
ollie8 0:5ef90cd25c10 19 1 0 1 1 X9
ollie8 0:5ef90cd25c10 20 1 1 0 0 X10
ollie8 0:5ef90cd25c10 21 1 1 0 1 X11
ollie8 0:5ef90cd25c10 22 1 1 1 0 X14
ollie8 0:5ef90cd25c10 23 1 1 1 1 X15
ollie8 0:5ef90cd25c10 24 */
ollie8 0:5ef90cd25c10 25
ollie8 0:5ef90cd25c10 26 #define X0 0x00
ollie8 0:5ef90cd25c10 27 #define X1 0x01
ollie8 0:5ef90cd25c10 28 #define X2 0x02
ollie8 0:5ef90cd25c10 29 #define X3 0x03
ollie8 0:5ef90cd25c10 30 #define X4 0x04
ollie8 0:5ef90cd25c10 31 #define X5 0x05
ollie8 0:5ef90cd25c10 32 #define X12 0x06
ollie8 0:5ef90cd25c10 33 #define X13 0x07
ollie8 0:5ef90cd25c10 34 #define X6 0x08
ollie8 0:5ef90cd25c10 35 #define X7 0x09
ollie8 0:5ef90cd25c10 36 #define X8 0x0A
ollie8 0:5ef90cd25c10 37 #define X9 0x0B
ollie8 0:5ef90cd25c10 38 #define X10 0x0C
ollie8 0:5ef90cd25c10 39 #define X11 0x0D
ollie8 0:5ef90cd25c10 40 #define X14 0x0E
ollie8 0:5ef90cd25c10 41 #define X15 0x0F
ollie8 0:5ef90cd25c10 42
ollie8 0:5ef90cd25c10 43 /*
ollie8 0:5ef90cd25c10 44 Y ADDRESS
ollie8 0:5ef90cd25c10 45 AY2 AY1 AY0 Y SWITCH
ollie8 0:5ef90cd25c10 46 0 0 0 Y0
ollie8 0:5ef90cd25c10 47 0 0 1 Y1
ollie8 0:5ef90cd25c10 48 0 1 0 Y2
ollie8 0:5ef90cd25c10 49 0 1 1 Y3
ollie8 0:5ef90cd25c10 50 1 0 0 Y4
ollie8 0:5ef90cd25c10 51 1 0 1 Y5
ollie8 0:5ef90cd25c10 52 1 1 0 Y6
ollie8 0:5ef90cd25c10 53 1 1 1 Y7
ollie8 0:5ef90cd25c10 54 */
ollie8 0:5ef90cd25c10 55
ollie8 0:5ef90cd25c10 56 #define Y0 0x0
ollie8 0:5ef90cd25c10 57 #define Y1 0x1
ollie8 0:5ef90cd25c10 58 #define Y2 0x2
ollie8 0:5ef90cd25c10 59 #define Y3 0x3
ollie8 0:5ef90cd25c10 60 #define Y4 0x4
ollie8 0:5ef90cd25c10 61 #define Y5 0x5
ollie8 0:5ef90cd25c10 62 #define Y6 0x6
ollie8 0:5ef90cd25c10 63 #define Y7 0x7
ollie8 0:5ef90cd25c10 64
ollie8 0:5ef90cd25c10 65 #define MAX_X 0x0F
ollie8 0:5ef90cd25c10 66 #define MAX_Y 0x7
ollie8 0:5ef90cd25c10 67
ollie8 0:5ef90cd25c10 68 class CD22M3494 {
ollie8 0:5ef90cd25c10 69
ollie8 0:5ef90cd25c10 70 public:
ollie8 0:5ef90cd25c10 71
ollie8 0:5ef90cd25c10 72 CD22M3494(PinName x0, PinName x1, PinName x2, PinName x3, PinName y0, PinName y1, PinName y2, PinName d, PinName str, PinName rs) {
ollie8 0:5ef90cd25c10 73 xbus = new BusOut(x0, x1, x2, x3);
ollie8 0:5ef90cd25c10 74 ybus = new BusOut(y0, y1, y2);
ollie8 0:5ef90cd25c10 75 data = new DigitalOut(d);
ollie8 0:5ef90cd25c10 76 strobe = new DigitalOut(str);
ollie8 0:5ef90cd25c10 77 reset = new DigitalOut(rs);
ollie8 0:5ef90cd25c10 78 data->write(0);
ollie8 0:5ef90cd25c10 79 strobe->write(0);
ollie8 0:5ef90cd25c10 80 reset->write(0);
ollie8 0:5ef90cd25c10 81 }
ollie8 0:5ef90cd25c10 82
ollie8 0:5ef90cd25c10 83 ~CD22M3494() {
ollie8 0:5ef90cd25c10 84 delete xbus;
ollie8 0:5ef90cd25c10 85 delete ybus;
ollie8 0:5ef90cd25c10 86 delete data;
ollie8 0:5ef90cd25c10 87 delete strobe;
ollie8 0:5ef90cd25c10 88 delete reset;
ollie8 0:5ef90cd25c10 89 }
ollie8 0:5ef90cd25c10 90
ollie8 0:5ef90cd25c10 91 bool crossPointConnect(unsigned short x, unsigned short y) {
ollie8 0:5ef90cd25c10 92 if (x <= MAX_X && y <= MAX_Y) {
ollie8 0:5ef90cd25c10 93 data->write(1);
ollie8 0:5ef90cd25c10 94 xbus->write(x);
ollie8 0:5ef90cd25c10 95 ybus->write(y);
ollie8 0:5ef90cd25c10 96 // let the data busses settle before setting strobe high
ollie8 0:5ef90cd25c10 97 wait_us(2);
ollie8 0:5ef90cd25c10 98 strobe->write(1);
ollie8 0:5ef90cd25c10 99 // strobe must be high for at least 20 ns
ollie8 0:5ef90cd25c10 100 wait_us(1);
ollie8 0:5ef90cd25c10 101 strobe->write(0);
ollie8 0:5ef90cd25c10 102 return true;
ollie8 0:5ef90cd25c10 103 }
ollie8 0:5ef90cd25c10 104 return false;
ollie8 0:5ef90cd25c10 105 }
ollie8 0:5ef90cd25c10 106
ollie8 0:5ef90cd25c10 107 bool crossPointDisconnect(unsigned short x, unsigned short y) {
ollie8 0:5ef90cd25c10 108 if (x <= MAX_X && y <= MAX_Y) {
ollie8 0:5ef90cd25c10 109 data->write(0);
ollie8 0:5ef90cd25c10 110 xbus->write(x);
ollie8 0:5ef90cd25c10 111 ybus->write(y);
ollie8 0:5ef90cd25c10 112 // let the data busses settle before setting strobe high
ollie8 0:5ef90cd25c10 113 wait_us(2);
ollie8 0:5ef90cd25c10 114 strobe->write(1);
ollie8 0:5ef90cd25c10 115 // strobe must be high for at least 20 ns
ollie8 0:5ef90cd25c10 116 wait_us(1);
ollie8 0:5ef90cd25c10 117 strobe->write(0);
ollie8 0:5ef90cd25c10 118 return true;
ollie8 0:5ef90cd25c10 119 }
ollie8 0:5ef90cd25c10 120 return false;
ollie8 0:5ef90cd25c10 121 }
ollie8 0:5ef90cd25c10 122
ollie8 0:5ef90cd25c10 123 private:
ollie8 0:5ef90cd25c10 124 BusOut* xbus;
ollie8 0:5ef90cd25c10 125 BusOut* ybus;
ollie8 0:5ef90cd25c10 126 DigitalOut* data;
ollie8 0:5ef90cd25c10 127 DigitalOut* strobe;
ollie8 0:5ef90cd25c10 128 DigitalOut* reset;
ollie8 0:5ef90cd25c10 129 };
ollie8 0:5ef90cd25c10 130
ollie8 0:5ef90cd25c10 131
ollie8 0:5ef90cd25c10 132 #endif