/*************************************************  
  File name     : hal_interface_temp_sensor.c
  Module        : hal temp_senso library interface
  Author        : 
  Version       :
  Created on    : 2020-10-20
  Description   :
      Data structure and function definitions required by 
      the temp_senso interface
    
  Modify History:   
  1. Date:        Author:         Modification:
  2020-10-20    amir.liang         create
*************************************************/
#include "pal.h"
#include "hal_product_config.h"
#include "hal_interface_temp_sensor.h"


#if (HAL_CFG_TEMP_SENSOR_TYPE ==  HAL_CFG_TEMP_SENSOR_TYPE_T31)

#elif (HAL_CFG_TEMP_SENSOR_TYPE ==  HAL_CFG_TEMP_SENSOR_TYPE_MCU)
#include "temp_sensor_mcu.h"
#elif (HAL_CFG_TEMP_SENSOR_TYPE ==  HAL_CFG_TEMP_SENSOR_TYPE_6441)
#include "temp_sensor_atbm6441.h"
#endif


static ST_HAL_TEMP_SENSOR_INTERFACE gHalTempSensorInterface[] =
{
    #if (HAL_CFG_TEMP_SENSOR_TYPE ==  HAL_CFG_TEMP_SENSOR_TYPE_T31)
    {
        .pfnInit = NULL,
        .pfnDeinit = NULL,
        .pfnGetTemp = NULL,
        .pfnSetAlarmLevel = NULL,
        .pfnGetAlarmLevel = NULL,
    }
    #elif (HAL_CFG_TEMP_SENSOR_TYPE ==  HAL_CFG_TEMP_SENSOR_TYPE_MCU)
    {
        .pfnInit = Mcu_TempSensor_Init,
        .pfnDeinit = Mcu_TempSensor_Deinit,
        .pfnGetTemp = Mcu_TempSensor_GetTemp,
        .pfnSetAlarmLevel = Mcu_TempSensor_SetAlarmLevel,
        .pfnGetAlarmLevel = Mcu_TempSensor_GetAlarmLevel,
    }
    #elif (HAL_CFG_TEMP_SENSOR_TYPE ==  HAL_CFG_TEMP_SENSOR_TYPE_6441)
    {
        .pfnInit = Atbm6441_TempSensor_Init,
        .pfnDeinit = Atbm6441_TempSensor_Deinit,
        .pfnGetTemp = Atbm6441_TempSensor_GetTemp,
        .pfnSetAlarmLevel = Atbm6441_TempSensor_SetAlarmLevel,
        .pfnGetAlarmLevel = Atbm6441_TempSensor_GetAlarmLevel,
    }
    #endif
};


ST_HAL_TEMP_SENSOR_INTERFACE * HAL_TempSensor_GetInterface(int32_t Channel)
{
#if (HAL_CFG_TEMP_SENSOR_TYPE == HAL_TYPE_NONE)
    return NULL;
    
#else
    HAL_ITF_INDEX idx = HAL_SELF;

    if ( Channel == HAL_CHANNEL_SELF )
    {
        idx = HAL_SELF;
    }
    else
    {
        // 需要从NV获取通道号Channel对应的设备类型对应的hal
        //idx = HAL_REMOTE_SUB1G;
        return NULL;
    }

    return &gHalTempSensorInterface[idx];
#endif
}

