Maxim Integrated / MAX44000

Dependents:   LED_Demo LED_Demo2 LED_Demo

Fork of BMP180 by Kevin Gillepsie

Embed: (wiki syntax)

« Back to documentation index

MAX44000 Class Reference

MAX44000 Class Reference

MAX44000 Ambient Light and Infrared Proximity Sensor. More...

#include <MAX44000.h>

Public Types

enum  registers_t {
  REG_STATUS, REG_MAIN_CONFIG, REG_RX_CONFIG, REG_TX_CONFIG,
  REG_ALS_DATA_HIGH, REG_ALS_DATA_LOW, REG_ALS_UPTHR_HIGH, REG_ALS_UPTHR_LOW,
  REG_ALS_LOTHR_HIGH, REG_ALS_LOTHR_LOW, REG_PST, REG_PRX_IND,
  REG_PRX_THR, REG_TRIM_GAIN_GREEN, REG_TRIM_GAIN_IR = 0x0F, REG_PRX_DATA = 0x16
}
 

Register Addresses.

More...
enum  modes_t {
  MODE_SHUTDOWN, MODE_ALS_GMIR, MODE_ALS_G, MODE_ALS_IR,
  MODE_ALS_PROX, MODE_PROX, MODE_RSVD_110, MODE_RSVD_111
}
 

Operating Modes.

More...
enum  alstim_t { ALSTIM_1X, ALSTIM_4X, ALSTIM_16X, ALSTIM_64X }
 

ALS ADC Conversion Time.

More...
enum  alspga_t { ALSPGA_1X, ALSPGA_4X, ALSPGA_16X, ALSPGA_128X }
 

alspga_t - MAX44000 Ambient Light Measurement Gain

More...
enum  drive_t {
  DRV_0, DRV_10, DRV_20, DRV_30,
  DRV_40, DRV_50, DRV_60, DRV_70,
  DUP_40, DUP_50, DUP_60, DUP_70,
  DRV_80, DRV_90, DRV_100, DRV_110
}
 

LED Driver Current.

More...
enum  persist_t { PST_1, PST_2, PST_4, PST_16 }
 

Persist Times.

More...

Public Member Functions

 MAX44000 (PinName sda, PinName scl)
 MAX44000 constructor.
 MAX44000 (I2C *i2c)
 MAX44000 constructor.
 ~MAX44000 ()
 MAX44000 destructor.
int init (MAX44000::modes_t mode, MAX44000::alstim_t alstim, MAX44000::alspga_t alspga, MAX44000::drive_t drive)
 Initialize MAX44000.
int writeReg (MAX44000::registers_t reg_addr, char reg_data)
 Write Register.
int readReg (MAX44000::registers_t reg_addr)
 Read Register.
int readALS (void)
 Read ALS Data.

Detailed Description

MAX44000 Ambient Light and Infrared Proximity Sensor.

 #include <stdio.h>
 #include "mbed.h"
 #include "MAX44000.h"

 I2C i2c(I2C_SDA, I2C_SCL);
 MAX44000 max44000(&i2c);

 int main(void) {

     while(1) {
         if (max44000.init(MAX44000::MODE_ALS_PROX, MAX44000::ALSTIM_1X, MAX44000::ALSPGA_128X, MAX44000::DRV_110) != 0) {
             printf("Error communicating with MAX44000\n");
         } else {
             printf("Initialized MAX44000\n");
             break;
         }
         wait(1);
     }

     while(1) {
         int alsValue = max44000.readALS();
         if(alsValue < 0) {
             printf("Error reading ALS value\n");
             continue;
         }

         int proxValue = max44000.readReg(MAX44000::REG_PRX_DATA);
         if(proxValue < 0) {
             printf("Error reading proximity value\n");
             continue;
         }

         printf("ALS = 0x%04X  Proximity = 0x%02X\n", alsValue, proxValue);
         wait(1);
     }
 }

Definition at line 81 of file MAX44000.h.


Member Enumeration Documentation

enum alspga_t

alspga_t - MAX44000 Ambient Light Measurement Gain

Enumerator:
ALSPGA_1X 

0.03125 lux/lsb

ALSPGA_4X 

0.125 lux/lsb

ALSPGA_16X 

0.5 lux/lsb

ALSPGA_128X 

4 lux/lsb

Definition at line 141 of file MAX44000.h.

enum alstim_t

ALS ADC Conversion Time.

MAX44000 Ambient Light Sensor ADC Conversion Time

Enumerator:
ALSTIM_1X 

100ms, 16,384 counts, 14 bit resolution

ALSTIM_4X 

25ms, 4096 counts, 12 bit resolution

ALSTIM_16X 

6.25ms, 1024 counts, 10 bit resolution

ALSTIM_64X 

1.5625ms, 256 counts, 8 bit resolution

Definition at line 130 of file MAX44000.h.

enum drive_t

LED Driver Current.

MAX44000 LED Driver Current Settings

Enumerator:
DRV_0 

LED driver disabled.

DRV_10 

10mA

DRV_20 

20mA

DRV_30 

30mA

DRV_40 

40mA

DRV_50 

50mA

DRV_60 

60mA

DRV_70 

70mA

DUP_40 

40mA

DUP_50 

50mA

DUP_60 

60mA

DUP_70 

70mA

DRV_80 

80mA

DRV_90 

90mA

DRV_100 

100mA

DRV_110 

110mA

Definition at line 153 of file MAX44000.h.

enum modes_t

Operating Modes.

Enumerated MAX44000 operating modes

Enumerator:
MODE_SHUTDOWN 

Analog circuits are shut down, but the digital register retains values.

MODE_ALS_GMIR 

Standard ALS mode, stores difference between green and IR channels.

MODE_ALS_G 

ALS green channel only.

MODE_ALS_IR 

Infrared channel only.

MODE_ALS_PROX 

ALS and PROX are interleaved continuously.

MODE_PROX 

PROX only.

MODE_RSVD_110 

Reserved, do not use.

MODE_RSVD_111 

Reserved, do not use.

Definition at line 114 of file MAX44000.h.

enum persist_t

Persist Times.

MAX44000 ALS/PROX Threshold Persist Timer Settings

Enumerator:
PST_1 

1 trigger before interrupt

PST_2 

2 consecutive triggers before interrupt

PST_4 

4 consecutive triggers before interrupt

PST_16 

16 consecutive triggers before interrupt

Definition at line 177 of file MAX44000.h.

Register Addresses.

Enumerated MAX44000 register addresses

Enumerator:
REG_STATUS 

Interrupt Status.

REG_MAIN_CONFIG 

Main Configuration.

REG_RX_CONFIG 

Receive Configuration.

REG_TX_CONFIG 

Transmit Configuration.

REG_ALS_DATA_HIGH 

ADC High Byte (ALS)

REG_ALS_DATA_LOW 

ADC Low Byte (ALS)

REG_ALS_UPTHR_HIGH 

ALS Upper Threshold (High Byte)

REG_ALS_UPTHR_LOW 

ALS Upper Threshold (Low Byte)

REG_ALS_LOTHR_HIGH 

ALS Lower Threshold (High Byte)

REG_ALS_LOTHR_LOW 

ALS Lower Threshold (Low Byte)

REG_PST 

Threshold Persist Timer.

REG_PRX_IND 

PROX Threshold Indicator.

REG_PRX_THR 

PROX Threshold.

REG_TRIM_GAIN_GREEN 

Digital Gain Trim of Green Channel.

REG_TRIM_GAIN_IR 

Digital Gain Trim of Infrared Channel.

REG_PRX_DATA 

ADC Byte (PROX)

Definition at line 90 of file MAX44000.h.


Constructor & Destructor Documentation

MAX44000 ( PinName  sda,
PinName  scl 
)

MAX44000 constructor.

Parameters:
sdambed pin to use for SDA line of I2C interface.
sclmbed pin to use for SCL line of I2C interface.

Definition at line 40 of file MAX44000.cpp.

MAX44000 ( I2C *  i2c )

MAX44000 constructor.

Parameters:
i2cI2C object to use.

Definition at line 49 of file MAX44000.cpp.

~MAX44000 (  )

MAX44000 destructor.

Definition at line 56 of file MAX44000.cpp.


Member Function Documentation

int init ( MAX44000::modes_t  mode,
MAX44000::alstim_t  alstim,
MAX44000::alspga_t  alspga,
MAX44000::drive_t  drive 
)

Initialize MAX44000.

Gets the device ID and saves the calibration values.

Parameters:
modeOperating Mode
alstimAmbient Light ADC Conversion Time
alspgaAmbient Light Measurement Gain
driveLED Driver Current
Returns:
0 if no errors, -1 if error.

Definition at line 64 of file MAX44000.cpp.

int readALS ( void   )

Read ALS Data.

Reads both ALS data registers and returns combined value

Returns:
data if no errors, -1 if error.

Definition at line 121 of file MAX44000.cpp.

int readReg ( MAX44000::registers_t  reg_addr )

Read Register.

Reads data from MAX44000 register

Parameters:
reg_addrRegister to read
Returns:
data if no errors, -1 if error.

Definition at line 104 of file MAX44000.cpp.

int writeReg ( MAX44000::registers_t  reg_addr,
char  reg_data 
)

Write Register.

Writes data to MAX44000 register

Parameters:
reg_addrRegister to write
reg_dataData to write
Returns:
0 if no errors, -1 if error.

Definition at line 90 of file MAX44000.cpp.