2019-12-03 18:43:54 +01:00
|
|
|
|
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> {
|
2019-02-17 14:08:57 +01:00
|
|
|
|
/// <summary>
|
2019-12-03 18:43:54 +01:00
|
|
|
|
/// Prevents a default instance of the <see cref="SpiBus"/> class from being created.
|
2019-02-17 14:08:57 +01:00
|
|
|
|
/// </summary>
|
2019-12-03 18:43:54 +01:00
|
|
|
|
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
|
|
|
|
|
}
|
2019-02-17 14:08:57 +01:00
|
|
|
|
}
|