Skip to content

Commit cda99a5

Browse files
committed
ODAS Tester
1 parent bca27de commit cda99a5

File tree

2 files changed

+73
-236
lines changed

2 files changed

+73
-236
lines changed

LBCards/ODAS/ODASTESTER/ODASTESTER.ino

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
#include <LandBoards_I2CRPT01.h>
1313
#include <Adafruit_MCP23008.h>
1414
#include <Adafruit_MCP23017.h>
15+
#include <LandBoards_MCP23008.h>
1516

1617
//////////////////////////////////////////////////////////
1718
// defines follow
@@ -56,7 +57,7 @@ Digio128 Dio128; // Call the class constructor for the DigIO-128 card
5657
Digio32 Dio32;
5758
LandBoards_I2CIO8 i2cio8Card;
5859
LandBoards_I2CIO8X i2cio8xCard;
59-
Adafruit_MCP23008 singleMCP23008;
60+
LandBoards_MCP23008 singleMCP23008;
6061
Adafruit_MCP23017 singleMCP23017;
6162

6263
//////////////////////////////////////////////////////////

LBCards/ODAS/ODASTester/ODASInternalTest.ino

Lines changed: 71 additions & 235 deletions
Original file line numberDiff line numberDiff line change
@@ -15,32 +15,26 @@ uint8_t internalLoopBackTestCard(void)
1515
myI2CMux.setI2CChannel(UUT_CARD_MUX_CH);
1616
switch (boardType)
1717
{
18-
case DIGIO16I2C_CARD:
19-
return (intLBTstSingleMCP23017());
20-
break;
21-
case DIGIO128_CARD:
22-
return (internalLoopBackTestDIGIO128_CARD());
23-
break;
24-
case DIGIO32I2C_CARD:
25-
return (internaltestDigio32Card());
18+
// Cards with single MCP23008 parts
19+
case OPTOIN8I2C_CARD:
20+
case OPTOOUT8I2C_CARD:
21+
case I2CIO8_CARD:
22+
case I2CIO8X_CARD:
23+
return (internalLoopbackTestSingleMCP23008());
2624
break;
25+
// Cards with single MCP23017 parts
26+
case DIGIO16I2C_CARD:
2727
case PROTO16I2C_CARD:
28-
return (intLBTstSingleMCP23017());
29-
break;
3028
case ODASRELAY16_CARD:
3129
return (intLBTstSingleMCP23017());
3230
break;
33-
case OPTOIN8I2C_CARD:
34-
return (internalLoopBackTestOptoIn8());
35-
break;
36-
case OPTOOUT8I2C_CARD:
37-
return (internalLoopBackTestOptoOut8());
38-
break;
39-
case I2CIO8_CARD:
40-
return (internalLoopBackTestI2CIO8());
31+
// Cards with two MCP23017 parts
32+
case DIGIO32I2C_CARD:
33+
return (internaltestDigio32Card());
4134
break;
42-
case I2CIO8X_CARD:
43-
return (internalLoopBackTestI2CIO8X());
35+
// Cards with 8 MCP23017 parts
36+
case DIGIO128_CARD:
37+
return (internalLoopBackTestDIGIO128_CARD());
4438
break;
4539
case ODASPSOC5_CARD:
4640
Serial.println(F("Not supported at present"));
@@ -57,6 +51,63 @@ uint8_t internalLoopBackTestCard(void)
5751
return 1; // fail
5852
}
5953

54+
//////////////////////////////////////////////////////////////////////////////////////
55+
// uint8_t internalLoopbackTestSingleMCP23008(void) - Test the OptoIn8-I2C card
56+
// Puts out 8 bit test vector on DIGIO32 pins
57+
// Looks at the returned values on the OptoIn8-I2C
58+
//////////////////////////////////////////////////////////////////////////////////////
59+
60+
uint8_t internalLoopbackTestSingleMCP23008(void)
61+
{
62+
unsigned char readVal;
63+
int testPass = 1;
64+
// Serial.println(F("Internal tests OptoIn8-I2C card"));
65+
for (int loopVal = 0; loopVal < 8; loopVal++)
66+
singleMCP23008.pinMode(loopVal,INPUT);
67+
singleMCP23008.writeOLAT(0x5a);
68+
if (singleMCP23008.readOLAT() != 0x5a)
69+
testPass = 0;
70+
if (testPass)
71+
return 0;
72+
else
73+
return 1;
74+
}
75+
76+
//////////////////////////////////////////////////////////////////////////////////////
77+
// uint8_t intLBTstSingleMCP23017(void) - Test the PROTO16-I2C card
78+
//////////////////////////////////////////////////////////////////////////////////////
79+
80+
uint8_t intLBTstSingleMCP23017(void)
81+
{
82+
uint8_t failed = 0;
83+
uint8_t loopCnt;
84+
uint16_t readBackVal;
85+
// Serial.println(F("Testing single MCP23017 card"));
86+
for (loopCnt = 0; loopCnt < 16; loopCnt++)
87+
singleMCP23017.pinMode(loopCnt, OUTPUT);
88+
singleMCP23017.writeGPIOAB(0x55aa);
89+
readBackVal = singleMCP23017.readGPIOAB();
90+
if (readBackVal != 0x55aa)
91+
{
92+
Serial.print(F("Readback="));
93+
Serial.println(readBackVal);
94+
failed = 1;
95+
}
96+
delay(10);
97+
singleMCP23017.writeGPIOAB(0xaa55);
98+
readBackVal = singleMCP23017.readGPIOAB();
99+
if (readBackVal != 0xaa55)
100+
{
101+
Serial.print(F("Readback="));
102+
Serial.println(readBackVal);
103+
failed = 1;
104+
}
105+
for (loopCnt = 0; loopCnt < 16; loopCnt++)
106+
singleMCP23017.pinMode(loopCnt, INPUT);
107+
delay(10);
108+
return (failed);
109+
}
110+
60111
//////////////////////////////////////////////////////////////////////////////////////
61112
// uint8_t internaltestDigio32Card()
62113
//////////////////////////////////////////////////////////////////////////////////////
@@ -123,220 +174,6 @@ uint8_t internaltestDigio32Card(void)
123174
return pass0fail1;
124175
}
125176

126-
//////////////////////////////////////////////////////////////////////////////////////
127-
// uint8_t intLBTstSingleMCP23017(void) - Test the PROTO16-I2C card
128-
//////////////////////////////////////////////////////////////////////////////////////
129-
130-
uint8_t intLBTstSingleMCP23017(void)
131-
{
132-
uint8_t failed = 0;
133-
uint8_t loopCnt;
134-
uint16_t readBackVal;
135-
// Serial.println(F("Testing single MCP23017 card"));
136-
for (loopCnt = 0; loopCnt < 16; loopCnt++)
137-
singleMCP23017.pinMode(loopCnt, OUTPUT);
138-
singleMCP23017.writeGPIOAB(0x55aa);
139-
readBackVal = singleMCP23017.readGPIOAB();
140-
if (readBackVal != 0x55aa)
141-
{
142-
Serial.print(F("Readback="));
143-
Serial.println(readBackVal);
144-
failed = 1;
145-
}
146-
delay(10);
147-
singleMCP23017.writeGPIOAB(0xaa55);
148-
readBackVal = singleMCP23017.readGPIOAB();
149-
if (readBackVal != 0xaa55)
150-
{
151-
Serial.print(F("Readback="));
152-
Serial.println(readBackVal);
153-
failed = 1;
154-
}
155-
for (loopCnt = 0; loopCnt < 16; loopCnt++)
156-
singleMCP23017.pinMode(loopCnt, INPUT);
157-
delay(10);
158-
return (failed);
159-
}
160-
161-
//////////////////////////////////////////////////////////////////////////////////////
162-
// uint8_t internalLoopBackTestI2CIO8(void) - Test the I2CIO8 card
163-
//////////////////////////////////////////////////////////////////////////////////////
164-
165-
uint8_t internalLoopBackTestI2CIO8(void)
166-
{
167-
Serial.println(F("I2CIO8 card tests"));
168-
Serial.println(F("Move jumper across H5-H8, observe LEDs D0-D3"));
169-
Serial.println(F("Verify Int LED blinks"));
170-
Serial.println(F("Hit a key to stop test"));
171-
while (1)
172-
{
173-
i2cio8Card.writeLED(LED0, !i2cio8Card.readJumper(H4JUMPER));
174-
i2cio8Card.writeLED(LED1, !i2cio8Card.readJumper(H5JUMPER));
175-
i2cio8Card.writeLED(LED2, !i2cio8Card.readJumper(H6JUMPER));
176-
i2cio8Card.writeLED(LED3, !i2cio8Card.readJumper(H7JUMPER));
177-
delay(250);
178-
if (Serial.available() > 0)
179-
{
180-
Serial.read();
181-
return 0;
182-
}
183-
}
184-
}
185-
186-
//////////////////////////////////////////////////////////////////////////////////////
187-
// uint8_t internalLoopBackTestI2CIO8X(void)
188-
//////////////////////////////////////////////////////////////////////////////////////
189-
190-
uint8_t internalLoopBackTestI2CIO8X(void)
191-
{
192-
uint8_t jumpers;
193-
// Serial.println(F("I2CIO8X card"));
194-
// Serial.println(F("Install test jumper"));
195-
// Serial.println(F("Hit a key to stop test"));
196-
for (jumpers = 0; jumpers < 4; jumpers++)
197-
i2cio8xCard.pinMode(jumpers, INPUT);
198-
for (jumpers = 4; jumpers < 8; jumpers++)
199-
i2cio8xCard.pinMode(jumpers, OUTPUT);
200-
for (jumpers = 0; jumpers < 4; jumpers++)
201-
{
202-
i2cio8xCard.digitalWrite(jumpers + H4JUMPER, LOW);
203-
if (i2cio8xCard.digitalRead(jumpers) != LOW)
204-
{
205-
Serial.println(F("Failed LOW"));
206-
return 1;
207-
}
208-
i2cio8xCard.digitalWrite(jumpers + H4JUMPER, HIGH);
209-
if (i2cio8xCard.digitalRead(jumpers) != HIGH)
210-
{
211-
Serial.println(F("Failed HIGH"));
212-
return 1;
213-
}
214-
}
215-
return 0;
216-
}
217-
218-
//////////////////////////////////////////////////////////////////////////////////////
219-
// OptoIn8-I2C card test code
220-
//////////////////////////////////////////////////////////////////////////////////////
221-
222-
//////////////////////////////////////////////////////////////////////////////////////
223-
// uint8_t internalLoopBackTestOptoIn8(void) - Test the OptoIn8-I2C card
224-
// Puts out 8 bit test vector on Arduino pins
225-
// Arduino Output lines aew D2-D5, D7, D8, D14(A0), D15(A1)
226-
// Looks at the returned values on the OptoIn8-I2C
227-
//////////////////////////////////////////////////////////////////////////////////////
228-
229-
uint8_t internalLoopBackTestOptoIn8(void)
230-
{
231-
unsigned char readVal;
232-
int testPass = 1;
233-
// Serial.println(F("Internal tests OptoIn8-I2C card"));
234-
myI2CMux.setI2CChannel(UUT_CARD_MUX_CH);
235-
for (int loopVal = 0; loopVal < 8; loopVal++)
236-
singleMCP23008.pinMode(loopVal,INPUT);
237-
for (int loopVal = 0; loopVal < 8; loopVal++)
238-
{
239-
// singleMCP23008.
240-
}
241-
if (testPass)
242-
return 0;
243-
else
244-
return 1;
245-
}
246-
247-
//////////////////////////////////////////////////////////////////////////////////////
248-
// uint8_t internalLoopBackTestOptoOut8(void) - Test the OptoOut8-I2C card
249-
// Puts out 8 bits on OptoOut8-I2C card
250-
// Reads the 8 bits on Arduino pins
251-
// Arduino Input lines are D2-D5, D7, D8, D14(A0), D15(A1)
252-
// Looks at the returned values on the OptoIn8-I2C
253-
//////////////////////////////////////////////////////////////////////////////////////
254-
255-
uint8_t internalLoopBackTestOptoOut8(void)
256-
{
257-
// Serial.println(F("Testing OptoOut8-I2C card"));
258-
259-
initOO8pins();
260-
uint8_t readVal;
261-
int testPass = 1;;
262-
uint8_t testChannel = 0;
263-
int testBit = 0x1;
264-
delay(2);
265-
for (uint8_t loopVal = 2; loopVal < 6; loopVal++)
266-
{
267-
singleMCP23008.digitalWrite(testChannel, HIGH);
268-
delayMicroseconds(15);
269-
readVal = digitalRead(loopVal);
270-
if (readVal != HIGH)
271-
{
272-
testPass = 0;
273-
Serial.print(F("OptoOut8-I2C failed HIGH on bit "));
274-
Serial.println(testChannel);
275-
}
276-
singleMCP23008.digitalWrite(testChannel, LOW);
277-
delayMicroseconds(15);
278-
readVal = digitalRead(loopVal);
279-
if (readVal != LOW)
280-
{
281-
testPass = 0;
282-
Serial.print(F("OptoOut8-I2C failed LOW on bit "));
283-
Serial.println(testChannel);
284-
}
285-
testBit <<= 1;
286-
testChannel++;
287-
}
288-
for (uint8_t loopVal = 7; loopVal < 9; loopVal++)
289-
{
290-
singleMCP23008.digitalWrite(testChannel, HIGH);
291-
delayMicroseconds(15);
292-
readVal = digitalRead(loopVal);
293-
if (readVal != HIGH)
294-
{
295-
testPass = 0;
296-
Serial.print(F("OptoOut8-I2C failed HIGH on bit "));
297-
Serial.println(testChannel);
298-
}
299-
singleMCP23008.digitalWrite(testChannel, LOW);
300-
delayMicroseconds(15);
301-
readVal = digitalRead(loopVal);
302-
if (readVal != LOW)
303-
{
304-
testPass = 0;
305-
Serial.print(F("OptoOut8-I2C failed LOW on bit "));
306-
Serial.println(testChannel);
307-
}
308-
testBit <<= 1;
309-
testChannel++;
310-
}
311-
for (uint8_t loopVal = 14; loopVal < 16; loopVal++)
312-
{
313-
singleMCP23008.digitalWrite(testChannel, HIGH);
314-
delayMicroseconds(15);
315-
readVal = digitalRead(loopVal);
316-
if (readVal != HIGH)
317-
{
318-
testPass = 0;
319-
Serial.print(F("OptoOut8-I2C failed HIGH on bit "));
320-
Serial.println(testChannel);
321-
}
322-
singleMCP23008.digitalWrite(testChannel, LOW);
323-
delayMicroseconds(15);
324-
readVal = digitalRead(loopVal);
325-
if (readVal != LOW)
326-
{
327-
testPass = 0;
328-
Serial.print(F("OptoOut8-I2C failed LOW on bit "));
329-
Serial.println(testChannel);
330-
}
331-
testBit <<= 1;
332-
testChannel++;
333-
}
334-
if (testPass)
335-
return 0;
336-
else
337-
return 1;
338-
}
339-
340177
//////////////////////////////////////////////////////////////////////////////////////
341178
// uint8_t internalLoopBackTestDIGIO128_CARD(void) -
342179
//////////////////////////////////////////////////////////////////////////////////////
@@ -387,4 +224,3 @@ uint8_t internalLoopBackTestDIGIO128_CARD(void)
387224
return 1;
388225
}
389226

390-

0 commit comments

Comments
 (0)