Files
TX/source/System/system.c

112 lines
2.5 KiB
C
Raw Normal View History

/*
* system.c
*
* Created on: Oct 23, 2023
* Author: Brian.Bailey
*/
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <ctype.h>
//Application includes
#include "eeprom.h"
#include "soft_timer.h"
#include "System/system.h"
/*******************************************************************************
* Definitions
******************************************************************************/
SYSTEM_DATA_t sys;
/*******************************************************************************
* Variables
******************************************************************************/
/*******************************************************************************
* Static Function Declarations
******************************************************************************/
/*******************************************************************************
* Static Functions
******************************************************************************/
/*******************************************************************************
* Public Functions
******************************************************************************/
/*
* Load factory default settings
* System info, Data, Frequencies, etc.
*/
void SYS_LoadFactoryDefaults(void)
{
//System info
sprintf(sys.manufacturer, "UM");
sprintf(sys.modelNumber, "N/A");
sprintf(sys.modelName, "N/A");
sprintf(sys.serialNumber, "N/A");
sprintf(sys.mfgDate, "N/A");
//Data
//Frequencies
}
uint32_t SYS_GetLanguage(void)
{
return sys.language;
}
SYSTEM_DATA_t* system_getSys(void)
{
return &sys;
}
// monitor for overvoltage, power, current, etc.
// call from the main timer at 100Hz
void system_monitor(void)
{
// system level monitoring in timer ISR
}
void system_init(void)
{
memset(&sys, 0, sizeof(SYSTEM_DATA_t));
sys.systemTime = 0;
sys.safeMode = false;
sys.usbConnected = false;
sys.guiMode = GUI_MODE_NORMAL;
sys.activeAccessory = NULL;
sys.nextAccessory = NULL;
sys.maxPowerLimit = POWER_LIMIT_ALKALINE; // default until battery type determined.
sys.driver = driver_getDriver();
char *ver = SW_VERSION;
for (int i=0; i < strlen(ver); ++i)
{
if (isalpha(ver[i]))
{
sys.isBeta = true;
break;
}
}
stimer_init();
sys.h100HzTimer = stimer_start( 10, TIMER_MODE_PERIODIC, NULL, NULL);
sys.h10HzTimer = stimer_start( 100, TIMER_MODE_PERIODIC, NULL, NULL);
sys.h1HzTimer = stimer_start(1000, TIMER_MODE_PERIODIC, NULL, NULL);
}