Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
I2C.hxx
Go to the documentation of this file.
1
34#ifndef _FREERTOS_DRIVERS_COMMON_I2C_HXX_
35#define _FREERTOS_DRIVERS_COMMON_I2C_HXX_
36
37
38
39#include "BlockOrWakeUp.hxx"
40#include "SimpleLog.hxx"
41#include "Devtab.hxx"
42#include "nmranet_config.h"
43#include "os/OS.hxx"
44#include "i2c.h"
45#include "i2c-dev.h"
46
50class I2C : public Node
51{
52protected:
56 I2C(const char *name)
57 : Node(name)
58 {
59 }
60
64 {
65 HASSERT(0);
66 }
67
73 virtual int transfer(struct i2c_msg *msg, bool stop) = 0;
74
75private:
82 ssize_t read(File *file, void *buf, size_t count) OVERRIDE;
83
90 ssize_t write(File *file, const void *buf, size_t count) OVERRIDE;
91
98 int ioctl(File *file, unsigned long int key, unsigned long data) OVERRIDE;
99
105 int transfer_messages(struct i2c_msg *msgs, int num);
106
112 int smbus(File *file, unsigned long data);
113
116
120
122};
123
124#endif /* _FREERTOS_DRIVERS_COMMON_I2C_HXX_ */
const char * name
device name
Definition Devtab.hxx:266
Private data for an I2C device.
Definition I2C.hxx:51
ssize_t write(File *file, const void *buf, size_t count) OVERRIDE
Write to a file or device.
Definition I2C.cxx:73
int smbus(File *file, unsigned long data)
Request an smbus (ioctl) transaction.
Definition I2C.cxx:156
I2C(const char *name)
Constructor.
Definition I2C.hxx:56
void flush_buffers() OVERRIDE
Discards all pending buffers.
Definition I2C.hxx:115
I2C()
Default constructor.
ssize_t read(File *file, void *buf, size_t count) OVERRIDE
Read from a file or device.
Definition I2C.cxx:45
int ioctl(File *file, unsigned long int key, unsigned long data) OVERRIDE
Request an ioctl transaction.
Definition I2C.cxx:101
virtual int transfer(struct i2c_msg *msg, bool stop)=0
Method to transmit/receive the data.
~I2C()
Destructor.
Definition I2C.hxx:63
int transfer_messages(struct i2c_msg *msgs, int num)
Conduct multiple message transfers with one stop at the end.
Definition I2C.cxx:128
Node information.
Definition Devtab.hxx:549
#define OVERRIDE
Function attribute for virtual functions declaring that this funciton is overriding a funciton that s...
Definition macros.h:180
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
Definition macros.h:138
#define DISALLOW_COPY_AND_ASSIGN(TypeName)
Removes default copy-constructor and assignment added by C++.
Definition macros.h:171
File information.
Definition Devtab.hxx:52