2019-12-06 22:24:34 +01:00
|
|
|
|
using System;
|
|
|
|
|
|
|
|
|
|
namespace Unosquare.RaspberryIO.Abstractions {
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Interface for GPIO Pin on a RaspberryPi board.
|
|
|
|
|
/// </summary>
|
|
|
|
|
public interface IGpioPin {
|
2019-12-04 18:57:18 +01:00
|
|
|
|
/// <summary>
|
2019-12-06 22:24:34 +01:00
|
|
|
|
/// Gets the <see cref="Abstractions.BcmPin"/>.
|
2019-12-04 18:57:18 +01:00
|
|
|
|
/// </summary>
|
2019-12-06 22:24:34 +01:00
|
|
|
|
/// <value>
|
|
|
|
|
/// The pin number.
|
|
|
|
|
/// </value>
|
|
|
|
|
BcmPin BcmPin {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the BCM chip (hardware) pin number.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The pin number.
|
|
|
|
|
/// </value>
|
|
|
|
|
Int32 BcmPinNumber {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the physical (header) pin number.
|
|
|
|
|
/// </summary>
|
|
|
|
|
Int32 PhysicalPinNumber {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets the pin's header (physical board) location.
|
|
|
|
|
/// </summary>
|
|
|
|
|
GpioHeader Header {
|
|
|
|
|
get;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets the pin operating mode.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// The pin mode.
|
|
|
|
|
/// </value>
|
|
|
|
|
GpioPinDriveMode PinMode {
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// This sets or gets the pull-up or pull-down resistor mode on the pin, which should be set as an input.
|
|
|
|
|
/// Unlike the Arduino, the BCM2835 has both pull-up an down internal resistors.
|
|
|
|
|
/// The parameter pud should be; PUD_OFF, (no pull up/down), PUD_DOWN (pull to ground) or PUD_UP (pull to 3.3v)
|
|
|
|
|
/// The internal pull up/down resistors have a value of approximately 50KΩ on the Raspberry Pi.
|
|
|
|
|
/// </summary>
|
|
|
|
|
GpioPinResistorPullMode InputPullMode {
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Gets or sets a value indicating whether this <see cref="IGpioPin"/> is value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <value>
|
|
|
|
|
/// <c>true</c> if value; otherwise, <c>false</c>.
|
|
|
|
|
/// </value>
|
|
|
|
|
Boolean Value {
|
|
|
|
|
get; set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Reads the digital value on the pin as a boolean value.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns>The state of the pin.</returns>
|
|
|
|
|
Boolean Read();
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes the specified bit value.
|
|
|
|
|
/// This method performs a digital write.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">if set to <c>true</c> [value].</param>
|
|
|
|
|
void Write(Boolean value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Writes the specified pin value.
|
|
|
|
|
/// This method performs a digital write.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="value">The value.</param>
|
|
|
|
|
void Write(GpioPinValue value);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Wait for specific pin status.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="status">status to check.</param>
|
|
|
|
|
/// <param name="timeOutMillisecond">timeout to reach status.</param>
|
|
|
|
|
/// <returns>true/false.</returns>
|
|
|
|
|
Boolean WaitForValue(GpioPinValue status, Int32 timeOutMillisecond);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Registers the interrupt callback on the pin. Pin mode has to be set to Input.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="edgeDetection">The edge detection.</param>
|
|
|
|
|
/// <param name="callback">The callback function. This function is called whenever
|
|
|
|
|
/// the interrupt occurs.</param>
|
|
|
|
|
void RegisterInterruptCallback(EdgeDetection edgeDetection, Action callback);
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Registers the interrupt callback on the pin. Pin mode has to be set to Input.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="edgeDetection">The edge detection.</param>
|
|
|
|
|
/// <param name="callback">The callback function. This function is called whenever the interrupt occurs.
|
|
|
|
|
/// The function is passed the GPIO, the current level, and the current tick
|
|
|
|
|
/// (The number of microseconds since boot).</param>
|
|
|
|
|
void RegisterInterruptCallback(EdgeDetection edgeDetection, Action<Int32, Int32, UInt32> callback);
|
|
|
|
|
}
|
2019-12-04 18:57:18 +01:00
|
|
|
|
}
|