Hardware Reference
In-Depth Information
23 unsigned char day_10s : 2; /
Tens digit : day of
month
/
24 unsigned char mbz_3 : 2; /
Zero bits
/
25 /
/
26 unsigned char month_1s : 4; /
Register Address 0x05 : Month
Ones digit : month (1−12)
/
27 unsigned char month_10s : 1; /
Tens digit : month
/
28 unsigned char mbz_4 : 3; /
Zero
/
29 /
/
30 unsigned char year_1s : 4 /
Register Address 0x06 : Year
Ones digit : year (00−99)
/
31 unsigned char year_10s : 4; /
Tens digit : year
/
32 /
Register Address 0x07 : Control
/
33 unsigned char rs0 : 1; /
RS0
/
34 unsigned char rs1 : 1; /
RS1
/
35 unsigned char mbz_5 : 2; /
Zeros
/
36 unsigned char sqwe : 1; /
SQWE
/
37 unsigned char mbz_6 : 2;
38 unsigned char outbit : 1; /
OUT
/
39 } ds1307_rtc_regs;
40
41 /
End ds1307 . h
/
1 /
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
2
i2c_common.c : Common I2C Access Functions
3
/
∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗∗
4
5 static int i2c_fd = −1; /
Device node: /dev/i2c−1
/
6 static unsigned long i2c_funcs = 0; /
Support flags
/
7
8 /
9
Open I2C bus and check cap abilities:
10
/
11 static void
12 i2c_init(const char
node) {
13 int rc;
14
15 i2c_fd = open(node,O_RDWR); /
Open driver /dev/i2s−1
/
16 if ( i2c_fd < 0 ) {
17 perror("Opening /dev/ i 2 s −1");
18 puts("Check that the i2c−dev & i2c−bcm2708 kernelmodules "
19 " are loaded . " ) ;
20 abort();
21 }
22
23 /
24
Make sure the driver suppor tsplain I2C I /O:
Search WWH ::




Custom Search