PIDUINO
Loading...
Searching...
No Matches
gpio.h
1/* Copyright © 2015-2025 Pascal JEAN, All rights reserved.
2 This file is part of the Piduino Library.
3
4 The Piduino Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 3 of the License, or (at your option) any later version.
8
9 The Piduino Library is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 Lesser General Public License for more details.
13
14 You should have received a copy of the GNU Lesser General Public License
15 along with the Piduino Library; if not, see <http://www.gnu.org/licenses/>.
16*/
17#pragma once
18
19#include <string>
20#include <vector>
21#include <map>
22#include <memory>
23#include <exception>
24#include <piduino/gpioconnector.h>
25#include <piduino/soc.h>
26
39namespace Piduino {
40
41 class GpioDevice;
42
54 class Gpio {
55 public:
56 friend class Connector;
57
64 class Descriptor {
65 public:
66 std::string name;
67 long long id;
68 std::vector<Connector::Descriptor> connector;
69 // -- functions
70 Descriptor (long long gpioId = -1);
71 bool insert ();
72 bool hasConnector (const Connector::Descriptor &c) const;
73 long long findId() const;
74 };
75
76
84
91 Gpio (long long gpioDatabaseId, const SoC & soc, AccessLayer layer);
92
96 virtual ~Gpio();
97
102 bool open();
103
107 void close();
108
112 bool isOpen() const;
113
117 const std::string &name() const;
118
122 long long id() const;
123
132 void setReleaseOnClose (bool enable);
133
142 bool releaseOnClose() const;
143
150
156
160 const std::string &numberingName () const;
161
166
170 bool isDebug() const;
171
178 void setDebug (bool enable);
179
180 //------------------------------------------------------------------------
181 // Accès aux connecteurs
182 //------------------------------------------------------------------------
183
187 int connectors() const;
188
198 Connector *connector (int conn) const;
199
216 const std::map<int, std::shared_ptr<Connector>> &connector();
217
218
219 //------------------------------------------------------------------------
220 // Accès aux broches
221 //------------------------------------------------------------------------
222
226 int size() const;
227
239 Pin &pin (int num) const;
240
251 Pin *pin (long long id) const;
252
270 const std::map<int, std::shared_ptr<Pin>> &pin();
271
272 protected:
277
286 //explicit Gpio (GpioDevice * device, AccessLayer layer);
287
288 protected:
289 class Private;
291 std::unique_ptr<Private> d_ptr;
292
293 private:
295
296 };
297 // ---------------------------------------------------------------------------
298 //
299 // Piduino Gpio Global Object
300 //
301 // ---------------------------------------------------------------------------
302 extern Gpio gpio;
306}
307
308/* ========================================================================== */
Descripteur d'un connecteur.
Descripteur d'un GPIO.
Definition gpio.h:64
std::vector< Connector::Descriptor > connector
Descripteurs des connecteurs.
Definition gpio.h:68
std::string name
Nom de la carte.
Definition gpio.h:66
bool insert()
Insertion dans la base de données.
long long id
Database Id.
Definition gpio.h:67
long long findId() const
bool hasConnector(const Connector::Descriptor &c) const
Descriptor(long long gpioId=-1)
Abstract base class for GPIO devices.
Definition gpiodevice.h:34
Classe Gpio.
Definition gpio.h:54
Pin & pin(int num) const
Broche GPIO.
const std::string & numberingName() const
Nom de la numérotation en cours.
bool releaseOnClose() const
Lecture la libération des broches à la fermeture.
bool isDebug() const
Indique si le mode mise au point est actif.
const std::map< int, std::shared_ptr< Pin > > & pin()
Liste des broches de type GPIO.
Gpio(Private &dd)
std::unique_ptr< Private > d_ptr
Definition gpio.h:291
const std::string & name() const
Nom de la carte.
bool isOpen() const
Indique si ouvert.
void close()
Fermeture du GPIO.
void setNumbering(Pin::Numbering numbering)
Modifie la numérotation.
Gpio(AccessLayer layer=AccessLayerAuto)
Constructeur par défaut.
void setDebug(bool enable)
Active le mode mise au point.
int connectors() const
Nombre de connecteurs.
virtual ~Gpio()
Destructeur.
void setReleaseOnClose(bool enable)
Modifie la libération des broches à la fermeture.
AccessLayer accessLayer() const
Lecture de la couche d'accès utilisée.
bool open()
Ouverture.
Pin * pin(long long id) const
Broche GPIO par identifiant de base de données.
GpioDevice * device() const
Accès à la couche matérielle.
int size() const
Nombre de broches de type GPIO sur la carte(TypeGpio)
Gpio(long long gpioDatabaseId, const SoC &soc, AccessLayer layer)
Constructeur.
Connector * connector(int conn) const
Connecteur.
const std::map< int, std::shared_ptr< Connector > > & connector()
Liste des connecteurs de la carte.
long long id() const
Identifiant en base de données.
Pin::Numbering numbering() const
Numérotation en cours.
Represents a general-purpose input/output (GPIO) pin and its configuration.
Definition gpiopin.h:68
Numbering
Enumerates the possible pin numbering schemes.
Definition gpiopin.h:121
Internal implementation class for GpioDevice.
#define PIMP_DECLARE_PRIVATE(Class)
PIMP_DECLARE_PRIVATE.
Definition global.h:82
Gpio gpio
Piduino Gpio Global Object.
Global namespace for Piduino.
Definition board.h:28
AccessLayer
Enumerates the possible hardware access layers for GPIO operations.
Definition gpiopin.h:48
@ AccessLayerAuto
Definition gpiopin.h:49