Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 58 additions & 0 deletions nanoFramework.Device.Can/CanBitTiming.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
//
// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Device.Can
{
/// <summary>
/// CAN bit timings.
/// </summary>
public enum CanBitTiming
{
/// <summary>
/// None. Manually setted values.
/// </summary>
_None,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't start enums we underscore _, so you can rename them all to remove it

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and in case of numbres, like in most here, the trick is to start with the unit. So Baud25k, etc


/// <summary>
/// 25kBaud.
/// </summary>
_25kBaud,

/// <summary>
/// 50kBaud.
/// </summary>
_50kBaud,

/// <summary>
/// 100kBaud.
/// </summary>
_100kBaud,

/// <summary>
/// 125kBaud.
/// </summary>
_125kBaud,

/// <summary>
/// 250kBaud.
/// </summary>
_250kBaud,

/// <summary>
/// 500kBaud.
/// </summary>
_500kBaud,

/// <summary>
/// 800kBaud.
/// </summary>
_800kBaud,

/// <summary>
/// 1000kBaud.
/// </summary>
_1000kBaud,
}
}
20 changes: 20 additions & 0 deletions nanoFramework.Device.Can/CanSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,9 @@ public sealed class CanSettings
[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
private byte _syncJumpWidth;

[System.Diagnostics.DebuggerBrowsable(System.Diagnostics.DebuggerBrowsableState.Never)]
private CanBitTiming _timing = CanBitTiming._None;

/// <summary>
/// Initializes a new instance of <see cref="CanSettings"/>.
/// </summary>
Expand All @@ -37,6 +40,14 @@ public sealed class CanSettings
_syncJumpWidth = syncJumpWidth;
}

/// <summary>
/// Initializes a new instance of <see cref="CanSettings"/>.
/// </summary>
/// <param name="timing">Bus baud rate timing preset.</param>
public CanSettings (CanBitTiming timing) {
_timing = timing;
}

/// <summary>
/// Initializes a copy of a <see cref="CanSettings"/> object.
/// </summary>
Expand Down Expand Up @@ -84,5 +95,14 @@ public byte SyncJumpWidth
get { return _syncJumpWidth; }
set { _syncJumpWidth = value; }
}

/// <summary>
/// Gets or sets the <see cref="CanBitTiming"/>.
/// </summary>
public CanBitTiming Timing
{
get { return _timing; }
set { _timing = value; }
}
}
}
1 change: 1 addition & 0 deletions nanoFramework.Device.Can/nanoFramework.Device.Can.nfproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
<Compile Include="CanMessageReceivedEventArgs.cs" />
<Compile Include="CanControllerEventListener.cs" />
<Compile Include="CanMessageEvent.cs" />
<Compile Include="CanBitTiming.cs" />
<None Include="key.snk" />
</ItemGroup>
<ItemGroup>
Expand Down