-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOctalBusTransceivers.cpp
More file actions
48 lines (45 loc) · 1.1 KB
/
OctalBusTransceivers.cpp
File metadata and controls
48 lines (45 loc) · 1.1 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include "OctalBusTransceivers.h"
#include "implements.h"
#include <Arduino.h>
#define INPUT 0
#define OUTPUT 1
void OctalBusTransceivers::transfer(int DIR, int OE, int A[8], int B[8], int result[8])
{
int emptyBus[8] = {0, 0, 0, 0, 0, 0, 0, 0};
if (OE == false)
{ // active low OE
if (DIR == false)
{
implements::setMode(A, INPUT);
implements::setMode(B, OUTPUT);
for (int i = 0; i < 8; i++)
{
B[i] = A[i];
}
for (int i = 0; i < 8; i++)
{
result[i] = B[i];
}
return;
}
else
{
implements::setMode(B, INPUT);
implements::setMode(A, OUTPUT);
for (int i = 0; i < 8; i++)
{
A[i] = B[i];
}
for (int i = 0; i < 8; i++)
{
result[i] = A[i];
}
return;
}
}
// If OE is high (disabled), return empty bus
for (int i = 0; i < 8; i++)
{
result[i] = emptyBus[i];
}
}