33 #include <mraa/gpio.h>    35 #include <upm_types.h>    37 #include "bh1792glc_registers.h"    47 #define ONE_SEC_IN_MIRCO_SEC 1000000    48 #define FIFO_WATERMARK 32    49 #define LED_CURRENT_MAX 63    56     MSR_64Hz = BH1792_MEAS_CONTROL1_MSR_64HZ,
    57     MSR_32Hz = BH1792_MEAS_CONTROL1_MSR_32HZ,
    58     MSR_128Hz = BH1792_MEAS_CONTROL1_MSR_128HZ,
    59     MSR_256Hz = BH1792_MEAS_CONTROL1_MSR_256HZ,
    60     MSR_1024Hz = BH1792_MEAS_CONTROL1_MSR_1024HZ,
    61     MSR_NON_SYNC = BH1792_MEAS_CONTROL1_MSR_NON_SYNCH_MODE,
    62     MSR_SINGLE = BH1792_MEAS_CONTROL1_MSR_SINGLE_MEAS_MODE
    77     WATER_MARK = BH1792_MEAS_CONTROL5_INT_SEL_FIFO_WATERMARK,
    78     IR_THRESHOLD_JUDGE = BH1792_MEAS_CONTROL5_INT_SEL_IR_THRESHOLD,
    79     ON_COMPLETE = BH1792_MEAS_CONTROL5_INT_SEL_ON_COMPLETE
    98     mraa_gpio_context interrupt;
   102     pthread_t sync_thread;
   103     bool sync_thread_alive;
   105     INTERRUPT_MODES interrupt_mode;
   107     uint8_t green_current;
   284                                     uint16_t fifo_led_on[]);
   304                                     uint16_t *green_led_on);
   315                                 uint16_t *ir_led_on);
   332                                     uint8_t green_current);
   379                                 int pin, 
void (*isr)(
void *), 
void *isr_args);
   391                                 void (*isr)(
void *), 
void *isr_args);
 upm_result_t bh1792_clear_interrupt(bh1792_context dev)
Clears the interrupt flag allowing more interrupts to be raised. 
Definition: bh1792.c:580
 
upm_result_t bh1792_install_isr_falling_edge(bh1792_context dev, int pin, void(*isr)(void *), void *isr_args)
Installs the ISR to a given GPIO pin. 
Definition: bh1792.c:849
 
upm_result_t bh1792_soft_reset(bh1792_context dev)
Initiates a software reset to the sensor. All register values will be written to their defaults...
Definition: bh1792.c:340
 
upm_result_t bh1792_enable_non_sync_mode(bh1792_context dev, uint8_t ir_current, uint16_t threshold)
Enabled and configures the sensor to use non-synchronized mode. This mode uses IR_THRESHOLD interrupt...
Definition: bh1792.c:767
 
upm_result_t bh1792_get_ir_threshold(bh1792_context dev, uint16_t *threshold)
Gets interrupt ir threshold value. 
Definition: bh1792.c:532
 
upm_result_t bh1792_get_fifo_size(bh1792_context dev, uint8_t *count)
Gets the current size of built-in FIFO. 
Definition: bh1792.c:547
 
LED_TYPES
LED light types. 
Definition: bh1792.h:68
 
bh1792 sensor context 
Definition: bh1792.h:95
 
upm_result_t bh1792_get_ir_data(bh1792_context dev, uint16_t *ir_led_off, uint16_t *ir_led_on)
Gets the values from using IR LED light. 
Definition: bh1792.c:722
 
upm_result_t bh1792_get_green_leds_current(bh1792_context dev, uint8_t *current)
Gets the green LED current value. 
Definition: bh1792.c:468
 
upm_result_t bh1792_set_green_leds_current(bh1792_context dev, uint8_t current)
Sets the green LED Current value. 
Definition: bh1792.c:448
 
upm_result_t bh1792_install_isr(bh1792_context dev, mraa_gpio_edge_t edge, int pin, void(*isr)(void *), void *isr_args)
Installs the ISR to a given GPIO pin. 
Definition: bh1792.c:819
 
upm_result_t bh1792_disable_interrupt(bh1792_context dev)
Disables interrupt function. Interrupt is enabled by default on all operation modes, so this have to be called after enabling a specific operation mode. 
Definition: bh1792.c:574
 
upm_result_t bh1792_stop_measurement(bh1792_context dev)
Definition: bh1792.c:620
 
upm_result_t bh1792_get_ir_led_current(bh1792_context dev, uint8_t *current)
Gets the IR LED current value. 
Definition: bh1792.c:502
 
upm_result_t bh1792_check_who_am_i(bh1792_context dev)
Check "who am I" register value to identify the sensor. 
Definition: bh1792.c:302
 
void bh1792_remove_isr(bh1792_context dev)
Removes the ISR if it is installed. 
Definition: bh1792.c:855
 
upm_result_t bh1792_enable_sync_mode(bh1792_context dev, uint16_t meas_freq, uint8_t green_current)
Enables and configures the sensor to use synchronized mode. This will use the built-in FIFO and raise...
Definition: bh1792.c:742
 
upm_result_t bh1792_restart_measurement(bh1792_context dev)
Restart the measurement, This function stops measurement, then re-writes the configuration registers ...
Definition: bh1792.c:633
 
upm_result_t bh1792_enable_single_mode(bh1792_context dev, LED_TYPES led_type, uint8_t current)
Enables and configures the sensor to use single mode. This sets the sensor to take only one measureme...
Definition: bh1792.c:788
 
struct _bh1792_context * bh1792_context
bh1792 sensor context 
 
upm_result_t bh1792_start_measurement(bh1792_context dev)
Starts the measuremnt on sensor or enable the sensor. 
Definition: bh1792.c:599
 
upm_result_t bh1792_discard_fifo_data(bh1792_context dev)
Reads and discard the 32 FIFO entries to reset the WATERMARK interrupt flag. 
Definition: bh1792.c:689
 
OP_MODES
Operations modes available with the sensor. 
Definition: bh1792.h:85
 
upm_result_t bh1792_set_ir_led_current(bh1792_context dev, uint8_t current)
Sets the IR LED Current value. 
Definition: bh1792.c:482
 
upm_result_t bh1792_get_fifo_data(bh1792_context dev, uint16_t fifo_led_off[], uint16_t fifo_led_on[])
Gets the fifo data of 32 entries and resets the WATERMARK interrupt flag. 
Definition: bh1792.c:668
 
upm_result_t bh1792_get_meas_time_ms(bh1792_context dev, float *meas_time)
Gets the value of measurement time is milli-seconds. 
Definition: bh1792.c:412
 
bool bh1792_is_enabled(bh1792_context dev)
Checks if the measuremnt on sensor is enabled. 
Definition: bh1792.c:332
 
upm_result_t bh1792_get_green_data(bh1792_context dev, uint16_t *green_led_off, uint16_t *green_led_on)
Gets the values from using green LED light. 
Definition: bh1792.c:702
 
bh1792_context bh1792_init(int bus, int addr)
Init the sensor with specific bus and address. Before starting measurement, one of (bh1792_enable_syn...
Definition: bh1792.c:246
 
void bh1792_close(bh1792_context dev)
Close and free sensor context. 
Definition: bh1792.c:283
 
MEAS_MODES
Measurement modes, for synchronized time modes, non synchronized and single modes. 
Definition: bh1792.h:55
 
INTERRUPT_MODES
Interrupt modes of the sensor. 
Definition: bh1792.h:76
 
upm_result_t bh1792_registers_dump(bh1792_context dev, char *dump)
Gets a dump of configuration registers as a string. 
Definition: bh1792.c:865
 
upm_result_t bh1792_set_ir_threshold(bh1792_context dev, uint16_t threshold)
Sets interrupt ir threshold value for non-synchronized mode. 
Definition: bh1792.c:516