Refs #789, #1874. Improved timer accuracy and added Modbus RTU support to the TI TM4C port.

git-svn-id: https://svn.code.sf.net/p/openblt/code/trunk@1146 5dc33758-31d5-4daf-9ae8-b24bf3d40d73
This commit is contained in:
Frank Voorburg 2023-12-13 21:22:37 +00:00
parent ec6253883b
commit 39d8e47c0e
6 changed files with 810 additions and 122 deletions

View File

@ -224,7 +224,7 @@
<ColumnWidth0>22</ColumnWidth0>
<ColumnWidth1>1865</ColumnWidth1>
<FilterLevel>2</FilterLevel>
<LiveFile></LiveFile>
<LiveFile />
<LiveLogEnabled>0</LiveLogEnabled>
<LiveFilterLevel>-1</LiveFilterLevel>
</IarPane-34048>
@ -291,7 +291,7 @@
</IarPane-34063>
<ControlBarVersion>
<Major>14</Major>
<Minor>32</Minor>
<Minor>36</Minor>
</ControlBarVersion>
<MFCToolBarParameters>
<Tooltips>1</Tooltips>
@ -301,16 +301,16 @@
<RecentlyUsedMenus>1</RecentlyUsedMenus>
<MenuShadows>1</MenuShadows>
<ShowAllMenusAfterDelay>1</ShowAllMenusAfterDelay>
<CommandsUsage>07000000080059840000010000001086000001000000178100000100000003E10000010000000E81000005000000148600000100000011860000010000004681000001000000</CommandsUsage>
<CommandsUsage>0700000008005984000001000000108600000100000017810000010000000E8100000500000003E1000001000000148600000100000011860000010000004681000001000000</CommandsUsage>
</MFCToolBarParameters>
<CommandManager>
<CommandsWithoutImages>18000D8400000F84000008840000FFFFFFFF54840000328100001C81000009840000778400000784000086840000808C000044D500002AE10000008200001C82000001820000BB800000BC800000538400000E840000308400000484000006840000</CommandsWithoutImages>
<MenuUserImages>2B002CE100004400000015810000280000003184000054000000239200000000000007E100003C0000000F81000026000000208100002E00000004E100003A0000000C8100002300000023E100003E000000848000001A0000000D8000001800000001E10000370000001982000013000000038400004C0000001682000011000000178100002A00000000840000490000002BE10000430000001481000027000000008100001D0000000E810000250000001F8100002D00000025E10000400000002F8200001400000003E10000390000000B8100001B00000022E100003D00000000E1000036000000058400004E000000D18400000A000000188200001200000041E1000046000000028400004B000000168100002900000032840000550000001084000052000000518400005700000005E100003B0000000D8100001D0000000A84000050000000858000001B00000002E1000038000000</MenuUserImages>
<CommandsWithoutImages>14000D8400000F84000008840000FFFFFFFF54840000328100001C81000009840000778400000784000086840000808C000044D500002AE10000008200001C82000001820000BB800000BC80000053840000</CommandsWithoutImages>
<MenuUserImages>2F00048400004D00000015810000280000002CE100004400000007E100003C0000002392000000000000318400005400000004E100003A000000208100002E0000000F8100002600000001E10000370000000D80000018000000848000001A00000023E100003E0000000C81000023000000068400004F0000001982000013000000178100002A0000001682000011000000038400004C00000014810000270000002BE1000043000000008400004900000030840000530000000E84000051000000008100001D00000003E10000390000002F8200001400000025E10000400000001F8100002D0000000E8100002500000000E100003600000022E100003D0000000B8100001E00000041E10000460000001882000012000000D18400000A000000058400004E0000001681000029000000028400004B0000001084000052000000328400005500000005E100003B000000518400005700000002E1000038000000858000001B0000000A840000500000000D81000020000000</MenuUserImages>
</CommandManager>
<Pane-59393>
<ID>0</ID>
<RectRecentFloat>0A0000000A0000006E0000006E000000</RectRecentFloat>
<RectRecentDocked>00000000F00300008007000003040000</RectRecentDocked>
<RectRecentDocked>00000000F20300008007000003040000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -323,7 +323,7 @@
<Pane--1>
<ID>4294967295</ID>
<RectRecentFloat>000000003D0300008007000025040000</RectRecentFloat>
<RectRecentDocked>000000000803000080070000F0030000</RectRecentDocked>
<RectRecentDocked>000000000A03000080070000F2030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -336,7 +336,7 @@
<Pane-34051>
<ID>34051</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>32768</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -350,7 +350,7 @@
<Pane-34052>
<ID>34052</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -373,20 +373,20 @@
<item>_I0</item>
</col-names>
<col-widths>
<item>609</item>
<item>608</item>
<item>40</item>
<item>1220</item>
<item>1221</item>
<item>20</item>
</col-widths>
<BuildLogLevel>2</BuildLogLevel>
<LiveFile>C:\Work\software\OpenBLT\Target\Demo\ARMCM4_TM4C_DK_TM4C123G_IAR\Boot\ide\BuildLog.log</LiveFile>
<LiveFile>$WS_DIR$\BuildLog.log</LiveFile>
<LiveLogEnabled>0</LiveLogEnabled>
<LiveFilterLevel>-1</LiveFilterLevel>
</IarPane-34052>
<Pane-34048>
<ID>34048</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -399,7 +399,7 @@
<Pane-34056>
<ID>34056</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -414,14 +414,14 @@
<ColumnWidth1>95</ColumnWidth1>
<ColumnWidth2>1144</ColumnWidth2>
<FilterLevel>2</FilterLevel>
<LiveFile></LiveFile>
<LiveFile />
<LiveLogEnabled>0</LiveLogEnabled>
<LiveFilterLevel>-1</LiveFilterLevel>
</IarPane-34056>
<Pane-34057>
<ID>34057</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -436,14 +436,14 @@
<ColumnWidth1>95</ColumnWidth1>
<ColumnWidth2>1144</ColumnWidth2>
<FilterLevel>2</FilterLevel>
<LiveFile></LiveFile>
<LiveFile />
<LiveLogEnabled>0</LiveLogEnabled>
<LiveFilterLevel>-1</LiveFilterLevel>
</IarPane-34057>
<Pane-34058>
<ID>34058</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -457,7 +457,7 @@
<Pane-34059>
<ID>34059</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -472,14 +472,14 @@
<ColumnWidth1>95</ColumnWidth1>
<ColumnWidth2>1144</ColumnWidth2>
<FilterLevel>2</FilterLevel>
<LiveFile></LiveFile>
<LiveFile />
<LiveLogEnabled>0</LiveLogEnabled>
<LiveFilterLevel>-1</LiveFilterLevel>
</IarPane-34059>
<Pane-34062>
<ID>34062</ID>
<RectRecentFloat>000000003500000022010000E6000000</RectRecentFloat>
<RectRecentDocked>04000000200300007C070000D6030000</RectRecentDocked>
<RectRecentDocked>04000000220300007C070000D8030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -491,7 +491,7 @@
</BasePane-34062>
<IarPane-34062>
<FilterLevel>2</FilterLevel>
<LiveFile></LiveFile>
<LiveFile />
<LiveLogEnabled>0</LiveLogEnabled>
<LiveFilterLevel>-1</LiveFilterLevel>
</IarPane-34062>
@ -513,16 +513,16 @@
<item>2</item>
</cg_type>
<cg_symbol>
<item></item>
<item />
</cg_symbol>
<cg_user>
<item></item>
<item />
</cg_user>
<cg_display>
<item>&lt;Right-click on a symbol in the editor to show a call graph&gt;</item>
</cg_display>
<cg_def_file>
<item></item>
<item />
</cg_def_file>
<cg_def_line>
<item>0</item>
@ -531,7 +531,7 @@
<item>0</item>
</cg_def_col>
<cg_call_file>
<item></item>
<item />
</cg_call_file>
<cg_call_line>
<item>0</item>
@ -651,7 +651,7 @@
<Pane-34063>
<ID>34063</ID>
<RectRecentFloat>00000000350000000601000096010000</RectRecentFloat>
<RectRecentDocked>00000000320000006601000004030000</RectRecentDocked>
<RectRecentDocked>00000000320000006601000006030000</RectRecentDocked>
<RecentFrameAlignment>4096</RecentFrameAlignment>
<RecentRowIndex>0</RecentRowIndex>
<IsFloating>0</IsFloating>
@ -662,11 +662,11 @@
<IsVisible>1</IsVisible>
</BasePane-34063>
<DockingManager-256>
<DockingPaneAndPaneDividers>000000000E000000000000000010000001000000FFFFFFFFFFFFFFFF66010000320000006A010000040300000100000002000010040000000100000091FFFFFF710600000F85000000000000000000000000000000000000010000000F850000010000000F850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000D85000000000000000000000000000000000000010000000D850000010000000D850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000C85000000000000000000000000000000000000010000000C850000010000000C850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000078500000000000000000000000000000000000001000000078500000100000007850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000068500000000000000000000000000000000000001000000068500000100000006850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000058500000000000000000000000000000000000001000000058500000100000005850000000000000080000001000000FFFFFFFFFFFFFFFF000000000403000080070000080300000100000001000010040000000100000087FDFFFFFA000000FFFFFFFF0800000003850000048500000085000008850000098500000A8500000B8500000E850000FFFF02000B004354616262656450616E650080000001000000000000003D0300008007000025040000000000000803000080070000F0030000000000004080005608000000FFFEFF0B42007200650061006B0070006F0069006E0074007300000000000385000001000000FFFFFFFFFFFFFFFFFFFEFF054200750069006C006400010000000485000001000000FFFFFFFFFFFFFFFFFFFEFF094400650062007500670020004C006F006700010000000085000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300000000000885000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000A85000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000B85000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000E85000001000000FFFFFFFFFFFFFFFF01000000000000000000000000000000000000000000000001000000FFFFFFFF0385000001000000FFFFFFFF03850000000000000000000000000000</DockingPaneAndPaneDividers>
<DockingPaneAndPaneDividers>000000000E000000000000000010000001000000FFFFFFFFFFFFFFFF66010000320000006A010000060300000100000002000010040000000100000091FFFFFF710600000F85000000000000000000000000000000000000010000000F850000010000000F850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000D85000000000000000000000000000000000000010000000D850000010000000D850000000000000080000000000000FFFFFFFFFFFFFFFF000000000000000004000000040000000000000001000000040000000100000000000000000000000C85000000000000000000000000000000000000010000000C850000010000000C850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000078500000000000000000000000000000000000001000000078500000100000007850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000068500000000000000000000000000000000000001000000068500000100000006850000000000000080000000000000FFFFFFFFFFFFFFFF00000000000000000400000004000000000000000100000004000000010000000000000000000000058500000000000000000000000000000000000001000000058500000100000005850000000000000080000001000000FFFFFFFFFFFFFFFF0000000006030000800700000A0300000100000001000010040000000100000087FDFFFFFA000000FFFFFFFF0800000003850000048500000085000008850000098500000A8500000B8500000E850000FFFF02000B004354616262656450616E650080000001000000000000003D0300008007000025040000000000000A03000080070000F2030000000000004080005608000000FFFEFF0B42007200650061006B0070006F0069006E0074007300000000000385000001000000FFFFFFFFFFFFFFFFFFFEFF054200750069006C006400010000000485000001000000FFFFFFFFFFFFFFFFFFFEFF094400650062007500670020004C006F006700010000000085000001000000FFFFFFFFFFFFFFFFFFFEFF0C4400650063006C00610072006100740069006F006E007300000000000885000001000000FFFFFFFFFFFFFFFFFFFEFF0A5200650066006500720065006E00630065007300000000000985000001000000FFFFFFFFFFFFFFFFFFFEFF0D460069006E006400200069006E002000460069006C0065007300000000000A85000001000000FFFFFFFFFFFFFFFFFFFEFF1541006D0062006900670075006F0075007300200044006500660069006E006900740069006F006E007300000000000B85000001000000FFFFFFFFFFFFFFFFFFFEFF0B54006F006F006C0020004F0075007400700075007400000000000E85000001000000FFFFFFFFFFFFFFFF01000000000000000000000000000000000000000000000001000000FFFFFFFF0385000001000000FFFFFFFF03850000000000000000000000000000</DockingPaneAndPaneDividers>
</DockingManager-256>
<MFCToolBar-34049>
<Name>CMSIS-Pack</Name>
<Buttons>00200000010000000100FFFF01001100434D4643546F6F6C426172427574746F6ED1840000020000000A000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF0A43004D005300490053002D005000610063006B0018000000</Buttons>
<Buttons>00200000010000000100FFFF01001100434D4643546F6F6C426172427574746F6ED18400000200000008000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF0A43004D005300490053002D005000610063006B0018000000</Buttons>
</MFCToolBar-34049>
<Pane-34049>
<ID>34049</ID>
@ -737,7 +737,7 @@
</IarPane-34064>
<MFCToolBar-34064>
<Name>Main</Name>
<Buttons>00200000010000002000FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000036000000FFFEFF000000000000000000000000000100000001000000018001E100000000000037000000FFFEFF000000000000000000000000000100000001000000018003E100000000000039000000FFFEFF000000000000000000000000000100000001000000018000810000000000001D000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E10000000000003C000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E10000000004003E000000FFFEFF000000000000000000000000000100000001000000018022E10000000004003D000000FFFEFF000000000000000000000000000100000001000000018025E100000000000040000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE100000000040043000000FFFEFF00000000000000000000000000010000000100000001802CE100000000040044000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01000D005061737465436F6D626F426F784281000000000000FFFFFFFFFFFEFF0001000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF0096000000000000000000018021810000000004002F000000FFFEFF000000000000000000000000000100000001000000018024E10000000000003F000000FFFEFF000000000000000000000000000100000001000000018028E100000000040041000000FFFEFF000000000000000000000000000100000001000000018029E100000000000042000000FFFEFF000000000000000000000000000100000001000000018002810000000000001E000000FFFEFF0000000000000000000000000001000000010000000180298100000000000033000000FFFEFF0000000000000000000000000001000000010000000180278100000000000031000000FFFEFF0000000000000000000000000001000000010000000180288100000000000032000000FFFEFF00000000000000000000000000010000000100000001801D810000000000002B000000FFFEFF00000000000000000000000000010000000100000001801E810000000004002C000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B8100000200040022000000FFFEFF00000000000000000000000000010000000100000001800C8100000200000023000000FFFEFF00000000000000000000000000010000000100000001805F8600000000000035000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800E8100000200000025000000FFFEFF00000000000000000000000000010000000100000001800F8100000200000026000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00E8020000</Buttons>
<Buttons>00200000010000002000FFFF01001100434D4643546F6F6C426172427574746F6E00E100000000000039000000FFFEFF000000000000000000000000000100000001000000018001E10000000000003A000000FFFEFF000000000000000000000000000100000001000000018003E10000000004003C000000FFFEFF0000000000000000000000000001000000010000000180008100000000000019000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018007E10000000004003F000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000018023E100000000000041000000FFFEFF000000000000000000000000000100000001000000018022E100000000040040000000FFFEFF000000000000000000000000000100000001000000018025E100000000000042000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001802BE100000000040043000000FFFEFF00000000000000000000000000010000000100000001802CE100000000040044000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF000000000000000000000000000100000001000000FFFF01000D005061737465436F6D626F426F784281000000000400FFFFFFFFFFFEFF0000000000000000000100000000000000010000007800000002002050FFFFFFFFFFFEFF0096000000000000000000018021810000000004002B000000FFFEFF000000000000000000000000000100000001000000018024E100000000040034000000FFFEFF000000000000000000000000000100000001000000018028E100000000040033000000FFFEFF000000000000000000000000000100000001000000018029E100000000040035000000FFFEFF000000000000000000000000000100000001000000018002810000000004001A000000FFFEFF000000000000000000000000000100000001000000018029810000000004002F000000FFFEFF000000000000000000000000000100000001000000018027810000000004002D000000FFFEFF000000000000000000000000000100000001000000018028810000000004002E000000FFFEFF00000000000000000000000000010000000100000001801D8100000000040027000000FFFEFF00000000000000000000000000010000000100000001801E8100000000040028000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800B810000020004001E000000FFFEFF00000000000000000000000000010000000100000001800C810000020000001F000000FFFEFF00000000000000000000000000010000000100000001805F8600000200040032000000FFFEFF00000000000000000000000000010000000100000001800000000001000000FFFFFFFFFFFEFF00000000000000000000000000010000000100000001800E8100000200000021000000FFFEFF00000000000000000000000000010000000100000001800F8100000200000022000000FFFEFF00000000000000000000000000010000000100000000000000FFFEFF044D00610069006E00E8020000</Buttons>
</MFCToolBar-34064>
<Pane-34064>
<ID>34064</ID>
@ -774,7 +774,7 @@
</ChildIdMap>
<MDIWindows>
<MDIClientArea-0>
<MDITabsState>010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000001000000020000000100000001000000FFFEFF122400570053005F0044004900520024005C002E002E005C006D00610069006E002E00630001000000FFFF010014004966436F6E74656E7453746F72616765496D706CFFFEFF00FFFEFFFF27013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E00330036003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0032003800330031003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0032003800330031003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF066D00610069006E002E00630000000000FFFFFFFFFFFFFFFFFFFEFF162400570053005F0044004900520024005C002E002E005C0062006C0074005F0063006F006E0066002E006800010000000180FFFEFF00FFFEFFFF28013C003F0078006D006C002000760065007200730069006F006E003D00220031002E0030002200200065006E0063006F00640069006E0067003D0022005500540046002D00380022003F003E000A003C0052006F006F0074003E000A0020002000200020003C004E0075006D0052006F00770073003E0031003C002F004E0075006D0052006F00770073003E000A0020002000200020003C004E0075006D0043006F006C0073003E0031003C002F004E0075006D0043006F006C0073003E000A0020002000200020003C00580050006F0073003E0030003C002F00580050006F0073003E000A0020002000200020003C00590050006F0073003E0030003C002F00590050006F0073003E000A0020002000200020003C00530065006C00530074006100720074003E0030003C002F00530065006C00530074006100720074003E000A0020002000200020003C00530065006C0045006E0064003E0030003C002F00530065006C0045006E0064003E000A0020002000200020003C00580050006F00730032003E0030003C002F00580050006F00730032003E000A0020002000200020003C00590050006F00730032003E003100330036003C002F00590050006F00730032003E000A0020002000200020003C00530065006C005300740061007200740032003E0038003200340038003C002F00530065006C005300740061007200740032003E000A0020002000200020003C00530065006C0045006E00640032003E0038003200340038003C002F00530065006C0045006E00640032003E000A003C002F0052006F006F0074003E000A00FFFEFF0A62006C0074005F0063006F006E0066002E00680000000000FFFFFFFFFFFFFFFF0000000010000000C5D4F200FFDC7800BECEA100F0A0A100BCA8E1009CC1B600F7B88600D9ADC200A5C2D700B3A6BE00EAD6A300F6FA7D00B5E99D005FC3CF00C1838300CACAD5000100000001000000020000006A010000670000008007000039030000</MDITabsState>
<MDITabsState>010000000300000001000000000000000000000001000000010000000200000000000000010000000100000000000000280000002800000000000000</MDITabsState>
</MDIClientArea-0>
</MDIWindows>
</WindowStorage>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<fileVersion>3</fileVersion>
<fileVersion>4</fileVersion>
<configuration>
<name>Debug</name>
<toolchain>
@ -11,7 +11,7 @@
<name>C-SPY</name>
<archiveVersion>2</archiveVersion>
<data>
<version>31</version>
<version>33</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -44,7 +44,7 @@
</option>
<option>
<name>MemFile</name>
<state>$TOOLKIT_DIR$\CONFIG\debugger\TexasInstruments\TM4C123GH6PGE.ddf</state>
<state>$TOOLKIT_DIR$\config\debugger\TexasInstruments\TM4C123GH6PGE.ddf</state>
</option>
<option>
<name>RunToEnable</name>
@ -88,7 +88,7 @@
</option>
<option>
<name>OCLastSavedByProductVersion</name>
<state>8.40.1.21529</state>
<state>9.40.2.67586</state>
</option>
<option>
<name>UseFlashLoader</name>
@ -112,7 +112,7 @@
</option>
<option>
<name>FlashLoadersV3</name>
<state>$TOOLKIT_DIR$\config\flashloader\TexasInstruments\FlashTC4_H6_o.board</state>
<state>$TOOLKIT_DIR$/config/flashloader/TexasInstruments/FlashTC4_H6_o.board</state>
</option>
<option>
<name>OCImagesSuppressCheck1</name>
@ -218,6 +218,42 @@
<name>OCMulticoreSessionFile</name>
<state></state>
</option>
<option>
<name>OCTpiuBaseOption</name>
<state>1</state>
</option>
<option>
<name>OCOverrideSlave</name>
<state>0</state>
</option>
<option>
<name>OCOverrideSlavePath</name>
<state></state>
</option>
<option>
<name>C_32_64Device</name>
<state>1</state>
</option>
<option>
<name>AuthEnable</name>
<state>0</state>
</option>
<option>
<name>AuthSdmSelection</name>
<state>1</state>
</option>
<option>
<name>AuthSdmManifest</name>
<state></state>
</option>
<option>
<name>AuthSdmExplicitLib</name>
<state></state>
</option>
<option>
<name>AuthEnforce</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
@ -453,6 +489,39 @@
</option>
</data>
</settings>
<settings>
<name>E2_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>0</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
<name>E2PowerFromProbe</name>
<state>1</state>
</option>
<option>
<name>CE2UsbSerialNo</name>
<state></state>
</option>
<option>
<name>CE2IdCodeEditB</name>
<state>0xFFFF'FFFF'FFFF'FFFF'FFFF'FFFF'FFFF'FFFF</state>
</option>
<option>
<name>CE2LogFileCheck</name>
<state>0</state>
</option>
<option>
<name>CE2LogFileEditB</name>
<state>$PROJ_DIR$\cspycomm.log</state>
</option>
<option>
<name>OCDriverInfo</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
<name>GDBSERVER_ID</name>
<archiveVersion>2</archiveVersion>
@ -494,7 +563,7 @@
<name>IJET_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>8</version>
<version>9</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -718,6 +787,58 @@
<name>CCIjetUsbSerialNoSelect</name>
<state>0</state>
</option>
<option>
<name>CatchV8ARReset</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREREL1NS</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREREL1S</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREREL2NS</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREREL3S</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREEL1NS</name>
<state>0</state>
</option>
<option>
<name>CatchV8ARREL1NS</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREEL1S</name>
<state>0</state>
</option>
<option>
<name>CatchV8ARREL1S</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREEL2NS</name>
<state>0</state>
</option>
<option>
<name>CatchV8ARREL2NS</name>
<state>0</state>
</option>
<option>
<name>CatchV8AREEL3S</name>
<state>0</state>
</option>
<option>
<name>CatchV8ARREL3S</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
@ -924,7 +1045,7 @@
<name>LMIFTDI_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>2</version>
<version>3</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -951,6 +1072,19 @@
<name>CCLmiFtdiInterfaceCmdLine</name>
<state>0</state>
</option>
<option>
<name>CCLmiftdiUsbSerialNo</name>
<state></state>
</option>
<option>
<name>CCLmiftdiUsbSerialNoSelect</name>
<state>0</state>
</option>
<option>
<name>CCLmiftdiResetList</name>
<version>0</version>
<state>0</state>
</option>
</data>
</settings>
<settings>
@ -1003,7 +1137,7 @@
<name>STLINK_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>6</version>
<version>8</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -1118,9 +1252,17 @@
</option>
<option>
<name>CCSTLinkProbeList</name>
<version>0</version>
<version>2</version>
<state>2</state>
</option>
<option>
<name>CCSTLinkTargetVccEnable</name>
<state>1</state>
</option>
<option>
<name>CCSTLinkTargetVoltage</name>
<state>###Uninitialized###</state>
</option>
</data>
</settings>
<settings>
@ -1223,7 +1365,7 @@
<name>XDS100_ID</name>
<archiveVersion>2</archiveVersion>
<data>
<version>8</version>
<version>9</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -1348,7 +1490,7 @@
</option>
<option>
<name>CCXds100ResetList</name>
<version>0</version>
<version>1</version>
<state>0</state>
</option>
<option>
@ -1397,6 +1539,10 @@
<name>OCXDSDigitalStatesConfigFile</name>
<state>1</state>
</option>
<option>
<name>OCSelectedCoreName</name>
<state>1</state>
</option>
</data>
</settings>
<debuggerPlugins>
@ -1416,10 +1562,6 @@
<file>$TOOLKIT_DIR$\plugins\rtos\FreeRtos\FreeRtosArmPlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\HWRTOSplugin\HWRTOSplugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\Mbed\MbedArmPlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
@ -1432,30 +1574,18 @@
<file>$TOOLKIT_DIR$\plugins\rtos\OpenRTOS\OpenRTOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\RemedyRtosViewer\RemedyRtosViewer.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\SafeRTOS\SafeRTOSPlugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm8BE.ewplugin</file>
<file>$TOOLKIT_DIR$\plugins\rtos\SMX\smxAwareIarArm9a.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\ThreadX\ThreadXArmPlugin.ENU.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\TI-RTOS\tirtosplugin.ewplugin</file>
<loadFlag>0</loadFlag>
</plugin>
<plugin>
<file>$TOOLKIT_DIR$\plugins\rtos\uCOS-II\uCOS-II-286-KA-CSpy.ewplugin</file>
<loadFlag>0</loadFlag>

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project>
<fileVersion>3</fileVersion>
<fileVersion>4</fileVersion>
<configuration>
<name>Debug</name>
<toolchain>
@ -11,7 +11,7 @@
<name>General</name>
<archiveVersion>3</archiveVersion>
<data>
<version>33</version>
<version>36</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -70,7 +70,7 @@
</option>
<option>
<name>OGLastSavedByProductVersion</name>
<state>9.10.2.39304</state>
<state>9.40.2.67586</state>
</option>
<option>
<name>OGChipSelectEditMenu</name>
@ -98,7 +98,7 @@
</option>
<option>
<name>GBECoreSlave</name>
<version>30</version>
<version>33</version>
<state>39</state>
</option>
<option>
@ -115,7 +115,7 @@
</option>
<option>
<name>CoreVariant</name>
<version>30</version>
<version>33</version>
<state>39</state>
</option>
<option>
@ -138,7 +138,7 @@
</option>
<option>
<name>GFPUCoreSlave2</name>
<version>30</version>
<version>33</version>
<state>39</state>
</option>
<option>
@ -199,13 +199,30 @@
<name>OG_32_64Device</name>
<state>0</state>
</option>
<option>
<name>BuildFilesPath</name>
<state>Debug</state>
</option>
<option>
<name>PointerAuthentication</name>
<state>0</state>
</option>
<option>
<name>FPU64</name>
<state>1</state>
</option>
<option>
<name>OG_32_64DeviceCoreSlave</name>
<version>33</version>
<state>39</state>
</option>
</data>
</settings>
<settings>
<name>ICCARM</name>
<archiveVersion>2</archiveVersion>
<data>
<version>37</version>
<version>38</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -468,13 +485,21 @@
<name>CCStackProtection</name>
<state>0</state>
</option>
<option>
<name>CCPointerAutentiction</name>
<state>0</state>
</option>
<option>
<name>CCBranchTargetIdentification</name>
<state>0</state>
</option>
</data>
</settings>
<settings>
<name>AARM</name>
<archiveVersion>2</archiveVersion>
<data>
<version>11</version>
<version>12</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -636,6 +661,10 @@
<name>PreInclude</name>
<state></state>
</option>
<option>
<name>A_32_64Device</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
@ -678,19 +707,11 @@
<buildSequence>inputOutputBased</buildSequence>
</data>
</settings>
<settings>
<name>BUILDACTION</name>
<archiveVersion>1</archiveVersion>
<data>
<prebuild></prebuild>
<postbuild></postbuild>
</data>
</settings>
<settings>
<name>ILINK</name>
<archiveVersion>0</archiveVersion>
<data>
<version>25</version>
<version>27</version>
<wantNonLocal>1</wantNonLocal>
<debug>1</debug>
<option>
@ -1042,6 +1063,22 @@
<name>IlinkDemangle</name>
<state>0</state>
</option>
<option>
<name>IlinkWrapperFileEnable</name>
<state>0</state>
</option>
<option>
<name>IlinkWrapperFile</name>
<state></state>
</option>
<option>
<name>IlinkProcessor</name>
<state>1</state>
</option>
<option>
<name>IlinkFpuProcessor</name>
<state>1</state>
</option>
</data>
</settings>
<settings>
@ -1065,6 +1102,11 @@
</option>
</data>
</settings>
<settings>
<name>BUILDACTION</name>
<archiveVersion>2</archiveVersion>
<data />
</settings>
</configuration>
<group>
<name>Boot</name>
@ -1532,6 +1574,9 @@
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C\flash.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C\mbrtu.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\ARMCM4_TM4C\nvm.c</name>
</file>
@ -1608,6 +1653,12 @@
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\file.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\mb.c</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\mb.h</name>
</file>
<file>
<name>$PROJ_DIR$\..\..\..\..\Source\nvm.h</name>
</file>

View File

@ -0,0 +1,504 @@
/************************************************************************************//**
* \file Source/ARMCM4_TM4C/mbrtu.c
* \brief Bootloader Modbus RTU communication interface source file.
* \ingroup Target_ARMCM4_TM4C
* \internal
*----------------------------------------------------------------------------------------
* C O P Y R I G H T
*----------------------------------------------------------------------------------------
* Copyright (c) 2023 by Feaser http://www.feaser.com All rights reserved
*
*----------------------------------------------------------------------------------------
* L I C E N S E
*----------------------------------------------------------------------------------------
* This file is part of OpenBLT. OpenBLT is free software: you can redistribute it and/or
* modify it under the terms of the GNU General Public License as published by the Free
* Software Foundation, either version 3 of the License, or (at your option) any later
* version.
*
* OpenBLT is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
* without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
* PURPOSE. See the GNU General Public License for more details.
*
* You have received a copy of the GNU General Public License along with OpenBLT. It
* should be located in ".\Doc\license.html". If not, contact Feaser to obtain a copy.
*
* \endinternal
****************************************************************************************/
/****************************************************************************************
* Include files
****************************************************************************************/
#include "boot.h" /* bootloader generic header */
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_memmap.h"
#include "inc/hw_types.h"
#include "inc/hw_nvic.h"
#include "inc/hw_uart.h"
#if (BOOT_COM_MBRTU_ENABLE > 0)
#include "driverlib/sysctl.h"
#include "driverlib/uartlib.h"
/****************************************************************************************
* Macro definitions
****************************************************************************************/
/** \brief Timeout for transmitting a byte in milliseconds. */
#define MBRTU_BYTE_TX_TIMEOUT_MS (10u)
/****************************************************************************************
* Local data declarations
****************************************************************************************/
/** \brief Stores the number of free running counter ticks that represents the 3.5
* character delay time (T3_5) for Modbus RTU.
*/
static blt_int16u mbRtuT3_5Ticks;
/****************************************************************************************
* Function prototypes
****************************************************************************************/
static blt_bool MbRtuReceiveByte(blt_int8u *data);
static void MbRtuTransmitByte(blt_int8u data, blt_bool end_of_packet);
/************************************************************************************//**
** \brief Initializes the Modbus RTU communication interface.
** \attention It is the application's responsibility to initialize a timer peripheral
** to have an upwards counting free running counter, which runs at 100 kHz.
** \return none.
**
****************************************************************************************/
void MbRtuInit(void)
{
blt_int16u startTimeTicks;
blt_int16u deltaTimeTicks;
blt_int16u currentTimeTicks;
blt_int8u rxDummy;
blt_int32u uartConfig;
/* the current implementation supports UART0. throw an assertion error in case a
* different UART channel is configured.
*/
ASSERT_CT(BOOT_COM_MBRTU_CHANNEL_INDEX == 0);
/* calculate the 3.5 character delay time in free running counter ticks. note that
* the free running counter runs at 100 kHz, so one tick is 10 us. For baudrates >
* 19200 bps, it can be fixed to 1750 us.
*/
if (BOOT_COM_MBRTU_BAUDRATE > 19200)
{
/* set T3_5 time to a fixed value of 1750 us. */
mbRtuT3_5Ticks = 175;
}
/* calculate the T3_5 time, because the baudrate is <= 19200 bps. */
else
{
/* T3_5 [us * 10] = 3.5 * Tchar = 3.5 * 11 * 100000 / baudrate = 3850000 / baudrate.
* make sure to do integer round up though. Make sure to add 1 to adjust for 10us
* timer resolution inaccuracy.
*/
mbRtuT3_5Ticks = (blt_int16u)(((3850000UL + (BOOT_COM_MBRTU_BAUDRATE - 1U)) /
BOOT_COM_MBRTU_BAUDRATE) + 1);
}
/* enable the UART0 peripheral */
SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0);
/* configure the number of databits. this also default to no parity and 1 stopbit */
uartConfig = UART_CONFIG_WLEN_8;
/* configure the parity */
#if (BOOT_COM_MBRTU_PARITY == 1)
uartConfig |= UART_CONFIG_PAR_ODD;
#elif (BOOT_COM_MBRTU_PARITY == 2)
uartConfig |= UART_CONFIG_PAR_EVEN;
#endif
/* configure the stop bits */
#if (BOOT_COM_MBRTU_STOPBITS == 2)
uartConfig |= UART_CONFIG_STOP_TWO;
#endif
/* configure the UART0 baudrate and communication parameters */
UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), BOOT_COM_MBRTU_BAUDRATE, uartConfig);
/* enable the receiver output to be able to receive. */
MbRtuDriverOutputControlHook(BLT_FALSE);
/* wait for idle line detection. This is T3_5 time after reception of the last byte. */
startTimeTicks = MbRtuFreeRunningCounterGet();
do
{
/* service the watchdog. */
CopService();
/* get the current value of the free running counter. */
currentTimeTicks = MbRtuFreeRunningCounterGet();
/* check if a byte was received while waiting for the idle line. */
if (MbRtuReceiveByte(&rxDummy) == BLT_TRUE)
{
/* restart the idle line detection. */
startTimeTicks = currentTimeTicks;
}
/* calculate the number of ticks that elapsed since the start or since the last
* byte reception. Note that this calculation works, even if the free running counter
* overflowed.
*/
deltaTimeTicks = currentTimeTicks - startTimeTicks;
}
while (deltaTimeTicks < mbRtuT3_5Ticks);
} /*** end of MbRtuInit ***/
/************************************************************************************//**
** \brief Transmits a packet formatted for the communication interface.
** \param data Pointer to byte array with data that it to be transmitted.
** \param len Number of bytes that are to be transmitted.
** \return none.
**
****************************************************************************************/
void MbRtuTransmitPacket(blt_int8u *data, blt_int8u len)
{
blt_int16u data_index;
blt_int16u checksum;
blt_bool endOfPacket = BLT_FALSE;
/* Made static to lower stack load and +5 for Modbus RTU packet overhead. */
static blt_int8u txPacket[BOOT_COM_MBRTU_TX_MAX_DATA + 5];
/* On Modbus RTU, there must always be a T3_5 time separation between packet trans-
* missions.
*
* This bootloader uses XCP packets embedded in Modbus RTU packets. The XCP
* communication is always request / response based. That means that this packet is
* a response packet and it will only be sent, after the reception of a request packet.
*
* A response packet is only deemed valid, after the T3_5 idle time. This module
* implements the T3_5 end-of-packet time event detection. Consequently, it is already
* guaranteed that there is T3_5 between subsequent packet transmissions. As such, no
* further T3_5 wait time is needed here.
*/
/* verify validity of the len-parameter */
ASSERT_RT(len <= BOOT_COM_MBRTU_TX_MAX_DATA);
/* construct the Modbus RTU packet. start by adding the slave address. */
txPacket[0] = BOOT_COM_MBRTU_NODE_ID;
/* add the user-defined function code for embedding XCP packets. */
txPacket[1] = BOOT_COM_MBRTU_FCT_CODE_USER_XCP;
/* add the XCP packet length. */
txPacket[2] = len;
/* copy the XCP packet data. */
CpuMemCopy((blt_int32u)&txPacket[3], (blt_int32u)data, len);
/* calculate the checksum for the packet, including slave address, function code and
* extra XCP length.
*/
checksum = MbRtuCrcCalculate(&txPacket[0], len + 3);
/* add the checksum at the end of the packet */
txPacket[len + 3] = (blt_int8u)(checksum & 0xff);
txPacket[len + 4] = (blt_int8u)(checksum >> 8);
/* enable the driver output to be able to send. just make sure to wait a little around
* the togglng of the DE/NRE pin.
*/
MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_ENABLE_DELAY_US);
MbRtuDriverOutputControlHook(BLT_TRUE);
MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_ENABLE_DELAY_US);
/* transmit all the packet bytes one-by-one */
for (data_index = 0; data_index < (len + 5); data_index++)
{
/* keep the watchdog happy */
CopService();
/* last byte of the packet? */
if (data_index == ((len + 5) - 1))
{
/* update the end of packet flag. */
endOfPacket = BLT_TRUE;
}
/* write byte */
MbRtuTransmitByte(txPacket[data_index], endOfPacket);
}
/* enable the receiver output to be able to receive again. just make sure to wait a
* little around the togglng of the DE/NRE pin.
*/
MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_DISABLE_DELAY_US);
MbRtuDriverOutputControlHook(BLT_FALSE);
MbRtuDelay(BOOT_COM_MBRTU_DRIVER_OUTPUT_DISABLE_DELAY_US);
} /*** end of MbRtuTransmitPacket ***/
/************************************************************************************//**
** \brief Receives a communication interface packet if one is present.
** \param data Pointer to byte array where the data is to be stored.
** \param len Pointer where the length of the packet is to be stored.
** \return BLT_TRUE if a packet was received, BLT_FALSE otherwise.
**
****************************************************************************************/
blt_bool MbRtuReceivePacket(blt_int8u *data, blt_int8u *len)
{
blt_bool result = BLT_FALSE;
blt_int8u rxByte;
blt_int16u currentTimeTicks;
blt_int16u deltaTimeTicks;
blt_int16u checksumCalculated;
blt_int16u checksumReceived;
/* Made static to lower stack load and +5 for Modbus RTU packet overhead. */
static blt_int8u rxPacket[BOOT_COM_MBRTU_RX_MAX_DATA + 5];
static blt_int8u rxLength = 0;
static blt_bool packetRxInProgress = BLT_FALSE;
static blt_int16u lastRxByteTimeTicks = 0;
/* get the current value of the free running counter. */
currentTimeTicks = MbRtuFreeRunningCounterGet();
/* check for a newly received byte. */
if (MbRtuReceiveByte(&rxByte) == BLT_TRUE)
{
/* store the time at which the byte was received. */
lastRxByteTimeTicks = currentTimeTicks;
/* is this the potential start of a new packet? */
if (packetRxInProgress == BLT_FALSE)
{
/* initialize the reception of a new packet. */
rxLength = 0;
packetRxInProgress = BLT_TRUE;
}
/* store the newly received byte in the buffer, with buffer overrun protection. */
if (rxLength < (sizeof(rxPacket)/sizeof(rxPacket[0])))
{
rxPacket[rxLength] = rxByte;
rxLength++;
}
/* buffer overrun occurred. received packet was longer than supported so discard
* the packet to try and sync to the next one.
*/
else
{
/* discard the partially received packet. */
packetRxInProgress = BLT_FALSE;
}
}
/* only attempt to detect the end of packet, when a reception is in progress. */
if (packetRxInProgress == BLT_TRUE)
{
/* calculate the number of ticks that elapsed since the last byte reception. note
* that this calculation works, even if the free running counter overflowed.
*/
deltaTimeTicks = currentTimeTicks - lastRxByteTimeTicks;
/* packet reception is assumed complete after T3_5 of not receiving new data. */
if (deltaTimeTicks >= mbRtuT3_5Ticks)
{
/* a Modbus RTU packet consists of at least the address field, function code and
* 16-bit CRC. Validate the packet length based on this info.
*/
if (rxLength >= 4)
{
/* calculate the packet checksum. */
checksumCalculated = MbRtuCrcCalculate(&rxPacket[0], rxLength - 2);
/* extract the checksum received with the packet. */
checksumReceived = rxPacket[rxLength - 2] | (rxPacket[rxLength - 1] << 8);
/* only continue with packet processing if the checksums match. */
if (checksumCalculated == checksumReceived)
{
/* we are only interested in Modbus RTU packets that are addressed to us and
* have an XCP packet embedded.
*/
if ( (rxPacket[0] == BOOT_COM_MBRTU_NODE_ID) &&
(rxPacket[1] == BOOT_COM_MBRTU_FCT_CODE_USER_XCP) )
{
/* An XCP packet embedded in a Modbus RTU packet has an extra XCP packet
* length value. Use it to double-check that the packet length is valid.
*/
if (rxPacket[2] == (rxLength - 5))
{
/* copy the packet's XCP data. */
CpuMemCopy((blt_int32u)data, (blt_int32u)&rxPacket[3], rxLength - 5);
/* set the packet's XCP length. */
*len = rxLength - 5;
/* update the result to success to indicate that this XCP packet is ready
* for processing.
*/
result = BLT_TRUE;
}
}
}
}
/* reset the packet reception in progress flag, to be able to receive the next. */
packetRxInProgress = BLT_FALSE;
}
}
/* give the result back to the caller. */
return result;
} /*** end of MbRtuReceivePacket ***/
/************************************************************************************//**
** \brief Receives a communication interface byte if one is present.
** \param data Pointer to byte where the data is to be stored.
** \return BLT_TRUE if a byte was received, BLT_FALSE otherwise.
**
****************************************************************************************/
static blt_bool MbRtuReceiveByte(blt_int8u *data)
{
blt_bool result = BLT_FALSE;
blt_int32u data_and_status;
/* check if a new byte was received by means of the RXFE-bit. */
if (UARTCharsAvail(UART0_BASE) == true)
{
/* update the result */
result = BLT_TRUE;
/* read out the newly received data, including its reception status flags. */
data_and_status = HWREG(UART0_BASE + UART_O_DR);
/* check for a frame error. the frame error check is important because it can detect
* a missing stopbit. on an RS485 bus without bias resistors, the A-B differential
* voltage is 0. for an RS485 transceiver this is neither a 0 nor a 1 bit, so
* undefined. most RS485 transceivers feature a reception failsafe function to drive
* the Rx output (going to the UART Rx) to a defined state of logic 1. in case the
* used RS485 transceiver doesn't have such a feature, it typically leaves the Rx
* output in a logic 0 state. this means that after the stop bit of the last packet
* byte, the UART Rx input sees a logic 0, and assumes it is a start bit. the
* remaining data bits will always be 0 and, most importantly no stop bit is
* present, causing a framing error. Long story short: if you don't check for the
* framing error flag, you might receive an extra byte with value 0, which is not
* actually transmitted on the RS485 bus. you can catch and ignore this byte by doing
* a frame error check.
*/
if ((data_and_status & UART_DR_FE) != 0U)
{
/* ignore the byte because of a detected frame error. */
result = BLT_FALSE;
}
#if (BOOT_COM_MBRTU_PARITY > 0)
/* check for a parity error. */
if ((data_and_status & UART_DR_PE) != 0U)
{
/* ignore the byte because of a detected parity error. */
result = BLT_FALSE;
}
#endif
/* store the newly received byte by casting it to exclude the status flags. */
*data = (blt_int8u)data_and_status;
}
/* give the result back to the caller */
return result;
} /*** end of MbRtuReceiveByte ***/
/************************************************************************************//**
** \brief Transmits a communication interface byte.
** \param data Value of byte that is to be transmitted.
** \param end_of_packet BLT_TRUE if this is the last byte of the packet, BLT_FALSE
** otherwise.
** \return none.
**
****************************************************************************************/
static void MbRtuTransmitByte(blt_int8u data, blt_bool end_of_packet)
{
blt_int32u timeout;
/* write byte to transmit holding register */
UARTCharPutNonBlocking(UART0_BASE, data);
/* set timeout time to wait for transmit completion. */
timeout = TimerGet() + MBRTU_BYTE_TX_TIMEOUT_MS;
/* not the last byte of the packet? */
if (end_of_packet == BLT_FALSE)
{
/* wait for tx holding register to be empty */
while (UARTSpaceAvail(UART0_BASE) == false)
{
/* keep the watchdog happy. */
CopService();
/* break loop upon timeout. this would indicate a hardware failure. */
if (TimerGet() > timeout)
{
break;
}
}
}
/* this is the last byte of a packet. */
else
{
/* wait for busy flag to be reset. this indicated that the last byte has completely
* left the shift register, including its stop bit. this is needed for the last byte,
* otherwise the transceiver's transmit output gets disabled with
* MbRtuDriverOutputControlHook() before the byte reception completes.
*/
while (UARTBusy(UART0_BASE) == true)
{
/* keep the watchdog happy. */
CopService();
/* break loop upon timeout. this would indicate a hardware failure. */
if (TimerGet() > timeout)
{
break;
}
}
}
} /*** end of MbRtuTransmitByte ***/
/************************************************************************************//**
** \brief Obtains the counter value of the 100 kHz free running counter. Note that
** each count represent 10 us. The Modbus RTU communication module uses this
** free running counter for Modbus RTU packet timing related purposes. The
** already available 1 ms timer does not have the needed resolution for this
** purpose.
** \return Current value of the free running counter.
**
****************************************************************************************/
blt_int16u MbRtuFreeRunningCounterGet(void)
{
static blt_bool initialized = BLT_FALSE;
static blt_int32u counts_per_ten_us = 0;
static blt_int32u free_running_counter_last = 0;
static blt_int16u ten_us_tick_counter = 0;
blt_int32u free_running_counter_now;
blt_int32u delta_counts;
blt_int32u ten_us_ticks;
/* perform one-time initialization.*/
if (initialized == BLT_FALSE)
{
/* set the flag to make sure that this part only runs once. */
initialized = BLT_TRUE;
/* calculate how many counts of the SysTick's free running counter equals 10us,
* because one count of a 100 kHz counter equals that. Note that the timer module
* already initialized and enable the SysTick.
*/
counts_per_ten_us = SysCtlClockGet() / 100000UL;
/* initialize current value of the timer's free running counter. */
free_running_counter_last = (HWREG(NVIC_ST_CURRENT) & NVIC_ST_CURRENT_M);
}
/* get the current value of the free running counter. */
free_running_counter_now = (HWREG(NVIC_ST_CURRENT) & NVIC_ST_CURRENT_M);
/* calculate the number of counts that passed since the detection of the last
* millisecond event. keep in mind that the SysTick has a down-counting 24-bit free
* running counter. note that this calculation also works, in case the free running
* counter overflowed, thanks to integer math.
*/
delta_counts = free_running_counter_last - free_running_counter_now;
delta_counts &= NVIC_ST_CURRENT_M;
/* did one or more ten microsecond counts pass since the last event? */
if (delta_counts >= counts_per_ten_us)
{
/* calculate how many ten microsecond counts passed. */
ten_us_ticks = delta_counts / counts_per_ten_us;
/* update the counter. */
ten_us_tick_counter += ten_us_ticks;
/* store the counter value of the last event to detect the next one. */
free_running_counter_last -= (ten_us_ticks * counts_per_ten_us);
free_running_counter_last &= NVIC_ST_CURRENT_M;
}
/* return the current value of the 100 kHz free running counter to the caller. */
return ten_us_tick_counter;
} /*** end of MbRtuFreeRunningCounterGet ***/
#endif /* BOOT_COM_MBRTU_ENABLE > 0 */
/*********************************** end of mbrtu.c ************************************/

View File

@ -37,10 +37,8 @@
#if (BOOT_COM_RS232_ENABLE > 0)
#include "driverlib/sysctl.h"
#include "driverlib/uartlib.h"
#endif
#if (BOOT_COM_RS232_ENABLE > 0)
/****************************************************************************************
* Macro definitions
****************************************************************************************/

View File

@ -30,29 +30,11 @@
* Include files
****************************************************************************************/
#include "boot.h" /* bootloader generic header */
/****************************************************************************************
* Type definitions
****************************************************************************************/
/** \brief Systick registers. */
typedef struct
{
volatile blt_int32u CTRL; /**< SysTick Control and Status Register */
volatile blt_int32u LOAD; /**< SysTick Reload Value Register */
volatile blt_int32u VAL; /**< SysTick Current Value Register */
} tSysTickRegs;
/****************************************************************************************
* Macro definitions
****************************************************************************************/
/** \brief CLKSOURCE bit of the system tick. */
#define SYSTICK_BIT_CLKSOURCE ((blt_int32u)0x00000004)
/** \brief ENABLE bit of the system tick. */
#define SYSTICK_BIT_ENABLE ((blt_int32u)0x00000001)
/** \brief COUNTERFLAG bit of the system tick. */
#define SYSTICK_BIT_COUNTERFLAG ((blt_int32u)0x00010000)
#include <stdbool.h>
#include <stdint.h>
#include "inc/hw_types.h"
#include "inc/hw_nvic.h"
#include "driverlib/sysctl.h"
/****************************************************************************************
@ -63,12 +45,13 @@ typedef struct
*/
static blt_int32u millisecond_counter;
/** \brief Buffer for storing the last value of the free running counter. */
static blt_int32u free_running_counter_last;
/****************************************************************************************
* Register definitions
****************************************************************************************/
/** \brief Macro to access the system tick registers. */
#define SYSTICK ((tSysTickRegs *) (blt_int32u)0xE000E010)
/** \brief Stores the number of counts of the free running counter that equals one
* millisecond.
*/
static blt_int32u counts_per_millisecond;
/************************************************************************************//**
@ -78,16 +61,19 @@ static blt_int32u millisecond_counter;
****************************************************************************************/
void TimerInit(void)
{
/* reset the timer configuration */
/* reset the timer configuration. */
TimerReset();
/* configure the systick frequency as a 1 ms event generator */
SYSTICK->LOAD = BOOT_CPU_SYSTEM_SPEED_KHZ - 1;
/* reset the current counter value */
SYSTICK->VAL = 0;
/* select core clock as source and enable the timer */
SYSTICK->CTRL = SYSTICK_BIT_CLKSOURCE | SYSTICK_BIT_ENABLE;
/* reset the millisecond counter value */
/* configure the reload value such that the full 24-bit range is used. */
HWREG(NVIC_ST_RELOAD) = (0xFFFFFFFFUL & NVIC_ST_RELOAD_M);
/* reset the current counter value. */
HWREG(NVIC_ST_CURRENT) = 0UL;
/* select core clock as source and enable the timer. */
HWREG(NVIC_ST_CTRL) = NVIC_ST_CTRL_ENABLE | NVIC_ST_CTRL_CLK_SRC;
/* calculate how many counts equal 1 millisecond. */
counts_per_millisecond = SysCtlClockGet() / 1000UL;
/* initialize remaining locals. */
millisecond_counter = 0;
free_running_counter_last = (HWREG(NVIC_ST_CURRENT) & NVIC_ST_CURRENT_M);
} /*** end of TimerInit ***/
@ -100,10 +86,10 @@ void TimerInit(void)
void TimerReset(void)
{
/* set the systick's registers back into the default reset value */
SYSTICK->CTRL = 0;
SYSTICK->LOAD = 0;
SYSTICK->VAL = 0;
} /* end of TimerReset */
HWREG(NVIC_ST_CTRL) = 0UL;
HWREG(NVIC_ST_RELOAD) = 0UL;
HWREG(NVIC_ST_CURRENT) = 0UL;
} /*** end of TimerReset ***/
/************************************************************************************//**
@ -113,11 +99,30 @@ void TimerReset(void)
****************************************************************************************/
void TimerUpdate(void)
{
/* check if the millisecond event occurred */
if ((SYSTICK->CTRL & SYSTICK_BIT_COUNTERFLAG) != 0)
blt_int32u free_running_counter_now;
blt_int32u delta_counts;
blt_int32u ms_counts;
/* get the current value of the free running counter. */
free_running_counter_now = (HWREG(NVIC_ST_CURRENT) & NVIC_ST_CURRENT_M);
/* calculate the number of counts that passed since the detection of the last
* millisecond event. keep in mind that the SysTick has a down-counting 24-bit free
* running counter. note that this calculation also works, in case the free running
* counter overflowed, thanks to integer math.
*/
delta_counts = free_running_counter_last - free_running_counter_now;
delta_counts &= NVIC_ST_CURRENT_M;
/* did one or more milliseconds pass since the last event? */
if (delta_counts >= counts_per_millisecond)
{
/* increment the millisecond counter */
millisecond_counter++;
/* calculate how many milliseconds passed. */
ms_counts = delta_counts / counts_per_millisecond;
/* update the millisecond counter. */
millisecond_counter += ms_counts;
/* store the counter value of the last millisecond event, to detect the next one. */
free_running_counter_last -= (ms_counts * counts_per_millisecond);
free_running_counter_last &= NVIC_ST_CURRENT_M;
}
} /*** end of TimerUpdate ***/