Browse Source

drivers/bh1750fvi: added names to return values

pr/spi.typo
Hauke Petersen 6 years ago
parent
commit
40116c7c66
  1. 9
      drivers/bh1750fvi/bh1750fvi.c
  2. 8
      drivers/include/bh1750fvi.h

9
drivers/bh1750fvi/bh1750fvi.c

@ -25,6 +25,9 @@
#include "bh1750fvi.h"
#include "bh1750fvi_internal.h"
#define ENABLE_DEBUG (0)
#include "debug.h"
int bh1750fvi_init(bh1750fvi_t *dev, bh1750fvi_params_t *params)
{
int res;
@ -41,9 +44,9 @@ int bh1750fvi_init(bh1750fvi_t *dev, bh1750fvi_params_t *params)
res = i2c_write_byte(dev->i2c, dev->addr, OP_POWER_DOWN);
i2c_release(dev->i2c);
if (res < 0) {
return -1;
return BH1750FVI_ERR_I2C;
}
return 0;
return BH1750FVI_OK;
}
uint16_t bh1750fvi_sample(bh1750fvi_t *dev)
@ -52,6 +55,7 @@ uint16_t bh1750fvi_sample(bh1750fvi_t *dev)
uint8_t raw[2];
/* power on the device and send single H-mode measurement command */
DEBUG("[bh1750fvi] sample: triggering a conversion\n");
i2c_acquire(dev->i2c);
i2c_write_byte(dev->i2c, dev->addr, OP_POWER_ON);
i2c_write_byte(dev->i2c, dev->addr, OP_SINGLE_HRES1);
@ -61,6 +65,7 @@ uint16_t bh1750fvi_sample(bh1750fvi_t *dev)
xtimer_usleep(DELAY_HMODE);
/* read the results */
DEBUG("[bh1750fvi] sample: reading the results\n");
i2c_acquire(dev->i2c);
i2c_read_bytes(dev->i2c, dev->addr, raw, 2);
i2c_release(dev->i2c);

8
drivers/include/bh1750fvi.h

@ -48,6 +48,14 @@ extern "C" {
*/
#define BH1750FVI_I2C_MAX_CLK I2C_SPEED_FAST
/**
* @brief Status and error return codes
*/
enum {
BH1750FVI_OK = 0, /**< everything was fine */
BH1750FVI_ERR_I2C = -1 /**< error initializing the I2C bus */
};
/**
* @brief Device descriptor for BH1570FVI devices
*/

Loading…
Cancel
Save