33 #include <mraa/gpio.h> 35 #include <upm_types.h> 36 #include "bh1749_registers.h" 50 INT_JUDGE_0 = BH1749_PERSISTENCE_MODE_STATUS_ACTIVE_AFTER_MEASUREMENT,
51 INT_JUDGE_1 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_MEASUREMENT,
52 INT_JUDGE_4 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_4_SAME,
53 INT_JUDGE_8 = BH1749_PERSISTENCE_MODE_STATUS_UPDATE_AFTER_8_SAME,
60 MEAS_35MS = BH1749_MODE_CONTROL1_ODR_28P6,
61 MEAS_120MS = BH1749_MODE_CONTROL1_ODR_8P333,
62 MEAS_240MS = BH1749_MODE_CONTROL1_ODR_4P167
69 RGB_GAIN_1X = BH1749_MODE_CONTROL1_RGB_GAIN_1X,
70 RGB_GAIN_32X = BH1749_MODE_CONTROL1_RGB_GAIN_32X
77 IR_GAIN_1X = BH1749_MODE_CONTROL1_IR_GAIN_1X,
78 IR_GAIN_32X = BH1749_MODE_CONTROL1_IR_GAIN_32X
85 RED = BH1749_INTERRUPT_SOURCE_SELECT_RED,
86 GREEN = BH1749_INTERRUPT_SOURCE_SELECT_GREEN,
87 BLUE = BH1749_INTERRUPT_SOURCE_SELECT_BLUE
96 mraa_gpio_context interrupt;
104 MEAS_TIMES meas_time;
105 OPERATING_MODES operating_mode;
165 INT_SOURCES intSource);
409 void (*isr)(
void *),
void *isr_args);
upm_result_t bh1749_get_threshold_high(bh1749_context dev, uint16_t *threshold)
Gets interrupt threshold high value.
Definition: bh1749.c:519
upm_result_t bh1749_enable_interrupt(bh1749_context dev)
Enables interrupt mode and resets the interrupt status (clear)
Definition: bh1749.c:453
upm_result_t bh1749_set_measurement_time(bh1749_context dev, MEAS_TIMES measTime)
Sets measurement time (ODR)
Definition: bh1749.c:312
char bh1749_get_interrupt_source_char(bh1749_context dev)
Gets interrupt source value.
Definition: bh1749.c:428
void bh1749_close(bh1749_context dev)
Close and free sensor context.
Definition: bh1749.c:222
bool bh1749_is_interrupted(bh1749_context dev)
Checks the status of the interrupt.
Definition: bh1749.c:470
upm_result_t bh1749_get_threshold_low(bh1749_context dev, uint16_t *threshold)
Gets interrupt threshold low value.
Definition: bh1749.c:543
The full sensor context.
Definition: bh1749.h:93
upm_result_t bh1749_get_ir_gain(bh1749_context dev, uint8_t *gain)
Gets IR gain value.
Definition: bh1749.c:394
upm_result_t bh1749_get_blue(bh1749_context dev, uint16_t *blue)
Gets value of Blue color channel.
Definition: bh1749.c:583
upm_result_t bh1749_get_red(bh1749_context dev, uint16_t *red)
Gets value of Red color channel.
Definition: bh1749.c:556
RGB_GAINS
RGB gain choices.
Definition: bh1749.h:68
upm_result_t bh1749_get_measurement_time(bh1749_context dev, uint8_t *meas_time)
Sets measurement time (ODR)
Definition: bh1749.c:324
upm_result_t bh1749_disable_interrupt(bh1749_context dev)
Disables interrupt mode.
Definition: bh1749.c:460
upm_result_t bh1749_disable(bh1749_context dev)
Disables RGB color measurement on the sensor.
Definition: bh1749.c:248
upm_result_t bh1749_sensor_init(bh1749_context dev, OPERATING_MODES opMode, MEAS_TIMES measTime, RGB_GAINS rgbGain, IR_GAINS irGain, INT_SOURCES intSource)
Initializes (writes) configuration values to sensor.
Definition: bh1749.c:263
struct _bh1749_context * bh1749_context
The full sensor context.
upm_result_t bh1749_set_threshold_high(bh1749_context dev, uint16_t threshold)
Sets interrupt threshold high value.
Definition: bh1749.c:507
upm_result_t bh1749_set_ir_gain(bh1749_context dev, IR_GAINS irGain)
Sets IR gain values.
Definition: bh1749.c:382
upm_result_t bh1749_install_isr(bh1749_context dev, mraa_gpio_edge_t edge, int pin, void(*isr)(void *), void *isr_args)
Installs the ISR to a given GPIO pin.
Definition: bh1749.c:646
upm_result_t bh1749_reset_interrupt(bh1749_context dev)
Resets interrupt status (clear) to allow new interrupts.
Definition: bh1749.c:465
upm_result_t bh1749_registers_dump(bh1749_context dev, char *dump)
Gets a dump of configuration registers as a string.
Definition: bh1749.c:681
upm_result_t bh1749_get_operating_mode(bh1749_context dev, uint8_t *opMode)
Gets operating mode (interrupt persistance) value.
Definition: bh1749.c:291
upm_result_t bh1749_enable(bh1749_context dev)
Enables RGB color measurement on the sensor.
Definition: bh1749.c:233
OPERATING_MODES
Operation modes enum for interrupt modes (persistance)
Definition: bh1749.h:49
void bh1749_remove_isr(bh1749_context dev)
Removes the ISR if it is installed.
Definition: bh1749.c:673
upm_result_t bh1749_get_ir(bh1749_context dev, uint16_t *ir)
Gets value of IR color channel.
Definition: bh1749.c:596
upm_result_t bh1749_get_measurements(bh1749_context dev, uint16_t *result)
Gets all channels measurements values.
Definition: bh1749.c:622
upm_result_t bh1749_set_rgb_gain(bh1749_context dev, RGB_GAINS rgbGain)
Sets RGB gain values.
Definition: bh1749.c:348
upm_result_t bh1749_soft_reset(bh1749_context dev)
Initiates a software reset to the sensor. All register values will be written to their defaults...
Definition: bh1749.c:502
IR_GAINS
IR gain choices.
Definition: bh1749.h:76
upm_result_t bh1749_get_green(bh1749_context dev, uint16_t *green)
Gets value of Green color channel.
Definition: bh1749.c:570
bh1749_context bh1749_init(int bus, int addr)
Init the sensor with specific bus and address. This function calls the sensor_init() function to set ...
Definition: bh1749.c:182
upm_result_t bh1749_get_green2(bh1749_context dev, uint16_t *green2)
Gets value of Green2 color channel.
Definition: bh1749.c:609
upm_result_t bh1749_set_int_source(bh1749_context dev, INT_SOURCES intSource)
Sets interrupt source value.
Definition: bh1749.c:416
MEAS_TIMES
Measuremnt time choices.
Definition: bh1749.h:59
INT_SOURCES
Interrupt source choices.
Definition: bh1749.h:84
upm_result_t bh1749_get_rgb_gain(bh1749_context dev, uint8_t *gain)
Gets RGB gain value.
Definition: bh1749.c:360
upm_result_t bh1749_check_who_am_i(bh1749_context dev)
Check "who am I" register value to identify the sensor.
Definition: bh1749.c:167
upm_result_t bh1749_set_threshold_low(bh1749_context dev, uint16_t threshold)
Sets interrupt threshold low value.
Definition: bh1749.c:531
upm_result_t bh1749_set_operating_mode(bh1749_context dev, OPERATING_MODES opMode)
Sets operating mode (interrupt persistance)
Definition: bh1749.c:280
bool bh1749_is_interrupt_enabled(bh1749_context dev)
Checks whether interrupt mode is enabled.
Definition: bh1749.c:486