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

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

#if (HAL_CFG_LOCK_TYPE ==  HAL_CFG_LOCK_TYPE_T31)

#elif (HAL_CFG_LOCK_TYPE ==  HAL_CFG_LOCK_TYPE_MCU)
#include "lock_mcu.h"
#endif

ST_HAL_LOCK_INTERFACE gHalLockInterface[] = 
{
#if (HAL_CFG_LOCK_TYPE ==  HAL_CFG_LOCK_TYPE_T31)
        {
            .pfnInit             = NULL,
            .pfnDeinit           = NULL,
            .pfnCtrl             = NULL,
            .pfnGetStatus        = NULL,
            .pfnSetOpenTimeout   = NULL,
            .pfnGetOpenTimeout   = NULL,
            .pfnSetLockType      = NULL,
            .pfnGetLockType      = NULL,
         },
#elif (HAL_CFG_LOCK_TYPE ==  HAL_CFG_LOCK_TYPE_MCU)
          {
            .pfnInit             = Mcu_Lock_Init,
            .pfnDeinit           = Mcu_Lock_Deinit,
            .pfnCtrl             = Mcu_Lock_Ctrl,
            .pfnGetStatus        = Mcu_Lock_GetStatus,
            .pfnSetOpenTimeout   = Mcu_Lock_SetOpenTimeout,
            .pfnGetOpenTimeout   = Mcu_Lock_GetOpenTimeout,
            .pfnSetLockType      = Mcu_Lock_SetLockType,
            .pfnGetLockType      = Mcu_Lock_GetLockType,
         },
#endif
};

ST_HAL_LOCK_INTERFACE * HAL_Lock_GetInterface(int32_t Channel)
{
#if (HAL_CFG_LOCK_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 &gHalLockInterface[idx];
#endif
}

