@@ -68,9 +68,10 @@ use core::{
6868} ;
6969
7070// Third Party Stuff
71+ use chrono:: DateTime ;
7172use defmt:: info;
7273use defmt_rtt as _;
73- use ds1307:: { Datelike , NaiveDateTime , Timelike } ;
74+ use ds1307:: { Datelike , Timelike } ;
7475use embedded_hal:: {
7576 blocking:: i2c:: {
7677 Read as _I2cRead, WriteIter as _I2cWriteIter, WriteIterRead as _I2cWriteIterRead,
@@ -677,6 +678,19 @@ fn sign_on() {
677678 false ,
678679 ) ) ;
679680
681+ let _ = writeln ! ( & tc) ;
682+
683+ // Show the time.
684+ if let Some ( hw) = HARDWARE . lock ( ) . as_mut ( ) {
685+ if let Some ( rtc_kind) = hw. rtc . get_kind ( ) {
686+ let _ = writeln ! ( & tc, "RTC : Found {}" , rtc_kind) ;
687+ } else {
688+ let _ = writeln ! ( & tc, "RTC : None" ) ;
689+ }
690+ }
691+
692+ // Do a delay.
693+ //
680694 // This is in 100ms units
681695 let mut countdown = 15 ;
682696 loop {
@@ -707,7 +721,7 @@ fn sign_on() {
707721 }
708722 }
709723
710- write ! ( & tc, "Now starting OS (if present) ..." ) . unwrap ( ) ;
724+ write ! ( & tc, "Looking for OS at 0x1002_0000. ..." ) . unwrap ( ) ;
711725}
712726
713727/// Paint the Core 0 and Core 1 stacks
@@ -897,8 +911,8 @@ impl Hardware {
897911 time. minute( ) ,
898912 time. second( )
899913 ) ;
900- let ticks_at_boot_us =
901- time . timestamp_micros ( ) - ( SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH * 1_000_000 ) ;
914+ let ticks_at_boot_us = time . and_utc ( ) . timestamp_micros ( )
915+ - ( SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH * 1_000_000 ) ;
902916 defmt:: info!( "Ticks at boot: {}" , ticks_at_boot_us) ;
903917 ticks_at_boot_us
904918 }
@@ -1745,12 +1759,12 @@ pub extern "C" fn time_clock_set(time: common::Time) {
17451759 hw. bootup_at = ticks_at_boot;
17461760
17471761 // 5. Convert to calendar time
1748- if let Some ( new_time) = NaiveDateTime :: from_timestamp_opt (
1762+ if let Some ( new_time) = DateTime :: from_timestamp (
17491763 i64:: from ( time. secs ) + SECONDS_BETWEEN_UNIX_AND_NEOTRON_EPOCH ,
17501764 time. nsecs ,
17511765 ) {
17521766 // 6. Update the hardware RTC as well
1753- match hw. rtc . set_time ( hw. i2c . acquire_i2c ( ) , new_time) {
1767+ match hw. rtc . set_time ( hw. i2c . acquire_i2c ( ) , new_time. naive_utc ( ) ) {
17541768 Ok ( _) => {
17551769 defmt:: info!( "Time set in RTC OK" ) ;
17561770 }
0 commit comments