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 InitDisplay(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; #if BOOTLOADER /* * enable RAM alternate interrupt vectors * these are defined in AltVect.s43 and copied to RAM by cstartup */ SYSCTL |= SYSRIVECT; ClearBootloaderSignature(); #endif SetupClockAndPowerManagementModule(); CheckClip(); // enable debuguart __enable_interrupt(); PrintF("\r\n*** %s:%c%c%c ***", (niResetType == NORMAL_RESET ? "NORMAL" : "MASTER"), BUILD[0], BUILD[1], BUILD[2]); if (niResetType != NORMAL_RESET) InitStateLog(); SaveStateLog(); WhoAmI(); ShowStateInfo(); InitAdc(); /* timer for battery checking at a regular frequency. */ StartTimer(BatteryTimer); InitVibration(); InitRealTimeClock(); // enable rtc interrupt LcdPeripheralInit(); DrawSplashScreen(); InitSerialRam(); /* turn the radio on; initialize the serial port profile or BLE/GATT */ SendMessage(TurnRadioOnMsg, MSG_OPT_NONE); DISABLE_LCD_LED(); }
/*! Led Change Handler * * \param tHostMsg* pMsg The message options contain the type of operation that * should be performed on the LED outout. */ static void LedChangeHandler(tMessage* pMsg) { switch (pMsg->Options) { case LED_ON_OPTION: LedOn = 1; ENABLE_LCD_LED(); StartOneSecondTimer(LedTimerId); break; case LED_TOGGLE_OPTION: if ( LedOn ) { LedOn = 0; DISABLE_LCD_LED(); StopOneSecondTimer(LedTimerId); } else { LedOn = 1; ENABLE_LCD_LED(); StartOneSecondTimer(LedTimerId); } break; case LED_START_OFF_TIMER: LedOn = 1; ENABLE_LCD_LED(); StartOneSecondTimer(LedTimerId); break; case LED_OFF_OPTION: default: LedOn = 0; DISABLE_LCD_LED(); StopOneSecondTimer(LedTimerId); break; } }
/*! Led Change Handler * * \param tHostMsg* pMsg The message options contain the type of operation that * should be performed on the LED outout. */ static void LedChangeHandler(tMessage* pMsg) { if (LedTimerId == UNASSIGNED) { LedTimerId = AllocateOneSecondTimer(); SetupOneSecondTimer(LedTimerId, 5, NO_REPEAT, DISPLAY_QINDEX, LedChange, LED_OFF_OPTION); } switch (pMsg->Options) { case LED_ON_OPTION: ENABLE_LCD_LED(); LedOn = 1; StartOneSecondTimer(LedTimerId); break; case LED_TOGGLE_OPTION: if (LedOn) { StopOneSecondTimer(LedTimerId); DISABLE_LCD_LED(); LedOn = 0; } else { ENABLE_LCD_LED(); LedOn = 1; StartOneSecondTimer(LedTimerId); } break; case LED_OFF_OPTION: default: StopOneSecondTimer(LedTimerId); DISABLE_LCD_LED(); LedOn = 0; break; } }
void WatchdogTimerIsr(void) #endif { /* add your debug code here */ __no_operation(); #if USE_LED_FOR_WATCHDOG_DEBUG ENABLE_LCD_LED(); WATCHDOG_LED_DELAY(); #endif // BOR reset // PMMCTL0 = PMMPW | PMMSWBOR; /* write the inverse of the password and cause a PUC reset */ WDTCTL = ~WDTPW; }
/* this is for unrecoverable errors */ void WatchdogReset(void) { __disable_interrupt(); #if USE_LED_FOR_WATCHDOG_DEBUG ENABLE_LCD_LED(); WATCHDOG_LED_DELAY(); #endif #if USE_FAILSAFE_WATCHDOG while(1); #else /* write the inverse of the password and cause a reset */ WDTCTL = ~WDTPW; #endif }
/*! Led Change Handler * * \param tHostMsg* pMsg The message options contain the type of operation that * should be performed on the LED outout. */ static void SetBacklight(unsigned char Value) { if (Value == LED_ON_OPTION && LedOn) StartTimer(BacklightTimer); else if (Value == LED_OFF_OPTION && !LedOn) return; else { LedOn = !LedOn; if (Value == LED_ON_OPTION) { ENABLE_LCD_LED(); StartTimer(BacklightTimer); } else DISABLE_LCD_LED(); // LED_OFF only when timeout } }
void main(void) { ENABLE_LCD_LED(); #if ENABLE_WATCHDOG RestartWatchdog(); #else WDTCTL = WDTPW + WDTHOLD; #endif /* clear shipping mode, if set to allow configuration */ PMMCTL0_H = PMMPW_H; PM5CTL0 &= ~LOCKLPM5; /* disable DMA during read-modify-write cycles */ DMACTL4 = DMARMWDIS; DetermineErrata(); #ifdef BOOTLOADER /* * enable RAM alternate interrupt vectors * these are defined in AltVect.s43 and copied to RAM by cstartup */ SYSCTL |= SYSRIVECT; ClearBootloaderSignature(); #endif /* calibration data is used for clock setup */ InitializeCalibrationData(); #ifndef BOOTLOADER SaveResetSource(); #endif SetupClockAndPowerManagementModule(); OsalNvInit(0); /* change the mux settings according to presense of the charging clip */ InitializeMuxMode(); ChangeMuxMode(); InitDebugUart(); TestModeControl(); /* adc is required to get the board configuration */ InitializeAdc(); ConfigureDefaultIO(GetBoardConfiguration()); InitializeDebugFlags(); // InitButton(); InitializeVibration(); InitializeOneSecondTimers(); InitializeBufferPool(); InitializeWrapperTask(); InitializeRealTimeClock(); InitializeDisplayTask(); DISABLE_LCD_LED(); #if CHECK_FOR_PMM15 /* make sure error pmm15 does not exist */ while ( PMM15Check() ); #endif /* Errata PMM17 - automatic prolongation mechanism * SVSLOW is disabled */ *(unsigned int*)(0x0110) = 0x9602; *(unsigned int*)(0x0112) |= 0x0800; WhoAmI(); PrintResetSource(); /* if a watchdog occurred then print and save information about the source */ WatchdogTimeoutHandler(GetResetSource()); PrintString("Starting Task Scheduler\r\n"); SetUartNormalMode(); vTaskStartScheduler(); /* if vTaskStartScheduler exits an error occured. */ PrintString("Program Error\r\n"); ForceWatchdogReset(); }