amiro-os / include / amiro / bus / i2c / mux / pca9544.hpp @ a3c54343
History | View | Annotate | Download (1.349 KB)
1 | 58fe0e0b | Thomas Schöpping | /*
|
---|---|---|---|
2 | * pca9544.hpp
|
||
3 | *
|
||
4 | * Created on: Jun 6, 2014
|
||
5 | * Author: Robert ABEL
|
||
6 | */
|
||
7 | |||
8 | #ifndef AMIRO_PCA9544_HPP_
|
||
9 | #define AMIRO_PCA9544_HPP_
|
||
10 | |||
11 | #include <ch.hpp> |
||
12 | #include <hal.h> |
||
13 | #include <amiro/bus/i2c/I2CParams.hpp> |
||
14 | #include <amiro/bus/i2c/I2CMultiplexer.hpp> |
||
15 | |||
16 | /**
|
||
17 | * @brief AMiRo
|
||
18 | */
|
||
19 | namespace amiro {
|
||
20 | |||
21 | class I2CDriver; |
||
22 | |||
23 | /**
|
||
24 | * @brief Input/Output driver class
|
||
25 | */
|
||
26 | template <bool ignore_deselect> |
||
27 | class PCA9544 : public I2CMultiplexer { |
||
28 | |||
29 | enum { SLA = 0x70u }; |
||
30 | enum { BUS_OFF = 0x00u, BUS_ON = 0x04u }; |
||
31 | |||
32 | public:
|
||
33 | |||
34 | PCA9544(I2CDriver *driver, const uint8_t master_id);
|
||
35 | virtual ~PCA9544() {}
|
||
36 | |||
37 | virtual msg_t select(const uint8_t bus_id); |
||
38 | virtual msg_t deselect();
|
||
39 | |||
40 | uint8_t getInterruptSource(); |
||
41 | |||
42 | /**
|
||
43 | * Return types of getCheck()
|
||
44 | */
|
||
45 | enum {
|
||
46 | CHECK_OK = 0x00u,
|
||
47 | CHECK_FAIL = 0x01u,
|
||
48 | }; |
||
49 | |||
50 | /**
|
||
51 | * Checks the multiplexer by writing all possible bit
|
||
52 | * combinations into the MUX register and directly
|
||
53 | * reading from it.
|
||
54 | * TODO Check possible register write corruption if vcnl4020 is running in parallel
|
||
55 | *
|
||
56 | * @return [CHECK_OK | CHECK_FAIL]
|
||
57 | */
|
||
58 | uint8_t getCheck(void);
|
||
59 | |||
60 | private:
|
||
61 | |||
62 | uint8_t master_id; |
||
63 | I2CTxParams tx_params; |
||
64 | I2CRxParams rx_params; |
||
65 | uint8_t selected; |
||
66 | |||
67 | }; |
||
68 | |||
69 | } /* amiro */
|
||
70 | |||
71 | #include <components/bus/i2c/mux/pca9544.tpp> |
||
72 | |||
73 | #endif /* AMIRO_PCA9544_HPP_ */ |