RPICSIO

The OutputPortMM Class

 

The OutputPortMM Class

The OutputPortMM class is designed to set the state (high or low) of a GPIO pin on the Raspberry Pi via a Memory Mapped access method. The maximum output rate has been observed to be in the range of about 2.4MHz (yes, mega Hz). The OutputPortFS class is a similar version of this class which uses SYSFS access.

IMPORTANT NOTE: Before creating any RPICSIO Port class you will need to ensure that the RPICSIO Library knows which type of Raspberry Pi you are dealing with. This is done by executing a call (only once is necessary) like the one below somewhere in your code before you create any port.

            RPICSIOConfig.Instance.RPIType = RPITypeEnum.RPITYPE_RPI2;

 

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 Output Port Example page.

 

Syntax

public class OutputPortMM : PortMM, IDisposable

Provides output port functionality for a Raspberry Pi (Memory Mapped Version).

 

Public Constructors

public OutputPortMM(GpioEnum gpioIDIn) : base(gpioIDIn)

Constructor.

Parameters
gpioIDIn - The GPIO the port will access.

 

public OutputPortMM(GpioEnum gpioIDIn, bool initialState) : base(gpioIDIn)

Constructor.

Parameters
gpioIDIn - The GPIO the port will access.
initialState - The initial state, true or false, of the port.

 

Public Methods

public override void ClosePort()

Closes the port. Throws an exception on failure, including if the port is already closed.

 

public void Dispose()

Implements IDisposable. Should be called after the class is closed to release resources.

 

public override PortDirectionEnum PortDirection()

Gets the PortDirection

Returns
A PortDirectionEnum value. This value is always PortDirectionEnum.PORTDIR_INPUT.

 

public bool Read()

Gets the port value (high or low) as a boolean.

Returns
true, the GPIO pin is at a high voltage level. false - GPIO pin is at a low voltage level.

 

public void Write(bool valueToSet)

Sets the port state.

Parameters
true, set the GPIO pin to a high voltage level. false - set the GPIO pin to a low voltage level.

 

Public Properties

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.