amiro-os / components / bus / i2c / HWI2CDriver.cpp @ 309980f0
History | View | Annotate | Download (1.468 KB)
1 | 58fe0e0b | Thomas Schöpping | #include <amiro/bus/i2c/I2CParams.hpp> |
---|---|---|---|
2 | #include <amiro/bus/i2c/HWI2CDriver.hpp> |
||
3 | |||
4 | namespace amiro {
|
||
5 | |||
6 | |||
7 | HWI2CDriver:: |
||
8 | HWI2CDriver(::I2CDriver *d) : |
||
9 | driver(d) { |
||
10 | |||
11 | }; |
||
12 | |||
13 | void
|
||
14 | HWI2CDriver:: |
||
15 | start(const ::I2CConfig *config) {
|
||
16 | |||
17 | i2cStart(this->driver, config);
|
||
18 | |||
19 | }; |
||
20 | |||
21 | void
|
||
22 | HWI2CDriver:: |
||
23 | stop() { |
||
24 | |||
25 | i2cStop(this->driver);
|
||
26 | |||
27 | } |
||
28 | |||
29 | i2cflags_t |
||
30 | HWI2CDriver:: |
||
31 | getErrors() { |
||
32 | |||
33 | return i2cGetErrors(this->driver); |
||
34 | |||
35 | } |
||
36 | |||
37 | msg_t |
||
38 | HWI2CDriver:: |
||
39 | masterTransmit(const I2CTxParams *params, systime_t timeout) {
|
||
40 | |||
41 | return i2cMasterTransmitTimeout(
|
||
42 | this->driver,
|
||
43 | params->addr, |
||
44 | params->txbuf, |
||
45 | params->txbytes, |
||
46 | params->rxbuf, |
||
47 | params->rxbytes, |
||
48 | timeout); |
||
49 | |||
50 | } |
||
51 | |||
52 | msg_t |
||
53 | HWI2CDriver:: |
||
54 | masterReceive(const I2CRxParams *params, systime_t timeout) {
|
||
55 | |||
56 | return i2cMasterReceiveTimeout(
|
||
57 | this->driver,
|
||
58 | params->addr, |
||
59 | params->rxbuf, |
||
60 | params->rxbytes, |
||
61 | timeout); |
||
62 | |||
63 | } |
||
64 | |||
65 | void
|
||
66 | HWI2CDriver:: |
||
67 | acquireBus() { |
||
68 | |||
69 | #if I2C_USE_MUTUAL_EXCLUSION
|
||
70 | i2cAcquireBus(this->driver);
|
||
71 | #endif /* I2C_USE_MUTUAL_EXCLUSION */ |
||
72 | } |
||
73 | |||
74 | void
|
||
75 | HWI2CDriver:: |
||
76 | releaseBus() { |
||
77 | |||
78 | #if I2C_USE_MUTUAL_EXCLUSION
|
||
79 | i2cReleaseBus(this->driver);
|
||
80 | #endif /* I2C_USE_MUTUAL_EXCLUSION */ |
||
81 | |||
82 | } |
||
83 | |||
84 | } /* amiro */ |