32 #pragma GCC diagnostic ignored "-pedantic"
56 unsigned char cmd = (
unsigned char) state;
67 unsigned char partID = 0x00;
79 unsigned int channelValue = 0;
103 float AL_Lux(
unsigned int ch0,
unsigned int ch1)
108 if((k>=0)&& (k<=0.52))
109 Lux=(0.0315*ch0)-(0.0593*ch0*pow(k,1.4));
110 else if((k>0.52)&& (k<=0.65))
111 Lux=(0.0229*ch0)-(0.0291*ch1);
112 else if((k>0.65)&& (k<=0.80))
113 Lux=(0.0157*ch0)-(0.0180*ch1);
114 else if((k>0.80)&& (k<=1.30))
115 Lux=(0.00338*ch0)-(0.00260*ch1);
128 unsigned char value = 0;
244 buffer[1] = (
unsigned char) (data >> 8);
245 buffer[0] = (
unsigned char) (data && 0xff);
275 char buff[2] = {0x00,0x00};
276 bcm2835_i2c_read(buff,2);
278 return (buff[1] << 8)|buff[0];
void APDS9300_WriteWord(unsigned char reg, unsigned int data)
Writes a word to the specific register.
unsigned int APDS9300_ReadWord(void)
Read a single word from the sensor. Assumes register pointer is preset.
void AL_SetSamplingTime(sampTime_t sampling_time)
Sets the sampling time for the sensor,can be one of three predetermined values.
unsigned char buffer[256]
void AL_SetIntHighThreshold(unsigned int highthreshvalue)
Sets the high threshold value for the interrupt.
void I2C_WriteByte(char bdata)
Writes a byte value to the I2C bus. This assumes the register pointer is preset.
unsigned char AL_ChipID(void)
Returns the CHIP id.
unsigned char AL_Initialize(void)
Powers on the sensor , sets sensor gain to 1x and clears any existing interrupts. ...
void I2C_WriteByteRegister(unsigned char reg, unsigned char data)
Writes a byte value to a register address.
void AL_SetIntLowThreshold(unsigned int lowthreshvalue)
Sets the low threshold value for the interrupt.
unsigned char AL_SetGain(gain val)
Set sensor gain. Default gain value is GAIN_1 or 1x.
void AL_PowerState(powerState state)
Set the sensor power state to either POWER_ON or POWER_OFF.
void AL_ConfigureInterrupt(unsigned char enable, unsigned char persistence)
Enables or disables the interrupt and sets the persistence of interrupt occurences The interrupt will...
unsigned int APDS9300_ReadWordReg(char reg)
Read word from register.
void APDS9300_WriteByte(unsigned char data)
Writes a single byte of data to the current sensor register. Function assumes that I2C peripheral is ...
void AL_Clear_Interrupt(void)
Clear any existing interrupts.
APDS9300 driver header file.
void I2C_WriteWordRegister(unsigned char reg, unsigned char *data)
Writes a word value (16 bit) to a register address.
unsigned char I2C_ReadByteRegister(char reg)
Reads a byte from a register.
unsigned int AL_ReadChannel(channel chan)
Reads the value from one of the two photodiode channels.
char APDS9300_ReadByte(char reg)
Reads a single byte from the given sensor register.
float AL_Lux(unsigned int ch0, unsigned int ch1)
Computes LUX ambient light value from sensor data.
unsigned int I2C_ReadWordRegisterRS(char reg)
Readm result from a word length register.
void APDS9300_WriteRegister(unsigned char reg, unsigned char data)
Writes a byte to the specific register.