upm
1.7.1
Sensor/Actuator repository for libmraa (v2.0.0)
|
Go to the source code of this file.
Data Structures | |
struct | _bh1792_context |
bh1792 sensor context More... | |
Functions | |
bh1792_context | bh1792_init (int bus, int addr) |
Init the sensor with specific bus and address. Before starting measurement, one of (bh1792_enable_sync_mode, bh1792_enable_non_sync_mode, or bh1792_enable_single_mode) have to be called. More... | |
void | bh1792_close (bh1792_context dev) |
Close and free sensor context. More... | |
upm_result_t | bh1792_check_who_am_i (bh1792_context dev) |
Check "who am I" register value to identify the sensor. More... | |
bool | bh1792_is_enabled (bh1792_context dev) |
Checks if the measuremnt on sensor is enabled. More... | |
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, thus intended operation mode need to be enabled. More... | |
upm_result_t | bh1792_get_meas_time_ms (bh1792_context dev, float *meas_time) |
Gets the value of measurement time is milli-seconds. More... | |
upm_result_t | bh1792_set_green_leds_current (bh1792_context dev, uint8_t current) |
Sets the green LED Current value. More... | |
upm_result_t | bh1792_get_green_leds_current (bh1792_context dev, uint8_t *current) |
Gets the green LED current value. More... | |
upm_result_t | bh1792_set_ir_led_current (bh1792_context dev, uint8_t current) |
Sets the IR LED Current value. More... | |
upm_result_t | bh1792_get_ir_led_current (bh1792_context dev, uint8_t *current) |
Gets the IR LED current value. More... | |
upm_result_t | bh1792_set_ir_threshold (bh1792_context dev, uint16_t threshold) |
Sets interrupt ir threshold value for non-synchronized mode. More... | |
upm_result_t | bh1792_get_ir_threshold (bh1792_context dev, uint16_t *threshold) |
Gets interrupt ir threshold value. More... | |
upm_result_t | bh1792_get_fifo_size (bh1792_context dev, uint8_t *count) |
Gets the current size of built-in FIFO. More... | |
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. More... | |
upm_result_t | bh1792_clear_interrupt (bh1792_context dev) |
Clears the interrupt flag allowing more interrupts to be raised. More... | |
upm_result_t | bh1792_start_measurement (bh1792_context dev) |
Starts the measuremnt on sensor or enable the sensor. More... | |
upm_result_t | bh1792_stop_measurement (bh1792_context dev) |
upm_result_t | bh1792_restart_measurement (bh1792_context dev) |
Restart the measurement, This function stops measurement, then re-writes the configuration registers again and start measurement with same configuration. More... | |
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. More... | |
upm_result_t | bh1792_discard_fifo_data (bh1792_context dev) |
Reads and discard the 32 FIFO entries to reset the WATERMARK interrupt flag. More... | |
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. More... | |
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. More... | |
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 raises a WATERMARK interrupt when FIFO size reaches 32 entries. To clear that interrupt flag FIFO must be read or discarded. This mode uses only green LED. More... | |
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, it will raise an interrupt if IR LED ON value is equal or greater than the threshold value. Interrupt must be cleared before receiving new interrupts. This mode uses only IR LED. More... | |
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 measurement and raise an interrupt after measurement is finished. Interrupt flags has to be cleared to recieved new interrupts. This mode uses both green and IR LEDs. More... | |
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. More... | |
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. More... | |
void | bh1792_remove_isr (bh1792_context dev) |
Removes the ISR if it is installed. More... | |
upm_result_t | bh1792_registers_dump (bh1792_context dev, char *dump) |
Gets a dump of configuration registers as a string. More... | |
Macros | |
#define | ONE_SEC_IN_MIRCO_SEC 1000000 |
#define | FIFO_WATERMARK 32 |
#define | LED_CURRENT_MAX 63 |
Typedefs | |
typedef struct _bh1792_context * | bh1792_context |
bh1792 sensor context | |
Enumerations | |
enum | MEAS_MODES { MSR_64Hz = BH1792_MEAS_CONTROL1_MSR_64HZ, MSR_32Hz = BH1792_MEAS_CONTROL1_MSR_32HZ, MSR_128Hz = BH1792_MEAS_CONTROL1_MSR_128HZ, MSR_256Hz = BH1792_MEAS_CONTROL1_MSR_256HZ, MSR_1024Hz = BH1792_MEAS_CONTROL1_MSR_1024HZ, MSR_NON_SYNC = BH1792_MEAS_CONTROL1_MSR_NON_SYNCH_MODE, MSR_SINGLE = BH1792_MEAS_CONTROL1_MSR_SINGLE_MEAS_MODE } |
Measurement modes, for synchronized time modes, non synchronized and single modes. | |
enum | LED_TYPES { GREEN, IR } |
LED light types. | |
enum | INTERRUPT_MODES { WATER_MARK = BH1792_MEAS_CONTROL5_INT_SEL_FIFO_WATERMARK, IR_THRESHOLD_JUDGE = BH1792_MEAS_CONTROL5_INT_SEL_IR_THRESHOLD, ON_COMPLETE = BH1792_MEAS_CONTROL5_INT_SEL_ON_COMPLETE } |
Interrupt modes of the sensor. | |
enum | OP_MODES { SYNCHRONIZED, NON_SYNCHRONIZED, SINGLE_GREEN, SINGLE_IR } |
Operations modes available with the sensor. | |
bh1792_context bh1792_init | ( | int | bus, |
int | addr | ||
) |
bus | I2C bus number |
addr | I2C sensor address |
void bh1792_close | ( | bh1792_context | dev | ) |
dev | Sensor context |
upm_result_t bh1792_check_who_am_i | ( | bh1792_context | dev | ) |
dev | Sensor context |
bool bh1792_is_enabled | ( | bh1792_context | dev | ) |
The | sensor context |
upm_result_t bh1792_soft_reset | ( | bh1792_context | dev | ) |
dev | Sensor context |
upm_result_t bh1792_get_meas_time_ms | ( | bh1792_context | dev, |
float * | meas_time | ||
) |
dev | The sensor context |
meas_time_ms | Float pointer to store value of measurement time |
upm_result_t bh1792_set_green_leds_current | ( | bh1792_context | dev, |
uint8_t | current | ||
) |
dev | The sensor context |
current | The current value, accepted values are between 0-63 |
upm_result_t bh1792_get_green_leds_current | ( | bh1792_context | dev, |
uint8_t * | current | ||
) |
dev | The sensor context |
current | Pointer to store the read current value |
upm_result_t bh1792_set_ir_led_current | ( | bh1792_context | dev, |
uint8_t | current | ||
) |
dev | The sensor context |
current | The current value, accepted values are between 0-63 |
upm_result_t bh1792_get_ir_led_current | ( | bh1792_context | dev, |
uint8_t * | current | ||
) |
dev | The sensor context |
current | Pointer to store the read current value |
upm_result_t bh1792_set_ir_threshold | ( | bh1792_context | dev, |
uint16_t | threshold | ||
) |
dev | Sensor context |
threshold | Value to be written, range 0-65536 |
upm_result_t bh1792_get_ir_threshold | ( | bh1792_context | dev, |
uint16_t * | threshold | ||
) |
dev | Sensor context |
threshold | Pointer (uint16_t) to write value |
upm_result_t bh1792_get_fifo_size | ( | bh1792_context | dev, |
uint8_t * | count | ||
) |
dev | The sensor context |
count | The pointer to store the size |
upm_result_t bh1792_disable_interrupt | ( | bh1792_context | dev | ) |
dev | The sensor context |
upm_result_t bh1792_clear_interrupt | ( | bh1792_context | dev | ) |
dev | The sensor context |
upm_result_t bh1792_start_measurement | ( | bh1792_context | dev | ) |
dev | The sensor context |
upm_result_t bh1792_stop_measurement | ( | bh1792_context | dev | ) |
Stops the measurement by setting the software reset bit. This function will reset all config registers. To resume from previous configuration call bh1792_restart_measurement().
dev | The sensor context |
upm_result_t bh1792_restart_measurement | ( | bh1792_context | dev | ) |
dev | The sensor context |
upm_result_t bh1792_get_fifo_data | ( | bh1792_context | dev, |
uint16_t | fifo_led_off[], | ||
uint16_t | fifo_led_on[] | ||
) |
dev | The sensor context |
fifo_led_off | Array/Pointer to store 32 entries of fifo LED_OFF data |
fifo_led_on | Array/Pointer to store 32 entries of fifo LED_ON data |
upm_result_t bh1792_discard_fifo_data | ( | bh1792_context | dev | ) |
dev | The sensor context |
upm_result_t bh1792_get_green_data | ( | bh1792_context | dev, |
uint16_t * | green_led_off, | ||
uint16_t * | green_led_on | ||
) |
dev | The sensor context |
green_led_off | Pointer to store the reading value of LED_OFF |
green_led_on | Pointer to store the reading value of LED_ON |
upm_result_t bh1792_get_ir_data | ( | bh1792_context | dev, |
uint16_t * | ir_led_off, | ||
uint16_t * | ir_led_on | ||
) |
dev | The sensor context |
ir_led_off | Pointer to store the reading value of LED_OFF |
ir_led_on | Pointer to store the reading value of LED_ON |
upm_result_t bh1792_enable_sync_mode | ( | bh1792_context | dev, |
uint16_t | meas_freq, | ||
uint8_t | green_current | ||
) |
You need to call bh1792_start_measurement() after this.
dev | The sensor context |
meas_freq | Measurement frequncy mode, valid values 32, 64, 128, 256, 1024 |
green_current | Green LED current value |
upm_result_t bh1792_enable_non_sync_mode | ( | bh1792_context | dev, |
uint8_t | ir_current, | ||
uint16_t | threshold | ||
) |
You need to call bh1792_start_measurement() after this.
dev | The sensor context |
ir_current | The IR LED current value |
threshold | The IR LED interrupt threshold value |
upm_result_t bh1792_enable_single_mode | ( | bh1792_context | dev, |
LED_TYPES | led_type, | ||
uint8_t | current | ||
) |
You need to call bh1792_start_measurement() after this. If you need to get continuous values, clear interrupt and bh1792_start_measurement() continuously.
dev | The sensor context |
led_type | LED light type to use, takes GREEN or IR values |
current | The chosen led_type current value |
upm_result_t bh1792_install_isr | ( | bh1792_context | dev, |
mraa_gpio_edge_t | edge, | ||
int | pin, | ||
void(*)(void *) | isr, | ||
void * | isr_args | ||
) |
dev | Sensor context |
edge | Edge type to raise ISR with, of type mraa_gpio_edge_t |
pin | GPIO pin number |
isr | Pointer to ISR function |
isr_args | Arguments to pass the ISR function |
upm_result_t bh1792_install_isr_falling_edge | ( | bh1792_context | dev, |
int | pin, | ||
void(*)(void *) | isr, | ||
void * | isr_args | ||
) |
dev | Sensor context |
pin | GPIO pin number |
isr | Pointer to ISR function |
isr_args | Arguments to pass the ISR function |
void bh1792_remove_isr | ( | bh1792_context | dev | ) |
dev | Sensor context |
upm_result_t bh1792_registers_dump | ( | bh1792_context | dev, |
char * | dump | ||
) |
dev | Sensor context |
dump | Pointer of char to save dump string |