Esempio n. 1
0
        public static DateTime GetTime()
        {
#if CHRONODOT
            RTC_DS3231 rtc = new RTC_DS3231();
            var dt = rtc.GetDateTime();
            rtc.Dispose();
            return dt;
#endif
            return RealTimeClock.GetTime();

        }
Esempio n. 2
0
        public static void SetTime(DateTime dateTime)
        {
#if CHRONODOT
            RTC_DS3231 rtc = new RTC_DS3231();
            rtc.SetDateTime(dateTime);
            rtc.Dispose();
            return;
#endif

#if !G120
            RealTimeClock.SetTime(dateTime);
            return;
#endif
            DebugHelper.Print("G120RTC.SetTime: " + dateTime);
            RealTimeClock.SetTime(dateTime);
            if (!_calibrationDone)
                return;
            DebugHelper.Print("Reinit RTC calibration register with value: " + _calibrationValue);

            uint toSet;
            if (_calibrationValue >= 0)
            {
                toSet = (uint)(_calibrationValue | (1 << 17));
            }
            else
            {
                toSet = (uint)(_calibrationValue * -1);
            }

            new Register(0x40024008).SetBits(1 << 4); // calibration counter disable, implies a reset 
            new Register(0x40024040).Write(toSet); // load
            new Register(0x40024008).ClearBits(1 << 4); // calibration counter enable
        }