Skip to content

Commit 80562b7

Browse files
authored
Add Power mode sample for GG (#253)
1 parent e2b5e51 commit 80562b7

File tree

8 files changed

+193
-9
lines changed

8 files changed

+193
-9
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project ToolsVersion="Current" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup Label="Globals">
4+
<NanoFrameworkProjectSystemPath>$(MSBuildExtensionsPath)\nanoFramework\v1.0\</NanoFrameworkProjectSystemPath>
5+
</PropertyGroup>
6+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.Default.props')" />
7+
<PropertyGroup>
8+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
9+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
10+
<ProjectTypeGuids>{11A8DD76-328B-46DF-9F39-F559912D0360};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}</ProjectTypeGuids>
11+
<ProjectGuid>5eee640b-5049-4bb9-a223-96b96b04f514</ProjectGuid>
12+
<OutputType>Exe</OutputType>
13+
<AppDesignerFolder>Properties</AppDesignerFolder>
14+
<FileAlignment>512</FileAlignment>
15+
<RootNamespace>GiantGecko.PowerMode</RootNamespace>
16+
<AssemblyName>GiantGecko.PowerMode</AssemblyName>
17+
<TargetFrameworkVersion>v1.0</TargetFrameworkVersion>
18+
</PropertyGroup>
19+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.props" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.props')" />
20+
<ItemGroup>
21+
<Compile Include="Program.cs" />
22+
<Compile Include="Properties\AssemblyInfo.cs" />
23+
</ItemGroup>
24+
<ItemGroup>
25+
<Reference Include="mscorlib">
26+
<HintPath>..\packages\nanoFramework.CoreLibrary.1.12.0\lib\mscorlib.dll</HintPath>
27+
</Reference>
28+
<Reference Include="nanoFramework.Hardware.GiantGecko">
29+
<HintPath>..\packages\nanoFramework.Hardware.GiantGecko.1.0.5\lib\nanoFramework.Hardware.GiantGecko.dll</HintPath>
30+
</Reference>
31+
<Reference Include="nanoFramework.Runtime.Events">
32+
<HintPath>..\packages\nanoFramework.Runtime.Events.1.11.1\lib\nanoFramework.Runtime.Events.dll</HintPath>
33+
</Reference>
34+
<Reference Include="System.Device.Gpio">
35+
<HintPath>..\packages\nanoFramework.System.Device.Gpio.1.1.22\lib\System.Device.Gpio.dll</HintPath>
36+
</Reference>
37+
</ItemGroup>
38+
<ItemGroup>
39+
<None Include="packages.config" />
40+
</ItemGroup>
41+
<Import Project="$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets" Condition="Exists('$(NanoFrameworkProjectSystemPath)NFProjectSystem.CSharp.targets')" />
42+
<ProjectExtensions>
43+
<ProjectCapabilities>
44+
<ProjectConfigurationsDeclaredAsItems />
45+
</ProjectCapabilities>
46+
</ProjectExtensions>
47+
</Project>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
using System;
2+
using System.Device.Gpio;
3+
using System.Diagnostics;
4+
using System.Threading;
5+
using GiantGecko = nanoFramework.Hardware.GiantGecko;
6+
7+
namespace PowerMode
8+
{
9+
public class Program
10+
{
11+
private static GpioController _gpioController;
12+
13+
public static void Main()
14+
{
15+
_gpioController = new GpioController();
16+
17+
// Silabs SLSTK3701A: LED1 PH14 is LLED1
18+
GpioPin led = _gpioController.OpenPin(PinNumber('H', 14), PinMode.Output);
19+
20+
// start a thread blinking the LED to check that something is happening
21+
new Thread(() => {
22+
while (true)
23+
{
24+
Thread.Sleep(125);
25+
led.Toggle();
26+
}
27+
}).Start();
28+
29+
// sleep here for 5 seconds to allow the LED to blink
30+
Thread.Sleep(5_000);
31+
32+
Debug.WriteLine($"Going to standby mode now...");
33+
34+
//////////////////////////////////////
35+
// *** these calls never return *** //
36+
//////////////////////////////////////
37+
38+
/////////////////////////////////////////////////////////////////////////////////
39+
// Uncomment one of the following according to the power mode you want to test //
40+
/////////////////////////////////////////////////////////////////////////////////
41+
42+
// after this the target will enter EM4 hibernate mode (RTC will be on and counting)
43+
GiantGecko.Power.EnterHibernateMode();
44+
45+
// after this the target will enter EM4 shutoff mode: nothing is running on the device and everything is shutoff
46+
// GiantGecko.Power.EnterShutoffMode();
47+
}
48+
49+
static int PinNumber(char port, byte pin)
50+
{
51+
if (port < 'A' || port > 'J')
52+
throw new ArgumentException();
53+
54+
return ((port - 'A') * 16) + pin;
55+
}
56+
}
57+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
using System.Runtime.InteropServices;
4+
5+
// General Information about an assembly is controlled through the following
6+
// set of attributes. Change these attribute values to modify the information
7+
// associated with an assembly.
8+
[assembly: AssemblyTitle("CSharp.BlankApplication")]
9+
[assembly: AssemblyDescription("")]
10+
[assembly: AssemblyConfiguration("")]
11+
[assembly: AssemblyCompany("")]
12+
[assembly: AssemblyProduct("CSharp.BlankApplication")]
13+
[assembly: AssemblyCopyright("Copyright © 2022")]
14+
[assembly: AssemblyTrademark("")]
15+
[assembly: AssemblyCulture("")]
16+
17+
// Setting ComVisible to false makes the types in this assembly not visible
18+
// to COM components. If you need to access a type in this assembly from
19+
// COM, set the ComVisible attribute to true on that type.
20+
[assembly: ComVisible(false)]
21+
22+
// Version information for an assembly consists of the following four values:
23+
//
24+
// Major Version
25+
// Minor Version
26+
// Build Number
27+
// Revision
28+
//
29+
// You can specify all the values or you can default the Build and Revision Numbers
30+
// by using the '*' as shown below:
31+
// [assembly: AssemblyVersion("1.0.*")]
32+
[assembly: AssemblyVersion("1.0.0.0")]
33+
[assembly: AssemblyFileVersion("1.0.0.0")]
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# 🌶️🌶️ - Giant Gecko Power Mode
2+
3+
This samples shows how to use the Power Mode on Silabs Giant Gecko MCU's.
4+
5+
## Build the sample
6+
7+
1. Start Microsoft Visual Studio 2022 (VS 2019 should be OK too) and select `File > Open > Project/Solution`.
8+
1. Starting in the folder where you unzipped the samples/cloned the repository, go to the subfolder for this specific sample. Double-click the Visual Studio Solution (.sln) file.
9+
1. Press `Ctrl+Shift+B`, or select `Build > Build Solution`.
10+
11+
## Run the sample
12+
13+
The next steps depend on whether you just want to deploy the sample or you want to both deploy and run it.
14+
15+
### Deploying the sample
16+
17+
- Select `Build > Deploy Solution`.
18+
19+
### Deploying and running the sample
20+
21+
- To debug the sample and then run it, press F5 or select `Debug > Start Debugging`.
22+
23+
> **Important**: Before deploying or running the sample, please make sure your device is visible in the Device Explorer.
24+
25+
> **Tip**: To display the Device Explorer, go to Visual Studio menus: `View > Other Windows > Device Explorer`.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ggecko
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<packages>
3+
<package id="nanoFramework.CoreLibrary" version="1.12.0" targetFramework="netnano1.0" />
4+
<package id="nanoFramework.Hardware.GiantGecko" version="1.0.5" targetFramework="netnano1.0" />
5+
<package id="nanoFramework.Runtime.Events" version="1.11.1" targetFramework="netnano1.0" />
6+
<package id="nanoFramework.System.Device.Gpio" version="1.1.22" targetFramework="netnano1.0" />
7+
</packages>

samples/Hardware.GiantGecko/Hardware.GiantGecko.sln

+21-7
Original file line numberDiff line numberDiff line change
@@ -3,20 +3,34 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 17
44
VisualStudioVersion = 17.3.32929.385
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "GiantGecko.ReadDeviceIDs", "GiantGecko.ReadDeviceIDs\GiantGecko.ReadDeviceIDs.nfproj", "{8f29f025-77c7-48f5-a66d-9f46e26470f6}"
6+
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "GiantGecko.ReadDeviceIDs", "GiantGecko.ReadDeviceIDs\GiantGecko.ReadDeviceIDs.nfproj", "{8F29F025-77C7-48F5-A66D-9F46E26470F6}"
7+
EndProject
8+
Project("{11A8DD76-328B-46DF-9F39-F559912D0360}") = "GiantGecko.PowerMode", "GiantGecko.PowerMode\GiantGecko.PowerMode.nfproj", "{5EEE640B-5049-4BB9-A223-96B96B04F514}"
9+
EndProject
10+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{22B536D0-9F84-46DA-856B-694BB107CD88}"
11+
ProjectSection(SolutionItems) = preProject
12+
category.txt = category.txt
13+
README.md = README.md
14+
EndProjectSection
715
EndProject
816
Global
917
GlobalSection(SolutionConfigurationPlatforms) = preSolution
1018
Debug|Any CPU = Debug|Any CPU
1119
Release|Any CPU = Release|Any CPU
1220
EndGlobalSection
1321
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14-
{8f29f025-77c7-48f5-a66d-9f46e26470f6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15-
{8f29f025-77c7-48f5-a66d-9f46e26470f6}.Debug|Any CPU.Build.0 = Debug|Any CPU
16-
{8f29f025-77c7-48f5-a66d-9f46e26470f6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
17-
{8f29f025-77c7-48f5-a66d-9f46e26470f6}.Release|Any CPU.ActiveCfg = Release|Any CPU
18-
{8f29f025-77c7-48f5-a66d-9f46e26470f6}.Release|Any CPU.Build.0 = Release|Any CPU
19-
{8f29f025-77c7-48f5-a66d-9f46e26470f6}.Release|Any CPU.Deploy.0 = Release|Any CPU
22+
{8F29F025-77C7-48F5-A66D-9F46E26470F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
23+
{8F29F025-77C7-48F5-A66D-9F46E26470F6}.Debug|Any CPU.Build.0 = Debug|Any CPU
24+
{8F29F025-77C7-48F5-A66D-9F46E26470F6}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
25+
{8F29F025-77C7-48F5-A66D-9F46E26470F6}.Release|Any CPU.ActiveCfg = Release|Any CPU
26+
{8F29F025-77C7-48F5-A66D-9F46E26470F6}.Release|Any CPU.Build.0 = Release|Any CPU
27+
{8F29F025-77C7-48F5-A66D-9F46E26470F6}.Release|Any CPU.Deploy.0 = Release|Any CPU
28+
{5EEE640B-5049-4BB9-A223-96B96B04F514}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
29+
{5EEE640B-5049-4BB9-A223-96B96B04F514}.Debug|Any CPU.Build.0 = Debug|Any CPU
30+
{5EEE640B-5049-4BB9-A223-96B96B04F514}.Debug|Any CPU.Deploy.0 = Debug|Any CPU
31+
{5EEE640B-5049-4BB9-A223-96B96B04F514}.Release|Any CPU.ActiveCfg = Release|Any CPU
32+
{5EEE640B-5049-4BB9-A223-96B96B04F514}.Release|Any CPU.Build.0 = Release|Any CPU
33+
{5EEE640B-5049-4BB9-A223-96B96B04F514}.Release|Any CPU.Deploy.0 = Release|Any CPU
2034
EndGlobalSection
2135
GlobalSection(SolutionProperties) = preSolution
2236
HideSolutionNode = FALSE

samples/Hardware.GiantGecko/README.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1-
# 🌶️ to 🌶️🌶️ - Hardware Giant Gecko sample pack
1+
# 🌶️ to 🌶️🌶️ - Giant Gecko hardware sample pack
22

33
Shows how to use various APIs specific to Silabs Giant Gecko targets.
44

55
- [🌶️ - Read device IDs](GiantGecko.ReadDeviceIDs/)
6+
- [🌶️🌶️ - Power down/off demo](GiantGecko.PowerMode/)
67

78
## Hardware requirements
89

@@ -33,5 +34,4 @@ The next steps depend on whether you just want to deploy the sample or you want
3334
- To debug the sample and then run it, press F5 or select `Debug > Start Debugging`.
3435

3536
> **Important**: Before deploying or running the sample, please make sure your device is visible in the Device Explorer.
36-
3737
> **Tip**: To display the Device Explorer, go to Visual Studio menus: `View > Other Windows > Device Explorer`.

0 commit comments

Comments
 (0)