RaspberryIO/Unosquare.RaspberryIO/Gpio/SpiBus.cs
2019-12-03 18:43:54 +01:00

73 lines
1.7 KiB
C#

using System;
using Unosquare.Swan.Abstractions;
namespace Unosquare.RaspberryIO.Gpio {
/// <summary>
/// The SPI Bus containing the 2 SPI channels
/// </summary>
public class SpiBus : SingletonBase<SpiBus> {
/// <summary>
/// Prevents a default instance of the <see cref="SpiBus"/> class from being created.
/// </summary>
private SpiBus() {
// placeholder
}
#region SPI Access
/// <summary>
/// Gets or sets the channel 0 frequency in Hz.
/// </summary>
/// <value>
/// The channel0 frequency.
/// </value>
public Int32 Channel0Frequency {
get; set;
}
/// <summary>
/// Gets the SPI bus on channel 1.
/// </summary>
/// <value>
/// The channel0.
/// </value>
public SpiChannel Channel0 {
get {
if(this.Channel0Frequency == 0) {
this.Channel0Frequency = SpiChannel.DefaultFrequency;
}
return SpiChannel.Retrieve(SpiChannelNumber.Channel0, this.Channel0Frequency);
}
}
/// <summary>
/// Gets or sets the channel 1 frequency in Hz
/// </summary>
/// <value>
/// The channel1 frequency.
/// </value>
public Int32 Channel1Frequency {
get; set;
}
/// <summary>
/// Gets the SPI bus on channel 1.
/// </summary>
/// <value>
/// The channel1.
/// </value>
public SpiChannel Channel1 {
get {
if(this.Channel1Frequency == 0) {
this.Channel1Frequency = SpiChannel.DefaultFrequency;
}
return SpiChannel.Retrieve(SpiChannelNumber.Channel1, this.Channel1Frequency);
}
}
#endregion
}
}