Skip to content

Commit acdc254

Browse files
authored
First working version (#1)
1 parent eda3fc8 commit acdc254

File tree

7 files changed

+188
-24
lines changed

7 files changed

+188
-24
lines changed

nanoFramework.Hardware.TI.nuspec

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,34 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<package xmlns="http://schemas.microsoft.com/packaging/2012/06/nuspec.xsd">
33
<metadata>
4-
<id>nanoFramework.Hardware.Stm32</id>
4+
<id>nanoFramework.Hardware.TI</id>
55
<version>$version$</version>
6-
<title>nanoFramework.Hardware.Stm32</title>
6+
<title>nanoFramework.Hardware.TI</title>
77
<authors>nanoFramework project contributors</authors>
88
<owners>nanoFramework project contributors</owners>
99
<requireLicenseAcceptance>false</requireLicenseAcceptance>
1010
<license type="expression">Apache-2.0</license>
1111
<releaseNotes>
1212
</releaseNotes>
1313
<developmentDependency>false</developmentDependency>
14-
<projectUrl>https://github.com/nanoframework/lib-nanoFramework.Hardware.Stm32</projectUrl>
14+
<projectUrl>https://github.com/nanoframework/lib-nanoFramework.Hardware.TI</projectUrl>
1515
<iconUrl>https://secure.gravatar.com/avatar/97d0e092247f0716db6d4b47b7d1d1ad</iconUrl>
16-
<repository type="git" url="https://github.com/nanoframework/lib-nanoFramework.Hardware.Stm32" commit="$commit$" />
17-
<copyright>Copyright (c) 2018 The nanoFramework project contributors</copyright>
18-
<description>This package includes the nanoFramework.Hardware.Stm32 assembly for nanoFramework C# projects.
19-
This package requires a target with nanoFramework.Hardware.Stm32 v$nativeVersion$.</description>
20-
<summary>nanoFramework.Hardware.Stm32 assembly for nanoFramework C# projects</summary>
21-
<tags>nanoFramework C# csharp netmf netnf nanoFramework.Hardware.Stm32</tags>
16+
<repository type="git" url="https://github.com/nanoframework/lib-nanoFramework.Hardware.TI" commit="$commit$" />
17+
<copyright>Copyright (c) 2020 The nanoFramework project contributors</copyright>
18+
<description>This package includes the nanoFramework.Hardware.TI assembly for nanoFramework C# projects.
19+
This package requires a target with nanoFramework.Hardware.TI v$nativeVersion$.</description>
20+
<summary>nanoFramework.Hardware.TI assembly for nanoFramework C# projects</summary>
21+
<tags>nanoFramework C# csharp netmf netnf nanoFramework.Hardware.TI</tags>
2222
<dependencies>
2323
<dependency id="nanoFramework.CoreLibrary" version="1.7.3" />
2424
</dependencies>
2525
</metadata>
2626
<files>
27-
<file src="nanoFramework.Hardware.Stm32\bin\Release\nanoFramework.Hardware.Stm32.dll" target="lib\nanoFramework.Hardware.Stm32.dll" />
28-
<file src="nanoFramework.Hardware.Stm32\bin\Release\nanoFramework.Hardware.Stm32.pdb" target="lib\nanoFramework.Hardware.Stm32.pdb" />
29-
<file src="nanoFramework.Hardware.Stm32\bin\Release\nanoFramework.Hardware.Stm32.pdbx" target="lib\nanoFramework.Hardware.Stm32.pdbx" />
30-
<file src="nanoFramework.Hardware.Stm32\bin\Release\nanoFramework.Hardware.Stm32.pe" target="lib\nanoFramework.Hardware.Stm32.pe" />
31-
<file src="nanoFramework.Hardware.Stm32\bin\Release\nanoFramework.Hardware.Stm32.xml" target="lib\nanoFramework.Hardware.Stm32.xml" />
27+
<file src="nanoFramework.Hardware.TI\bin\Release\nanoFramework.Hardware.TI.dll" target="lib\nanoFramework.Hardware.TI.dll" />
28+
<file src="nanoFramework.Hardware.TI\bin\Release\nanoFramework.Hardware.TI.pdb" target="lib\nanoFramework.Hardware.TI.pdb" />
29+
<file src="nanoFramework.Hardware.TI\bin\Release\nanoFramework.Hardware.TI.pdbx" target="lib\nanoFramework.Hardware.TI.pdbx" />
30+
<file src="nanoFramework.Hardware.TI\bin\Release\nanoFramework.Hardware.TI.pe" target="lib\nanoFramework.Hardware.TI.pe" />
31+
<file src="nanoFramework.Hardware.TI\bin\Release\nanoFramework.Hardware.TI.xml" target="lib\nanoFramework.Hardware.TI.xml" />
3232
<!-- readme -->
3333
<file src="readme.txt" target="readme.txt" />
3434
</files>
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Hardware.TI
7+
{
8+
public partial class Power
9+
{
10+
/// <summary>
11+
/// Configuration for GPIO pin internal pull-up or pull-down resitor.
12+
/// </summary>
13+
14+
// these values match the corresponding definitions from TI SimpleLink SDK
15+
// PIN_NOPULL
16+
// PIN_PULLUP
17+
// PIN_PULLDOWN
18+
public enum PinPullUpDown : uint
19+
{
20+
/// <summary>
21+
/// No pull-up or pull-down resistor.
22+
/// </summary>
23+
None = 0x80000000,
24+
25+
/// <summary>
26+
/// Enable internal pull-up resistor for GPIO pin.
27+
/// </summary>
28+
PullUp = 0x80002000,
29+
30+
/// <summary>
31+
/// Enable internal pull-down resistor for GPIO pin.
32+
/// </summary>
33+
PullDown = 0x80004000
34+
}
35+
}
36+
}
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Hardware.TI
7+
{
8+
public partial class Power
9+
{
10+
/// <summary>
11+
/// Configuration for GPIO pin to wakeup device.
12+
/// </summary>
13+
public class PinWakeupConfig
14+
{
15+
#pragma warning disable S4487 // these fields will be read in native code
16+
private readonly int _pin;
17+
18+
private readonly PinWakeupEdge _wakeupConfig;
19+
20+
private readonly PinPullUpDown _pinPullUpDown;
21+
#pragma warning restore S4487 // Unread "private" fields should be removed
22+
23+
/// <summary>
24+
/// Create a wakeup configuration for a GPIO pin.
25+
/// </summary>
26+
/// <param name="pin">GPIO pin number to configure for wakeup.</param>
27+
/// <param name="wakeupConfig">Wakeup configuration for the GPIO pin.</param>
28+
/// <param name="pinPullUpDown">Option for internal pull-up or pull-down resistor.</param>
29+
/// <remarks>
30+
/// To remove a wakeup configuration from a pin set the <paramref name="wakeupConfig"/> to <see cref="PinWakeupEdge.None"/>.
31+
/// </remarks>
32+
public PinWakeupConfig(int pin, PinWakeupEdge wakeupConfig, PinPullUpDown pinPullUpDown = PinPullUpDown.None)
33+
{
34+
_pin = pin;
35+
_wakeupConfig = wakeupConfig;
36+
_pinPullUpDown = pinPullUpDown;
37+
}
38+
}
39+
}
40+
}
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
//
2+
// Copyright (c) 2020 The nanoFramework project contributors
3+
// See LICENSE file in the project root for full license information.
4+
//
5+
6+
namespace nanoFramework.Hardware.TI
7+
{
8+
public partial class Power
9+
{
10+
/// <summary>
11+
/// Configuration for GPIO pin wakeup sensivity.
12+
/// </summary>
13+
14+
// these values match the corresponding definitions from TI SimpleLink SDK
15+
// PINCC26XX_NO_WAKEUP
16+
// PINCC26XX_WAKEUP_POSEDGE
17+
// PINCC26XX_WAKEUP_NEGEDGE
18+
public enum PinWakeupEdge
19+
{
20+
/// <summary>
21+
/// No wakeup.
22+
/// </summary>
23+
None = 0,
24+
25+
/// <summary>
26+
/// Wakeup from shutdown on positive edge.
27+
/// </summary>
28+
PositiveEdge = 0x18000000,
29+
30+
/// <summary>
31+
/// Wakeup from shutdown on negative edge.
32+
/// </summary>
33+
NegativeEdge = 0x10000000
34+
}
35+
}
36+
}

nanoFramework.Hardware.TI/Power.WakeupReasonType.cs

Lines changed: 38 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,24 +8,54 @@ namespace nanoFramework.Hardware.TI
88
public partial class Power
99
{
1010
/// <summary>
11-
/// Wakeup reason enumeration.
11+
/// Source of system reset.
1212
/// </summary>
13-
public enum WakeupReasonType
13+
public enum ResetSource : byte
1414
{
1515
/// <summary>
16-
/// Undetermined wakeup reason.
16+
/// Power-on reset.
1717
/// </summary>
18-
Undetermined = 0,
18+
PowerOn = 0,
1919

2020
/// <summary>
21-
/// Wakeup from shudown mode.
21+
/// Reset pin.
2222
/// </summary>
23-
FromShutdown,
23+
ResetPin,
2424

2525
/// <summary>
26-
/// Wakeup from pin.
26+
/// VDDS failure.
2727
/// </summary>
28-
FromPin
28+
VddsFailure,
29+
30+
/// <summary>
31+
/// VDDR failure.
32+
/// </summary>
33+
VddrFailure,
34+
35+
/// <summary>
36+
/// Clock loss detected.
37+
/// </summary>
38+
ClockLoss,
39+
40+
/// <summary>
41+
/// Software initiated system reset.
42+
/// </summary>
43+
SoftwareReset,
44+
45+
/// <summary>
46+
/// Warm reset.
47+
/// </summary>
48+
WarmReset,
49+
50+
/// <summary>
51+
/// System wakeup from shutdown.
52+
/// </summary>
53+
WakeupFromShutdown,
54+
55+
/// <summary>
56+
/// Detected noise on TCK pin.
57+
/// </summary>
58+
NoiseOnTck
2959
}
3060
}
3161
}

nanoFramework.Hardware.TI/Power.cs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,28 @@ public static void EnterShutdownMode()
3333
System.Threading.Thread.Sleep(System.Threading.Timeout.Infinite);
3434
}
3535

36+
/// <summary>
37+
/// Setup wakeup configuration from GPIO pins.
38+
/// </summary>
39+
/// <param name="pinWakeupConfig">Array of <see cref="PinWakeupConfig"/> with the configuration for the GPIO pins.</param>
40+
/// <remarks>
41+
/// This method is used to setup the wakeup configuration from GPIO pins.
42+
/// If there is a need to make furhter changes to the configuration just call this method again with the new configuration.
43+
/// There is no storage for the configuration nor any method to query the existing configuration, if any.
44+
/// If a GPIO pin has been setup with a wakeup configuration and that needs to be removed, it should be added to the new configuration
45+
/// array with <see cref="PinWakeupEdge.None"/>.
46+
/// </remarks>
47+
[MethodImpl(MethodImplOptions.InternalCall)]
48+
#pragma warning disable S4200 // OK to call native method directly
49+
public static extern void ConfigureWakeupFromGpioPin(PinWakeupConfig[] pinWakeupConfig);
50+
#pragma warning restore S4200 // Native methods should be wrapped
51+
3652
#region native methods calls
3753

3854
/// <summary>
39-
/// Gets the reason for device wakeup.
55+
/// Gets the reset source.
4056
/// </summary>
41-
public static extern WakeupReasonType WakeupReason
57+
public static extern ResetSource SourceOfReset
4258
{
4359
[MethodImpl(MethodImplOptions.InternalCall)]
4460
get;

nanoFramework.Hardware.TI/nanoFramework.Hardware.TI.nfproj

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@
3737
<NFMDP_PE_ExcludeClassByName Include="ThisAssembly">
3838
<InProject>false</InProject>
3939
</NFMDP_PE_ExcludeClassByName>
40+
<NFMDP_PE_ExcludeClassByName Include="ResetSource">
41+
<InProject>false</InProject>
42+
</NFMDP_PE_ExcludeClassByName>
4043
</ItemGroup>
4144
<ItemGroup>
4245
<NFMDP_PE_LoadHints Include="..\packages\nanoFramework.CoreLibrary.1.7.3\lib\mscorlib.dll">
@@ -45,6 +48,9 @@
4548
</ItemGroup>
4649
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
4750
<ItemGroup>
51+
<Compile Include="Power.PinPullUpDown.cs" />
52+
<Compile Include="Power.PinWakeupEdge.cs" />
53+
<Compile Include="Power.PinWakeupConfig.cs" />
4854
<Compile Include="Power.WakeupReasonType.cs" />
4955
<Compile Include="Properties\AssemblyInfo.cs" />
5056
<Compile Include="Power.cs" />

0 commit comments

Comments
 (0)