j
Fork of ds3231 by
Diff: ds3231.cpp
- Revision:
- 10:3b55ed3f71d3
- Parent:
- 7:0551d7e7c13f
- Child:
- 11:1654fcc0a5ea
diff -r e57201ee8921 -r 3b55ed3f71d3 ds3231.cpp --- a/ds3231.cpp Fri Dec 05 22:31:35 2014 +0000 +++ b/ds3231.cpp Fri Feb 06 05:13:22 2015 +0000 @@ -420,9 +420,17 @@ time->seconds = bcd_2_uchar(data[0]); time->minutes = bcd_2_uchar(data[1]); - time->hours = bcd_2_uchar((data[2]&0x1F)); time->am_pm = (data[2]&AM_PM); time->mode = (data[2]&MODE); + + if(time->mode) + { + time->hours = bcd_2_uchar((data[2]&0x1F)); + } + else + { + time->hours = bcd_2_uchar((data[2]&0x3F)); + } } return(rtn_val); @@ -523,11 +531,19 @@ alarm->am1 = (data[0]&ALRM_MASK); alarm->minutes = bcd_2_uchar(data[1]&0x7F); alarm->am2 = (data[1]&ALRM_MASK); - alarm->hours = bcd_2_uchar(data[2]&0x1F); alarm->am3 = (data[2]&ALRM_MASK); alarm->am_pm = (data[2]&AM_PM); alarm->mode = (data[2]&MODE); + if(alarm->mode) + { + alarm->hours = bcd_2_uchar((data[2]&0x1F)); + } + else + { + alarm->hours = bcd_2_uchar((data[2]&0x3F)); + } + if(data[3] & DY_DT) { alarm->dy_dt = 1; @@ -551,11 +567,19 @@ alarm->minutes = bcd_2_uchar(data[0]&0x7F); alarm->am2 = (data[0]&ALRM_MASK); - alarm->hours = bcd_2_uchar(data[1]&0x1F); alarm->am3 = (data[1]&ALRM_MASK); alarm->am_pm = (data[1]&AM_PM); alarm->mode = (data[1]&MODE); + if(alarm->mode) + { + alarm->hours = bcd_2_uchar((data[2]&0x1F)); + } + else + { + alarm->hours = bcd_2_uchar((data[2]&0x3F)); + } + if(data[2] & DY_DT) { alarm->dy_dt = 1;