-
Notifications
You must be signed in to change notification settings - Fork 594
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add a generic GPIO driver for Allwinner SoCs and Orange Pi Zero/Lite/…
…Lite2 pin map (#1130) * add cs files * add csproj * resolve some feedbacks * MSBuild fail * derive from UnixDriver * reference source files * reference csproj * resolve some issues * using GpioController * _interruptController is assigned a value in the constructor * _interruptController nullable type * nullable check * SunxiDriver instead of inheriting SysFsDriver; add samples * add readme; update samples * add pin mode check; add static to _pinNumberConverter * call initialize in constructor * update README.md * fix init problem; add some validates * add Orange Pi Lite driver * clean up; fix cpux-port initial problem; remove internal exceptions * remove tiny delay * private opi zero _pinNumberConverter * add xml comment * update README.md * fix error SA1208 * fix copyright headers * cleanup * fix error SA1028 * fix CPUX port offset * count the number of pins; update README.md * fix typo * Fix Interop duplication Co-authored-by: Jose Perez Rodriguez <[email protected]>
- Loading branch information
1 parent
03e3a24
commit fe22a80
Showing
14 changed files
with
748 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Iot.Device.Gpio.Drivers | ||
{ | ||
/// <summary> | ||
/// A GPIO driver for the Orange Pi Lite 2. | ||
/// </summary> | ||
/// <remarks> | ||
/// SoC: Allwinner H6 (sun50iw6p1) | ||
/// </remarks> | ||
public class OrangePiLite2Driver : Sun50iw6p1Driver | ||
{ | ||
private static readonly int[] _pinNumberConverter = new int[] | ||
{ | ||
-1, -1, -1, MapPinNumber('H', 6), -1, MapPinNumber('H', 5), -1, MapPinNumber('H', 4), MapPinNumber('D', 21), -1, | ||
MapPinNumber('D', 22), MapPinNumber('D', 24), MapPinNumber('C', 9), MapPinNumber('D', 23), -1, MapPinNumber('D', 26), | ||
MapPinNumber('C', 8), -1, MapPinNumber('C', 7), MapPinNumber('C', 2), -1, MapPinNumber('C', 3), MapPinNumber('D', 25), | ||
MapPinNumber('C', 0), MapPinNumber('C', 5), -1, MapPinNumber('H', 3) | ||
}; | ||
|
||
/// <inheritdoc/> | ||
protected override int PinCount => 17; | ||
|
||
/// <inheritdoc/> | ||
protected override int ConvertPinNumberToLogicalNumberingScheme(int pinNumber) | ||
{ | ||
int num = _pinNumberConverter[pinNumber]; | ||
|
||
return num != -1 ? num : throw new ArgumentException($"Board (header) pin {pinNumber} is not a GPIO pin on the {GetType().Name} device.", nameof(pinNumber)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Iot.Device.Gpio.Drivers | ||
{ | ||
/// <summary> | ||
/// A GPIO driver for the Orange Pi Lite. | ||
/// </summary> | ||
/// <remarks> | ||
/// SoC: Allwinner H3 (sun8iw7p1) | ||
/// </remarks> | ||
public class OrangePiLiteDriver : Sun8iw7p1Driver | ||
{ | ||
private static readonly int[] _pinNumberConverter = new int[] | ||
{ | ||
-1, -1, -1, MapPinNumber('A', 12), -1, MapPinNumber('A', 11), -1, MapPinNumber('A', 6), MapPinNumber('A', 13), -1, | ||
MapPinNumber('A', 14), MapPinNumber('A', 1), MapPinNumber('D', 14), MapPinNumber('A', 0), -1, MapPinNumber('A', 3), | ||
MapPinNumber('C', 4), -1, MapPinNumber('C', 7), MapPinNumber('C', 0), -1, MapPinNumber('C', 1), MapPinNumber('A', 2), | ||
MapPinNumber('C', 2), MapPinNumber('C', 3), -1, MapPinNumber('A', 21), MapPinNumber('A', 19), MapPinNumber('A', 18), | ||
MapPinNumber('A', 7), -1, MapPinNumber('A', 8), MapPinNumber('G', 8), MapPinNumber('A', 9), -1, MapPinNumber('A', 10), | ||
MapPinNumber('G', 9), MapPinNumber('A', 20), MapPinNumber('G', 6), -1, MapPinNumber('G', 7) | ||
}; | ||
|
||
/// <inheritdoc/> | ||
protected override int PinCount => 28; | ||
|
||
/// <inheritdoc/> | ||
protected override int ConvertPinNumberToLogicalNumberingScheme(int pinNumber) | ||
{ | ||
int num = _pinNumberConverter[pinNumber]; | ||
|
||
return num != -1 ? num : throw new ArgumentException($"Board (header) pin {pinNumber} is not a GPIO pin on the {GetType().Name} device.", nameof(pinNumber)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System; | ||
|
||
namespace Iot.Device.Gpio.Drivers | ||
{ | ||
/// <summary> | ||
/// A GPIO driver for the Orange Pi Zero. | ||
/// </summary> | ||
/// <remarks> | ||
/// SoC: Allwinner H2+ (sun8iw7p1) | ||
/// </remarks> | ||
public class OrangePiZeroDriver : Sun8iw7p1Driver | ||
{ | ||
private static readonly int[] _pinNumberConverter = new int[] | ||
{ | ||
-1, -1, -1, MapPinNumber('A', 12), -1, MapPinNumber('A', 11), -1, MapPinNumber('A', 6), MapPinNumber('G', 6), -1, | ||
MapPinNumber('G', 7), MapPinNumber('A', 1), MapPinNumber('A', 7), MapPinNumber('A', 0), -1, MapPinNumber('A', 3), | ||
MapPinNumber('A', 19), -1, MapPinNumber('A', 18), MapPinNumber('A', 15), -1, MapPinNumber('A', 16), MapPinNumber('A', 2), | ||
MapPinNumber('A', 14), MapPinNumber('A', 13), -1, MapPinNumber('A', 10) | ||
}; | ||
|
||
/// <inheritdoc/> | ||
protected override int PinCount => 17; | ||
|
||
/// <inheritdoc/> | ||
protected override int ConvertPinNumberToLogicalNumberingScheme(int pinNumber) | ||
{ | ||
int num = _pinNumberConverter[pinNumber]; | ||
|
||
return num != -1 ? num : throw new ArgumentException($"Board (header) pin {pinNumber} is not a GPIO pin on the {GetType().Name} device.", nameof(pinNumber)); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Iot.Device.Gpio.Drivers | ||
{ | ||
/// <summary> | ||
/// A GPIO driver for Allwinner H5. | ||
/// </summary> | ||
public class Sun50iw2p1Driver : SunxiDriver | ||
{ | ||
/// <inheritdoc/> | ||
protected override int CpuxPortBaseAddress => 0x01C20800; | ||
|
||
/// <inheritdoc/> | ||
protected override int CpusPortBaseAddress => 0x01F02C00; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Iot.Device.Gpio.Drivers | ||
{ | ||
/// <summary> | ||
/// A GPIO driver for Allwinner H6. | ||
/// </summary> | ||
public class Sun50iw6p1Driver : SunxiDriver | ||
{ | ||
/// <inheritdoc/> | ||
protected override int CpuxPortBaseAddress => 0x0300B000; | ||
|
||
/// <inheritdoc/> | ||
protected override int CpusPortBaseAddress => 0x07022000; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
namespace Iot.Device.Gpio.Drivers | ||
{ | ||
/// <summary> | ||
/// A GPIO driver for Allwinner H2+/H3. | ||
/// </summary> | ||
public class Sun8iw7p1Driver : SunxiDriver | ||
{ | ||
/// <inheritdoc/> | ||
protected override int CpuxPortBaseAddress => 0x01C20800; | ||
|
||
/// <inheritdoc/> | ||
protected override int CpusPortBaseAddress => 0x01F02C00; | ||
} | ||
} |
Oops, something went wrong.