I2C-Library for various sensors

Committer:
JOEV
Date:
Wed Jul 31 13:38:00 2019 +0000
Revision:
0:782435d2cc06
abcdef

Who changed what in which revision?

UserRevisionLine numberNew contents of line
JOEV 0:782435d2cc06 1 /**
JOEV 0:782435d2cc06 2 * @brief
JOEV 0:782435d2cc06 3 *
JOEV 0:782435d2cc06 4 * @file twi_master.h
JOEV 0:782435d2cc06 5 * @author Joel von Rotz
JOEV 0:782435d2cc06 6 * @date 18.07.2018
JOEV 0:782435d2cc06 7 */
JOEV 0:782435d2cc06 8 #ifndef TWI_MASTER_H
JOEV 0:782435d2cc06 9 #define TWI_MASTER_H
JOEV 0:782435d2cc06 10 #include "mbed.h"
JOEV 0:782435d2cc06 11
JOEV 0:782435d2cc06 12 /**
JOEV 0:782435d2cc06 13 * @brief <strong>TWI_Master</strong> is used for interacting with different libraries of I2C sensors, which I wrote.
JOEV 0:782435d2cc06 14 * This library has been inspired by the <a href="https://github.com/adafruit/Adafruit_Sensor">Adafruit Sensor-Library</a>
JOEV 0:782435d2cc06 15 * and the <a href="https://github.com/jrowberg/i2cdevlib/">I2Cdevlib</a> by jrowberg.
JOEV 0:782435d2cc06 16 * \n\n
JOEV 0:782435d2cc06 17 * It is not an I2C driver, since the existing I2C functions are used and new things, such as masking and individual
JOEV 0:782435d2cc06 18 * bit changes, are built in around them.
JOEV 0:782435d2cc06 19 * \n\n
JOEV 0:782435d2cc06 20 */
JOEV 0:782435d2cc06 21 class TWI_Master
JOEV 0:782435d2cc06 22 {
JOEV 0:782435d2cc06 23 public:
JOEV 0:782435d2cc06 24 TWI_Master(PinName sda, PinName scl, uint32_t frequency = 400000);
JOEV 0:782435d2cc06 25 void i2c_write(uint8_t i2c_address, uint8_t slave_address, const uint8_t data);
JOEV 0:782435d2cc06 26 void i2c_writeBits(uint8_t i2c_address, uint8_t slave_address, const uint8_t data, uint8_t mask);
JOEV 0:782435d2cc06 27 uint8_t i2c_readBits(uint8_t i2c_address, uint8_t slave_address, uint8_t mask);
JOEV 0:782435d2cc06 28 void i2c_readSeries(uint8_t i2c_address, uint8_t slave_address, uint8_t *data, uint8_t length);
JOEV 0:782435d2cc06 29 uint8_t i2c_read(uint8_t i2c_address, uint8_t slave_address);
JOEV 0:782435d2cc06 30
JOEV 0:782435d2cc06 31 private:
JOEV 0:782435d2cc06 32 I2C m_i2c_sensor;
JOEV 0:782435d2cc06 33 uint32_t m_i2c_frequency;
JOEV 0:782435d2cc06 34 };
JOEV 0:782435d2cc06 35
JOEV 0:782435d2cc06 36 #endif
JOEV 0:782435d2cc06 37