Hardware Reference
In-Depth Information
DS1307_FORMAT environment variable in order to produce a format suitable for the
console date command. To set the system date (as root), you would use this command:
# date [-u|--utc|--universal] [MMDDhhmm[[CC]YY][.ss]]
The startup script for doing all of this has not been provided here. I don't want to
spoil your fun when you can develop this yourself. You learn best by doing. Refer to
Chapter 3 of Raspberry Pi System Software Reference (Apress, 2014) if you need some help.
As a further hint, you'll want to develop a script for the /etc/rc2.d directory, with
a name starting with S and two digits. The digits determine where the script runs in the
startup sequence (you'll want to make sure your script runs after the system has come up
far enough that I2C drivers are loaded).
Once your startup script is developed, your Raspberry Pi can happily reboot after
days, even years, of being powered off, and still be able to come up with the correct date
and time.
if you're running the older model B, where the i2C bus 0 is used instead of 1,
change line 21 in ds1307set.c and line 21 in ds1307get.c . See Chapter 12 of
Raspberry Pi Hardware Reference (apress, 2014) for more information.
Note
1 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
2
ds1307.h: Common DS1307 types and macro definitions
3
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
4
5 typedef struct {
6 /
/
7 unsigned char secs_1s : 4; /
Register Address 0x00 : Seconds
Ones digit : seconds
/
8 unsigned char secs_10s : 3; /
Tens digit : seconds
/
9 unsigned char ch : 1; /
CH bit
/
10 /
/
11 unsigned char mins_1s : 4; /
Register Address 0x01 : Minutes
Ones digit : minutes
/
12 unsigned char mins_10s : 3; /
Tens digit : minutes
/
13 unsigned char mbz_1 : 1; /
Zero bit
/
14 /
/
15 unsigned char hour_1s : 4; /
Register Address 0x02 : Hours
Ones digit : hours
/
16 unsigned char hour_10s : 2; /
Tens digit : hours
(24 hr mode)
/
17 unsigned char mode_1224 : 1; /
Mode bit : 12/24 hour
format
/
18 /
/
19 unsigned char wkday : 3; /
Register Address 0x03 : Weekday
Day of week (1−7)
/
20 unsigned char mbz_2 : 5; /
Zero bits
/
21 /
Register Address 0x04 : Day of Month
/
22 unsigned char day_1s : 4; /
Ones digit : day of month
(1−31)
/
 
Search WWH ::




Custom Search