Пример #1
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void ActivateDisplayShortDuration(uint16 secondsToDisplay)
{
	// Check if the LCD Power was turned off
	if (g_lcdPowerFlag == DISABLED)
	{
		g_lcdPowerFlag = ENABLED;
		PowerControl(LCD_POWER_ENABLE, ON);
		SoftUsecWait(LCD_ACCESS_DELAY);
		SetLcdContrast(g_contrast_value);
		InitLcdDisplay();					// Setup LCD segments and clear display buffer
		AssignSoftTimer(LCD_POWER_ON_OFF_TIMER_NUM, (secondsToDisplay * TICKS_PER_SEC), LcdPwTimerCallBack);

		// Check if the unit is monitoring, if so, reassign the monitor update timer
		if (g_sampleProcessing == ACTIVE_STATE)
		{
			debug("Keypress Timer Mgr: enabling Monitor Update Timer.\r\n");
			AssignSoftTimer(MENU_UPDATE_TIMER_NUM, ONE_SECOND_TIMEOUT, MenuUpdateTimerCallBack);
		}
	}

	// Check if the LCD Backlight was turned off
	if (g_lcdBacklightFlag == DISABLED)
	{
		g_lcdBacklightFlag = ENABLED;
		SetLcdBacklightState(BACKLIGHT_BRIGHT);
		AssignSoftTimer(LCD_BACKLIGHT_ON_OFF_TIMER_NUM, (secondsToDisplay * TICKS_PER_SEC), DisplayTimerCallBack);
	}
}
Пример #2
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void AutoMonitorTimerCallBack(void)
{
	INPUT_MSG_STRUCT mn_msg;

	debug("Auto Monitor Timer callback: activated.\r\n");

	// Check if the USB is currently handling an active connection
	if (g_usbMassStorageState == USB_CONNECTED_AND_PROCESSING)
	{
		AssignSoftTimer(AUTO_MONITOR_TIMER_NUM, (uint32)(g_unitConfig.autoMonitorMode * TICKS_PER_MIN), AutoMonitorTimerCallBack);
	}
	else
	{
		// Make sure the Auto Monitor timer is disabled
		ClearSoftTimer(AUTO_MONITOR_TIMER_NUM);

		// Check if the unit is not already monitoring
		if (g_sampleProcessing != ACTIVE_STATE)
		{
			if (CheckAndDisplayErrorThatPreventsMonitoring(OVERLAY))
			{
				AssignSoftTimer(AUTO_MONITOR_TIMER_NUM, (uint32)(g_unitConfig.autoMonitorMode * TICKS_PER_MIN), AutoMonitorTimerCallBack);
			}
			else // Safe to enter monitor mode
			{
				// Enter monitor mode with the current mode
				SETUP_MENU_WITH_DATA_MSG(MONITOR_MENU, g_triggerRecord.opMode);
				JUMP_TO_ACTIVE_MENU();
			}
		}
	}
}
Пример #3
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void CraftInitStatusFlags(void)
{
	memset(&g_modemStatus, 0, sizeof(g_modemStatus));

	// Modem and craft port specific flags.
	g_modemStatus.connectionState = NOP_CMD;	// State flag to indicate which modem command to handle.

	// Check if the Modem setup record is valid and Modem status is yes
	if ((!g_modemSetupRecord.invalid) && (g_modemSetupRecord.modemStatus == YES))
	{
		// Signal that the modem is available
		g_modemStatus.modemAvailable = YES;

		AssignSoftTimer(MODEM_DELAY_TIMER_NUM, (MODEM_ATZ_DELAY), ModemDelayTimerCallback);
	}
	else
	{
		// Signal that the modem is not available
		g_modemStatus.modemAvailable = NO;
	}

	g_modemStatus.craftPortRcvFlag = NO;	// Flag to indicate that incomming data has been received.
	g_modemStatus.xferState = NOP_CMD;		// Flag for xmitting data to the craft.
	g_modemStatus.xferMutex = NO;			// Flag to stop other message command from executing.
	g_modemStatus.systemIsLockedFlag = YES;

	g_modemStatus.ringIndicator = 0;
	g_modemStatus.xferPrintState = NO;
	
	// Modem is being tested/debugged set debug to true.
	g_modemStatus.testingPrintFlag = g_disableDebugPrinting;		
	// Modem is being tested/debugged, set to print to the PC
	g_modemStatus.testingFlag = OFF;
}
Пример #4
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void MenuUpdateTimerCallBack(void)
{
	INPUT_MSG_STRUCT mn_msg;

	// Clear out the message parameters
	mn_msg.cmd = 0; mn_msg.length = 0; mn_msg.data[0] = 0;

	// Recall the current active menu to repaint the display
	JUMP_TO_ACTIVE_MENU();

	AssignSoftTimer(MENU_UPDATE_TIMER_NUM, ONE_SECOND_TIMEOUT, MenuUpdateTimerCallBack);
}
Пример #5
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void ModemResetTimerCallback(void)
{
	if (g_modemResetStage == 0)
	{
		// If for some reason this executes, make sure the timer is disabled
		ClearSoftTimer(MODEM_RESET_TIMER_NUM);
	}
	else if (g_modemResetStage == 1)
	{
		SET_DTR;

		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 2;
	}
	else if (g_modemResetStage == 2)
	{
		UartPuts((char*)(CMDMODE_CMD_STRING), CRAFT_COM_PORT);
		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 3;
	}
	else if (g_modemResetStage == 3)
	{
		UartPuts((char*)(CMDMODE_CMD_STRING), CRAFT_COM_PORT);
		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 4;
	}
	else if (g_modemResetStage == 4)
	{
		UartPuts((char*)(ATH_CMD_STRING), CRAFT_COM_PORT);
		UartPuts((char*)&g_CRLF, CRAFT_COM_PORT);
		AssignSoftTimer(MODEM_RESET_TIMER_NUM, (uint32)(3 * TICKS_PER_SEC), ModemResetTimerCallback);
		g_modemResetStage = 5;
	}
	else if (g_modemResetStage == 5)
	{
		ModemInitProcess();
		g_modemResetStage = 0;
	}
}
Пример #6
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void ModemDelayTimerCallback(void)
{
	if (YES == g_modemStatus.modemAvailable)
	{
		if ((READ_DSR == MODEM_CONNECTED) && (READ_DCD == NO_CONNECTION))
		{
			ModemInitProcess();
		}
		else
		{
			AssignSoftTimer(MODEM_DELAY_TIMER_NUM, MODEM_ATZ_DELAY, ModemDelayTimerCallback);
		}
	}
}
Пример #7
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void ProcessTimerModeSettings(uint8 mode)
{
	//uint8 dayOfWeek = 0;
	uint8 startDay = 0;
	uint8 startHour = 0;
	uint16 minutesLeft = 0;
	DATE_TIME_STRUCT currentTime = GetCurrentTime();
	uint8 status = ValidateTimerModeSettings();

	// Check if the timer mode settings check failed or if the timer mode setting has been disabled
	if ((status == FAILED) || (g_unitConfig.timerMode == DISABLED))
	{
		g_unitConfig.timerMode = DISABLED;
		SaveRecordData(&g_unitConfig, DEFAULT_RECORD, REC_UNIT_CONFIG_TYPE);

		// Disable the Power Off timer in case it's set
		ClearSoftTimer(POWER_OFF_TIMER_NUM);

		if (mode == PROMPT)
		{
			sprintf((char*)g_spareBuffer, "%s %s", getLangText(TIMER_SETTINGS_INVALID_TEXT), getLangText(TIMER_MODE_DISABLED_TEXT));
			MessageBox(getLangText(ERROR_TEXT), (char*)g_spareBuffer, MB_OK);
		}
	}
	else // status == PASSED || status == IN_PROGRESS
	{
		// Calculate timer mode active run time in minutes
		TimerModeActiveMinutes();

		// Init start day based on the start date provided by the user
		startDay = g_unitConfig.timerStartDate.day;

		// Check if in progress, requiring extra logic to determine alarm settings
		if (status == IN_PROGRESS)
		{
			// Check if the stop time is greater than the start time
			if ((g_unitConfig.timerStopTime.hour > g_unitConfig.timerStartTime.hour) ||
			((g_unitConfig.timerStopTime.hour == g_unitConfig.timerStartTime.hour) &&
			(g_unitConfig.timerStopTime.min > g_unitConfig.timerStartTime.min)))
			{
				// Advance the start day
				startDay++;

				// Check if the start day is beyond the total days in the current month
				if (startDay > g_monthTable[(uint8)(g_unitConfig.timerStartDate.month)].days)
				{
					// Set the start day to the first day of next month
					startDay = 1;
				}
			}
		}

		// Check for specialty case hourly mode and in progress, requiring extra logic to determine alarm settings
		if ((g_unitConfig.timerModeFrequency == TIMER_MODE_HOURLY) && (status == IN_PROGRESS))
		{
			// Check if another hour time slot to run again today
			if (currentTime.hour != g_unitConfig.timerStopTime.hour)
			{
				// Start day remains the same
				startDay = g_unitConfig.timerStartDate.day;

				// Check if current hour time slot has not started
				if (currentTime.min < g_unitConfig.timerStartTime.min)
				{
					// Set alarm for the same hour
					startHour = currentTime.hour;
				}
				else
				{
					// Set alarm for the next hour
					startHour = currentTime.hour + 1;
					
					// Account for end of day boundary
					if (startHour > 23)
					{
						startHour = 0;

						// Advance the start day
						startDay++;

						// Check if the start day is beyond the total days in the current month
						if (startDay > g_monthTable[(uint8)(g_unitConfig.timerStartDate.month)].days)
						{
							// Set the start day to the first day of next month
							startDay = 1;
						}
					}
				}
				
				EnableExternalRtcAlarm(startDay, startHour, g_unitConfig.timerStartTime.min, 0);
			}
			else // This is the last hour time slot to run today, set alarm for next day
			{
				// startDay calculated correctly in above previous status == IN_PROGRESS logic
				EnableExternalRtcAlarm(startDay, g_unitConfig.timerStartTime.hour, g_unitConfig.timerStartTime.min, 0);
			}
		}
		else // All other timer modes
		{
			EnableExternalRtcAlarm(startDay, g_unitConfig.timerStartTime.hour, g_unitConfig.timerStartTime.min, 0);
		}

		if (status == PASSED)
		{
			if (mode == PROMPT)
			{
				sprintf((char*)g_spareBuffer, "%s %s", getLangText(TIMER_MODE_NOW_ACTIVE_TEXT), getLangText(PLEASE_POWER_OFF_UNIT_TEXT));
				MessageBox(getLangText(STATUS_TEXT), (char*)g_spareBuffer, MB_OK);
			}

			// Check if start time is greater than the current time
			if (((g_unitConfig.timerStartTime.hour * 60) + g_unitConfig.timerStartTime.min) >
			((currentTime.hour * 60) + currentTime.min))
			{
				// Take the difference between start time and current time
				minutesLeft = (uint16)(((g_unitConfig.timerStartTime.hour * 60) + g_unitConfig.timerStartTime.min) -
				((currentTime.hour * 60) + currentTime.min));
			}
			else // Current time is after the start time, meaning the start time is the next day
			{
				// Take the difference between 24 hours and the current time plus the start time
				minutesLeft = (uint16)((24 * 60) - ((currentTime.hour * 60) + currentTime.min) +
				((g_unitConfig.timerStartTime.hour * 60) + g_unitConfig.timerStartTime.min));
			}

			// Check if the start time is within the next minute
			if (minutesLeft <= 1)
			{
				OverlayMessage(getLangText(WARNING_TEXT), getLangText(POWERING_UNIT_OFF_NOW_TEXT), 2 * SOFT_SECS);

				// Need to shutdown the unit now, otherwise the start time window will be missed
				PowerUnitOff(SHUTDOWN_UNIT); // Return unnecessary
			}
			else // More than 1 minute left before the start time
			{
				// Make sure the unit turns off one minute before the start time if the user forgets to turn the unit off
				minutesLeft -= 1;

				// Need to handle state where timer mode is going active but unit hasn't power cycled into timer mode yet
				g_allowQuickPowerOffForTimerModeSetup = YES;

				// Set the Power off soft timer to prevent the unit from staying on past the Timer mode start time
				AssignSoftTimer(POWER_OFF_TIMER_NUM, (uint32)(minutesLeft * 60 * 2), PowerOffTimerCallback);
			}
		}
		else // status == IN_PROGRESS
		{
			if (mode == PROMPT)
			{
				sprintf((char*)g_spareBuffer, "%s", getLangText(TIMER_MODE_NOW_ACTIVE_TEXT));
				MessageBox(getLangText(STATUS_TEXT), (char*)g_spareBuffer, MB_OK);
			}

			// Check if specialty mode hourly
			if (g_unitConfig.timerModeFrequency == TIMER_MODE_HOURLY)
			{
				if (currentTime.min	< g_unitConfig.timerStopTime.min)
				{
					minutesLeft = (g_unitConfig.timerStopTime.min - currentTime.min);
				}
				else
				{
					minutesLeft = (60 + g_unitConfig.timerStopTime.min - currentTime.min);
				}
				
				if (minutesLeft > 58)
				minutesLeft = 58;
			}
			// Check if the current time is greater than the stop time, indicating that midnight boundary was crossed
			else if (((currentTime.hour * 60) + currentTime.min) > ((g_unitConfig.timerStopTime.hour * 60) + g_unitConfig.timerStopTime.min))
			{
				// Calculate the time left before powering off to be 24 + the stop time minus the current time
				minutesLeft = (uint16)(((24 * 60) + (g_unitConfig.timerStopTime.hour * 60) + g_unitConfig.timerStopTime.min) -
				((currentTime.hour * 60) + currentTime.min));
			}
			else // Current time is less than start time, operating within the same day
			{
				// Calculate the time left before powering off to be the stop time minus the current time
				minutesLeft = (uint16)(((g_unitConfig.timerStopTime.hour * 60) + g_unitConfig.timerStopTime.min) -
				((currentTime.hour * 60) + currentTime.min));
			}

			// Make sure timeout value is not zero
			if (minutesLeft == 0) minutesLeft = 1;

			debug("Timer Mode: In progress, minutes left before power off: %d (Expired secs this min: %d)\r\n", minutesLeft, currentTime.sec);

			// Setup soft timer to turn system off when timer mode is finished for the day
			AssignSoftTimer(POWER_OFF_TIMER_NUM, (uint32)((minutesLeft * 60 * 2) - (currentTime.sec	* 2)), PowerOffTimerCallback);
		}
	}
}
Пример #8
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void ProcessTimerMode(void)
{
	DATE_TIME_STRUCT currTime = GetExternalRtcTime();

	// Check if the Timer mode activated after stop date
	if (// First Check for past year
		(currTime.year > g_unitConfig.timerStopDate.year) ||

		// Second check for equal year but past month
		((currTime.year == g_unitConfig.timerStopDate.year) && (currTime.month > g_unitConfig.timerStopDate.month)) ||

		// Third check for equal year, equal month, but past day
		((currTime.year == g_unitConfig.timerStopDate.year) && (currTime.month == g_unitConfig.timerStopDate.month) &&
		(currTime.day > g_unitConfig.timerStopDate.day)))
	{
		// Disable alarm output generation
		debug("Timer Mode: Activated after date...\r\n");
		debug("Timer Mode: Disabling...\r\n");
		g_unitConfig.timerMode = DISABLED;

		// Save Unit Config
		SaveRecordData(&g_unitConfig, DEFAULT_RECORD, REC_UNIT_CONFIG_TYPE);

		// Deactivate alarm interrupts
		DisableExternalRtcAlarm();

		// Turn unit off/sleep
		debug("Timer mode: Powering unit off...\r\n");
		PowerUnitOff(SHUTDOWN_UNIT); // Return unnecessary
	}
	// Check if the Timer mode activated before start date
	else if (// First Check for before year
		(currTime.year < g_unitConfig.timerStartDate.year) ||

		// Second check for equal year but before month
		((currTime.year == g_unitConfig.timerStartDate.year) && (currTime.month < g_unitConfig.timerStartDate.month)) ||

		// Third check for equal year, equal month, but before day
		((currTime.year == g_unitConfig.timerStartDate.year) && (currTime.month == g_unitConfig.timerStartDate.month) &&
		(currTime.day < g_unitConfig.timerStartDate.day)))
	{
		debug("Timer Mode: Activated before date...\r\n");
		ResetTimeOfDayAlarm();

		// Turn unit off/sleep
		debug("Timer mode: Powering unit off...\r\n");
		PowerUnitOff(SHUTDOWN_UNIT); // Return unnecessary
	}
	// Check if the Timer mode activated during active dates but on an off day
	else if ((g_unitConfig.timerModeFrequency == TIMER_MODE_WEEKDAYS) && ((currTime.weekday == SAT) || (currTime.weekday == SUN)))
	{
		debug("Timer Mode: Activated on an off day (weekday freq)...\r\n");
		ResetTimeOfDayAlarm();

		// Turn unit off/sleep
		debug("Timer mode: Powering unit off...\r\n");
		PowerUnitOff(SHUTDOWN_UNIT); // Return unnecessary
	}
	// Check if the Timer mode activated during active dates but on an off day
	else if ((g_unitConfig.timerModeFrequency == TIMER_MODE_MONTHLY) && (currTime.day != g_unitConfig.timerStartDate.day))
	{
		debug("Timer Mode: Activated on off day (monthly freq)...\r\n");
		ResetTimeOfDayAlarm();

		// Turn unit off/sleep
		debug("Timer mode: Powering unit off...\r\n");
		PowerUnitOff(SHUTDOWN_UNIT); // Return unnecessary
	}
	// Check if the Timer mode activated on end date (and not hourly mode)
	else if ((g_unitConfig.timerModeFrequency != TIMER_MODE_HOURLY) && (currTime.year == g_unitConfig.timerStopDate.year) &&
			(currTime.month == g_unitConfig.timerStopDate.month) && (currTime.day == g_unitConfig.timerStopDate.day))
	{
		// Disable alarm output generation
		debug("Timer Mode: Activated on end date...\r\n");

		// Signal the timer mode end of session timer to stop timer mode due to this being the last run
		g_timerModeLastRun = YES;

		// Deactivate alarm interrupts
		DisableExternalRtcAlarm();
	}
	// Check if the Timer mode activated on end date and end hour (hourly mode)
	else if ((g_unitConfig.timerModeFrequency == TIMER_MODE_HOURLY) && (currTime.year == g_unitConfig.timerStopDate.year) &&
			(currTime.month == g_unitConfig.timerStopDate.month) && (currTime.day == g_unitConfig.timerStopDate.day) &&
			(currTime.hour == g_unitConfig.timerStopTime.hour))
	{
		// Disable alarm output generation
		debug("Timer Mode: Activated on end date...\r\n");

		// Signal the timer mode end of session timer to stop timer mode due to this being the last run
		g_timerModeLastRun = YES;

		// Deactivate alarm interrupts
		DisableExternalRtcAlarm();
	}
	else // Timer mode started during the active dates on a day it's supposed to run
	{
		if (g_unitConfig.timerModeFrequency == TIMER_MODE_ONE_TIME)
		{
			// Signal the timer mode end of session timer to stop timer mode due to this being the last run
			g_timerModeLastRun = YES;

			// Deactivate alarm interrupts
			DisableExternalRtcAlarm();
		}
		else // All other timer modes
		{
			// Reset the Time of Day Alarm to wake the unit up again
			ResetTimeOfDayAlarm();
		}
	}

	OverlayMessage(getLangText(STATUS_TEXT), getLangText(TIMER_MODE_NOW_ACTIVE_TEXT), (2 * SOFT_SECS));

	raiseTimerEventFlag(TIMER_MODE_TIMER_EVENT);

	// Setup soft timer to turn system off when timer mode is finished for the day (minus the expired secs in the current minute
	AssignSoftTimer(POWER_OFF_TIMER_NUM, ((g_unitConfig.TimerModeActiveMinutes * 60 * 2) - (currTime.sec * 2)), PowerOffTimerCallback);

	debug("Timer mode: running...\r\n");
}
Пример #9
0
///----------------------------------------------------------------------------
///	Function Break
///----------------------------------------------------------------------------
void KeypadLedUpdateTimerCallBack(void)
{
	static uint8 ledState = KEYPAD_LED_STATE_UNKNOWN;
	uint8 lastLedState;
	uint8 config; // = ReadMcp23018(IO_ADDRESS_KPD, GPIOA);
	BOOLEAN externalChargePresent = CheckExternalChargeVoltagePresent();

	// States
	// 1) Init complete, not monitoring, not charging --> Static Green
	// 2) Init complete, not monitoring, charging --> Static Red
	// 3) Init complete, monitoring, not charging --> Flashing Green (state transition)
	// 4) Init complete, monitoring, charging --> Alternate Flashing Green/Red (state transition)

	// Hold the last state
	lastLedState = ledState;

	if ((g_sampleProcessing == IDLE_STATE) && (externalChargePresent == FALSE))
	{
		//debug("Keypad LED: State 1\r\n");
		
		ledState = KEYPAD_LED_STATE_IDLE_GREEN_ON;
	}
	else if ((g_sampleProcessing == IDLE_STATE) && (externalChargePresent == TRUE))
	{
		//debug("Keypad LED: State 2\r\n");

		ledState = KEYPAD_LED_STATE_CHARGE_RED_ON;
	}
	else if ((g_sampleProcessing == ACTIVE_STATE) && (externalChargePresent == FALSE))
	{
		//debug("Keypad LED: State 3\r\n");

		if (ledState == KEYPAD_LED_STATE_ACTIVE_GREEN_ON)
		{
			ledState = KEYPAD_LED_STATE_ACTIVE_GREEN_OFF;
		}
		else
		{
			ledState = KEYPAD_LED_STATE_ACTIVE_GREEN_ON;
		}
	}		
	else // ((g_sampleProcessing == ACTIVE_STATE) && (externalChargePresent == TRUE))
	{
		//debug("Keypad LED: State 4\r\n");

		if (ledState == KEYPAD_LED_STATE_ACTIVE_CHARGE_GREEN_ON)
		{
			ledState = KEYPAD_LED_STATE_ACTIVE_CHARGE_RED_ON;
		}
		else
		{
			ledState = KEYPAD_LED_STATE_ACTIVE_CHARGE_GREEN_ON;
		}
	}
	
	// Check if the state changed
	if (ledState != lastLedState)
	{
		config = ReadMcp23018(IO_ADDRESS_KPD, GPIOA);
		
		switch (ledState)
		{
			case KEYPAD_LED_STATE_BOTH_OFF:
			case KEYPAD_LED_STATE_ACTIVE_GREEN_OFF:
				config &= ~RED_LED_PIN;
				config &= ~GREEN_LED_PIN;
				break;
				
			case KEYPAD_LED_STATE_IDLE_GREEN_ON:
			case KEYPAD_LED_STATE_ACTIVE_GREEN_ON:
			case KEYPAD_LED_STATE_ACTIVE_CHARGE_GREEN_ON:
				config &= ~RED_LED_PIN;
				config |= GREEN_LED_PIN;
				break;
				
			case KEYPAD_LED_STATE_CHARGE_RED_ON:
			case KEYPAD_LED_STATE_ACTIVE_CHARGE_RED_ON:
				config &= ~GREEN_LED_PIN;
				config |= RED_LED_PIN;
				break;
		}

		WriteMcp23018(IO_ADDRESS_KPD, GPIOA, config);
	}

	AssignSoftTimer(KEYPAD_LED_TIMER_NUM, ONE_SECOND_TIMEOUT, KeypadLedUpdateTimerCallBack);
}
Пример #10
0
void InitSoftwareSettings_NS8100(void)
{
	INPUT_MSG_STRUCT mn_msg;

	debug("Init Software Settings...\r\n");

	//-------------------------------------------------------------------------
	// Init version msg
	//-------------------------------------------------------------------------
	InitVersionMsg();

	//-------------------------------------------------------------------------
	// Init time msg and update current time
	//-------------------------------------------------------------------------
	InitTimeMsg();
	UpdateCurrentTime();

	//-------------------------------------------------------------------------
	// Get the function address passed by the bootloader
	//-------------------------------------------------------------------------
	CheckBootloaderAppPresent(); debug("Bootloader check complete\r\n");

	//-------------------------------------------------------------------------
	// Load the Unit Config
	//-------------------------------------------------------------------------
	LoadUnitConfig(); debug("Loading Unit Config record\r\n");

	//-------------------------------------------------------------------------
	// Build the language table based on the user's last language choice
	//-------------------------------------------------------------------------
	BuildLanguageLinkTable(g_unitConfig.languageMode); debug("Language Tables built\r\n");

	//-------------------------------------------------------------------------
	// Initialize Unit Config items such as contrast, timers
	//-------------------------------------------------------------------------
	ActivateUnitConfigOptions(); debug("Activated Unit Config Options\r\n");

	//-------------------------------------------------------------------------
	// Display the Splash screen
	//-------------------------------------------------------------------------
	DisplaySplashScreen(); debug("Display Splash screen complete\r\n");

	//-------------------------------------------------------------------------
	// Wait at least 3 seconds for the main screen to be displayed
	//-------------------------------------------------------------------------
	debug("Three second delay for Splash screen\r\n");
	SoftUsecWait(3 * SOFT_SECS);

	//-------------------------------------------------------------------------
	// Display Smart Sensor information if found
	//-------------------------------------------------------------------------
	DisplaySmartSensorInfo(INFO_ON_INIT);

	//-------------------------------------------------------------------------
	// Bootloader entry check
	//-------------------------------------------------------------------------
	BootloaderEntryCheck();

	//-------------------------------------------------------------------------
	// Load the Factory Setup Record
	//-------------------------------------------------------------------------
	LoadFactorySetupRecord(); debug("Factory setup record loaded\r\n");

	//-------------------------------------------------------------------------
	// Load Default Trigger Record
	//-------------------------------------------------------------------------
	LoadDefaultTriggerRecord(); debug("Default Trigger record loaded\r\n");

	//-------------------------------------------------------------------------
	// Load the Modem Setup Record
	//-------------------------------------------------------------------------
	LoadModemSetupRecord();	debug("Modem Setup record loaded\r\n");

	//-------------------------------------------------------------------------
	// Add OnOff Log Timestamp
	//-------------------------------------------------------------------------
	AddOnOffLogTimestamp(ON); debug("On/Off Log timestamp appended\r\n");

#if 0 // Removed debug log file due to inducing system problems
	//-------------------------------------------------------------------------
	// Switch Debug Log file
	SwitchDebugLogFile();
#endif

	//-------------------------------------------------------------------------
	// Init Global Unique Event Number
	//-------------------------------------------------------------------------
	InitCurrentEventNumber(); debug("Current Event Number initialized\r\n");

	//-------------------------------------------------------------------------
	// Init AutoDialout
	//-------------------------------------------------------------------------
	InitAutoDialout(); debug("Auto Dialout initialized\r\n");

	//-------------------------------------------------------------------------
	// Init Monitor Log
	//-------------------------------------------------------------------------
	InitMonitorLog(); debug("Monitor Log initialized\r\n");

	//-------------------------------------------------------------------------
	// Init the Sensor Parameters
	//-------------------------------------------------------------------------
	InitSensorParameters(g_factorySetupRecord.seismicSensorType, (uint8)g_triggerRecord.srec.sensitivity); debug("Sensor Parameters initialized\r\n");

	//-------------------------------------------------------------------------
	// Init the Summary List file
	//-------------------------------------------------------------------------
	ManageEventsDirectory();
	InitSummaryListFile(); debug("Summary List initialized\r\n");

	//-------------------------------------------------------------------------
	// Update Flash Usage Stats
	//-------------------------------------------------------------------------
	OverlayMessage(getLangText(STATUS_TEXT), getLangText(CALCULATING_EVENT_STORAGE_SPACE_FREE_TEXT), 0);
	GetSDCardUsageStats(); debug("Flash Usage Stats updated (Cluster size: %d bytes)\r\n", g_sdCardUsageStats.clusterSizeInBytes);

	//-------------------------------------------------------------------------
	// Check for Timer mode activation
	//-------------------------------------------------------------------------
	if (TimerModeActiveCheck() == TRUE)
	{
		debug("--- Timer Mode Startup ---\r\n");
		ProcessTimerMode();
	}
	else // Normal startup
	{
		debug("--- Normal Startup ---\r\n");
	}

	//-------------------------------------------------------------------------
	// Init the cmd message handling buffers before initialization of the ports.
	//-------------------------------------------------------------------------
	RemoteCmdMessageHandlerInit(); debug("Craft Message Handler initialized\r\n");

	//-------------------------------------------------------------------------
	// Init the input buffers and status flags for input craft data.
	//-------------------------------------------------------------------------
	CraftInitStatusFlags(); debug("Craft Status flags initilaized\r\n");

	//-------------------------------------------------------------------------
	// Signal remote end that RS232 Comm is available
	//-------------------------------------------------------------------------
	SET_RTS; SET_DTR; debug("Craft RTS and DTR enabled\r\n");

	//-------------------------------------------------------------------------
	// Reset LCD timers
	//-------------------------------------------------------------------------
	ResetSoftTimer(LCD_BACKLIGHT_ON_OFF_TIMER_NUM);
	ResetSoftTimer(LCD_POWER_ON_OFF_TIMER_NUM);

	//-------------------------------------------------------------------------
	// Turn on the Green keypad LED when system init complete
	//-------------------------------------------------------------------------
	debug("Init complete, turning Kepypad LED Green...\r\n");
	WriteMcp23018(IO_ADDRESS_KPD, GPIOA, ((ReadMcp23018(IO_ADDRESS_KPD, GPIOA) & 0xCF) | GREEN_LED_PIN));

	//-------------------------------------------------------------------------
	// Assign a one second keypad led update timer
	//-------------------------------------------------------------------------
	AssignSoftTimer(KEYPAD_LED_TIMER_NUM, ONE_SECOND_TIMEOUT, KeypadLedUpdateTimerCallBack); debug("Keypad LED Timer initialized\r\n");

	//-------------------------------------------------------------------------
	// Jump to the true main menu
	//-------------------------------------------------------------------------
	debug("Jumping to Main Menu\r\n");
	SETUP_MENU_MSG(MAIN_MENU);
	JUMP_TO_ACTIVE_MENU();

	//-------------------------------------------------------------------------
	// Enable Craft input (delayed to prevent serial input from locking unit)
	//-------------------------------------------------------------------------
	InitCraftInterruptBuffers();
	Setup_8100_Usart1_RS232_ISR();

	if (GET_HARDWARE_ID == HARDWARE_ID_REV_8_WITH_GPS_MOD)
	{
		EnableGps();
	}

	//-------------------------------------------------------------------------
	// Enable keypad key input (delayed to prevent key input from locking unit)
	//-------------------------------------------------------------------------
	EnableMcp23018Interrupts(); debug("Mcp23018 interrupts enabled\r\n");

	//-------------------------------------------------------------------------
	// Display last line of system init
	//-------------------------------------------------------------------------
	DisplayVersionToDebug();
}