Skip to content

Commit 3459139

Browse files
author
Eric Bézine
committed
Revert "Removed dependency on libbcm2835.so"
This reverts commit 89925f7.
1 parent 89925f7 commit 3459139

File tree

6 files changed

+14
-31
lines changed

6 files changed

+14
-31
lines changed

Raspberry.System.nuspec

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
Raspberry.System is a Mono/.NET assembly providing access to Raspberry Pi system features.
1515

1616
It is an initiative of the Raspberry# Community, aimed at providing tools and information concerning use of Raspberry Pi boards with Mono/.NET framework.
17+
Parts of this work are based on [BCM2835 C library](http://www.open.com.au/mikem/bcm2835/).
1718

1819
Visit project [Github site](https://github.com/raspberry-sharp/raspberry-sharp-system/) for documentation and samples.
1920
</description>
@@ -29,6 +30,7 @@
2930
<file src="Raspberry.System\bin\release\Raspberry.System.dll" target="lib\net40" />
3031
<file src="Raspberry.System\bin\release\Raspberry.System.pdb" target="lib\net40" />
3132
<file src="Raspberry.System\bin\release\Raspberry.System.xml" target="lib\net40" />
33+
<file src="Raspberry.System\bin\release\libbcm2835.so" target="lib\net40" />
3234
<file src="Raspberry.System\**\*.cs" target="src" />
3335
</files>
3436
</package>

Raspberry.System/Raspberry.System.csproj

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@
4545
<Compile Include="Timers\StandardTimer.cs" />
4646
<Compile Include="Timers\Timer.cs" />
4747
</ItemGroup>
48+
<ItemGroup>
49+
<None Include="libbcm2835.so">
50+
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
51+
</None>
52+
</ItemGroup>
4853
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
4954
<!-- To modify your build process, add your task inside one of the targets below and uncomment it.
5055
Other similar extension points exist, see Microsoft.Common.targets.

Raspberry.System/Timers/HighResolutionTimer.cs

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,6 @@
77

88
namespace Raspberry.Timers
99
{
10-
/// <summary>
11-
/// Represents a high-resolution timer
12-
/// </summary>
1310
public class HighResolutionTimer : ITimer
1411
{
1512
#region Fields
@@ -24,9 +21,6 @@ public class HighResolutionTimer : ITimer
2421

2522
#region Instance Management
2623

27-
/// <summary>
28-
/// Initializes a new instance of the <see cref="HighResolutionTimer"/> class.
29-
/// </summary>
3024
public HighResolutionTimer()
3125
{
3226
if (!Board.Current.IsRaspberryPi)
@@ -113,21 +107,6 @@ public void Stop()
113107
}
114108
}
115109

116-
/// <summary>
117-
/// Sleeps the specified delay.
118-
/// </summary>
119-
/// <param name="delay">The delay.</param>
120-
public static void Sleep(decimal delay)
121-
{
122-
var timeSpec = new Interop.timespec
123-
{
124-
tv_sec = (long) (delay/1000),
125-
tv_nsec = (long) ((delay%1000)*1000000)
126-
};
127-
128-
Interop.nanosleep(ref timeSpec);
129-
}
130-
131110
#endregion
132111

133112
#region Private Helpers
@@ -146,6 +125,11 @@ private void ThreadProcess()
146125

147126
private void NoOp(){}
148127

128+
public static void Sleep(decimal delay)
129+
{
130+
Interop.bcm2835_delayMicroseconds((uint) (delay*1000));
131+
}
132+
149133
#endregion
150134
}
151135
}

Raspberry.System/Timers/Interop.cs

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,8 @@ internal static class Interop
66
{
77
#region Methods
88

9-
public struct timespec
10-
{
11-
public long tv_sec;
12-
public long tv_nsec;
13-
};
14-
15-
[DllImport("libc.so.6")]
16-
public static extern void nanosleep(ref timespec timespec);
9+
[DllImport("libbcm2835.so", EntryPoint = "bcm2835_delayMicroseconds")]
10+
public static extern void bcm2835_delayMicroseconds(uint microseconds);
1711

1812
#endregion
1913
}

Raspberry.System/libbcm2835.so

29.5 KB
Binary file not shown.

Test.Board/Program.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
using System;
2-
using Raspberry.Timers;
32

43
namespace Test.Board
54
{
@@ -15,7 +14,6 @@ static void Main(string[] args)
1514
{
1615
Console.WriteLine("Raspberry Pi running on {0} processor", board.Processor);
1716
Console.WriteLine("Firmware rev{0}, board rev{1}", board.Firmware, board.Revision);
18-
Timer.Sleep(2000);
1917
Console.WriteLine();
2018
Console.WriteLine("Serial number: {0}", board.SerialNumber);
2119
}

0 commit comments

Comments
 (0)