DHCOM_HAL
Hardware-abstraction library (HAL) for multiple targets, including DHCOM modules
 All Data Structures Namespaces Files Functions Typedefs Enumerations Enumerator Macros Pages
I2CBus.h
Go to the documentation of this file.
1 /*
2  * i2c.h
3  *
4  * Created on: 07.11.2012
5  * Author: Peter Kishalov (PK), DH electronics GmbH
6  */
7 
8 
9 #ifndef I2CBUS_H_
10 #define I2CBUS_H_
11 
12 
13 #include <DHCOM_HAL.h>
14 #include <hal/Types.h>
15 #include <stddef.h>
16 
17 
18 namespace dhcom
19 {
20 
21 
22 class I2CBusImpl;
23 
24 
26 {
27 public:
29  enum BUS
30  {
31  BUS_I2C1 = 1,
32  BUS_I2C2 = 2,
33  BUS_I2C3 = 3,
34  };
35 
36  I2CBus(BUS bus);
37  ~I2CBus();
38 
39  STATUS open();
40  STATUS close();
41  bool isOpen() const;
42 
43  STATUS selectSlave(uint16_t address);
44  STATUS read(uint8_t *buffer, uint32_t count) const;
45  uint8_t read(STATUS *status = NULL) const;
46  STATUS write(const uint8_t *buffer, uint32_t count);
47  STATUS write(uint8_t byte);
48 
49 private:
50  I2CBusImpl * const impl_;
51 };
52 
53 
130 }
131 
132 
133 #endif /* I2CBUS_H_ */