BBBCSIO
The InterruptPortMM Class
The InterruptPortMM Class
The InterruptPortMM class is designed to monitor the state (high or low) of a GPIO pin on the Beaglebone Black and send an event through
a designated .NET delegate when the state changes to a pre-defined trigger level. All access is via a Memory Mapped access method.
There is no version of this class which uses SYSFS access.
Source Code
The source code for this class is available online for
download
and also in
browseable form.
Example Code
Example code which demonstrates the use of this class can be found on the Interrupt Port Example page.
Syntax
public class InterruptPortMM : PortMM, IComparable, IDisposable
Provides interrupt port functionality for a BeagleBone Black (Memory Mapped Version).
Public Constructors
public InterruptPortMM (GpioEnum gpioIn, InterruptMode eventInterruptModeIn) : base(gpioIn)
Constructor.
- Parameters
- gpioIDIn - The GPIO the port will access.
- InterruptMode - The Interrupt Mode the port will trigger on.
public InterruptPortMM (GpioEnum gpioIn, InterruptMode eventInterruptModeIn, int evPriorityIn, int evCodeIn) : base(gpioIn)
Constructor.
- Parameters
- gpioIDIn - The GPIO the port will access.
- InterruptMode - The Interrupt Mode the port will trigger on.
- evPriorityIn - The event priority relative to other InterruptPort objects on the same GPIO bank. Higher numbers are processed first.
- evCodeIn - A user specified code which appears in the event output.
Public Fields
public event InterruptEventHandlerMM OnInterrupt;
The event through which the InterruptPort class transmits the interrupt data to other objects.
Public Methods
public void ClearInterrupt()
Clears the interrupt. Must be called after every interrupt before a new interrupt can be received.
public override void ClosePort()
Closes the port. Dispose() should subsequently be called to release resources. It is not possible to re-open a
closed InterruptPort - a new instance must be created.
public void DisableInterrupt()
Disables the interrupt. Interrupts can be disabled when not needed and re-enabled without re-creating the interrupt.
public void Dispose()
Implements IDisposable. Should be called after the class is closed to release resources.
public void EnableInterrupt()
Enables the interrupt. Interrupts can be disabled when not needed and re-enabled without re-creating the interrupt.
public override PortDirectionEnum PortDirection()
Returns the port direction. This value is always PortDirectionEnum.PORTDIR_INPUT.
- Returns
- A PortDirectionEnum value.
Public Properties
public int InterruptEventPriority { get; set; }
Gets/Sets the event priority. For InterruptPorts on the same bank,
the InterruptPort with the higher priority will be activated in
preference to the others if there simultaneous events.
- value
- The event priority relative to other InterruptPort objects on the same GPIO bank. Higher numbers are processed first.
public int EvCode { get; }
Gets/Sets the event code. This is a userdefined value specified when the interrupt port was created and will
be present in the generated interrupt event.
- value
- A user defined value specified when the interrupt port was created.
public GpioConfig GpioCfgObject { get; }
Gets the objects gpioCfgObject. There is no set accessor. This object is built in the constructor
- value
- The working gpioID.
public GpioEnum GpioID { get; }
Gets the objects gpioID. There is no set accessor. This value is set in the constructor
- value
- The working gpioID.
public int InterruptEventsReceived { get; set; }
Gets/Sets the count of events received. Events triggered and lost because the processing of another event
took too long are not included in this count.
- value
- The count of events received.
public int InterruptEventsSent { get; set; }
Gets/Sets the cound of events sent. It is possible to receive an event and not send it if the port is not enabled when the event is received.
- value
- The count of events sent.
public InterruptMode EventInterruptMode { get; set; }
Gets/Sets the events interrupt mode.
- value
- The events interrupt mode