Refactor dds into dds and fgen
driver module started
This commit is contained in:
105
source/main.c
105
source/main.c
@@ -51,6 +51,7 @@
|
||||
#include "System/system.h"
|
||||
#include "io.h"
|
||||
#include "soft_timer.h"
|
||||
#include "driver.h"
|
||||
|
||||
extern volatile uint8_t BC_Duty_Cycle;
|
||||
|
||||
@@ -79,7 +80,8 @@ ClampData_t clampData;
|
||||
void setSafeMode(bool safe)
|
||||
{
|
||||
sys.safeMode = safe;
|
||||
Select_Estop((safe ? ISOLATED : CONNECTED));
|
||||
//Select_Estop((safe ? ISOLATED : CONNECTED));
|
||||
driver_isolateOutput(true);
|
||||
|
||||
if (safe)
|
||||
{
|
||||
@@ -119,84 +121,55 @@ static void init(void)
|
||||
CLOCK_SetupFROClocking(96000000U); // Set up high frequency FRO output for USB
|
||||
POWER_DisablePD(kPDRUNCFG_PD_USB0_PHY); /*Turn on USB Phy */
|
||||
|
||||
system_init();
|
||||
_firstInit = false;
|
||||
}
|
||||
|
||||
|
||||
Power_ON_OFF(ON); // Enable_Psu(); Ensure Power supply stays switched on.
|
||||
Select_Estop(ISOLATED); // Ensure output is ISOLATED from connections
|
||||
|
||||
Init_vars();
|
||||
driver_enablePower(true);
|
||||
driver_isolateOutput(true);
|
||||
|
||||
timer_init();
|
||||
SPI_Init();
|
||||
LCD_Init();
|
||||
|
||||
HWF_Init();
|
||||
FREQ_Init();
|
||||
Init_PSU_Pot(); // initialize pot.
|
||||
|
||||
Init_Ports(); // Ensure Ports are set to safe mode
|
||||
driver_init();
|
||||
ADC_SysInit();
|
||||
ACCY_Init();
|
||||
|
||||
io_expanderClearAll(false);
|
||||
io_backlightOn(true, NO_UPDATE);
|
||||
io_ampABOn(true, NO_UPDATE);
|
||||
io_update();
|
||||
|
||||
BL_ReadInfo();
|
||||
EE_LoadData(); //Read saved data
|
||||
|
||||
Display_Splash(); //Display splash screen
|
||||
|
||||
Display_Splash(); //Display splash screen
|
||||
Delay_Ticks(100); // execute short delay
|
||||
delayms(1000);
|
||||
|
||||
ADC_SysInit();
|
||||
ACCY_Init();
|
||||
|
||||
KEY_Init(); //Init keys after splash delay to prevent POWER short press on startup
|
||||
|
||||
//Init_Mode(); //
|
||||
|
||||
PWM_Setup(15890, 0); // switches off PWM
|
||||
driver_setDuty(0); // switches off PWM
|
||||
Delay_Ticks(100); // execute short delay
|
||||
|
||||
//Safety_Check(); // Check all voltages are safe to continue in DC.
|
||||
|
||||
Check_Bat_Id(); // Check for Alkaline or Lithium and battery insertion error.
|
||||
|
||||
init_flag = 0;
|
||||
|
||||
|
||||
if ((sys.adc.V_ID2 > 3.0) && (sys.adc.V_ID1 > 3.0))
|
||||
{
|
||||
Cur_Mode = BROADCAST;
|
||||
Port_changed_flag= 1;
|
||||
init_flag = 1;
|
||||
}
|
||||
|
||||
//Disconnect(ACCY_PORT_2);
|
||||
Delay_Ticks(30);
|
||||
|
||||
//Check_For_Clamp_On_Pwr_Up();
|
||||
|
||||
//Select_Output_Port();
|
||||
|
||||
//Safety_Check(); // Second time J.I.C Check all voltages are safe to continue in DC.
|
||||
|
||||
//Normal_Bypass_Chk();
|
||||
|
||||
old_freq = DUMMY_FRQ; //force a frequency on initialization
|
||||
frq_chg_tmr = 0;
|
||||
|
||||
//Update_Frequency();
|
||||
|
||||
// HACK
|
||||
Select_Estop(ISOLATED); // Restore output.
|
||||
|
||||
Init_Amplitude();
|
||||
|
||||
USB_Init();
|
||||
|
||||
Menu_init();
|
||||
|
||||
// Broadcast accessory is always connected
|
||||
ACCY_Connect(&sys.ports[ACCY_PORT_INDUCTION], ID_BROADCAST);
|
||||
ACCY_setActive(&sys.ports[ACCY_PORT_INDUCTION], CHANNEL_A);
|
||||
// ACCY_setActive(&sys.ports[ACCY_PORT_INDUCTION], CHANNEL_A);
|
||||
|
||||
sys.guiMode = GUI_MODE_NORMAL;
|
||||
}
|
||||
@@ -246,46 +219,33 @@ int main(void)
|
||||
}
|
||||
}
|
||||
|
||||
Delay_Ticks(1); //10mS delay
|
||||
//delayms(10); //10mS delay
|
||||
|
||||
KEY_Update();
|
||||
|
||||
//Tx_TimeOut(); // Check main transmitter timer
|
||||
|
||||
|
||||
if (stimer_fired(sys.hSysCheckTimer))
|
||||
if (stimer_fired(sys.h100HzTimer))
|
||||
{
|
||||
#if 0
|
||||
System_Check(); // Check all system functions
|
||||
Chk_Gain();
|
||||
|
||||
|
||||
if(catch_up_flag)
|
||||
{
|
||||
Delay_Ticks(10);
|
||||
Request_Current_Change(); // Request_Current_Change();
|
||||
catch_up_flag = false;
|
||||
}
|
||||
#endif
|
||||
stimer_clearFired(sys.hSysCheckTimer);
|
||||
KEY_Update();
|
||||
stimer_clearFired(sys.h100HzTimer);
|
||||
}
|
||||
|
||||
|
||||
// one second tasks
|
||||
if (stimer_fired(sys.hOneSecondTimer))
|
||||
// 1Hz tasks
|
||||
if (stimer_fired(sys.h1HzTimer))
|
||||
{
|
||||
// check for power off timeout
|
||||
|
||||
if (sys.usbConnected)
|
||||
{
|
||||
// send diagnostics
|
||||
//sprintf(tmpString, "Hello!");
|
||||
//USB_SendString(tmpString);
|
||||
}
|
||||
stimer_clearFired(sys.hOneSecondTimer);
|
||||
stimer_clearFired(sys.h1HzTimer);
|
||||
}
|
||||
|
||||
// 10Hz
|
||||
if(tickCount++ % 10 == 0)
|
||||
// 10Hz Tasks
|
||||
if (stimer_fired(sys.h10HzTimer))
|
||||
{
|
||||
stimer_clearFired(sys.h10HzTimer);
|
||||
|
||||
// check for accessories
|
||||
ACCY_service();
|
||||
|
||||
@@ -334,8 +294,9 @@ int main(void)
|
||||
{
|
||||
//mode_menu();
|
||||
// test accessory state machine
|
||||
ACCY_next();
|
||||
//ACCY_next();
|
||||
|
||||
ACCY_setActive(&sys.ports[ACCY_PORT_INDUCTION], CHANNEL_A);
|
||||
break;
|
||||
}
|
||||
#if 0
|
||||
|
||||
Reference in New Issue
Block a user