diff --git a/Unosquare.RaspberryIO.Abstractions/Definitions.cs b/Unosquare.RaspberryIO.Abstractions/Definitions.cs
index b1e368c..ba537e8 100644
--- a/Unosquare.RaspberryIO.Abstractions/Definitions.cs
+++ b/Unosquare.RaspberryIO.Abstractions/Definitions.cs
@@ -1,28 +1,20 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Represents Definitions for GPIO information.
+ ///
+ public static class Definitions {
+ private static readonly Int32[] GpioToPhysR1 = { 3, 5, -1, -1, 7, -1, -1, 26, 24, 21, 19, 23, -1, -1, 8, 10, -1, 11, 12, -1, -1, 13, 15, 16, 18, 22, -1, -1, -1, -1, -1, -1 };
+
+ private static readonly Int32[] GpioToPhysR2 = { 27, 28, 3, 5, 7, 29, 31, 26, 24, 21, 19, 23, 32, 33, 8, 10, 36, 11, 12, 35, 38, 40, 15, 16, 18, 22, 37, 13, /*P1*/ 3, 4, 5, 6 /*P5*/ };
+
///
- /// Represents Definitions for GPIO information.
+ /// BCMs to physical pin number.
///
- public static class Definitions
- {
- private static readonly int[] GpioToPhysR1 =
- {
- 3, 5, -1, -1, 7, -1, -1, 26, 24, 21, 19, 23, -1, -1, 8, 10, -1, 11, 12, -1, -1, 13, 15, 16, 18, 22, -1, -1, -1, -1, -1, -1,
- };
-
- private static readonly int[] GpioToPhysR2 =
- {
- 27, 28, 3, 5, 7, 29, 31, 26, 24, 21, 19, 23, 32, 33, 8, 10, 36, 11, 12, 35, 38, 40, 15, 16, 18, 22, 37, 13, // P1
- 3, 4, 5, 6, // P5
- };
-
- ///
- /// BCMs to physical pin number.
- ///
- /// The rev.
- /// The BCM pin.
- /// The physical pin number.
- public static int BcmToPhysicalPinNumber(BoardRevision rev, BcmPin bcmPin) =>
- rev == BoardRevision.Rev1 ? GpioToPhysR1[(int)bcmPin] : GpioToPhysR2[(int)bcmPin];
- }
+ /// The rev.
+ /// The BCM pin.
+ /// The physical pin number.
+ public static Int32 BcmToPhysicalPinNumber(BoardRevision rev, BcmPin bcmPin) => rev == BoardRevision.Rev1 ? GpioToPhysR1[(Int32)bcmPin] : GpioToPhysR2[(Int32)bcmPin];
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/Enums.cs b/Unosquare.RaspberryIO.Abstractions/Enums.cs
index 0a25eed..f3eb1da 100644
--- a/Unosquare.RaspberryIO.Abstractions/Enums.cs
+++ b/Unosquare.RaspberryIO.Abstractions/Enums.cs
@@ -1,527 +1,515 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Defines the SPI channel numbers.
+ ///
+ public enum SpiChannelNumber {
///
- /// Defines the SPI channel numbers.
+ /// The channel 0
///
- public enum SpiChannelNumber
- {
- ///
- /// The channel 0
- ///
- Channel0 = 0,
-
- ///
- /// The channel 1
- ///
- Channel1 = 1,
- }
-
+ Channel0 = 0,
+
///
- /// Defines the GPIO Pin values 0 for low, 1 for High.
+ /// The channel 1
///
- public enum GpioPinValue
- {
- ///
- /// Digital high
- ///
- High = 1,
-
- ///
- /// Digital low
- ///
- Low = 0,
- }
-
+ Channel1 = 1,
+ }
+
+ ///
+ /// Defines the GPIO Pin values 0 for low, 1 for High.
+ ///
+ public enum GpioPinValue {
///
- /// The GPIO pin resistor mode. This is used on input pins so that their
- /// lines are not floating.
+ /// Digital high
///
- public enum GpioPinResistorPullMode
- {
- ///
- /// Pull resistor not active. Line floating
- ///
- Off = 0,
-
- ///
- /// Pull resistor sets a default value of 0 on no-connects
- ///
- PullDown = 1,
-
- ///
- /// Pull resistor sets a default value of 1 on no-connects
- ///
- PullUp = 2,
- }
-
+ High = 1,
+
///
- /// Defines the different drive modes of a GPIO pin.
+ /// Digital low
///
- public enum GpioPinDriveMode
- {
- ///
- /// Input drive mode (perform reads)
- ///
- Input = 0,
-
- ///
- /// Output drive mode (perform writes)
- ///
- Output = 1,
-
- ///
- /// PWM output mode (only certain pins support this -- 2 of them at the moment)
- ///
- PwmOutput = 2,
-
- ///
- /// GPIO Clock output mode (only a pin supports this at this time)
- ///
- GpioClock = 3,
-
- ///
- /// The alt0 operating mode
- ///
- Alt0 = 4,
-
- ///
- /// The alt1 operating mode
- ///
- Alt1 = 5,
-
- ///
- /// The alt2 operating mode
- ///
- Alt2 = 6,
-
- ///
- /// The alt3 operating mode
- ///
- Alt3 = 7,
- }
-
+ Low = 0,
+ }
+
+ ///
+ /// The GPIO pin resistor mode. This is used on input pins so that their
+ /// lines are not floating.
+ ///
+ public enum GpioPinResistorPullMode {
///
- /// Defines the different threading locking keys.
+ /// Pull resistor not active. Line floating
///
- public enum ThreadLockKey
- {
- ///
- /// The lock 0
- ///
- Lock0 = 0,
-
- ///
- /// The lock 1
- ///
- Lock1 = 1,
-
- ///
- /// The lock 2
- ///
- Lock2 = 2,
-
- ///
- /// The lock 3
- ///
- Lock3 = 3,
- }
-
+ Off = 0,
+
///
- /// Defines the different edge detection modes for pin interrupts.
+ /// Pull resistor sets a default value of 0 on no-connects
///
- public enum EdgeDetection
- {
- ///
- /// Falling Edge
- ///
- FallingEdge,
-
- ///
- /// Rising edge
- ///
- RisingEdge,
-
- ///
- /// Both, falling and rising edges
- ///
- FallingAndRisingEdge,
- }
-
+ PullDown = 1,
+
///
- /// The hardware revision of the board.
+ /// Pull resistor sets a default value of 1 on no-connects
///
- public enum BoardRevision
- {
- ///
- /// Revision 1 (the early Model A and B's).
- ///
- Rev1 = 1,
-
- ///
- /// Revision 2 (everything else - it covers the B, B+ and CM).
- ///
- Rev2 = 2,
- }
-
+ PullUp = 2,
+ }
+
+ ///
+ /// Defines the different drive modes of a GPIO pin.
+ ///
+ public enum GpioPinDriveMode {
///
- /// Defines the Header connectors available.
+ /// Input drive mode (perform reads)
///
- public enum GpioHeader
- {
- ///
- /// Not defined
- ///
- None,
-
- ///
- /// P1 connector (main connector)
- ///
- P1,
-
- ///
- /// P5 connector (auxiliary, not commonly used)
- ///
- P5,
- }
-
+ Input = 0,
+
///
- /// Defines all the BCM Pin numbers available for the user.
+ /// Output drive mode (perform writes)
///
- public enum BcmPin
- {
- ///
- /// GPIO 0
- ///
- Gpio00 = 0,
-
- ///
- /// GPIO 1
- ///
- Gpio01 = 1,
-
- ///
- /// GPIO02
- ///
- Gpio02 = 2,
-
- ///
- /// GPIO 3
- ///
- Gpio03 = 3,
-
- ///
- /// GPIO 4
- ///
- Gpio04 = 4,
-
- ///
- /// GPIO 5
- ///
- Gpio05 = 5,
-
- ///
- /// GPIO 6
- ///
- Gpio06 = 6,
-
- ///
- /// GPIO 7
- ///
- Gpio07 = 7,
-
- ///
- /// GPIO 8
- ///
- Gpio08 = 8,
-
- ///
- /// GPIO 9
- ///
- Gpio09 = 9,
-
- ///
- /// GPIO 10
- ///
- Gpio10 = 10,
-
- ///
- /// GPIO 11
- ///
- Gpio11 = 11,
-
- ///
- /// GPIO 12
- ///
- Gpio12 = 12,
-
- ///
- /// GPIO 13
- ///
- Gpio13 = 13,
-
- ///
- /// GPIO 14
- ///
- Gpio14 = 14,
-
- ///
- /// GPIO 15
- ///
- Gpio15 = 15,
-
- ///
- /// GPIO 16
- ///
- Gpio16 = 16,
-
- ///
- /// GPIO 17
- ///
- Gpio17 = 17,
-
- ///
- /// GPIO 18
- ///
- Gpio18 = 18,
-
- ///
- /// GPIO 19
- ///
- Gpio19 = 19,
-
- ///
- /// GPIO 20
- ///
- Gpio20 = 20,
-
- ///
- /// GPIO 21
- ///
- Gpio21 = 21,
-
- ///
- /// GPIO 22
- ///
- Gpio22 = 22,
-
- ///
- /// GPIO 23
- ///
- Gpio23 = 23,
-
- ///
- /// GPIO 24
- ///
- Gpio24 = 24,
-
- ///
- /// GPIO 25
- ///
- Gpio25 = 25,
-
- ///
- /// GPIO 26
- ///
- Gpio26 = 26,
-
- ///
- /// GPIO 27
- ///
- Gpio27 = 27,
-
- ///
- /// GPIO 28
- ///
- Gpio28 = 28,
-
- ///
- /// GPIO 29
- ///
- Gpio29 = 29,
-
- ///
- /// GPIO 30
- ///
- Gpio30 = 30,
-
- ///
- /// GPIO 31
- ///
- Gpio31 = 31,
- }
-
+ Output = 1,
+
///
- /// Enumerates the different pins on the P1 Header.
- /// Enumeration values correspond to the physical pin number.
+ /// PWM output mode (only certain pins support this -- 2 of them at the moment)
///
- public enum P1
- {
- ///
- /// Header P1 Physical Pin 3. GPIO 0 for rev1 or GPIO 2 for rev2.
- ///
- Pin03 = 3,
-
- ///
- /// Header P1 Physical Pin 5. GPIO 1 for rev1 or GPIO 3 for rev2.
- ///
- Pin05 = 5,
-
- ///
- /// Header P1 Physical Pin 7. GPIO 4.
- ///
- Pin07 = 7,
-
- ///
- /// Header P1 Physical Pin 11. GPIO 17.
- ///
- Pin11 = 11,
-
- ///
- /// Header P1 Physical Pin 13. GPIO 21 for rev1 or GPIO 27 for rev2.
- ///
- Pin13 = 13,
-
- ///
- /// Header P1 Physical Pin 15. GPIO 22.
- ///
- Pin15 = 15,
-
- ///
- /// Header P1 Physical Pin 19. GPIO 10.
- ///
- Pin19 = 19,
-
- ///
- /// Header P1 Physical Pin 21. GPIO 9.
- ///
- Pin21 = 21,
-
- ///
- /// Header P1 Physical Pin 23. GPIO 11.
- ///
- Pin23 = 23,
-
- ///
- /// Header P1 Physical Pin 27. GPIO 0.
- ///
- Pin27 = 27,
-
- ///
- /// Header P1 Physical Pin 29. GPIO 5.
- ///
- Pin29 = 29,
-
- ///
- /// Header P1 Physical Pin 31. GPIO 6.
- ///
- Pin31 = 31,
-
- ///
- /// Header P1 Physical Pin 33. GPIO 13.
- ///
- Pin33 = 33,
-
- ///
- /// Header P1 Physical Pin 35. GPIO 19.
- ///
- Pin35 = 35,
-
- ///
- /// Header P1 Physical Pin 37. GPIO 26.
- ///
- Pin37 = 37,
-
- ///
- /// Header P1 Physical Pin 8. GPIO 14.
- ///
- Pin08 = 8,
-
- ///
- /// Header P1 Physical Pin 10. GPIO 15.
- ///
- Pin10 = 10,
-
- ///
- /// Header P1 Physical Pin 12. GPIO 18.
- ///
- Pin12 = 12,
-
- ///
- /// Header P1 Physical Pin 16. GPIO 23.
- ///
- Pin16 = 16,
-
- ///
- /// Header P1 Physical Pin 18. GPIO 24.
- ///
- Pin18 = 18,
-
- ///
- /// Header P1 Physical Pin 22. GPIO 25.
- ///
- Pin22 = 22,
-
- ///
- /// Header P1 Physical Pin 24. GPIO 8.
- ///
- Pin24 = 24,
-
- ///
- /// Header P1 Physical Pin 26. GPIO 7.
- ///
- Pin26 = 26,
-
- ///
- /// Header P1 Physical Pin 28. GPIO 1.
- ///
- Pin28 = 28,
-
- ///
- /// Header P1 Physical Pin 32. GPIO 12.
- ///
- Pin32 = 32,
-
- ///
- /// Header P1 Physical Pin 36. GPIO 16.
- ///
- Pin36 = 36,
-
- ///
- /// Header P1 Physical Pin 38. GPIO 20.
- ///
- Pin38 = 38,
-
- ///
- /// Header P1 Physical Pin 40. GPIO 21.
- ///
- Pin40 = 40,
- }
-
+ PwmOutput = 2,
+
///
- /// Enumerates the different pins on the P5 Header
- /// as commonly referenced by Raspberry Pi documentation.
- /// Enumeration values correspond to the physical pin number.
+ /// GPIO Clock output mode (only a pin supports this at this time)
///
- public enum P5
- {
- ///
- /// Header P5 Physical Pin 3, GPIO 28.
- ///
- Pin03 = 3,
-
- ///
- /// Header P5 Physical Pin 4, GPIO 29.
- ///
- Pin04 = 4,
-
- ///
- /// Header P5 Physical Pin 5, GPIO 30.
- ///
- Pin05 = 5,
-
- ///
- /// Header P5 Physical Pin 6, GPIO 31.
- ///
- Pin06 = 6,
- }
+ GpioClock = 3,
+
+ ///
+ /// The alt0 operating mode
+ ///
+ Alt0 = 4,
+
+ ///
+ /// The alt1 operating mode
+ ///
+ Alt1 = 5,
+
+ ///
+ /// The alt2 operating mode
+ ///
+ Alt2 = 6,
+
+ ///
+ /// The alt3 operating mode
+ ///
+ Alt3 = 7,
+ }
+
+ ///
+ /// Defines the different threading locking keys.
+ ///
+ public enum ThreadLockKey {
+ ///
+ /// The lock 0
+ ///
+ Lock0 = 0,
+
+ ///
+ /// The lock 1
+ ///
+ Lock1 = 1,
+
+ ///
+ /// The lock 2
+ ///
+ Lock2 = 2,
+
+ ///
+ /// The lock 3
+ ///
+ Lock3 = 3,
+ }
+
+ ///
+ /// Defines the different edge detection modes for pin interrupts.
+ ///
+ public enum EdgeDetection {
+ ///
+ /// Falling Edge
+ ///
+ FallingEdge,
+
+ ///
+ /// Rising edge
+ ///
+ RisingEdge,
+
+ ///
+ /// Both, falling and rising edges
+ ///
+ FallingAndRisingEdge,
+ }
+
+ ///
+ /// The hardware revision of the board.
+ ///
+ public enum BoardRevision {
+ ///
+ /// Revision 1 (the early Model A and B's).
+ ///
+ Rev1 = 1,
+
+ ///
+ /// Revision 2 (everything else - it covers the B, B+ and CM).
+ ///
+ Rev2 = 2,
+ }
+
+ ///
+ /// Defines the Header connectors available.
+ ///
+ public enum GpioHeader {
+ ///
+ /// Not defined
+ ///
+ None,
+
+ ///
+ /// P1 connector (main connector)
+ ///
+ P1,
+
+ ///
+ /// P5 connector (auxiliary, not commonly used)
+ ///
+ P5,
+ }
+
+ ///
+ /// Defines all the BCM Pin numbers available for the user.
+ ///
+ public enum BcmPin {
+ ///
+ /// GPIO 0
+ ///
+ Gpio00 = 0,
+
+ ///
+ /// GPIO 1
+ ///
+ Gpio01 = 1,
+
+ ///
+ /// GPIO02
+ ///
+ Gpio02 = 2,
+
+ ///
+ /// GPIO 3
+ ///
+ Gpio03 = 3,
+
+ ///
+ /// GPIO 4
+ ///
+ Gpio04 = 4,
+
+ ///
+ /// GPIO 5
+ ///
+ Gpio05 = 5,
+
+ ///
+ /// GPIO 6
+ ///
+ Gpio06 = 6,
+
+ ///
+ /// GPIO 7
+ ///
+ Gpio07 = 7,
+
+ ///
+ /// GPIO 8
+ ///
+ Gpio08 = 8,
+
+ ///
+ /// GPIO 9
+ ///
+ Gpio09 = 9,
+
+ ///
+ /// GPIO 10
+ ///
+ Gpio10 = 10,
+
+ ///
+ /// GPIO 11
+ ///
+ Gpio11 = 11,
+
+ ///
+ /// GPIO 12
+ ///
+ Gpio12 = 12,
+
+ ///
+ /// GPIO 13
+ ///
+ Gpio13 = 13,
+
+ ///
+ /// GPIO 14
+ ///
+ Gpio14 = 14,
+
+ ///
+ /// GPIO 15
+ ///
+ Gpio15 = 15,
+
+ ///
+ /// GPIO 16
+ ///
+ Gpio16 = 16,
+
+ ///
+ /// GPIO 17
+ ///
+ Gpio17 = 17,
+
+ ///
+ /// GPIO 18
+ ///
+ Gpio18 = 18,
+
+ ///
+ /// GPIO 19
+ ///
+ Gpio19 = 19,
+
+ ///
+ /// GPIO 20
+ ///
+ Gpio20 = 20,
+
+ ///
+ /// GPIO 21
+ ///
+ Gpio21 = 21,
+
+ ///
+ /// GPIO 22
+ ///
+ Gpio22 = 22,
+
+ ///
+ /// GPIO 23
+ ///
+ Gpio23 = 23,
+
+ ///
+ /// GPIO 24
+ ///
+ Gpio24 = 24,
+
+ ///
+ /// GPIO 25
+ ///
+ Gpio25 = 25,
+
+ ///
+ /// GPIO 26
+ ///
+ Gpio26 = 26,
+
+ ///
+ /// GPIO 27
+ ///
+ Gpio27 = 27,
+
+ ///
+ /// GPIO 28
+ ///
+ Gpio28 = 28,
+
+ ///
+ /// GPIO 29
+ ///
+ Gpio29 = 29,
+
+ ///
+ /// GPIO 30
+ ///
+ Gpio30 = 30,
+
+ ///
+ /// GPIO 31
+ ///
+ Gpio31 = 31,
+ }
+
+ ///
+ /// Enumerates the different pins on the P1 Header.
+ /// Enumeration values correspond to the physical pin number.
+ ///
+ public enum P1 {
+ ///
+ /// Header P1 Physical Pin 3. GPIO 0 for rev1 or GPIO 2 for rev2.
+ ///
+ Pin03 = 3,
+
+ ///
+ /// Header P1 Physical Pin 5. GPIO 1 for rev1 or GPIO 3 for rev2.
+ ///
+ Pin05 = 5,
+
+ ///
+ /// Header P1 Physical Pin 7. GPIO 4.
+ ///
+ Pin07 = 7,
+
+ ///
+ /// Header P1 Physical Pin 11. GPIO 17.
+ ///
+ Pin11 = 11,
+
+ ///
+ /// Header P1 Physical Pin 13. GPIO 21 for rev1 or GPIO 27 for rev2.
+ ///
+ Pin13 = 13,
+
+ ///
+ /// Header P1 Physical Pin 15. GPIO 22.
+ ///
+ Pin15 = 15,
+
+ ///
+ /// Header P1 Physical Pin 19. GPIO 10.
+ ///
+ Pin19 = 19,
+
+ ///
+ /// Header P1 Physical Pin 21. GPIO 9.
+ ///
+ Pin21 = 21,
+
+ ///
+ /// Header P1 Physical Pin 23. GPIO 11.
+ ///
+ Pin23 = 23,
+
+ ///
+ /// Header P1 Physical Pin 27. GPIO 0.
+ ///
+ Pin27 = 27,
+
+ ///
+ /// Header P1 Physical Pin 29. GPIO 5.
+ ///
+ Pin29 = 29,
+
+ ///
+ /// Header P1 Physical Pin 31. GPIO 6.
+ ///
+ Pin31 = 31,
+
+ ///
+ /// Header P1 Physical Pin 33. GPIO 13.
+ ///
+ Pin33 = 33,
+
+ ///
+ /// Header P1 Physical Pin 35. GPIO 19.
+ ///
+ Pin35 = 35,
+
+ ///
+ /// Header P1 Physical Pin 37. GPIO 26.
+ ///
+ Pin37 = 37,
+
+ ///
+ /// Header P1 Physical Pin 8. GPIO 14.
+ ///
+ Pin08 = 8,
+
+ ///
+ /// Header P1 Physical Pin 10. GPIO 15.
+ ///
+ Pin10 = 10,
+
+ ///
+ /// Header P1 Physical Pin 12. GPIO 18.
+ ///
+ Pin12 = 12,
+
+ ///
+ /// Header P1 Physical Pin 16. GPIO 23.
+ ///
+ Pin16 = 16,
+
+ ///
+ /// Header P1 Physical Pin 18. GPIO 24.
+ ///
+ Pin18 = 18,
+
+ ///
+ /// Header P1 Physical Pin 22. GPIO 25.
+ ///
+ Pin22 = 22,
+
+ ///
+ /// Header P1 Physical Pin 24. GPIO 8.
+ ///
+ Pin24 = 24,
+
+ ///
+ /// Header P1 Physical Pin 26. GPIO 7.
+ ///
+ Pin26 = 26,
+
+ ///
+ /// Header P1 Physical Pin 28. GPIO 1.
+ ///
+ Pin28 = 28,
+
+ ///
+ /// Header P1 Physical Pin 32. GPIO 12.
+ ///
+ Pin32 = 32,
+
+ ///
+ /// Header P1 Physical Pin 36. GPIO 16.
+ ///
+ Pin36 = 36,
+
+ ///
+ /// Header P1 Physical Pin 38. GPIO 20.
+ ///
+ Pin38 = 38,
+
+ ///
+ /// Header P1 Physical Pin 40. GPIO 21.
+ ///
+ Pin40 = 40,
+ }
+
+ ///
+ /// Enumerates the different pins on the P5 Header
+ /// as commonly referenced by Raspberry Pi documentation.
+ /// Enumeration values correspond to the physical pin number.
+ ///
+ public enum P5 {
+ ///
+ /// Header P5 Physical Pin 3, GPIO 28.
+ ///
+ Pin03 = 3,
+
+ ///
+ /// Header P5 Physical Pin 4, GPIO 29.
+ ///
+ Pin04 = 4,
+
+ ///
+ /// Header P5 Physical Pin 5, GPIO 30.
+ ///
+ Pin05 = 5,
+
+ ///
+ /// Header P5 Physical Pin 6, GPIO 31.
+ ///
+ Pin06 = 6,
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/IBootstrap.cs b/Unosquare.RaspberryIO.Abstractions/IBootstrap.cs
index 0a3a9ed..d7eef4c 100644
--- a/Unosquare.RaspberryIO.Abstractions/IBootstrap.cs
+++ b/Unosquare.RaspberryIO.Abstractions/IBootstrap.cs
@@ -1,13 +1,11 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interface for bootstrapping an implementation.
+ ///
+ public interface IBootstrap {
///
- /// Interface for bootstrapping an implementation.
+ /// Bootstraps an implementation.
///
- public interface IBootstrap
- {
- ///
- /// Bootstraps an implementation.
- ///
- void Bootstrap();
- }
+ void Bootstrap();
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/IGpioController.cs b/Unosquare.RaspberryIO.Abstractions/IGpioController.cs
index 356c517..95e8fb0 100644
--- a/Unosquare.RaspberryIO.Abstractions/IGpioController.cs
+++ b/Unosquare.RaspberryIO.Abstractions/IGpioController.cs
@@ -1,51 +1,50 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
- using System.Collections.Generic;
-
+using System;
+using System.Collections.Generic;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interface for Raspberry Pi GPIO controller.
+ ///
+ ///
+ public interface IGpioController : IReadOnlyCollection {
///
- /// Interface for Raspberry Pi GPIO controller.
+ /// Gets the with the specified BCM pin.
///
- ///
- public interface IGpioController : IReadOnlyCollection
- {
- ///
- /// Gets the with the specified BCM pin.
- ///
- ///
- /// The .
- ///
- /// The BCM pin number.
- /// A reference to the GPIO pin.
- IGpioPin this[int bcmPinNumber] { get; }
-
- ///
- /// Gets the with the specified BCM pin.
- ///
- ///
- /// The .
- ///
- /// The BCM pin.
- /// A reference to the GPIO pin.
- IGpioPin this[BcmPin bcmPin] { get; }
-
- ///
- /// Gets the with the specified pin number.
- ///
- ///
- /// The .
- ///
- /// The pin number in header P1.
- /// A reference to the GPIO pin.
- IGpioPin this[P1 pinNumber] { get; }
-
- ///
- /// Gets the with the specified pin number.
- ///
- ///
- /// The .
- ///
- /// The pin number in header P5.
- /// A reference to the GPIO pin.
- IGpioPin this[P5 pinNumber] { get; }
- }
+ ///
+ /// The .
+ ///
+ /// The BCM pin number.
+ /// A reference to the GPIO pin.
+ IGpioPin this[Int32 bcmPinNumber] { get; }
+
+ ///
+ /// Gets the with the specified BCM pin.
+ ///
+ ///
+ /// The .
+ ///
+ /// The BCM pin.
+ /// A reference to the GPIO pin.
+ IGpioPin this[BcmPin bcmPin] { get; }
+
+ ///
+ /// Gets the with the specified pin number.
+ ///
+ ///
+ /// The .
+ ///
+ /// The pin number in header P1.
+ /// A reference to the GPIO pin.
+ IGpioPin this[P1 pinNumber] { get; }
+
+ ///
+ /// Gets the with the specified pin number.
+ ///
+ ///
+ /// The .
+ ///
+ /// The pin number in header P5.
+ /// A reference to the GPIO pin.
+ IGpioPin this[P5 pinNumber] { get; }
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/IGpioPin.cs b/Unosquare.RaspberryIO.Abstractions/IGpioPin.cs
index cf435bc..d7af934 100644
--- a/Unosquare.RaspberryIO.Abstractions/IGpioPin.cs
+++ b/Unosquare.RaspberryIO.Abstractions/IGpioPin.cs
@@ -1,105 +1,117 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
- using System;
-
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interface for GPIO Pin on a RaspberryPi board.
+ ///
+ public interface IGpioPin {
///
- /// Interface for GPIO Pin on a RaspberryPi board.
+ /// Gets the .
///
- public interface IGpioPin
- {
- ///
- /// Gets the .
- ///
- ///
- /// The pin number.
- ///
- BcmPin BcmPin { get; }
-
- ///
- /// Gets the BCM chip (hardware) pin number.
- ///
- ///
- /// The pin number.
- ///
- int BcmPinNumber { get; }
-
- ///
- /// Gets the physical (header) pin number.
- ///
- int PhysicalPinNumber { get; }
-
- ///
- /// Gets the pin's header (physical board) location.
- ///
- GpioHeader Header { get; }
-
- ///
- /// Gets or sets the pin operating mode.
- ///
- ///
- /// The pin mode.
- ///
- GpioPinDriveMode PinMode { get; set; }
-
- ///
- /// 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.
- ///
- GpioPinResistorPullMode InputPullMode { get; set; }
-
- ///
- /// Gets or sets a value indicating whether this is value.
- ///
- ///
- /// true if value; otherwise, false.
- ///
- bool Value { get; set; }
-
- ///
- /// Reads the digital value on the pin as a boolean value.
- ///
- /// The state of the pin.
- bool Read();
-
- ///
- /// Writes the specified bit value.
- /// This method performs a digital write.
- ///
- /// if set to true [value].
- void Write(bool value);
-
- ///
- /// Writes the specified pin value.
- /// This method performs a digital write.
- ///
- /// The value.
- void Write(GpioPinValue value);
-
- ///
- /// Wait for specific pin status.
- ///
- /// status to check.
- /// timeout to reach status.
- /// true/false.
- bool WaitForValue(GpioPinValue status, int timeOutMillisecond);
-
- ///
- /// Registers the interrupt callback on the pin. Pin mode has to be set to Input.
- ///
- /// The edge detection.
- /// The callback function. This function is called whenever
- /// the interrupt occurs.
- void RegisterInterruptCallback(EdgeDetection edgeDetection, Action callback);
-
- ///
- /// Registers the interrupt callback on the pin. Pin mode has to be set to Input.
- ///
- /// The edge detection.
- /// 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).
- void RegisterInterruptCallback(EdgeDetection edgeDetection, Action callback);
- }
+ ///
+ /// The pin number.
+ ///
+ BcmPin BcmPin {
+ get;
+ }
+
+ ///
+ /// Gets the BCM chip (hardware) pin number.
+ ///
+ ///
+ /// The pin number.
+ ///
+ Int32 BcmPinNumber {
+ get;
+ }
+
+ ///
+ /// Gets the physical (header) pin number.
+ ///
+ Int32 PhysicalPinNumber {
+ get;
+ }
+
+ ///
+ /// Gets the pin's header (physical board) location.
+ ///
+ GpioHeader Header {
+ get;
+ }
+
+ ///
+ /// Gets or sets the pin operating mode.
+ ///
+ ///
+ /// The pin mode.
+ ///
+ GpioPinDriveMode PinMode {
+ get; set;
+ }
+
+ ///
+ /// 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.
+ ///
+ GpioPinResistorPullMode InputPullMode {
+ get; set;
+ }
+
+ ///
+ /// Gets or sets a value indicating whether this is value.
+ ///
+ ///
+ /// true if value; otherwise, false.
+ ///
+ Boolean Value {
+ get; set;
+ }
+
+ ///
+ /// Reads the digital value on the pin as a boolean value.
+ ///
+ /// The state of the pin.
+ Boolean Read();
+
+ ///
+ /// Writes the specified bit value.
+ /// This method performs a digital write.
+ ///
+ /// if set to true [value].
+ void Write(Boolean value);
+
+ ///
+ /// Writes the specified pin value.
+ /// This method performs a digital write.
+ ///
+ /// The value.
+ void Write(GpioPinValue value);
+
+ ///
+ /// Wait for specific pin status.
+ ///
+ /// status to check.
+ /// timeout to reach status.
+ /// true/false.
+ Boolean WaitForValue(GpioPinValue status, Int32 timeOutMillisecond);
+
+ ///
+ /// Registers the interrupt callback on the pin. Pin mode has to be set to Input.
+ ///
+ /// The edge detection.
+ /// The callback function. This function is called whenever
+ /// the interrupt occurs.
+ void RegisterInterruptCallback(EdgeDetection edgeDetection, Action callback);
+
+ ///
+ /// Registers the interrupt callback on the pin. Pin mode has to be set to Input.
+ ///
+ /// The edge detection.
+ /// 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).
+ void RegisterInterruptCallback(EdgeDetection edgeDetection, Action callback);
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/II2CBus.cs b/Unosquare.RaspberryIO.Abstractions/II2CBus.cs
index ffb7e5b..4de8ec8 100644
--- a/Unosquare.RaspberryIO.Abstractions/II2CBus.cs
+++ b/Unosquare.RaspberryIO.Abstractions/II2CBus.cs
@@ -1,39 +1,40 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
- using System.Collections.ObjectModel;
-
+using System;
+using System.Collections.ObjectModel;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interfaces the I2c bus on the Raspberry Pi.
+ ///
+ public interface II2CBus {
///
- /// Interfaces the I2c bus on the Raspberry Pi.
+ /// Gets the registered devices as a read only collection.
///
- public interface II2CBus
- {
- ///
- /// Gets the registered devices as a read only collection.
- ///
- ReadOnlyCollection Devices { get; }
-
- ///
- /// Gets the with the specified device identifier.
- ///
- ///
- /// The .
- ///
- /// The device identifier.
- /// A reference to an I2C device.
- II2CDevice this[int deviceId] { get; }
-
- ///
- /// Gets the device by identifier.
- ///
- /// The device identifier.
- /// The device reference.
- II2CDevice GetDeviceById(int deviceId);
-
- ///
- /// Adds a device to the bus by its Id. If the device is already registered it simply returns the existing device.
- ///
- /// The device identifier.
- /// The device reference.
- II2CDevice AddDevice(int deviceId);
- }
+ ReadOnlyCollection Devices {
+ get;
+ }
+
+ ///
+ /// Gets the with the specified device identifier.
+ ///
+ ///
+ /// The .
+ ///
+ /// The device identifier.
+ /// A reference to an I2C device.
+ II2CDevice this[Int32 deviceId] { get; }
+
+ ///
+ /// Gets the device by identifier.
+ ///
+ /// The device identifier.
+ /// The device reference.
+ II2CDevice GetDeviceById(Int32 deviceId);
+
+ ///
+ /// Adds a device to the bus by its Id. If the device is already registered it simply returns the existing device.
+ ///
+ /// The device identifier.
+ /// The device reference.
+ II2CDevice AddDevice(Int32 deviceId);
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/II2CDevice.cs b/Unosquare.RaspberryIO.Abstractions/II2CDevice.cs
index fee9ed2..243f19e 100644
--- a/Unosquare.RaspberryIO.Abstractions/II2CDevice.cs
+++ b/Unosquare.RaspberryIO.Abstractions/II2CDevice.cs
@@ -1,77 +1,81 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interfaces a device on the I2C Bus.
+ ///
+ public interface II2CDevice {
///
- /// Interfaces a device on the I2C Bus.
+ /// Gets the device identifier.
///
- public interface II2CDevice
- {
- ///
- /// Gets the device identifier.
- ///
- ///
- /// The device identifier.
- ///
- int DeviceId { get; }
-
- ///
- /// Gets the standard POSIX file descriptor.
- ///
- ///
- /// The file descriptor.
- ///
- int FileDescriptor { get; }
-
- ///
- /// Reads a byte from the specified file descriptor.
- ///
- /// The byte from device.
- byte Read();
-
- ///
- /// Reads a buffer of the specified length, one byte at a time.
- ///
- /// The length.
- /// The byte array from device.
- byte[] Read(int length);
-
- ///
- /// Writes a byte of data the specified file descriptor.
- ///
- /// The data.
- void Write(byte data);
-
- ///
- /// Writes a set of bytes to the specified file descriptor.
- ///
- /// The data.
- void Write(byte[] data);
-
- ///
- /// These write an 8 or 16-bit data value into the device register indicated.
- ///
- /// The register.
- /// The data.
- void WriteAddressByte(int address, byte data);
-
- ///
- /// These write an 8 or 16-bit data value into the device register indicated.
- ///
- /// The register.
- /// The data.
- void WriteAddressWord(int address, ushort data);
-
- ///
- /// These read an 8 or 16-bit value from the device register indicated.
- ///
- /// The register.
- /// The address byte from device.
- byte ReadAddressByte(int address);
-
- ///
- /// These read an 8 or 16-bit value from the device register indicated.
- ///
- /// The register.
- /// The address word from device.
- ushort ReadAddressWord(int address);
- }
+ ///
+ /// The device identifier.
+ ///
+ Int32 DeviceId {
+ get;
+ }
+
+ ///
+ /// Gets the standard POSIX file descriptor.
+ ///
+ ///
+ /// The file descriptor.
+ ///
+ Int32 FileDescriptor {
+ get;
+ }
+
+ ///
+ /// Reads a byte from the specified file descriptor.
+ ///
+ /// The byte from device.
+ Byte Read();
+
+ ///
+ /// Reads a buffer of the specified length, one byte at a time.
+ ///
+ /// The length.
+ /// The byte array from device.
+ Byte[] Read(Int32 length);
+
+ ///
+ /// Writes a byte of data the specified file descriptor.
+ ///
+ /// The data.
+ void Write(Byte data);
+
+ ///
+ /// Writes a set of bytes to the specified file descriptor.
+ ///
+ /// The data.
+ void Write(Byte[] data);
+
+ ///
+ /// These write an 8 or 16-bit data value into the device register indicated.
+ ///
+ /// The register.
+ /// The data.
+ void WriteAddressByte(Int32 address, Byte data);
+
+ ///
+ /// These write an 8 or 16-bit data value into the device register indicated.
+ ///
+ /// The register.
+ /// The data.
+ void WriteAddressWord(Int32 address, UInt16 data);
+
+ ///
+ /// These read an 8 or 16-bit value from the device register indicated.
+ ///
+ /// The register.
+ /// The address byte from device.
+ Byte ReadAddressByte(Int32 address);
+
+ ///
+ /// These read an 8 or 16-bit value from the device register indicated.
+ ///
+ /// The register.
+ /// The address word from device.
+ UInt16 ReadAddressWord(Int32 address);
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/ISpiBus.cs b/Unosquare.RaspberryIO.Abstractions/ISpiBus.cs
index 4b38696..091b9b9 100644
--- a/Unosquare.RaspberryIO.Abstractions/ISpiBus.cs
+++ b/Unosquare.RaspberryIO.Abstractions/ISpiBus.cs
@@ -1,48 +1,58 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interfaces a SPI Bus containing the 2 SPI channels.
+ ///
+ public interface ISpiBus {
///
- /// Interfaces a SPI Bus containing the 2 SPI channels.
+ /// Gets the default frequency.
///
- public interface ISpiBus
- {
- ///
- /// Gets the default frequency.
- ///
- ///
- /// The default frequency.
- ///
- int DefaultFrequency { get; }
-
- ///
- /// Gets or sets the channel 0 frequency in Hz.
- ///
- ///
- /// The channel0 frequency.
- ///
- int Channel0Frequency { get; set; }
-
- ///
- /// Gets or sets the channel 1 frequency in Hz.
- ///
- ///
- /// The channel1 frequency.
- ///
- int Channel1Frequency { get; set; }
-
- ///
- /// Gets the SPI bus on channel 0.
- ///
- ///
- /// The channel0.
- ///
- ISpiChannel Channel0 { get; }
-
- ///
- /// Gets the SPI bus on channel 1.
- ///
- ///
- /// The channel0.
- ///
- ISpiChannel Channel1 { get; }
- }
+ ///
+ /// The default frequency.
+ ///
+ Int32 DefaultFrequency {
+ get;
+ }
+
+ ///
+ /// Gets or sets the channel 0 frequency in Hz.
+ ///
+ ///
+ /// The channel0 frequency.
+ ///
+ Int32 Channel0Frequency {
+ get; set;
+ }
+
+ ///
+ /// Gets or sets the channel 1 frequency in Hz.
+ ///
+ ///
+ /// The channel1 frequency.
+ ///
+ Int32 Channel1Frequency {
+ get; set;
+ }
+
+ ///
+ /// Gets the SPI bus on channel 0.
+ ///
+ ///
+ /// The channel0.
+ ///
+ ISpiChannel Channel0 {
+ get;
+ }
+
+ ///
+ /// Gets the SPI bus on channel 1.
+ ///
+ ///
+ /// The channel0.
+ ///
+ ISpiChannel Channel1 {
+ get;
+ }
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/ISpiChannel.cs b/Unosquare.RaspberryIO.Abstractions/ISpiChannel.cs
index 48900ee..06665a3 100644
--- a/Unosquare.RaspberryIO.Abstractions/ISpiChannel.cs
+++ b/Unosquare.RaspberryIO.Abstractions/ISpiChannel.cs
@@ -1,43 +1,49 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interfaces a SPI buses on the GPIO.
+ ///
+ public interface ISpiChannel {
///
- /// Interfaces a SPI buses on the GPIO.
+ /// Gets the standard initialization file descriptor.
+ /// anything negative means error.
///
- public interface ISpiChannel
- {
- ///
- /// Gets the standard initialization file descriptor.
- /// anything negative means error.
- ///
- ///
- /// The file descriptor.
- ///
- int FileDescriptor { get; }
-
- ///
- /// Gets the channel.
- ///
- int Channel { get; }
-
- ///
- /// Gets the frequency.
- ///
- int Frequency { get; }
-
- ///
- /// Sends data and simultaneously receives the data in the return buffer.
- ///
- /// The buffer.
- /// The read bytes from the ring-style bus.
- byte[] SendReceive(byte[] buffer);
-
- ///
- /// Writes the specified buffer the the underlying FileDescriptor.
- /// Do not use this method if you expect data back.
- /// This method is efficient if used in a fire-and-forget scenario
- /// like sending data over to those long RGB LED strips.
- ///
- /// The buffer.
- void Write(byte[] buffer);
- }
+ ///
+ /// The file descriptor.
+ ///
+ Int32 FileDescriptor {
+ get;
+ }
+
+ ///
+ /// Gets the channel.
+ ///
+ Int32 Channel {
+ get;
+ }
+
+ ///
+ /// Gets the frequency.
+ ///
+ Int32 Frequency {
+ get;
+ }
+
+ ///
+ /// Sends data and simultaneously receives the data in the return buffer.
+ ///
+ /// The buffer.
+ /// The read bytes from the ring-style bus.
+ Byte[] SendReceive(Byte[] buffer);
+
+ ///
+ /// Writes the specified buffer the the underlying FileDescriptor.
+ /// Do not use this method if you expect data back.
+ /// This method is efficient if used in a fire-and-forget scenario
+ /// like sending data over to those long RGB LED strips.
+ ///
+ /// The buffer.
+ void Write(Byte[] buffer);
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/ISystemInfo.cs b/Unosquare.RaspberryIO.Abstractions/ISystemInfo.cs
index 3a18a89..e44062f 100644
--- a/Unosquare.RaspberryIO.Abstractions/ISystemInfo.cs
+++ b/Unosquare.RaspberryIO.Abstractions/ISystemInfo.cs
@@ -1,26 +1,28 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
- using System;
-
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interface for system info.
+ ///
+ public interface ISystemInfo {
///
- /// Interface for system info.
+ /// Gets the board revision (1 or 2).
///
- public interface ISystemInfo
- {
- ///
- /// Gets the board revision (1 or 2).
- ///
- ///
- /// The board revision.
- ///
- BoardRevision BoardRevision { get; }
-
- ///
- /// Gets the library version.
- ///
- ///
- /// The library version.
- ///
- Version LibraryVersion { get; }
- }
+ ///
+ /// The board revision.
+ ///
+ BoardRevision BoardRevision {
+ get;
+ }
+
+ ///
+ /// Gets the library version.
+ ///
+ ///
+ /// The library version.
+ ///
+ Version LibraryVersion {
+ get;
+ }
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/IThreading.cs b/Unosquare.RaspberryIO.Abstractions/IThreading.cs
index f929222..255c97c 100644
--- a/Unosquare.RaspberryIO.Abstractions/IThreading.cs
+++ b/Unosquare.RaspberryIO.Abstractions/IThreading.cs
@@ -1,30 +1,28 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
- using System;
-
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interface to represent threading methods using interop.
+ ///
+ public interface IThreading {
///
- /// Interface to represent threading methods using interop.
+ /// Starts a new thread of execution which runs concurrently with your main program.
///
- public interface IThreading
- {
- ///
- /// Starts a new thread of execution which runs concurrently with your main program.
- ///
- /// The thread routine.
- void StartThread(Action worker);
-
- ///
- /// Starts a new thread of execution which runs concurrently with your main program.
- ///
- /// The thread routine.
- /// A pointer to the user data.
- /// A pointer to the new thread.
- UIntPtr StartThreadEx(Action worker, UIntPtr userData);
-
- ///
- /// Stops the thread pointed at by handle.
- ///
- /// A thread pointer returned by .
- void StopThreadEx(UIntPtr handle);
- }
+ /// The thread routine.
+ void StartThread(Action worker);
+
+ ///
+ /// Starts a new thread of execution which runs concurrently with your main program.
+ ///
+ /// The thread routine.
+ /// A pointer to the user data.
+ /// A pointer to the new thread.
+ UIntPtr StartThreadEx(Action worker, UIntPtr userData);
+
+ ///
+ /// Stops the thread pointed at by handle.
+ ///
+ /// A thread pointer returned by .
+ void StopThreadEx(UIntPtr handle);
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/ITiming.cs b/Unosquare.RaspberryIO.Abstractions/ITiming.cs
index 0216602..98f3636 100644
--- a/Unosquare.RaspberryIO.Abstractions/ITiming.cs
+++ b/Unosquare.RaspberryIO.Abstractions/ITiming.cs
@@ -1,40 +1,44 @@
-namespace Unosquare.RaspberryIO.Abstractions
-{
+using System;
+
+namespace Unosquare.RaspberryIO.Abstractions {
+ ///
+ /// Interface for timing methods using interop.
+ ///
+ public interface ITiming {
///
- /// Interface for timing methods using interop.
+ /// This returns a number representing the number of milliseconds since system boot.
///
- public interface ITiming
- {
- ///
- /// This returns a number representing the number of milliseconds since system boot.
- ///
- /// The milliseconds since system boot.
- uint Milliseconds { get; }
-
- ///
- /// This returns a number representing the number of microseconds since system boot.
- ///
- /// The microseconds since system boot.
- uint Microseconds { get; }
-
- ///
- /// This causes program execution to pause for at least how long milliseconds.
- /// Due to the multi-tasking nature of Linux it could be longer.
- /// Note that the maximum delay is an unsigned 32-bit integer or approximately 49 days.
- ///
- /// The number of milliseconds to sleep.
- void SleepMilliseconds(uint millis);
-
- ///
- /// This causes program execution to pause for at least how long microseconds.
- /// Due to the multi-tasking nature of Linux it could be longer.
- /// Note that the maximum delay is an unsigned 32-bit integer microseconds or approximately 71 minutes.
- /// Delays under 100 microseconds are timed using a hard-coded loop continually polling the system time,
- /// Delays over 100 microseconds are done using the system nanosleep() function –
- /// You may need to consider the implications of very short delays on the overall performance of the system,
- /// especially if using threads.
- ///
- /// The number of microseconds to sleep.
- void SleepMicroseconds(uint micros);
- }
+ /// The milliseconds since system boot.
+ UInt32 Milliseconds {
+ get;
+ }
+
+ ///
+ /// This returns a number representing the number of microseconds since system boot.
+ ///
+ /// The microseconds since system boot.
+ UInt32 Microseconds {
+ get;
+ }
+
+ ///
+ /// This causes program execution to pause for at least how long milliseconds.
+ /// Due to the multi-tasking nature of Linux it could be longer.
+ /// Note that the maximum delay is an unsigned 32-bit integer or approximately 49 days.
+ ///
+ /// The number of milliseconds to sleep.
+ void SleepMilliseconds(UInt32 millis);
+
+ ///
+ /// This causes program execution to pause for at least how long microseconds.
+ /// Due to the multi-tasking nature of Linux it could be longer.
+ /// Note that the maximum delay is an unsigned 32-bit integer microseconds or approximately 71 minutes.
+ /// Delays under 100 microseconds are timed using a hard-coded loop continually polling the system time,
+ /// Delays over 100 microseconds are done using the system nanosleep() function –
+ /// You may need to consider the implications of very short delays on the overall performance of the system,
+ /// especially if using threads.
+ ///
+ /// The number of microseconds to sleep.
+ void SleepMicroseconds(UInt32 micros);
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/Native/HardwareException.cs b/Unosquare.RaspberryIO.Abstractions/Native/HardwareException.cs
index e11190b..ef80274 100644
--- a/Unosquare.RaspberryIO.Abstractions/Native/HardwareException.cs
+++ b/Unosquare.RaspberryIO.Abstractions/Native/HardwareException.cs
@@ -1,71 +1,70 @@
-namespace Unosquare.RaspberryIO.Abstractions.Native
-{
- using System;
- using System.Runtime.InteropServices;
-
+using System;
+using System.Runtime.InteropServices;
+
+namespace Unosquare.RaspberryIO.Abstractions.Native {
+ ///
+ /// Represents a low-level exception, typically thrown when return codes from a
+ /// low-level operation is non-zero or in some cases when it is less than zero.
+ ///
+ ///
+ public class HardwareException : Exception {
///
- /// Represents a low-level exception, typically thrown when return codes from a
- /// low-level operation is non-zero or in some cases when it is less than zero.
+ /// Initializes a new instance of the class.
///
- ///
- public class HardwareException : Exception
- {
- ///
- /// Initializes a new instance of the class.
- ///
- /// The error code.
- /// The component.
- public HardwareException(int errorCode, string component)
- : base($"A hardware exception occurred. Error Code: {errorCode}")
- {
- ExtendedMessage = null;
-
- try
- {
- ExtendedMessage = Standard.Strerror(errorCode);
- }
- catch
- {
- // Ignore
- }
-
- ErrorCode = errorCode;
- Component = component;
- }
-
- ///
- /// Gets the error code.
- ///
- ///
- /// The error code.
- ///
- public int ErrorCode { get; }
-
- ///
- /// Gets the component.
- ///
- ///
- /// The component.
- ///
- public string Component { get; }
-
- ///
- /// Gets the extended message (could be null).
- ///
- ///
- /// The extended message.
- ///
- public string? ExtendedMessage { get; }
-
- ///
- /// Throws a new instance of a hardware error by retrieving the last error number (errno).
- ///
- /// Name of the class.
- /// Name of the method.
- /// When an error thrown by an API call occurs.
- public static void Throw(string className, string methodName) => throw new HardwareException(Marshal.GetLastWin32Error(), $"{className}.{methodName}");
-
- ///
- public override string ToString() => $"{nameof(HardwareException)}{(string.IsNullOrWhiteSpace(Component) ? string.Empty : $" on {Component}")}: ({ErrorCode}) - {Message}";
- }
+ /// The error code.
+ /// The component.
+ public HardwareException(Int32 errorCode, String component) : base($"A hardware exception occurred. Error Code: {errorCode}") {
+ this.ExtendedMessage = null;
+
+ try {
+ this.ExtendedMessage = Standard.Strerror(errorCode);
+ } catch {
+ // Ignore
+ }
+
+ this.ErrorCode = errorCode;
+ this.Component = component;
+ }
+
+ ///
+ /// Gets the error code.
+ ///
+ ///
+ /// The error code.
+ ///
+ public Int32 ErrorCode {
+ get;
+ }
+
+ ///
+ /// Gets the component.
+ ///
+ ///
+ /// The component.
+ ///
+ public String Component {
+ get;
+ }
+
+ ///
+ /// Gets the extended message (could be null).
+ ///
+ ///
+ /// The extended message.
+ ///
+ public String? ExtendedMessage {
+ get;
+ }
+
+ ///
+ /// Throws a new instance of a hardware error by retrieving the last error number (errno).
+ ///
+ /// Name of the class.
+ /// Name of the method.
+ /// When an error thrown by an API call occurs.
+ public static void Throw(String className, String methodName) => throw new HardwareException(Marshal.GetLastWin32Error(), $"{className}.{methodName}");
+
+ ///
+ public override String ToString() => $"{nameof(HardwareException)}{(String.IsNullOrWhiteSpace(this.Component) ? String.Empty : $" on {this.Component}")}: ({this.ErrorCode}) - {this.Message}";
+ }
}
diff --git a/Unosquare.RaspberryIO.Abstractions/Native/Standard.cs b/Unosquare.RaspberryIO.Abstractions/Native/Standard.cs
index b671af3..0fc7516 100644
--- a/Unosquare.RaspberryIO.Abstractions/Native/Standard.cs
+++ b/Unosquare.RaspberryIO.Abstractions/Native/Standard.cs
@@ -1,45 +1,41 @@
-namespace Unosquare.RaspberryIO.Abstractions.Native
-{
- using System;
- using System.Runtime.InteropServices;
- using System.Text;
-
+using System;
+using System.Runtime.InteropServices;
+using System.Text;
+
+namespace Unosquare.RaspberryIO.Abstractions.Native {
+ ///
+ /// Provides standard 'libc' calls using platform-invoke.
+ ///
+ public static class Standard {
+ internal const String LibCLibrary = "libc";
+
+ #region LibC Calls
+
///
- /// Provides standard 'libc' calls using platform-invoke.
+ /// Strerrors the specified error.
///
- public static class Standard
- {
- internal const string LibCLibrary = "libc";
-
- #region LibC Calls
-
- ///
- /// Strerrors the specified error.
- ///
- /// The error.
- /// The error string.
- public static string Strerror(int error)
- {
- if (Type.GetType("Mono.Runtime") == null) return Marshal.PtrToStringAnsi(StrError(error));
-
- try
- {
- var buffer = new StringBuilder(256);
- var result = Strerror(error, buffer, (ulong)buffer.Capacity);
- return (result != -1) ? buffer.ToString() : null;
- }
- catch (Exception)
- {
- return null;
- }
- }
-
- [DllImport(LibCLibrary, EntryPoint = "strerror", SetLastError = true)]
- private static extern IntPtr StrError(int errnum);
-
- [DllImport("MonoPosixHelper", EntryPoint = "Mono_Posix_Syscall_strerror_r", SetLastError = true)]
- private static extern int Strerror(int error, [Out] StringBuilder buffer, ulong length);
-
- #endregion
- }
+ /// The error.
+ /// The error string.
+ public static String? Strerror(Int32 error) {
+ if(Type.GetType("Mono.Runtime") == null) {
+ return Marshal.PtrToStringAnsi(StrError(error));
+ }
+
+ try {
+ StringBuilder buffer = new StringBuilder(256);
+ Int32 result = Strerror(error, buffer, (UInt64)buffer.Capacity);
+ return (result != -1) ? buffer.ToString() : null;
+ } catch(Exception) {
+ return null;
+ }
+ }
+
+ [DllImport(LibCLibrary, EntryPoint = "strerror", SetLastError = true)]
+ private static extern IntPtr StrError(Int32 errnum);
+
+ [DllImport("MonoPosixHelper", EntryPoint = "Mono_Posix_Syscall_strerror_r", SetLastError = true)]
+ private static extern Int32 Strerror(Int32 error, [Out] StringBuilder buffer, UInt64 length);
+
+ #endregion
+ }
}
\ No newline at end of file
diff --git a/Unosquare.RaspberryIO.Abstractions/Unosquare.RaspberryIO.Abstractions.csproj b/Unosquare.RaspberryIO.Abstractions/Unosquare.RaspberryIO.Abstractions.csproj
index fd82b8c..fa41119 100644
--- a/Unosquare.RaspberryIO.Abstractions/Unosquare.RaspberryIO.Abstractions.csproj
+++ b/Unosquare.RaspberryIO.Abstractions/Unosquare.RaspberryIO.Abstractions.csproj
@@ -16,6 +16,7 @@ This library enables developers to use the various Raspberry Pi's hardware modul
https://raw.githubusercontent.com/unosquare/raspberryio/master/LICENSE
Raspberry Pi GPIO Camera SPI I2C Embedded IoT Mono C# .NET
8.0
+ enable