/*
 * Implement sensor driver function in here.
 * Every sensor include init,write,read function.
 * Author:Jimbo
 */
#include "sensor_tbl.h"
#include "sensor_thread.h"
#include <stdio.h>
#include "bmc_main.h"
//static sensor_tbl_t sensor_tbl[]=
sensor_tbl_t sensor_tbl[]=
{
	//lm73_1
	{
		0,		//sensor number
		10,		//power on delay
		3,		//reset delay
		2,		//Monitor interval
		MonitorOnStandby,	//monitor states
		lm73_1_read,	//read function
		lm73_1_write,	//write functon
		lm73_1_init,	//init function
	},
	/*lm73_2*/
	{
		1,
		10,		//power on delay
		3,		//reset delay
		2,		//Monitor interval
		MonitorOnStandby,	//monitor states
		lm73_2_read,
		lm73_2_write,
		lm73_2_init,
	},
	/*INA220_3V3*/
	{
		2,
		10,		//power on delay
		3,		//reset delay
		2,		//Monitor interval
		MonitorOnStandby,	//monitor states
		INA220_3V3_Volts_read,
		INA220_3V3_Volts_write,
		INA220_3V3_Volts_init,
	},
        /*INA220_5V0*/
        {
                3,
                10,             //power on delay
                3,              //reset delay
                2,             //Monitor interval
                MonitorOnStandby,       //monitor states
                INA220_5V0_Volts_read,
                INA220_5V0_Volts_write,
                INA220_5V0_Volts_init,
        },
        /*INA220_12V0*/
        {
                4,
                10,             //power on delay
                3,              //reset delay
                2,             //Monitor interval
                MonitorOnStandby,       //monitor states
                INA220_12V0_Volts_read,
                INA220_12V0_Volts_write,
                INA220_12V0_Volts_init,
        },

        /*INA220_3V3*/
        {
                5,
                10,             //power on delay
                3,              //reset delay
                2,             //Monitor interval
                MonitorOnStandby,       //monitor states
                INA220_3V3_Amps_read,
                INA220_3V3_Amps_write,
                INA220_3V3_Amps_init,
        },
        /*INA220_5V0*/
        {
                6,
                10,             //power on delay
                3,              //reset delay
                2,             //Monitor interval
                MonitorOnStandby,       //monitor states
                INA220_5V0_Amps_read,
                INA220_5V0_Amps_write,
                INA220_5V0_Amps_init,
        },
        /*INA220_12V0*/
        {
                7,
                10,             //power on delay
                3,              //reset delay
                2,             //Monitor interval
                MonitorOnStandby,       //monitor states
                INA220_12V0_Amps_read,
                INA220_12V0_Amps_write,
                INA220_12V0_Amps_init,
        },

	{ 0 }  /* dummy entry when 0 sensors */ 
};

sensor_tbl_t *getSensorDev(uint8_t sensorNum)
{
	uint8_t temp=0;
	temp = sizeof(sensor_tbl)/sizeof(sensor_tbl_t);
//	printf("sensor_tbl size:%d, sensor_tbl_t size:%d\n", sizeof(sensor_tbl), sizeof(sensor_tbl_t));
	if(temp != MAX_SENSOR_NUM+1)	//there is a dummy entry
	{
		printf("Error: Invalid sensor table!\n");
		return NULL;
	}

	if(sensorNum >= MAX_SENSOR_NUM)
	{
		printf("Error: Ivalid sensor number!\n");
		return NULL;
	}
	
	return &sensor_tbl[sensorNum];
}


