Hardware Reference
In-Depth Information
171 rtc.hour_10s,rtc.hour_1s,
172 rtc.mins_10s,rtc.mins_1s,
173 rtc.secs_10s,rtc.secs_1s,
174 rtc.wkday);
175 #end if
176 rc = i2c_wr_rtc(&rtc );
177
178 /
179
Display RTC values submitted :
180
/
181 strftime(dtbuf,sizeof dtbuf,date_format,&t1);
182 puts(dtbuf);
183
184 if ( rc < 0 )
185 perror("Writing to DS1307 RTC");
186 else if ( rc != 1 )
187 printf(" Incomplete write : %d msgs of 2written \n",rc);
188
189 i2c_close();
190 return rc ==1? 0 : 4;
191 }
192
1 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
2
ds1307get.c : Read real−time DS1307 clock on I2C bus
3
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
4
5 #include <stdio.h>
6 #include <stdlib.h>
7 #include <ctype.h>
8 #include <time h>
9 #include <fcntl.h>
10 #include <unistd.h>
11 #include <string.h>
12 #include <errno.h>
13 #include <assert.h>
14 #include <sys/ioctl.h>
15 #include <linux/i2c−dev.h>
16
17 #include "i2c_common.c" /
I2C routines
/
18 #include "ds1307.h" /
DS1307 types
/
19
20 /
Change to i2c−0 if using early Raspberry Pi
/
21 static const char
node = "/dev/i2c−1";
22
Search WWH ::




Custom Search