22#include <piduino/converter.h>
23#include <piduino/gpio2.h>
175 std::map<Mode, std::string>
name;
179 Descriptor (
long long pinId = -1,
int pinRow = -1,
int pinColumn = -1);
346 static const std::map<Type, std::string> &
types();
352 const std::string &
name()
const;
377 const std::map<Mode, std::string> &
modes()
const;
408 static const std::map<Pull, std::string> &
pulls();
552 long long id()
const;
The Converter class provides an interface for analog-to-digital and digital-to-analog converters.
Abstract base class for GPIO devices.
Describes a pin's type, numbering, and associated names.
void insertModeName(Mode m, const std::string &n)
Inserts a mode-name pair into the descriptor.
Number num
Pin numbering information.
long long findId() const
Finds the unique identifier for the pin.
long long id
Unique identifier for the pin.
bool insert()
Inserts the descriptor into the system.
bool hasModeName(Mode m, long long nameId) const
Checks if a mode name exists for a given mode and name ID.
std::map< Mode, std::string > name
Map of mode to pin name.
long long findName(const std::string &name) const
Finds the identifier for a given name.
Descriptor(long long pinId=-1, int pinRow=-1, int pinColumn=-1)
Constructs a Descriptor with optional parameters.
Holds various numbering representations for a pin.
int mcu
MCU-specific pin number.
int system
System pin number.
int chip
Chip number (for multi-chip systems).
int logical
Logical pin number.
int row
Row position (if applicable).
int column
Column position (if applicable).
int offset
Offset within the chip.
Number(int logical=-1, int mcu=-1, int system=-1, int row=-1, int column=-1, int chip=-1, int offset=-1)
Constructs a Number object with optional parameters.
Represents a SPI chip select configuration for a pin.
Pin::Mode mode
Pin mode for SPI.
int cs
Chip select number.
long long pin
Pin identifier.
Represents a general-purpose input/output (GPIO) pin and its configuration.
static const std::map< Pull, std::string > & pulls()
Returns the map of available pull configurations and their names.
Numbering
Enumerates the possible pin numbering schemes.
@ NumberingUnknown
Unknown or uninitialized numbering.
@ NumberingSystem
System numbering.
@ NumberingLogical
Logical numbering.
@ NumberingMcu
MCU-specific numbering.
Connector * connector() const
Returns the parent connector of the pin.
static const std::map< Numbering, std::string > & numberings()
Returns the map of available numbering schemes and their names.
int mcuNumber() const
Returns the MCU-specific pin number.
std::unique_ptr< Private > d_ptr
Unique pointer to the private implementation.
int drive()
Returns the drive strength of the pin.
bool read() const
Reads the digital value from the pin.
static const std::string & pullName(Pull n)
Returns the name of a specific pull configuration.
void release()
Releases the pin, closing any open resources.
int chipOffset() const
Returns the offset within the chip.
const std::string & pullName()
Returns the name of the current pull configuration.
void waitForInterrupt(Edge edge, Event &event, int timeout_ms=-1)
Waits for an interrupt event and returns the event data.
friend std::ostream & operator<<(std::ostream &os, const Pin &p)
Overloaded output stream operator for Pin.
int physicalNumber() const
Returns the physical pin number.
int row() const
Returns the row position of the pin.
bool isDebug() const
Checks if debug mode is enabled for the pin.
void write(bool value)
Writes a digital value to the pin.
Mode mode() const
Returns the current mode of the pin.
const std::string & modeName(Mode mode) const
Returns the name of a specific mode.
void setDebug(bool enable)
Enables or disables debug mode for the pin.
void waitForInterrupt(Edge edge, int debounce_ms, Event &event, int timeout_ms=-1)
Waits for an interrupt event with debounce and returns the event data.
static const std::map< Type, std::string > & types()
Returns the map of available pin types and their names.
static const std::string & numberingName(Numbering n)
Returns the name of a numbering scheme.
Type
Enumerates the possible types of pins.
@ TypeUnknown
Unknown or uninitialized type.
@ TypeNotConnected
Not connected.
@ TypeGpio
General-purpose I/O pin.
int systemNumber() const
Returns the system pin number.
void resetDac()
Resets the DAC converter for the pin.
bool isGpioDevEnabled() const
Checks if the GPIO device is enabled.
int logicalNumber() const
Returns the logical pin number.
Type type() const
Returns the type of the pin.
Pin(Connector *parent, const Descriptor *desc)
Constructs a Pin object.
const std::map< Mode, std::string > & modes() const
Returns the map of available modes and their names.
bool enableGpioDev(bool enable=true)
Enables or disables the GPIO device.
int number(Numbering numbering) const
Returns the pin number according to the specified numbering scheme.
int column() const
Returns the column position of the pin.
void setMode(Mode mode)
Sets the mode of the pin.
GpioDevice * device() const
Returns the underlying GPIO device.
virtual ~Pin()
Destructor for the Pin object.
Pin(Private &dd)
Constructs a Pin object from a Private data reference.
Pull pull() const
Returns the current pull resistor configuration.
void attachInterrupt(Isr isr, Edge edge, void *userData=nullptr)
Attaches an interrupt handler to the pin.
Gpio * gpio() const
Returns the GPIO object associated with the pin.
AccessLayer accessLayer() const
Returns the access layer used by the pin.
long long id() const
Returns the unique identifier of the pin.
bool open()
Opens the pin for use.
void close()
Closes the pin and releases resources.
unsigned int flags() const
Gets the capability flags of the GPIO Pin.
void analogWrite(long value)
Writes an analog value to the pin (PWM or DAC).
Converter * dac()
Returns the DAC converter associated with the pin.
const std::string & modeName()
Returns the name of the current mode.
const std::string & typeName() const
Returns the name of the pin type.
void attachInterrupt(Isr isr, Edge edge, int debounce_ms, void *userData=nullptr)
Attaches an interrupt handler with debounce.
void detachInterrupt()
Detaches the interrupt handler from the pin.
void(* Isr)(Event event, void *userData)
Interrupt service routine callback type.
void toggle()
Toggles the digital output value of the pin.
Pull
Enumerates the possible pull resistor configurations.
@ PullDown
Pull-down resistor enabled.
@ PullOff
No pull resistor.
@ PullUp
Pull-up resistor enabled.
@ PullUnknown
Unknown or uninitialized pull configuration.
void setDrive(int drive)
Sets the drive strength of the pin.
void setPull(Pull pull)
Sets the pull resistor configuration.
Mode
Enumerates the possible modes for a pin.
@ ModeAlt2
Alternate function 2.
@ ModePwm
Pin is configured for PWM output.
@ ModeInput
Pin is configured as input.
@ ModeOutput
Pin is configured as output.
@ ModeAlt9
Alternate function 9.
@ ModeAlt8
Alternate function 8.
@ ModeAlt1
Alternate function 1.
@ ModeAlt5
Alternate function 5.
@ ModeAlt6
Alternate function 6.
@ ModeDisabled
Pin is disabled.
@ ModeAlt3
Alternate function 3.
@ ModeAlt4
Alternate function 4.
@ ModeAlt7
Alternate function 7.
@ ModeUnknown
Unknown or uninitialized mode.
@ ModeAlt0
Alternate function 0.
Edge
Enumerates the possible edge detection types for interrupts.
@ EdgeUnknown
Unknown or uninitialized edge type.
@ EdgeFalling
Detect falling edge.
@ EdgeNone
No edge detection.
@ EdgeBoth
Detect both rising and falling edges.
@ EdgeRising
Detect rising edge.
bool isOpen() const
Checks if the pin is open.
void waitForInterrupt(Edge edge, int timeout_ms=-1)
Waits for an interrupt event on the pin.
const std::string & name(Mode mode) const
Returns the name of the pin for a specific mode.
int chipNumber() const
Returns the chip number for the pin.
bool setDac(Converter *dac)
Sets the DAC converter for the pin.
const std::string & name() const
Returns the default name of the pin.
static const std::string & typeName(Type t)
Returns the name of a given pin type.
Internal implementation class for GpioDevice.
#define PIMP_DECLARE_PRIVATE(Class)
PIMP_DECLARE_PRIVATE.
Global namespace for Piduino.
AccessLayer
Enumerates the possible hardware access layers for GPIO operations.
The actual event being pushed to userspace.