-
Notifications
You must be signed in to change notification settings - Fork 598
/
Copy pathGenericBoard.cs
71 lines (62 loc) · 2.44 KB
/
GenericBoard.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
using System.Device;
using System.Device.Gpio;
using System.Device.Gpio.Drivers;
using System.Device.I2c;
using System.Device.Pwm;
using System.Device.Spi;
using System.Text;
namespace Iot.Device.Board
{
/// <summary>
/// A generic board class. Uses generic implementations for GPIO, I2C etc
/// </summary>
public class GenericBoard : Board
{
/// <summary>
/// Creates a generic board instance with auto-detection of the best drivers for GPIO, I2c, SPI, etc.
/// The drivers are late-bound however, so whether it works or not can only be determined after pins are opened.
/// </summary>
public GenericBoard()
{
}
/// <inheritdoc />
protected override SpiDevice CreateSimpleSpiDevice(SpiConnectionSettings settings, int[] pins)
{
return SpiDevice.Create(settings);
}
/// <inheritdoc />
protected override PwmChannel CreateSimplePwmChannel(int chip, int channel, int frequency, double dutyCyclePercentage)
{
return PwmChannel.Create(chip, channel, frequency, dutyCyclePercentage);
}
/// <inheritdoc />
protected override I2cBusManager CreateI2cBusCore(int busNumber, int[]? pins)
{
return new I2cBusManager(this, busNumber, pins, I2cBus.Create(busNumber));
}
/// <inheritdoc />
public override int GetDefaultI2cBusNumber()
{
throw new NotSupportedException("The generic board has no default I2C bus");
}
/// <inheritdoc />
public override int[] GetDefaultPinAssignmentForI2c(int busId)
{
throw new NotSupportedException("For the generic board, you need to specify the pins to use for I2C");
}
/// <inheritdoc />
public override int GetDefaultPinAssignmentForPwm(int chip, int channel)
{
throw new NotSupportedException("For the generic board, you need to specify the pin to use for pwm");
}
/// <inheritdoc />
public override int[] GetDefaultPinAssignmentForSpi(SpiConnectionSettings connectionSettings)
{
throw new NotSupportedException("For the generic board, you need to specify the pins to use for SPI");
}
}
}