/*
 * VEML6031X00_Prototypes.h
 *
 * Created  : 20 August 2021
 * Modified : 13 June 2023
 * Author   : HWanyusof
 * Version	: 1.2
 */

#include "typedefinition.h"

/*Turn On/Off the Bandgap and LDO
 *VEML6031X00_SET_SD(Byte SD_Bit)
 *Byte SD_Bit - Input Parameter:
 *
 * VEML6031X00_SD_ON
 * VEML6031X00_SD_OFF
 *
 */
void VEML6031X00_SET_SD(Byte SD_Bit);

/*Turn On/Off the ALS IR Channel
 *VEML6031X00_SET_ALS_IR_SD(Byte SD_Bit)
 *Byte SD_Bit - Input Parameter:
 *
 * VEML6031X00_ALS_IR_SD_ON
 * VEML6031X00_ALS_IR_SD_OFF
 *
 */
void VEML6031X00_SET_ALS_IR_SD(Byte SD_Bit);

/*Set the Integration Time
 *VEML6031X00_SET_ALS_IT(Byte IntTime)
 *Byte IntTime - Input Parameter:
 *
 * VEML6031X00_ALS_IT_3_125ms
 * VEML6031X00_ALS_IT_6_25ms
 * VEML6031X00_ALS_IT_12_5ms
 * VEML6031X00_ALS_IT_25ms
 * VEML6031X00_ALS_IT_50ms
 * VEML6031X00_ALS_IT_100ms
 * VEML6031X00_ALS_IT_200ms
 * VEML6031X00_ALS_IT_400ms
 */
void VEML6031X00_SET_ALS_IT(Byte IntTime);

/*Enable/Disable Active Force or Auto Mode
 *VEML6031X00_SET_ALS_AF(Byte AF_Bit)
 *Byte AF_Bit - Input Parameter:
 *
 * VEML6031X00_ALS_AUTO
 * VEML6031X00_ALS_AF_EN
 */
void VEML6031X00_SET_ALS_AF(Byte AF_Bit);

/*Enable/Disable Trigger for AF Mode
 *VEML6031X00_SET_ALS_TRIG(Byte TriggerBit)
 *Byte TriggerBit - Input Parameter:
 *
 * VEML6031X00_ALS_TRIG_EN
 * VEML6031X00_ALS_TRIG_DIS
 */
void VEML6031X00_SET_ALS_TRIG(Byte TriggerBit);

/*Enable/Disable Interrupt
 *VEML6031X00_SET_ALS_INT_EN(Byte Interrupt)
 *Byte Interrupt - Input Parameter:
 *
 * VEML6031X00_ALS_INT_EN
 * VEML6031X00_ALS_INT_DIS
 */
void VEML6031X00_SET_ALS_INT_EN(Byte Interrupt);

/*Set effective PD size of ALS and IR channel
 *VEML6031X00_SET_PD_DIV4(Byte PD_Size)
 *Byte PD_Size - Input Parameter:
 *
 * VEML6031X00_PD_DIV4_FULL
 * VEML6031X00_PD_DIV4_QUARTER
 */
void VEML6031X00_SET_PD_DIV4(Byte PD_Size);

/*Set the Analog Gain
 *VEML6031X00_SET_ALS_GAIN(Byte Gain)
 *Byte Gain - Input Parameter:
 *
 * VEML6031X00_ALS_GAIN_x0_5
 * VEML6031X00_ALS_GAIN_x0_66
 * VEML6031X00_ALS_GAIN_x1
 * VEML6031X00_ALS_GAIN_x2
 */
void VEML6031X00_SET_ALS_GAIN(Byte Gain);

/*Set the Persistence
 *VEML6031X00_SET_PERS(Byte Pers)
 *Byte Pers - Input Parameter:
 *
 * VEML6031X00_ALS_PERS_1
 * VEML6031X00_ALS_PERS_2
 * VEML6031X00_ALS_PERS_4
 * VEML6031X00_ALS_PERS_8
 */
void VEML6031X00_SET_PERS(Byte Pers);

/*Set the ALS internal calibration (OTP Trigger)
 *VEML6031X00_SET_ALS_CAL(Byte als_cal)
 *Byte als_cal - Input Parameter:
 *
 * VEML6031X00_ALS_CAL_ON
 * VEML6031X00_ALS_CAL_OFF
 */
void VEML6031X00_SET_ALS_CAL(Byte als_cal);

/*Set the High Threshold
 *VEML6031X00_SET_ALS_HighThreshold(Word HighThreshold)
 *Word HighThreshold - Input Parameter:
 *
 * Value between 0d0 and 0d65535
 */
void VEML6031X00_SET_ALS_HighThreshold(Word HighThreshold);

/*Set the Low threshold
 *VEML6031X00_SET_ALS_LowThreshold(Word LowThreshold)
 *Word LowThreshold - Input Parameter:
 *
 * Value between 0d0 and 0d65535
 */
void VEML6031X00_SET_ALS_LowThreshold(Word LowThreshold);

/*Read the ALS Data
 *VEML6031X00_GET_ALS_DATA() returns ALS Data between 0d0 and 0d65535
 */
Word VEML6031X00_GET_ALS_DATA();

/*Read the IR Channel Data
 *VEML6031X00_GET_IR_DATA() returns IR Data between 0d0 and 0d65535
 */
Word VEML6031X00_GET_IR_DATA();

/*Read the ALS Interrupt Flag
 *VEML6031X00_GET_ALS_INT() returns interrupt flag status.
 *Please refer to Table 8 in the Datasheet page 10
 */
Byte VEML6031X00_GET_ALS_INT();

/*Read Register value
 *VEML6031X00_READ_Reg(Byte Reg)
 *Byte Reg - Input Parameter:
 *
 * VEML6031X00_ALS_CONF_0
 * VEML6031X00_ALS_WH_LB
 * VEML6031X00_ALS_WL_LB
 * VEML6031X00_ALS_DATA_LB
 * VEML6031X00_IR_DATA_LB
 * VEML6031X00_ID_CODE1
 * VEML6031X00_ALS_INT
 *
 *returns Register Value between 0d0/0x00 and 0d65535/0xFFFF
 */
Word VEML6031X00_READ_Reg(Byte Reg);

/*Read the SD bit
 *returns 1 for Shutdown and 0 for Bandgap and LDO On
 */
bool VEML6031X00_GET_SD_Bit();

/*Read the ALS_IR_SD bit
 *returns 0 for ALS IR channel on and 1 for shutdown
 */
bool VEML6031X00_GET_ALS_IR_SD_Bit();

/*Read the ALS_AF bit
 *returns 1 for AF Mode and 0 for Auto Mode
 */
bool VEML6031X00_GET_ALS_AF_Bit();

/*Read the ALS_IT bits
 *returns 0d0 - 0d8 depending on ALS_IT bits
 */
int VEML6031X00_GET_ALS_IT_Bits();

/*Read the ALS_GAIN bits
 *returns 0d0 - 0d4 depending on ALS_GAIN bits
 */
int VEML6031X00_GET_ALS_GAIN_Bits();

/*Read the PD_DIV4 bit
 *returns 1 for 1/4 PD size being used and 0 for full (4/4) PD size being used
 */
bool VEML6031X00_GET_PD_DIV4_Bit();

/*Read Device ID
 *Returns ID
 */
Word VEML6031X00_GET_ID();

/*Read the AF_DATA_READY flag
 *returns 1 for AF_DATA_READY flag and 0 for no AF_DATA_READY flag
 */
bool VEML6031X00_GET_AF_DATA_READY_FLAG();
