ds3231 ads111x bh1750 update + I2c device desciptor
This commit is contained in:
parent
130385fecd
commit
a731034e65
12 changed files with 190 additions and 177 deletions
|
|
@ -6,20 +6,19 @@
|
|||
* BSD Licensed as described in the file LICENSE
|
||||
*/
|
||||
#include "bh1750.h"
|
||||
#include <i2c/i2c.h>
|
||||
#include <stdio.h>
|
||||
|
||||
void bh1750_configure(uint8_t addr, uint8_t mode)
|
||||
void bh1750_configure(i2c_dev_t *dev, uint8_t mode)
|
||||
{
|
||||
i2c_slave_write(addr, NULL, &mode, 1);
|
||||
i2c_slave_write(dev->bus, dev->addr, NULL, &mode, 1);
|
||||
}
|
||||
|
||||
uint16_t bh1750_read(uint8_t addr)
|
||||
uint16_t bh1750_read(i2c_dev_t *dev)
|
||||
{
|
||||
uint8_t buf[2];
|
||||
uint16_t level;
|
||||
|
||||
i2c_slave_read(addr, NULL, buf, 2);
|
||||
i2c_slave_read(dev->bus, dev->addr, NULL, buf, 2);
|
||||
|
||||
level = buf[0] << 8 | buf[1];
|
||||
level = (level * 10) / 12; // convert to LUX
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue