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

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


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


#if (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_T31)
#include "led_t31.h"

#elif (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_MCU)
#include "led_mcu.h"


#elif (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_SN3218A)
#include "led_sn3218a.h"

#elif (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_6441)
#include "led_atbm6441.h"

#endif

ST_HAL_LED_INTERFACE g_HAL_LED_Itf[] =
{
#if (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_T31)
{
    .pfnInit = t31_led_init,
    .pfnDeinit = t31_led_deinit,
    .pfnSetBrightness = t31_led_set_brightness,
    .pfnEnable = t31_led_enable,
    .pfnBlink = t31_led_blink,
    .pfnBreath = t31_led_breath,
    .pfnHorseRace = NULL,
},
#elif (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_MCU)
{
    .pfnInit = mcu_led_init,
    .pfnDeinit = mcu_led_deinit,
    .pfnSetBrightness = mcu_led_set_brightness,
    .pfnEnable = mcu_led_enable,
    .pfnBlink = mcu_led_blink,
    .pfnBreath = mcu_led_breath,
    .pfnHorseRace = NULL,
},
#elif (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_SN3218A)
{
	.pfnInit = sn3218a_led_init,
	.pfnDeinit = sn3218a_led_deinit,
	.pfnSetBrightness = sn3218a_led_set_brightness,
	.pfnEnable = sn3218a_led_enable,
	.pfnBlink = sn3218a_led_blink,
	.pfnBreath = sn3218a_led_breath,
	.pfnHorseRace = sn3218a_led_HorseRace,
},
#elif (HAL_CFG_LED_TYPE ==  HAL_CFG_LED_TYPE_6441)
{
	.pfnInit = atbm6441_led_init,
	.pfnDeinit = atbm6441_led_deinit,
	.pfnSetBrightness = atbm6441_led_set_brightness,
	.pfnEnable = atbm6441_led_enable,
	.pfnBlink = atbm6441_led_blink,
	.pfnBreath = atbm6441_led_breath,
	.pfnHorseRace = atbm6441_led_HorseRace,
},
#endif
};

ST_HAL_LED_INTERFACE *HAL_Led_GetInterface(int32_t Channel)
{

#if (HAL_CFG_LED_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_LED_Itf[idx];
#endif

}

