/*************************************************
  File name     : hal_interface_pir.c
  Module        : hal pir library interface
  Author        : 
  Version       :
  Created on    : 2020-10-20
  Description   :
      Data structure and function definitions required by
      the pir interface

  Modify History:
  1. Date:        Author:         Modification:
  2020-10-20    amir.liang         create
*************************************************/
#include "pal.h"
#include "hal_interface_pir.h"
#include "hal_product_config.h"
#include "hal_interface.h"


#ifndef HAL_CFG_PIR_TYPE
#error HAL_CFG_PIR_TYPE undefined !!! Go to "hal_gernerate_product_config_h.sh" settings
#endif


#if (HAL_CFG_PIR_TYPE ==  HAL_CFG_PIR_TYPE_T31)
#include "pir_pyd1598.h"

#elif (HAL_CFG_PIR_TYPE ==  HAL_CFG_PIR_TYPE_MCU)
#include "pir_mcu.h"
#elif (HAL_CFG_PIR_TYPE ==  HAL_CFG_PIR_TYPE_6441)
#include "pir_atbm6441.h"
#endif


ST_HAL_PIR_INTERFACE g_HAL_PIR_Itf[] =
{
#if (HAL_CFG_PIR_TYPE ==  HAL_CFG_PIR_TYPE_T31)
    {
        .pfnInit = HAL_PIR_Pyt1598_Init,
        .pfnDeinit = HAL_PIR_Pyt1598_Deinit,
        .pfnSetSensitivity = HAL_PIR_Pyt1598_SetSensitivity,
        .pfnGetSensitivity = HAL_PIR_Pyt1598_GetSensitivity,
        .pfnSetSwitch = HAL_PIR_Pyt1598_SetSwitch,
        .pfnGetSwitch = HAL_PIR_Pyt1598_GetSwitch,
        .pfnSetQuiescentTime = HAL_PIR_Pyt1598_SetQuietSilentTime,
        .pfnGetQuiescentTime = HAL_PIR_Pyt1598_GetQuietSilentTime,
        .pfnGetStatisticsCnt = HAL_PIR_Pyt1598_GetStatisticsCnt,
        .pfnEnableTestMode = HAL_PIR_Pyt1598_EnableTestMode,
    },
#elif (HAL_CFG_PIR_TYPE == HAL_CFG_PIR_TYPE_6441)
    {
        .pfnInit = HAL_PIR_atbm6441_Init,
        .pfnDeinit = HAL_PIR_atbm6441_Deinit,
        .pfnSetSensitivity = HAL_PIR_atbm6441_SetSensitivity,
        .pfnGetSensitivity = HAL_PIR_atbm6441_GetSensitivity,
        .pfnSetSwitch = HAL_PIR_atbm6441_SetSwitch,
        .pfnGetSwitch = HAL_PIR_atbm6441_GetSwitch,
        .pfnSetQuiescentTime = HAL_PIR_atbm6441_SetQuietSilentTime,
        .pfnGetQuiescentTime = HAL_PIR_atbm6441_GetQuietSilentTime,
        .pfnGetStatisticsCnt = HAL_PIR_atbm6441_GetStatisticsCnt,
        .pfnEnableTestMode = HAL_PIR_atbm6441_EnableTestMode,
    },
#elif (HAL_CFG_PIR_TYPE ==  HAL_CFG_PIR_TYPE_MCU)
    {
        .pfnInit = mcu_pir_Init,
        .pfnDeinit = mcu_pir_Deinit,
        .pfnSetSensitivity = mcu_pir_SetSensitivity,
        .pfnGetSensitivity = mcu_pir_GetSensitivity,
        .pfnSetSwitch = mcu_pir_SetSwitch,
        .pfnGetSwitch = mcu_pir_GetSwitch,
        .pfnSetQuiescentTime = mcu_pir_SetQuietSilentTime,
        .pfnGetQuiescentTime = mcu_pir_GetQuietSilentTime,
        .pfnGetStatisticsCnt = NULL,
        .pfnEnableTestMode = mcu_pir_EnableTestMode,
    },
#endif
};

ST_HAL_PIR_INTERFACE *HAL_PIR_GetInterface(int32_t channel)
{

#if (HAL_CFG_PIR_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 &g_HAL_PIR_Itf[idx];
#endif

}

