I2C bus upgrade (#432)
This commit is contained in:
parent
d100f42b1f
commit
b83c2629b9
56 changed files with 909 additions and 804 deletions
|
|
@ -1,22 +1,20 @@
|
|||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#include <i2c/i2c.h>
|
||||
#include "pcf8591.h"
|
||||
|
||||
/**
|
||||
* CAUTION: PLEASE SET I2C_FREQUENCY_400K IS 'false' IN 'i2c.h' FILE
|
||||
* CAUTION: PLEASE SET LOW FREQUENCY
|
||||
*/
|
||||
|
||||
#define PCF8591_CTRL_REG_READ 0x03
|
||||
|
||||
uint8_t
|
||||
pcf8591_read(uint8_t addr, uint8_t analog_pin)
|
||||
uint8_t pcf8591_read(i2c_dev_t* dev, uint8_t analog_pin)
|
||||
{
|
||||
uint8_t res = 0;
|
||||
uint8_t control_reg = PCF8591_CTRL_REG_READ & analog_pin;
|
||||
|
||||
i2c_slave_read(addr, &control_reg, &res, 1);
|
||||
i2c_slave_read(dev->bus, dev->addr, &control_reg, &res, 1);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,6 +9,8 @@
|
|||
#ifndef _EXTRAS_PCF8591_H_
|
||||
#define _EXTRAS_PCF8591_H_
|
||||
|
||||
#include <i2c/i2c.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C"
|
||||
{
|
||||
|
|
@ -20,7 +22,7 @@ extern "C"
|
|||
|
||||
#define PCF8591_DEFAULT_ADDRESS 0x48
|
||||
|
||||
void pcf8591_init(void);
|
||||
void pcf8591_init(void); //FIXME : library incomplete ?
|
||||
|
||||
/**
|
||||
* Read input value of an analog pin.
|
||||
|
|
@ -32,7 +34,7 @@ void pcf8591_init(void);
|
|||
* 3 - AIN3
|
||||
* @return analog value
|
||||
*/
|
||||
uint8_t pcf8591_read(uint8_t addr, uint8_t analog_pin);
|
||||
uint8_t pcf8591_read(i2c_dev_t* dev, uint8_t analog_pin);
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue