Changeset 95060d5b in mainline
- Timestamp:
- 2012-04-13T20:23:29Z (13 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1170ea3c
- Parents:
- bb8f69d
- Location:
- uspace/drv/time/cmos-rtc
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/time/cmos-rtc/cmos-regs.h
rbb8f69d r95060d5b 38 38 39 39 #define RTC_STATUS_B 0x0B 40 #define RTC_MASK_24H 0x02 40 41 #define RTC_MASK_BCD 0x04 41 42 -
uspace/drv/time/cmos-rtc/cmos-rtc.c
rbb8f69d r95060d5b 268 268 { 269 269 bool bcd_mode; 270 bool pm_mode = false; 270 271 rtc_t *rtc = RTC_FROM_FNODE(fun); 271 272 … … 290 291 t->tm_mon != rtc_register_read(rtc, RTC_MON) || 291 292 t->tm_year != rtc_register_read(rtc, RTC_YEAR)); 293 294 /* Check if the RTC is working in 12h mode */ 295 bool _12h_mode = !(rtc_register_read(rtc, RTC_STATUS_B) & 296 RTC_MASK_24H); 297 298 if (_12h_mode) { 299 /* The RTC is working in 12h mode, check if it is AM or PM */ 300 if (t->tm_hour & 0x80) { 301 /* PM flag is active, it must to be cleared 302 * or the BCD conversion will fail. 303 */ 304 t->tm_hour &= ~0x80; 305 pm_mode = true; 306 } 307 } 292 308 293 309 /* Check if the RTC is working in BCD mode */ … … 301 317 t->tm_mon = bcd2dec(t->tm_mon); 302 318 t->tm_year = bcd2dec(t->tm_year); 319 } 320 321 if (_12h_mode) { 322 /* Convert to 24h mode */ 323 if (pm_mode) { 324 if (t->tm_hour < 12) 325 t->tm_hour += 12; 326 } else if (t->tm_hour == 12) 327 t->tm_hour = 0; 303 328 } 304 329
Note:
See TracChangeset
for help on using the changeset viewer.