void Init(void) { __disable_interrupt(); ENABLE_LCD_LED(); DISABLE_LCD_POWER(); /* clear shipping mode, if set to allow configuration */ PMMCTL0_H = PMMPW_H; PM5CTL0 &= ~LOCKLPM5; PMMCTL0_H = 0x00; /* disable DMA during read-modify-write cycles */ DMACTL4 = DMARMWDIS; #ifdef BOOTLOADER /* * enable RAM alternate interrupt vectors * these are defined in AltVect.s43 and copied to RAM by cstartup */ SYSCTL |= SYSRIVECT; ClearBootloaderSignature(); #else SaveResetSource(); #endif SetupClockAndPowerManagementModule(); CheckResetCode(); if (niReset != NORMAL_RESET_CODE) { InitProperty(); } InitBufferPool(); // message queue InitBattery(); CheckClip(); PrintF("*** %s:%s", niReset == FLASH_RESET_CODE ? "FLASH" : (niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL"), niBuild); ShowWatchdogInfo(); WhoAmI(); /* timer for battery checking at a regular frequency. */ StartTimer(BatteryTimer); InitVibration(); InitRealTimeClock(); // enable rtc interrupt LcdPeripheralInit(); DrawSplashScreen(); SerialRamInit(); /* turn the radio on; initialize the serial port profile or BLE/GATT */ CreateAndSendMessage(TurnRadioOnMsg, MSG_OPT_NONE); DISABLE_LCD_LED(); }
static void RestoreRtc(void) { CheckResetCode(); if (niReset == NORMAL_RESET_CODE && BCD_H(RtcHour) >= 0 && BCD_H(RtcHour) <= 2 && BCD_L(RtcHour) >= 0 && BCD_L(RtcHour) <= 9 && BCD_H(RtcMin) >= 0 && BCD_H(RtcMin) <= 6 && BCD_L(RtcMin) >= 0 && BCD_L(RtcMin) <= 9) { RTCYEAR = RtcYear; RTCMON = RtcMon; RTCDAY = RtcDay; RTCDOW = RtcDow; RTCHOUR = RtcHour; RTCMIN = RtcMin; RTCSEC = RtcSec; } else { RTCYEARH = 0x20; RTCYEARL = 0x13; RTCMON = 0x05; RTCDAY = 0x23; RTCDOW = 0x05; RTCHOUR = 0x11; RTCMIN = 0x58; RTCSEC = 0x0; } }