trikRuntime
i2cDevice.h
Go to the documentation of this file.
1 /* Copyright 2018 Aleksey Fefelov and CyberTech Labs Ltd.
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License. */
14 
15 #pragma once
16 
17 #include "i2cDeviceInterface.h"
18 #include "mspI2cCommunicator.h"
19 #include "i2cCommunicator.h"
20 
21 namespace trikControl{
22 
25 {
26  Q_OBJECT
27 
28 public:
31  I2cDevice(const trikKernel::Configurer &configurer, trikHal::MspI2cInterface &i2c, int bus, int address);
32 
33  Status status() const override;
34 
35 public slots:
37  void send(int reg, int value) override;
38 
40  int read(int reg) override;
41 
42 private:
43  DeviceState mState;
44  I2cCommunicator mCommunicator;
45 };
46 
47 }
Class for work with i2c.
Definition: i2cDeviceInterface.h:26
Communicates with MSP processor over I2C bus.
Definition: mspI2cInterface.h:22
Generic configuration helper, parses configuration XML files and presents configuration as a set of a...
Definition: configurer.h:28
Abstract i2c device.
Definition: i2cDevice.h:24
Status status() const override
Returns current status of the device.
Definition: i2cDevice.cpp:26
Helper class to track device state (off, starting, ready, stopping, fail).
Definition: deviceState.h:26
I2cDevice(const trikKernel::Configurer &configurer, trikHal::MspI2cInterface &i2c, int bus, int address)
Constructor.
Definition: i2cDevice.cpp:19
void send(int reg, int value) override
Sends data to current device, if it is connected.
Definition: i2cDevice.cpp:31
Status
Device status.
Definition: deviceInterface.h:33
Definition: trikCommunicator.h:27
int read(int reg) override
Reads data by given I2C command number and returns the result.
Definition: i2cDevice.cpp:43
Implementation of i2c communicator.
Definition: i2cCommunicator.h:33