Update documentation
This commit is contained in:
parent
60027f5580
commit
bdfc868f10
@ -1,55 +1,55 @@
|
|||||||
#include "gpio.h"
|
#include "gpio.h"
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
\class Gpio
|
\class Gpio
|
||||||
\brief Represents a system GPIO in linux systems.
|
\brief Represents a system GPIO in linux systems.
|
||||||
|
|
||||||
A "General Purpose Input/Output" (GPIO) is a flexible software-controlled
|
A "General Purpose Input/Output" (GPIO) is a flexible software-controlled
|
||||||
digital signal. They are provided from many kinds of chip, and are familiar
|
digital signal. They are provided from many kinds of chip, and are familiar
|
||||||
to Linux developers working with embedded and custom hardware. Each GPIO
|
to Linux developers working with embedded and custom hardware. Each GPIO
|
||||||
represents a bit connected to a particular pin, or "ball" on Ball Grid Array
|
represents a bit connected to a particular pin, or "ball" on Ball Grid Array
|
||||||
(BGA) packages. Board schematics show which external hardware connects to
|
(BGA) packages. Board schematics show which external hardware connects to
|
||||||
which GPIOs. Drivers can be written generically, so that board setup code
|
which GPIOs. Drivers can be written generically, so that board setup code
|
||||||
passes such pin configuration data to drivers
|
passes such pin configuration data to drivers
|
||||||
(\l{https://www.kernel.org/doc/Documentation/gpio/gpio.txt}{source}).
|
(\l{https://www.kernel.org/doc/Documentation/gpio/gpio.txt}{source}).
|
||||||
General Purpose Input/Output (a.k.a. GPIO) is a generic pin on a chip whose
|
General Purpose Input/Output (a.k.a. GPIO) is a generic pin on a chip whose
|
||||||
behavior (including whether it is an input or output pin) can be controlled
|
behavior (including whether it is an input or output pin) can be controlled
|
||||||
through this class. An object of of the Gpio class represents a pin.
|
through this class. An object of of the Gpio class represents a pin.
|
||||||
|
|
||||||
\code
|
\code
|
||||||
Gpio *gpioOut = new Gpio(23, this);
|
Gpio *gpioOut = new Gpio(23, this);
|
||||||
// Export Gpio
|
// Export Gpio
|
||||||
if (!gpioOut->exportGpio()) {
|
if (!gpioOut->exportGpio()) {
|
||||||
qWarning() << "Could not export Gpio" << gpioOut->gpioNumber();
|
qWarning() << "Could not export Gpio" << gpioOut->gpioNumber();
|
||||||
gpioOut->deleteLater();
|
gpioOut->deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Configure Gpio direction
|
// Configure Gpio direction
|
||||||
if (!gpioOut->setDirection(PiGpio::DirectionOutput)) {
|
if (!gpioOut->setDirection(PiGpio::DirectionOutput)) {
|
||||||
qWarning() << "Could not set direction of Gpio" << gpioOut->gpioNumber();
|
qWarning() << "Could not set direction of Gpio" << gpioOut->gpioNumber();
|
||||||
gpioOut->deleteLater();
|
gpioOut->deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
gpioOut->setValue(Gpio::ValueHigh)
|
gpioOut->setValue(Gpio::ValueHigh)
|
||||||
\endcode
|
\endcode
|
||||||
|
|
||||||
\code
|
\code
|
||||||
Gpio *gpioIn = new Gpio(24, this);
|
Gpio *gpioIn = new Gpio(24, this);
|
||||||
// Export Gpio
|
// Export Gpio
|
||||||
if (!gpioIn->exportGpio()) {
|
if (!gpioIn->exportGpio()) {
|
||||||
qWarning() << "Could not export Gpio" << gpioIn->gpioNumber();
|
qWarning() << "Could not export Gpio" << gpioIn->gpioNumber();
|
||||||
gpioIn->deleteLater();
|
gpioIn->deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// Configure Gpio direction
|
// Configure Gpio direction
|
||||||
if (!gpioIn->setDirection(PiGpio::DirectionInput)) {
|
if (!gpioIn->setDirection(PiGpio::DirectionInput)) {
|
||||||
qWarning() << "Could not set direction of Gpio" << gpioIn->gpioNumber();
|
qWarning() << "Could not set direction of Gpio" << gpioIn->gpioNumber();
|
||||||
gpioIn->deleteLater();
|
gpioIn->deleteLater();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
qDebug() << "Current value" << gpioIn->value();
|
qDebug() << "Current value" << gpioIn->value();
|
||||||
\endcode
|
\endcode
|
||||||
\sa GpioMonitor, GpioButton
|
\sa GpioMonitor, GpioButton
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*! \enum Gpio::Direction
|
/*! \enum Gpio::Direction
|
||||||
@ -86,7 +86,7 @@
|
|||||||
|
|
||||||
Q_LOGGING_CATEGORY(dcGpio, "Gpio")
|
Q_LOGGING_CATEGORY(dcGpio, "Gpio")
|
||||||
|
|
||||||
/*! Constructs a \l{Gpio} object to represent a GPIO with the given \a gpio number and \a parent. */
|
/*! Constructs a Gpio object to represent a GPIO with the given \a gpio number and \a parent. */
|
||||||
Gpio::Gpio(int gpio, QObject *parent) :
|
Gpio::Gpio(int gpio, QObject *parent) :
|
||||||
QObject(parent),
|
QObject(parent),
|
||||||
m_gpio(gpio),
|
m_gpio(gpio),
|
||||||
@ -96,7 +96,7 @@ Gpio::Gpio(int gpio, QObject *parent) :
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*! Destroys and unexports the \l{Gpio}. */
|
/*! Destroys and unexports the Gpio. */
|
||||||
Gpio::~Gpio()
|
Gpio::~Gpio()
|
||||||
{
|
{
|
||||||
unexportGpio();
|
unexportGpio();
|
||||||
|
|||||||
Reference in New Issue
Block a user