source: flair-src/trunk/lib/FlairCore/src/Unix_SpiPort.h@ 447

Last change on this file since 447 was 419, checked in by Sanahuja Guillaume, 3 years ago

spi changes

File size: 1.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 Unix_SpiPort.h
7 * \brief Class for unix spi port
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2021/04/13
10 * \version 4.0
11 */
12
13#ifndef UNIX_SPIPORT_H
14#define UNIX_SPIPORT_H
15
16#include <SpiPort.h>
17#include <linux/spi/spidev.h>
18
19namespace flair {
20namespace core {
21/*! \class Unix_SpiPort
22*
23* \brief Class for unix spi port
24*
25*/
26class Unix_SpiPort : public SpiPort {
27
28public:
29 /*!
30 * \brief Constructor
31 *
32 * Construct an unix serial spi
33 *
34 * \param parent parent
35 * \param name name
36 * \param device serial device (ex /dev/ttyS0)
37 * \param mode SPI_* (look "linux/spi/spidev.h")
38 * \param bits bits per word (usually 8)
39 * \param speed max speed [Hz]
40 */
41 Unix_SpiPort(const Object *parent, std::string port_name,
42 std::string device,int mode, int bits, int speed);
43
44 /*!
45 * \brief Destructor
46 *
47 */
48 ~Unix_SpiPort();
49
50 /*!
51 * \brief Write datas
52 *
53 * \param buf pointer to datas
54 * \param nbyte length of datas
55 *
56 * \return amount of written datas
57 */
58 ssize_t Write(const void *buf, size_t nbyte);
59
60 /*!
61 * \brief Read datas
62 *
63 * \param buf pointer to datas
64 * \param nbyte length of datas
65 *
66 * \return amount of read datas
67 */
68 ssize_t Read(void *buf, size_t nbyte);
69
70 /*!
71 * \brief Write datas
72 *
73 * \param tx_buf pointer to write datas
74 * \param rx_buf pointer to read datas
75 * \param nbyte length of datas
76 *
77 * \return amount of written datas
78 */
79 ssize_t WriteRead(const void *tx_buf, void *rx_buf,size_t nbyte);
80
81
82private:
83 int fd;
84
85};
86} // end namespace core
87} // end namespace flair
88
89#endif // UNIX_SPIPORT_H
Note: See TracBrowser for help on using the repository browser.