/*****************************************************************************
* (c) Copyright  Actel Corporation. All rights reserved.
*
*ACE configuration .c file
*Created by Actel MSS_ACE Configurator Thu Dec 08 19:32:25 2011
*
*/

#include "../../drivers/mss_ace/mss_ace_configurator.h"
#include "ace_config.h"
#include "ace_handles.h"

#include <stdint.h>


#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------------------------
*AB Configuration
*---------------------------------------------------------------------------*/
ace_adc_config_t g_ace_adc_config[ACE_NB_OF_ADC] = 
{
	{
        1024,                      /* uint16_t adc_resolution */
        2560                       /* uint16_t va_ref */
	},
	{
        1024,                      /* uint16_t adc_resolution */
        2560                       /* uint16_t va_ref */
	}
};

/*-----------------------------------------------------------------------------
*Current Monitor External Resistor Value ( milli-ohms )
*---------------------------------------------------------------------------*/
const uint16_t g_ace_current_resistors[ACE_NB_OF_CURRENT_MONITORS] = 
{
	1,	/*CM0 ( NOT USED AS CURRENT MONITOR ) */
	1,	/*CM1 ( NOT USED AS CURRENT MONITOR ) */
	1,	/*CM2 ( NOT USED AS CURRENT MONITOR ) */
	1	/*CM3 ( NOT USED AS CURRENT MONITOR ) */
};

/*-----------------------------------------------------------------------------
*External VAREF usage
*---------------------------------------------------------------------------*/
const uint8_t g_ace_external_varef_used[ACE_NB_OF_ADC] = 
{
	0,
	0
};

/*-----------------------------------------------------------------------------
*Analog Channels
*---------------------------------------------------------------------------*/
/* Names*/
const uint8_t g_ace_channel_0_name[] = "VoltageMonitor_0";
const uint8_t g_ace_channel_1_name[] = "VoltageMonitor_1";
const uint8_t g_ace_channel_2_name[] = "VoltageMonitor_3";
const uint8_t g_ace_channel_3_name[] = "VoltageMonitor_2";
const uint8_t g_ace_channel_4_name[] = "VoltageMonitor_7";
const uint8_t g_ace_channel_5_name[] = "VoltageMonitor_6";
const uint8_t g_ace_channel_6_name[] = "VoltageMonitor_4";
const uint8_t g_ace_channel_7_name[] = "VoltageMonitor_5";

/* Number of Flags per Channel*/
#define CHANNEL_0_NB_OF_FLAGS           0
#define CHANNEL_1_NB_OF_FLAGS           0
#define CHANNEL_2_NB_OF_FLAGS           0
#define CHANNEL_3_NB_OF_FLAGS           0
#define CHANNEL_4_NB_OF_FLAGS           0
#define CHANNEL_5_NB_OF_FLAGS           0
#define CHANNEL_6_NB_OF_FLAGS           0
#define CHANNEL_7_NB_OF_FLAGS           0

/* Input Channel to Flag Array Association*/

/* Channel Table*/
ace_channel_desc_t g_ace_channel_desc_table[ACE_NB_OF_INPUT_CHANNELS] = 
{
	{
        g_ace_channel_0_name,      /* const uint8_t * p_sz_channel_name */
        ABPS0,                     /* adc_channel_id_t signal_id; */
        14,                        /* uint16_t signal_ppe_offset */
        CHANNEL_0_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	},
	{
        g_ace_channel_1_name,      /* const uint8_t * p_sz_channel_name */
        ABPS1,                     /* adc_channel_id_t signal_id; */
        23,                        /* uint16_t signal_ppe_offset */
        CHANNEL_1_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	},
	{
        g_ace_channel_2_name,      /* const uint8_t * p_sz_channel_name */
        ABPS2,                     /* adc_channel_id_t signal_id; */
        32,                        /* uint16_t signal_ppe_offset */
        CHANNEL_2_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	},
	{
        g_ace_channel_3_name,      /* const uint8_t * p_sz_channel_name */
        ABPS3,                     /* adc_channel_id_t signal_id; */
        41,                        /* uint16_t signal_ppe_offset */
        CHANNEL_3_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	},
	{
        g_ace_channel_4_name,      /* const uint8_t * p_sz_channel_name */
        ABPS4,                     /* adc_channel_id_t signal_id; */
        50,                        /* uint16_t signal_ppe_offset */
        CHANNEL_4_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	},
	{
        g_ace_channel_5_name,      /* const uint8_t * p_sz_channel_name */
        ABPS5,                     /* adc_channel_id_t signal_id; */
        59,                        /* uint16_t signal_ppe_offset */
        CHANNEL_5_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	},
	{
        g_ace_channel_6_name,      /* const uint8_t * p_sz_channel_name */
        ABPS6,                     /* adc_channel_id_t signal_id; */
        68,                        /* uint16_t signal_ppe_offset */
        CHANNEL_6_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	},
	{
        g_ace_channel_7_name,      /* const uint8_t * p_sz_channel_name */
        ABPS7,                     /* adc_channel_id_t signal_id; */
        77,                        /* uint16_t signal_ppe_offset */
        CHANNEL_7_NB_OF_FLAGS,     /* uint16_t nb_of_flags */
        0                          /* uint16_t * p_flags_array */
	}
};

/*-----------------------------------------------------------------------------
*Threshold Flags
*---------------------------------------------------------------------------*/
/* Flag Names*/
/* Flag Table*/


/*-----------------------------------------------------------------------------
*PPE Linear Transforms
*---------------------------------------------------------------------------*/
const ppe_transforms_desc_t g_ace_ppe_transforms_desc_table[ACE_NB_OF_INPUT_CHANNELS] = 
{
	{
        16,                        /* uint16_t    m_ppe_offset */
        17,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	},
	{
        25,                        /* uint16_t    m_ppe_offset */
        26,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	},
	{
        34,                        /* uint16_t    m_ppe_offset */
        35,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	},
	{
        43,                        /* uint16_t    m_ppe_offset */
        44,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	},
	{
        52,                        /* uint16_t    m_ppe_offset */
        53,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	},
	{
        61,                        /* uint16_t    m_ppe_offset */
        62,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	},
	{
        70,                        /* uint16_t    m_ppe_offset */
        71,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	},
	{
        79,                        /* uint16_t    m_ppe_offset */
        80,                        /* uint16_t    c_ppe_offset */
        0xc000,                    /* int16_t     default_m2 */
        0xffff                     /* int16_t     default_c2 */
	}
};

/*-----------------------------------------------------------------------------
*Sequencer Procedures
*---------------------------------------------------------------------------*/
/* Procedure Name and Microcode*/
const uint8_t g_ace_sse_proc_0_name[] = "ADC0_MAIN";
const uint16_t g_ace_sse_proc_0_sequence[] = 
{
	0x1704, 0x1601, 0x1200 
};

const uint8_t g_ace_sse_proc_1_name[] = "ADC1_MAIN";
const uint16_t g_ace_sse_proc_1_sequence[] = 
{
	0x2704, 0x2601, 0x2200 
};

const uint8_t g_ace_sse_proc_2_name[] = "seq_adc00";
const uint16_t g_ace_sse_proc_2_sequence[] = 
{
	0x1704, 0x1601, 0x1562, 0x14c6, 
	0x0000, 0x1562, 0x14c5, 0x0000, 
	0x1f02, 0x1200 
};

const uint8_t g_ace_sse_proc_3_name[] = "seq_adc10";
const uint16_t g_ace_sse_proc_3_sequence[] = 
{
	0x2704, 0x2601, 0x2562, 0x24c2, 
	0x0000, 0x2562, 0x24c1, 0x0000, 
	0x2f01, 0x2200 
};

const uint8_t g_ace_sse_proc_4_name[] = "twoAdcs";
const uint16_t g_ace_sse_proc_4_sequence[] = 
{
	0x1704, 0x1601, 0x1562, 0x1401, 
	0x2562, 0x2405, 0x0233, 0x0000, 
	0x1562, 0x1402, 0x2562, 0x2406, 
	0x0233, 0x0000, 0x1f01, 0x1200 
};



/* Procedure Table*/
ace_procedure_desc_t g_sse_sequences_desc_table[ACE_NB_OF_SSE_PROCEDURES] = 
{
	{
        g_ace_sse_proc_0_name,                              /* const uint8_t * p_sz_proc_name */
        2,                                                  /* uint16_t sse_loop_pc */
        0,                                                  /* uint16_t sse_load_offset */
        sizeof(g_ace_sse_proc_0_sequence) / sizeof(uint16_t), /* uint16_t sse_ucode_length */
        g_ace_sse_proc_0_sequence,                          /* const uint16_t * sse_ucode */
        0                                                   /* uint8_t sse_pc_id */
	},
	{
        g_ace_sse_proc_1_name,                              /* const uint8_t * p_sz_proc_name */
        5,                                                  /* uint16_t sse_loop_pc */
        3,                                                  /* uint16_t sse_load_offset */
        sizeof(g_ace_sse_proc_1_sequence) / sizeof(uint16_t), /* uint16_t sse_ucode_length */
        g_ace_sse_proc_1_sequence,                          /* const uint16_t * sse_ucode */
        1                                                   /* uint8_t sse_pc_id */
	},
	{
        g_ace_sse_proc_2_name,                              /* const uint8_t * p_sz_proc_name */
        8,                                                  /* uint16_t sse_loop_pc */
        6,                                                  /* uint16_t sse_load_offset */
        sizeof(g_ace_sse_proc_2_sequence) / sizeof(uint16_t), /* uint16_t sse_ucode_length */
        g_ace_sse_proc_2_sequence,                          /* const uint16_t * sse_ucode */
        0                                                   /* uint8_t sse_pc_id */
	},
	{
        g_ace_sse_proc_3_name,                              /* const uint8_t * p_sz_proc_name */
        18,                                                 /* uint16_t sse_loop_pc */
        16,                                                 /* uint16_t sse_load_offset */
        sizeof(g_ace_sse_proc_3_sequence) / sizeof(uint16_t), /* uint16_t sse_ucode_length */
        g_ace_sse_proc_3_sequence,                          /* const uint16_t * sse_ucode */
        1                                                   /* uint8_t sse_pc_id */
	},
	{
        g_ace_sse_proc_4_name,                              /* const uint8_t * p_sz_proc_name */
        28,                                                 /* uint16_t sse_loop_pc */
        26,                                                 /* uint16_t sse_load_offset */
        sizeof(g_ace_sse_proc_4_sequence) / sizeof(uint16_t), /* uint16_t sse_ucode_length */
        g_ace_sse_proc_4_sequence,                          /* const uint16_t * sse_ucode */
        0                                                   /* uint8_t sse_pc_id */
	}
};


#ifdef __cplusplus
}
#endif

