source: flair-dev/trunk/include/FlairCore/RTDM_I2cPort.h @ 2

Last change on this file since 2 was 2, checked in by Sanahuja Guillaume, 5 years ago

initial commit flaircore

File size: 2.7 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5/*!
6 * \file RTDM_I2cPort.h
7 * \brief Class for real time i2c port using RTDM
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2011/08/19
10 * \version 4.0
11 */
12
13#ifndef RTDM_I2CPORT_H
14#define RTDM_I2CPORT_H
15
16#include <I2cPort.h>
17
18namespace flair
19{
20namespace core
21{
22    /*! \class RTDM_I2cPort
23    *
24    * \brief Class for real time i2c port using RTDM
25    *
26    * This class can only be used with the real time version of Framework library.
27    *
28    */
29    class RTDM_I2cPort: public I2cPort
30    {
31        public:
32            /*!
33            * \brief Constructor
34            *
35            * Construct an RTDM i2c port, with the following default values: \n
36            * - 400kbits baudrate \n
37            * - 500000ns RX timeout \n
38            * - 1000000ns TX timeout
39            *
40            * \param parent parent
41            * \param name name
42            * \param device i2c device (ex rti2c1)
43            */
44            RTDM_I2cPort(const Object* parent,std::string name,std::string device);
45
46            /*!
47            * \brief Destructor
48            *
49            */
50            ~RTDM_I2cPort();
51
52            /*!
53            * \brief Set slave's address
54            *
55            * This method need to be called before any communication.
56            *
57            * \param address slave's address
58            */
59            int SetSlave(uint16_t address);
60
61            /*!
62            * \brief Write datas
63            *
64            * \param buf pointer to datas
65            * \param nbyte length of datas
66            *
67            * \return amount of written datas
68            */
69            ssize_t Write(const void *buf,size_t nbyte);
70
71            /*!
72            * \brief Read datas
73            *
74            * \param buf pointer to datas
75            * \param nbyte length of datas
76            *
77            * \return amount of read datas
78            */
79            ssize_t Read(void *buf,size_t nbyte);
80
81            /*!
82            * \brief Set RX timeout
83            *
84            * Timeout for waiting an ACK from the slave.
85            *
86            * \param timeout_ns timeout in nano second
87            */
88            void SetRxTimeout(Time timeout_ns);
89
90            /*!
91            * \brief Set TX timeout
92            *
93            * Timeout for waiting an ACK from the slave.
94            *
95            * \param timeout_ns timeout in nano second
96            */
97            void SetTxTimeout(Time timeout_ns);
98
99        private:
100            int fd;
101    };
102} // end namespace core
103} // end namespace flair
104
105#endif // RTDM_I2CPORT_H
Note: See TracBrowser for help on using the repository browser.