/**
* Copyright(c) 2013 S2tek Technologies - All Rights Reserved.
*
* @file
*
* @brief The souce file of al PWM and GPIO cmd function
*
*/
#include "types.h"
#include <umf_debug.h>
#include "al_basictypes.h"
#include "board_config.h"
#include "util_ioctl.h"
#include "al_util.h"
#include "pin_config.h"

INT8 AL_GPIO_READ(UINT8 index, UINT8 *pValue)
{
	INT8 retval=-1;
	UINT8 getValue=0;
	retval=Cmd_gpio_Read(index,&getValue);
	*pValue=getValue;
	return retval;
}
INT8 AL_i2c_Read(UINT8 deviceID, UINT8 addr, UINT8 *pValue)
{
	INT8 retval=-1;
	UINT8 getValue=0;
	retval=Cmd_i2c_Read(deviceID, addr, &getValue);
	*pValue=getValue;
	return retval;	
}
INT8 AL_i2c_Write(UINT8 deviceID, UINT8 addr, UINT8 value)
{
	INT8 retval=-1;
	retval=Cmd_i2c_Write(deviceID, addr, value);
	return retval;	
}
INT8 AL_gpio_WriteOnLevel(UINT8 PinNum)
{
	INT8 retval=-1;
	retval=Cmd_gpio_WriteOnLevel(PinNum);
	return retval;	
}
INT8 AL_gpio_WriteOffLevel(UINT8 PinNum)
{
	INT8 retval=-1;
	retval=Cmd_gpio_WriteOffLevel(PinNum);
	return retval;	
}

INT8 AL_SET_LED_Flash_Status(AL_LED_CMD_t LEDcmd)
{
	INT8 retval=-1;
#ifdef LED_FLASH_MODE
	if(LEDcmd==LED_OFF)
	{
		retval=Cmd_SET_LED_Status(LED_OFF_LIGHT);
	}
	else
	{
		UINT8 LEDStatus=0x0;
		if(LEDcmd&LED_NORMAL)
		{
			if(LEDcmd&0x01)
			{
				LEDStatus|=LED_FLASH_NORMAL_LIGHT;
			}
		}
		if(LEDcmd&LED_SECOND)
		{
			if(LEDcmd&0x02)
			{
				LEDStatus|=LED_FLASH_FLASH_LIGHT;
			}
		}
		retval=Cmd_SET_LED_Status(LEDStatus);
	}
#endif
	return retval;	
}

