Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
83 changes: 83 additions & 0 deletions nanoFramework.Device.Can/CanTiming.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
//
Copy link
Member

Choose a reason for hiding this comment

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

file name must match the name of the class, so please rename to CanTimingSTM32.cs :-)

// Copyright (c) .NET Foundation and Contributors
// See LICENSE file in the project root for full license information.
//

namespace nanoFramework.Device.Can
{
/// <summary>
/// Helper for common CAN timings for the STM32
Copy link
Member

Choose a reason for hiding this comment

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

Missing . at end of sentence.

/// </summary>
public static class CanTimingSTM32
{
/// <summary>
/// 25 KBaud.
/// </summary>
public static CanSettings Timing500KBaud () {
Copy link
Member

Choose a reason for hiding this comment

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

Please use small caps k. Capital K is for Kelvin unit.

return new CanSettings(6, 8, 1, 0);
}

}

/// <summary>
/// Helper for common CAN timings for the ESP32. Values from https://github.com/espressif/esp-idf/blob/master/components/hal/include/hal/twai_types.h#L54
/// </summary>
public static class CanTimingESP32
Copy link
Member

Choose a reason for hiding this comment

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

For coherence with the usual naming:

Suggested change
public static class CanTimingESP32
public static class CanTimingEsp32

{
/// <summary>
/// 25 KBaud.
/// </summary>
public static CanSettings Timing25KBaud () {
Copy link
Member

Choose a reason for hiding this comment

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

Please hit CTRL+K + CTRL+D to have VS auto format the code.

return new CanSettings(128, 16, 8, 3);
}

/// <summary>
/// 50 KBaud.
/// </summary>
public static CanSettings Timing50KBaud () {
return new CanSettings(80, 15, 4, 3);
}

/// <summary>
/// 100 KBaud.
/// </summary>
public static CanSettings Timing100KBaud () {
return new CanSettings(40, 15, 4, 3);
}

/// <summary>
/// 125 KBaud.
/// </summary>
public static CanSettings Timing125KBaud () {
return new CanSettings(32, 15, 4, 3);
}

/// <summary>
/// 250 KBaud.
/// </summary>
public static CanSettings Timing250KBaud () {
return new CanSettings(16, 15, 4, 3);
}

/// <summary>
/// 500 KBaud.
/// </summary>
public static CanSettings Timing500KBaud () {
return new CanSettings(8, 15, 4, 3);
}

/// <summary>
/// 800 KBaud.
/// </summary>
public static CanSettings Timing800KBaud() {
return new CanSettings(4, 16, 8, 3);
}

/// <summary>
/// 1000 KBaud.
/// </summary>
public static CanSettings Timing1000KBaud () {
return new CanSettings(4, 15, 4, 3);
}
}
}
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="CanTiming.cs" />
<None Include="key.snk" />
</ItemGroup>
<ItemGroup>
Expand Down