Report abuse
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
|
#include <Wire.h>
#define BAUD_RATE 19200
#define statusLED 12
#define RTCAddressW 0xA2
#define RTCAddressR 0xA3
volatile int blinkStatus = LOW;
void setup(void)
{
Serial.begin(BAUD_RATE);
Wire.begin();
Wire.beginTransmission(RTCAddressW);
Wire.send(0);
Wire.endTransmission();
Wire.beginTransmission(RTCAddressW);
Wire.send(B00000000); Wire.send(B00000000); Wire.send(B00000001); Wire.send(30); Wire.send(19); Wire.send(11); Wire.send(2); Wire.send(B00000000); Wire.send(7); Wire.send(B00000000); Wire.send(B00000000); Wire.send(B10000000); Wire.send(B10000000); Wire.send(B10000011); Wire.send(B00000000); Wire.send(B00000000); Wire.endTransmission();
reportAVRState(3,0);
}
char i = 0;
#define numberOfRegisters 16
char c[numberOfRegisters];
void loop()
{
Wire.beginTransmission(RTCAddressR);
Wire.send(0);
Wire.endTransmission();
Wire.beginTransmission(RTCAddressR);
Wire.requestFrom(RTCAddressR, numberOfRegisters);
i = 0;
while(Wire.available()) {
c[i] = Wire.receive();
i++;
}
Wire.endTransmission();
for(i=0;i<numberOfRegisters;i++)
{
Serial.print(i);
Serial.print(":\t");
Serial.println(c, BIN); }
Serial.println("Waiting a little");
delay(2000);
}
void reportAVRState(int howManyTimes, int leaveOn)
{
int i;
pinMode(statusLED, OUTPUT);
for (i=0; i < howManyTimes; i++) {
digitalWrite(statusLED, HIGH);
delay(200);
digitalWrite(statusLED, LOW);
delay(200);
}
if (leaveOn) {
digitalWrite(statusLED, HIGH);
}
Serial.println();
Serial.println("AVR Initialized");
}
|