static void ChangeModeHandler(unsigned char Option) { unsigned char Mode = Option & MODE_MASK; tMessage Msg; SetupMessageAndAllocateBuffer(&Msg, ModeChangeIndMsg, (CurrentIdleScreen() << 4) | Mode); Msg.pBuffer[0] = eScUpdateComplete; Msg.Length = 1; RouteMsg(&Msg); PrintStringAndHexByte("- ChgModInd:", Msg.Options); if (Option & MSG_OPT_CHGMOD_IND) return; // ask for current idle page only if (Mode == MUSIC_MODE) SendMessage(&Msg, UpdConnParamMsg, ShortInterval); if (Mode != IDLE_MODE) { PageType = PAGE_TYPE_IDLE; if (ModeTimerId == UNASSIGNED) ModeTimerId = AllocateOneSecondTimer(); SetupOneSecondTimer(ModeTimerId, ModeTimeout[Mode], NO_REPEAT, DISPLAY_QINDEX, ModeTimeoutMsg, Mode); StartOneSecondTimer(ModeTimerId); if (Option & MSG_OPT_UPD_INTERNAL) SendMessage(&Msg, UpdateDisplayMsg, Option); } else { StopOneSecondTimer(ModeTimerId); IdleUpdateHandler(); } CurrentMode = Mode; }
int IdlePageQrCodeInit() { StopAllDisplayTimers(); if(timerid == -1) { timerid = AllocateOneSecondTimer(); if (timerid < 0) { // How do we report errors } SetupOneSecondTimer(timerid, 1, REPEAT_FOREVER, BarCode, QRTIMER_TIMER); StartOneSecondTimer(timerid); } FillMyBuffer(STARTING_ROW, NUM_LCD_ROWS, 0x00); return 0; }
/*! 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; } }
static void ShowCall(tString *pString, unsigned char Type) { static tString CallerId[15] = ""; static tTimerId NotifyTimerId = UNASSIGNED; tMessage Msg; if (Type == SHOW_NOTIF_CALLER_ID) strcpy(CallerId, pString); if (Type == SHOW_NOTIF_CALLER_NAME && *CallerId) { PrintString3("- Caller:", pString, CR); SetupMessageAndAllocateBuffer(&Msg, SetVibrateMode, MSG_OPT_NONE); *(tSetVibrateModePayload *)Msg.pBuffer = RingTone; RouteMsg(&Msg); PageType = PAGE_TYPE_INFO; CurrentPage[PageType] = CallPage; DrawCallScreen(CallerId, pString); // set a 5s timer for switching back to idle screen if (NotifyTimerId == UNASSIGNED) NotifyTimerId = AllocateOneSecondTimer(); SetupOneSecondTimer(NotifyTimerId, 10, NO_REPEAT, DISPLAY_QINDEX, CallerNameMsg, SHOW_NOTIF_END); StartOneSecondTimer(NotifyTimerId); } else if (Type == SHOW_NOTIF_END || Type == SHOW_NOTIF_REJECT_CALL) { PrintString2("- Call Notif End", CR); *CallerId = NULL; StopOneSecondTimer(NotifyTimerId); PageType = PAGE_TYPE_IDLE; SendMessage(&Msg, UpdateDisplayMsg, CurrentMode | MSG_OPT_UPD_INTERNAL | (CurrentMode == IDLE_MODE ? MSG_OPT_NEWUI : 0)); if (Type == SHOW_NOTIF_REJECT_CALL) SendMessage(&Msg, HfpMsg, MSG_OPT_HFP_HANGUP); } }
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; DetermineErrata(); #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 != NO_RESET_CODE) InitProperty(); InitBufferPool(); // message queue InitBattery(); CheckClip(); PrintString2("\r\n*** ", niReset == FLASH_RESET_CODE ? "FLASH" : (niReset == MASTER_RESET_CODE ? "MASTER" : "NORMAL")); PrintString3(":", niBuild, CR); ShowWatchdogInfo(); WhoAmI(); /* timer for battery checking at a regular frequency. */ BatteryTimerId = AllocateOneSecondTimer(); SetupOneSecondTimer(BatteryTimerId, BATTERY_MONITOR_INTERVAL, REPEAT_FOREVER, DISPLAY_QINDEX, MonitorBatteryMsg, MSG_OPT_NONE); StartOneSecondTimer(BatteryTimerId); InitVibration(); InitRealTimeClock(); // enable rtc interrupt LcdPeripheralInit(); DrawStartupScreen(); SerialRamInit(); /* turn the radio on; initialize the serial port profile or BLE/GATT */ CreateAndSendMessage(TurnRadioOnMsg, MSG_OPT_NONE); DISABLE_LCD_LED(); }
/*! Function to implement the BackgroundTask loop * * \param pvParameters not used * */ static void BackgroundTask(void *pvParameters) { if ( QueueHandles[BACKGROUND_QINDEX] == 0 ) { PrintString("Background Queue not created!\r\n"); } PrintString(SPP_DEVICE_NAME); PrintString2("\r\nSoftware Version ",VERSION_STRING); PrintString("\r\n\r\n"); InitializeRstNmiConfiguration(); /* * check on the battery */ ConfigureBatteryPins(); BatteryChargingControl(); BatterySenseCycle(); /* * now set up a timer that will cause the battery to be checked at * a regular frequency. */ BatteryMonitorTimerId = AllocateOneSecondTimer(); InitializeBatteryMonitorInterval(); SetupOneSecondTimer(BatteryMonitorTimerId, nvBatteryMonitorIntervalInSeconds, REPEAT_FOREVER, BACKGROUND_QINDEX, BatteryChargeControl, NO_MSG_OPTIONS); StartOneSecondTimer(BatteryMonitorTimerId); /* * Setup a timer to use with the LED for the LCD. */ LedTimerId = AllocateOneSecondTimer(); SetupOneSecondTimer(LedTimerId, ONE_SECOND*3, NO_REPEAT, BACKGROUND_QINDEX, LedChange, LED_OFF_OPTION); // Allocate a timer for wake-up iOS background BLE app CallbackTimerId = AllocateOneSecondTimer(); /****************************************************************************/ #ifdef RAM_TEST RamTestTimerId = AllocateOneSecondTimer(); SetupOneSecondTimer(RamTestTimerId, ONE_SECOND*20, NO_REPEAT, DISPLAY_QINDEX, RamTestMsg, NO_MSG_OPTIONS); StartOneSecondTimer(RamTestTimerId); #endif /****************************************************************************/ InitializeAccelerometer(); #ifdef ACCELEROMETER_DEBUG SetupMessageAndAllocateBuffer(&BackgroundMsg, AccelerometerSetupMsg, ACCELEROMETER_SETUP_INTERRUPT_CONTROL_OPTION); BackgroundMsg.pBuffer[0] = INTERRUPT_CONTROL_ENABLE_INTERRUPT; BackgroundMsg.Length = 1; RouteMsg(&BackgroundMsg); /* don't call AccelerometerEnable() directly use a message*/ SetupMessage(&BackgroundMsg,AccelerometerEnableMsg,NO_MSG_OPTIONS); RouteMsg(&BackgroundMsg); #endif /****************************************************************************/ #ifdef RATE_TEST StartCrystalTimer(CRYSTAL_TIMER_ID3,RateTestCallback,RATE_TEST_INTERVAL_MS); #endif /****************************************************************************/ for(;;) { if( pdTRUE == xQueueReceive(QueueHandles[BACKGROUND_QINDEX], &BackgroundMsg, portMAX_DELAY ) ) { PrintMessageType(&BackgroundMsg); BackgroundMessageHandler(&BackgroundMsg); SendToFreeQueue(&BackgroundMsg); CheckStackUsage(xBkgTaskHandle,"Background Task"); CheckQueueUsage(QueueHandles[BACKGROUND_QINDEX]); } } }