Refactor dds into dds and fgen
driver module started
This commit is contained in:
167
source/init.c
167
source/init.c
@@ -99,8 +99,8 @@ void Init_vars()
|
||||
|
||||
stimer_init();
|
||||
|
||||
sys.hSysCheckTimer = stimer_start(1000, TIMER_MODE_PERIODIC, NULL, NULL);
|
||||
sys.hOneSecondTimer = stimer_start(1000, 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);
|
||||
|
||||
Estop_timer = 0;
|
||||
Vchktmr = 0;
|
||||
@@ -165,67 +165,6 @@ void Clear_Flags()
|
||||
}
|
||||
|
||||
|
||||
void Init_Output(void)
|
||||
{
|
||||
|
||||
if(sys.adc.V_CHK < EXCEDED) // Read external voltage disable if present
|
||||
{
|
||||
|
||||
// Read_Tx_Ports(); // check for what's connected is controlled from timer interrupt
|
||||
|
||||
Init_Mode(); // default induction mode
|
||||
|
||||
|
||||
Update_Min_Frequency(); // determine frequency to be applied from last or if clamp or broadcast mode
|
||||
|
||||
Init_Amplitude(); // set amplitude to minimum
|
||||
|
||||
// Measure_Ohms(); // Done calculate Ohms
|
||||
|
||||
// Check_Taps(); // Done determine optimum taps etc
|
||||
|
||||
} //
|
||||
else
|
||||
Estop_Mode(); //
|
||||
|
||||
|
||||
}
|
||||
void Init_Mode()
|
||||
{
|
||||
uint8_t i;
|
||||
|
||||
// initialize until E2PROM fitted
|
||||
|
||||
for(i = 0; i <= MODE_MAX_NUM; i++ )
|
||||
{
|
||||
mode_Array[i].Selected = true;
|
||||
|
||||
}
|
||||
mode_Array[BROADCAST].Selected = true; //default BCAST always available
|
||||
mode_Array[PORT2_A].Selected = false;
|
||||
mode_Array[PORT2_B].Selected = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Cur_Mode = BROADCAST;
|
||||
Old_Mode = Cur_Mode;
|
||||
|
||||
Read_Tx_Ports(); // now scan external ports
|
||||
|
||||
}
|
||||
|
||||
void Init_Amplitude(void) // set amplitude to minimum
|
||||
{
|
||||
// if(Cur_Mode != BROADCAST)
|
||||
// {
|
||||
Dds_Pot_Val[0] = 0; // address
|
||||
Dds_Pot_Val[1] = Pot_Value[INIT_PWR_LEVEL]; // data
|
||||
SPI0_SendBytes(Dds_Pot_Val, 2, AMPLITUDE);
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
void Init_PWM_CLKS(void)
|
||||
@@ -246,14 +185,6 @@ void Init_Ext_Clk(void)
|
||||
|
||||
}
|
||||
|
||||
void Init_Int_Clk(void)
|
||||
{
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
void Init_PSU_Pot(void) // Set PSU_POT half way approx 23V
|
||||
{
|
||||
@@ -272,100 +203,6 @@ void Init_PSU_Pot(void) // Set PSU_POT half way approx 23V
|
||||
SPI0_SendBytes(Port_State, 3, EXPANDER);
|
||||
|
||||
|
||||
}
|
||||
|
||||
void Normal_Init(void)
|
||||
{
|
||||
|
||||
|
||||
Power_ON_OFF(ON); // Enable_Psu(); Ensure Power supply stays switched on.
|
||||
Select_Estop(ISOLATED); // Ensure output is ISOLATED from connections
|
||||
|
||||
|
||||
Init_vars();
|
||||
|
||||
|
||||
BL_ReadInfo();
|
||||
EE_LoadData(); //Read saved data
|
||||
|
||||
|
||||
Display_Splash(); //Display splash screen
|
||||
Delay_Ticks(200); // execute short delay
|
||||
KEY_Init(); //Init keys after splash delay to prevent POWER short press on startup
|
||||
|
||||
|
||||
Init_Mode(); //
|
||||
|
||||
PWM_Setup(15890, 0); // switches off PWM
|
||||
|
||||
|
||||
|
||||
Safety_Check(); // Check all voltages are safe to continue in DC.
|
||||
|
||||
|
||||
Check_Bat_Id(); // Check for Alkaline or Lithium and battery insertion error.
|
||||
|
||||
|
||||
|
||||
|
||||
what_val1=0;
|
||||
what_val2=0;
|
||||
Cur_Mode = PORT2_A;
|
||||
|
||||
init_flag = 0;
|
||||
for( i=0; i < 15; i++);
|
||||
{
|
||||
Delay_Ticks(10);
|
||||
Read_Tx_Ports(); // check for whats plugged in at the ports every 100mS.
|
||||
}
|
||||
|
||||
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();
|
||||
// Select_Bypass(OFF);
|
||||
|
||||
// HACK
|
||||
Select_Estop(CONNECTED); // Ensure output is ISOLATED from connections
|
||||
|
||||
Init_Amplitude();
|
||||
}
|
||||
|
||||
void Init_Pwr_Level_One(void)
|
||||
{
|
||||
if(!Init_Done)
|
||||
{
|
||||
Delay_Ticks(10); // Wait for Current to catch up
|
||||
inc_pwr(); // Set power level to 1
|
||||
Init_Done = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user