Sensorian  1.0
C API Reference Guide Library
APDS9300.h File Reference

APDS9300 driver header file. More...

#include "bcm2835.h"
#include <stdlib.h>

Go to the source code of this file.

Macros

#define APDS9300ADDR   0x29
 The I2C address of the APDS9300 ambient light sensor. More...
 
#define CONTROL   0x00
 
#define TIMING   0x01
 
#define THRESHLOWLOW   0x02
 
#define THRESHLOWHIGH   0x03
 
#define THRESHHIGHLOW   0x04
 
#define THRESHHIGHHIGH   0x05
 
#define INTERRUPT   0x06
 
#define CRC   0x08
 
#define ID   0x0A
 
#define DATA0LOW   0x0C
 
#define DATA0HIGH   0x0D
 
#define DATA1LOW   0x0E
 
#define DATA1HIGH   0x0F
 
#define COMMAND   0x80
 
#define CMD_CLEAR_INT   0x40
 
#define CMD_WORD   0x20
 
#define POWERON   0x03
 
#define POWEROFF   0x00
 
#define GAIN   0x10
 
#define MANUAL   0x08
 
#define INTEG13_7MS   0x00
 
#define INTEG101MS   0x01
 
#define INTEG402MS   0x02
 
#define MANUAL_INTEG   0x03
 
#define INTERR_DISMASK   0xCF
 
#define INTERR_ENA   0x10
 
#define EVERYCYCLE   0x00
 
#define OUTSIDE_THRESH   0x01
 
#define PER2_OUT_RANGE   0x02
 
#define PER4_OUT_RANGE   0x04
 
#define PER10_OUT_RANGE   0x0A
 
#define PER15_OUT_RANGE   0x0F
 

Enumerations

enum  channel { CH0, CH1, CH0, CH1 }
 
enum  gain { GAIN_1 =0, GAIN_16 =1, GAIN_1 =0, GAIN_16 =1 }
 
enum  powerState { POWER_ON =0x03, POWER_OFF =0x00, POWER_ON =0x03, POWER_OFF =0x00 }
 
enum  sampTime_t {
  S1 = INTEG13_7MS, S2 = INTEG101MS, S3 = INTEG402MS, S1 = INTEG13_7MS,
  S2 = INTEG101MS, S3 = INTEG402MS
}
 

Functions

unsigned char AL_Initialize (void)
 Powers on the sensor , sets sensor gain to 1x and clears any existing interrupts. More...
 
void AL_PowerState (powerState state)
 Set the sensor power state to either POWER_ON or POWER_OFF. More...
 
unsigned char AL_ChipID (void)
 Returns the CHIP id. More...
 
unsigned int AL_ReadChannel (channel chan)
 Reads the value from one of the two photodiode channels. More...
 
float AL_Lux (unsigned int ch0, unsigned int ch1)
 Computes LUX ambient light value from sensor data. More...
 
unsigned char AL_SetGain (gain val)
 Set sensor gain. Default gain value is GAIN_1 or 1x. More...
 
void AL_SetSamplingTime (sampTime_t sampling_time)
 Sets the sampling time for the sensor,can be one of three predetermined values. More...
 
void AL_SetIntLowThreshold (unsigned int lowthreshvalue)
 Sets the low threshold value for the interrupt. More...
 
void AL_SetIntHighThreshold (unsigned int highthreshvalue)
 Sets the high threshold value for the interrupt. More...
 
void AL_Clear_Interrupt (void)
 Clear any existing interrupts. More...
 
void AL_ConfigureInterrupt (unsigned char enable, unsigned char persistence)
 Enables or disables the interrupt and sets the persistence of interrupt occurences The interrupt will fire after x occurences outside the threshold values Default values are interrupts enabled and interrupts enabled. More...
 
void APDS9300_WriteRegister (unsigned char reg, unsigned char data)
 Writes a byte to the specific register. More...
 
void APDS9300_WriteByte (unsigned char data)
 Writes a single byte of data to the current sensor register. Function assumes that I2C peripheral is preconfigured. More...
 
void APDS9300_WriteWord (unsigned char reg, unsigned int data)
 Writes a word to the specific register. More...
 
char APDS9300_ReadByte (char reg)
 Reads a single byte from the given sensor register. More...
 
unsigned int APDS9300_ReadWordReg (char reg)
 Read word from register. More...
 
unsigned int APDS9300_ReadWord (void)
 Read a single word from the sensor. Assumes register pointer is preset. More...
 

Detailed Description

APDS9300 driver header file.

Author
D.Qendri
Date
28 May 2015

Definition in file APDS9300.h.

Macro Definition Documentation

#define APDS9300ADDR   0x29

The I2C address of the APDS9300 ambient light sensor.

Definition at line 37 of file APDS9300.h.

#define CMD_CLEAR_INT   0x40

Definition at line 58 of file APDS9300.h.

#define CMD_WORD   0x20

Definition at line 59 of file APDS9300.h.

#define COMMAND   0x80

Definition at line 57 of file APDS9300.h.

#define CONTROL   0x00

Definition at line 40 of file APDS9300.h.

#define CRC   0x08

Definition at line 47 of file APDS9300.h.

#define DATA0HIGH   0x0D

Definition at line 50 of file APDS9300.h.

#define DATA0LOW   0x0C

Definition at line 49 of file APDS9300.h.

#define DATA1HIGH   0x0F

Definition at line 52 of file APDS9300.h.

#define DATA1LOW   0x0E

Definition at line 51 of file APDS9300.h.

#define EVERYCYCLE   0x00

Definition at line 80 of file APDS9300.h.

#define GAIN   0x10

Definition at line 67 of file APDS9300.h.

#define ID   0x0A

Definition at line 48 of file APDS9300.h.

#define INTEG101MS   0x01

Definition at line 71 of file APDS9300.h.

#define INTEG13_7MS   0x00

Definition at line 70 of file APDS9300.h.

#define INTEG402MS   0x02

Definition at line 72 of file APDS9300.h.

#define INTERR_DISMASK   0xCF

Definition at line 77 of file APDS9300.h.

#define INTERR_ENA   0x10

Definition at line 78 of file APDS9300.h.

#define INTERRUPT   0x06

Definition at line 46 of file APDS9300.h.

#define MANUAL   0x08

Definition at line 68 of file APDS9300.h.

#define MANUAL_INTEG   0x03

Definition at line 73 of file APDS9300.h.

#define OUTSIDE_THRESH   0x01

Definition at line 81 of file APDS9300.h.

#define PER10_OUT_RANGE   0x0A

Definition at line 84 of file APDS9300.h.

#define PER15_OUT_RANGE   0x0F

Definition at line 85 of file APDS9300.h.

#define PER2_OUT_RANGE   0x02

Definition at line 82 of file APDS9300.h.

#define PER4_OUT_RANGE   0x04

Definition at line 83 of file APDS9300.h.

#define POWEROFF   0x00

Definition at line 64 of file APDS9300.h.

#define POWERON   0x03

Definition at line 63 of file APDS9300.h.

#define THRESHHIGHHIGH   0x05

Definition at line 45 of file APDS9300.h.

#define THRESHHIGHLOW   0x04

Definition at line 44 of file APDS9300.h.

#define THRESHLOWHIGH   0x03

Definition at line 43 of file APDS9300.h.

#define THRESHLOWLOW   0x02

Definition at line 42 of file APDS9300.h.

#define TIMING   0x01

Definition at line 41 of file APDS9300.h.

Enumeration Type Documentation

enum channel

Channel types

Enumerator
CH0 

Channel one.

CH1 

Channel two.

CH0 

Channel one.

CH1 

Channel two.

Definition at line 90 of file APDS9300.h.

enum gain

Gain types

Enumerator
GAIN_1 

Gain 1.

GAIN_16 

Gain 16.

GAIN_1 

Gain 1.

GAIN_16 

Gain 16.

Definition at line 94 of file APDS9300.h.

enum powerState

Power state types

Enumerator
POWER_ON 

Power on.

POWER_OFF 

Power off.

POWER_ON 

Power on.

POWER_OFF 

Power off.

Definition at line 98 of file APDS9300.h.

enum sampTime_t
Enumerator
S1 

Sampling time of 13.7ms .

S2 

Sampling time of 101 ms .

S3 

Sampling time of 402 ms .

S1 

Sampling time of 13.7ms .

S2 

Sampling time of 101 ms .

S3 

Sampling time of 402 ms .

Definition at line 101 of file APDS9300.h.

Function Documentation

char APDS9300_ReadByte ( char  reg)

Reads a single byte from the given sensor register.

Parameters
regAddress of sensor register
Returns
Val Value of sensor register

Definition at line 254 of file APDS9300.c.

unsigned int APDS9300_ReadWord ( void  )

Read a single word from the sensor. Assumes register pointer is preset.

Returns
value 16bit word read from the preset register

Definition at line 273 of file APDS9300.c.

unsigned int APDS9300_ReadWordReg ( char  reg)

Read word from register.

Parameters
regRegister address
Returns
val 16bit word content of register

Definition at line 264 of file APDS9300.c.

void APDS9300_WriteByte ( unsigned char  data)

Writes a single byte of data to the current sensor register. Function assumes that I2C peripheral is preconfigured.

Parameters
dataData byte to write to the pointer reg.
Returns
none

Definition at line 219 of file APDS9300.c.

void APDS9300_WriteRegister ( unsigned char  reg,
unsigned char  data 
)

Writes a byte to the specific register.

Parameters
regAddress of sensor register
dataValue to be written on the sensor register.
Returns
none

Definition at line 230 of file APDS9300.c.

void APDS9300_WriteWord ( unsigned char  reg,
unsigned int  data 
)

Writes a word to the specific register.

Parameters
regAddress of sensor register
data16 bit data to be written on the sensor register.
Returns
none

Definition at line 241 of file APDS9300.c.