//###########################################################################
//
// FILE:    main.c
//
// TITLE:
//
// NOTES:
//  1)
//###########################################################################
//
//  Ver  | dd mmm yyyy | Who  		| Description of changes
// ======|=============|============|========================================
//  00 	   05 04 2015 	 HPCS
//
//  Texas Instruments, Inc
//  Copyright Texas Instruments 2008. All rights reserved.
//###########################################################################
#define MAIN 1

#include "system_defines.h"
#include "cyclone_device.h"
#include "variables.h"
#include "function_definitions.h"
#include "software_interrupts.h"
#include "cyclone_defines.h"
#include "pmbus_common.h"
#include "pmbus_topology.h"
#include "pmbus_constants.h"

void main()
{



        volatile  int i,j,temp;
        init_pmbus(0x58);
        init_adc();
        poll_adc();
        delay();
		//check_need_for_clearing_checksum();
		init_variables();
		dflash_variables.variables.board_mode=0;
		set_board_mode();
/*
 * Initialize the pheripherals. It is adviced to initialize them in the sequence below.
 *
 *  */
		initial_setup();
		//init_IDE();
		init_dpwm();
		init_filter();
		init_front_end();
		init_loop_mux();
		init_fault();
//		init_CBC();
		global_enable();

		restore_defaults();
		converter_state=PS_OFF;
//		ps_state = ENTRY;
		mini_state=WAIT;
		interrupt_clearer = FaultMuxRegs.FAULTMUXINTSTAT.all;
		init_interrupts();

	    i=0;
		for(;;)
		{

		pmbus_handler();
		fine_tune();
		calculate_values();
		//update_current_limit();
	   // check_for_errors();

		}

}
void c_int00(void)
{

		main();
}
