SysIo  1.9.0
Embedded Library and tools
gpioconnector.h
1 
8 #ifndef _SYSIO_GPIO_CONNECTOR_H_
9 #define _SYSIO_GPIO_CONNECTOR_H_
10 
11 #include <iostream>
12 #include <sysio/gpiopin.h>
13 
14 namespace Sysio {
15 
16  class Gpio;
17  class Device;
18 
30  class Connector {
31 
32  public:
33  friend class Pin;
34  friend class Gpio;
35 
44  typedef int (* PinNumberFunc) (int row, int column, int columns);
45 
52  class Descriptor {
53  public:
54  std::string name;
55  int number;
56  int rows;
57  int columns;
58  PinNumberFunc pinNumber;
59  std::vector<Pin::Descriptor> pin;
60  };
61 
65  bool isOpen() const;
66 
70  const std::string & name() const;
71 
75  int number() const;
76 
80  int size() const;
81 
85  int rows() const;
86 
90  int columns() const;
91 
98  void setDebug (bool enable);
99 
103  bool isDebug() const;
104 
145  friend std::ostream& operator<< (std::ostream& os, const Connector * c);
146 
150  Gpio * gpio() const;
151 
152  //------------------------------------------------------------------------
153  // Accès aux broches
154  //------------------------------------------------------------------------
155 
163  Pin & pin (int num) const;
164 
184  const std::map<int, std::shared_ptr<Pin>> & pin ();
185 
194  Connector (Gpio * parent, const Descriptor * desc);
195 
199  virtual ~Connector();
200 
201  protected:
205  Device * device() const;
206 
210  bool open();
211 
215  void close();
216 
226  int pinNumber (int row, int column) const;
227 
232  void printHline (std::ostream & os) const;
233 
238  void printTitle (std::ostream & os) const;
239 
247  void printRow (std::ostream & os, int num) const;
248 
249  private:
250  bool _isopen;
251  Gpio * _parent;
252  const Descriptor * _descriptor; // descripteur
253  std::map<int, std::shared_ptr<Pin>> _pin; // toutes les broches
254  };
255 }
260 /* ========================================================================== */
261 #endif /*_SYSIO_GPIO_CONNECTOR_H_ defined */
void printTitle(std::ostream &os) const
Affiche l&#39;entête d&#39;un tableau de broches.
virtual ~Connector()
Destructeur.
Descripteur d&#39;un connecteur.
Definition: gpioconnector.h:52
Classe Gpio.
Definition: gpio.h:53
void close()
Fermeture du GPIO.
Device * device() const
Accès à la couche matérielle.
bool isOpen() const
Indique si ouvert.
Broche d&#39;un connecteur.
Definition: gpiopin.h:59
bool isDebug() const
Indique si le mode mise au point est actif.
Gpio * gpio() const
Accès au GPIO parent.
void printRow(std::ostream &os, int num) const
Affiche une ligne d&#39;un tableau de broches Si le connecteur à 2 colonnes, les broches num et num+1 son...
Connecteur.
Definition: gpioconnector.h:30
int(* PinNumberFunc)(int row, int column, int columns)
Fonction de calcul du numéro d&#39;une broche de connecteur Le numéro d&#39;une broche dépend de sa ligne row...
Definition: gpioconnector.h:44
void setDebug(bool enable)
Active le mode mise au point.
Definition: clock.h:18
Connector(Gpio *parent, const Descriptor *desc)
Constructeur.
bool open()
Ouverture.
int columns() const
Nombre de colonnes.
void printHline(std::ostream &os) const
Affiche une ligne horizontale d&#39;un tableau de broches.
friend std::ostream & operator<<(std::ostream &os, const Connector *c)
Affiche toutes les informations sur le connecteur et ses broches.
int size() const
Nombre de broches.