156 lines
16 KiB
HTML
156 lines
16 KiB
HTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
<head>
|
|
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
|
|
<meta http-equiv="X-UA-Compatible" content="IE=9"/>
|
|
<meta name="generator" content="Doxygen 1.8.11"/>
|
|
<title>Kinetis Bootloader: FlexCAN driver</title>
|
|
<link href="tabs.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="jquery.js"></script>
|
|
<script type="text/javascript" src="dynsections.js"></script>
|
|
<link href="navtree.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="resize.js"></script>
|
|
<script type="text/javascript" src="navtreedata.js"></script>
|
|
<script type="text/javascript" src="navtree.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(initResizable);
|
|
$(window).load(resizeHeight);
|
|
</script>
|
|
<link href="search/search.css" rel="stylesheet" type="text/css"/>
|
|
<script type="text/javascript" src="search/searchdata.js"></script>
|
|
<script type="text/javascript" src="search/search.js"></script>
|
|
<script type="text/javascript">
|
|
$(document).ready(function() { init_search(); });
|
|
</script>
|
|
<link href="doxygen.css" rel="stylesheet" type="text/css" />
|
|
</head>
|
|
<body>
|
|
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
|
<div id="titlearea">
|
|
<table cellspacing="0" cellpadding="0">
|
|
<tbody>
|
|
<tr style="height: 56px;">
|
|
<td id="projectlogo"><img alt="Logo" src="nxp_logo_small.png"/></td>
|
|
<td id="projectalign" style="padding-left: 0.5em;">
|
|
<div id="projectname">Kinetis Bootloader
|
|
 <span id="projectnumber">2.0.0</span>
|
|
</div>
|
|
<div id="projectbrief">Common bootloader for Kinetis devices</div>
|
|
</td>
|
|
</tr>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
<!-- end header part -->
|
|
<!-- Generated by Doxygen 1.8.11 -->
|
|
<script type="text/javascript">
|
|
var searchBox = new SearchBox("searchBox", "search",false,'Search');
|
|
</script>
|
|
<div id="navrow1" class="tabs">
|
|
<ul class="tablist">
|
|
<li><a href="index.html"><span>Introduction</span></a></li>
|
|
<li><a href="pages.html"><span>Related Pages</span></a></li>
|
|
<li class="current"><a href="modules.html"><span>Modules</span></a></li>
|
|
<li>
|
|
<div id="MSearchBox" class="MSearchBoxInactive">
|
|
<span class="left">
|
|
<img id="MSearchSelect" src="search/mag_sel.png"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
alt=""/>
|
|
<input type="text" id="MSearchField" value="Search" accesskey="S"
|
|
onfocus="searchBox.OnSearchFieldFocus(true)"
|
|
onblur="searchBox.OnSearchFieldFocus(false)"
|
|
onkeyup="searchBox.OnSearchFieldChange(event)"/>
|
|
</span><span class="right">
|
|
<a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
|
|
</span>
|
|
</div>
|
|
</li>
|
|
</ul>
|
|
</div>
|
|
</div><!-- top -->
|
|
<div id="side-nav" class="ui-resizable side-nav-resizable">
|
|
<div id="nav-tree">
|
|
<div id="nav-tree-contents">
|
|
<div id="nav-sync" class="sync"></div>
|
|
</div>
|
|
</div>
|
|
<div id="splitbar" style="-moz-user-select:none;"
|
|
class="ui-resizable-handle">
|
|
</div>
|
|
</div>
|
|
<script type="text/javascript">
|
|
$(document).ready(function(){initNavTree('group__flexcan__driver.html','');});
|
|
</script>
|
|
<div id="doc-content">
|
|
<!-- window showing the filter options -->
|
|
<div id="MSearchSelectWindow"
|
|
onmouseover="return searchBox.OnSearchSelectShow()"
|
|
onmouseout="return searchBox.OnSearchSelectHide()"
|
|
onkeydown="return searchBox.OnSearchSelectKey(event)">
|
|
</div>
|
|
|
|
<!-- iframe showing the search results (closed by default) -->
|
|
<div id="MSearchResultsWindow">
|
|
<iframe src="javascript:void(0)" frameborder="0"
|
|
name="MSearchResults" id="MSearchResults">
|
|
</iframe>
|
|
</div>
|
|
|
|
<div class="header">
|
|
<div class="headertitle">
|
|
<div class="title">FlexCAN driver<div class="ingroups"><a class="el" href="group__flexcan.html">Flex Controller Area Network (FlexCAN)</a></div></div> </div>
|
|
</div><!--header-->
|
|
<div class="contents">
|
|
<div id="dynsection-0" onclick="return toggleVisibility(this)" class="dynheader closed" style="cursor:pointer;">
|
|
<img id="dynsection-0-trigger" src="closed.png" alt="+"/> Collaboration diagram for FlexCAN driver:</div>
|
|
<div id="dynsection-0-summary" class="dynsummary" style="display:block;">
|
|
</div>
|
|
<div id="dynsection-0-content" class="dyncontent" style="display:none;">
|
|
<center><table><tr><td><div class="center"><iframe scrolling="no" frameborder="0" src="group__flexcan__driver.svg" width="304" height="52"><p><b>This browser is not able to show SVG: try Firefox, Chrome, Safari, or Opera instead.</b></p></iframe>
|
|
</div>
|
|
</td></tr></table></center>
|
|
</div>
|
|
<p>This section describes the programming interface of the FlexCAN driver. The FlexCAN driver configures FlexCAN module, provides a functional and transactional interfaces to build the FlexCAN application.</p>
|
|
<h1><a class="anchor" id="FlexCANFunGrps"></a>
|
|
Function groups</h1>
|
|
<h2><a class="anchor" id="FLEXCANInitReset"></a>
|
|
FLEXCAN Initialization and De-initialization</h2>
|
|
<p>This function group initializes a default configuration structure for the FlexCAN module, initializes the FlexCAN module with a given configuration, resets, and de-initializes the FlexCAN module.</p>
|
|
<h2><a class="anchor" id="FlexCANConfig"></a>
|
|
FlexCAN Configuration</h2>
|
|
<p>This function group configures the FlexCAN module including the timing characteristic, transmit/receive message buffer, receive FIFO and Global/Individual masks for both receive message buffer and receive FIFO.</p>
|
|
<h2><a class="anchor" id="FlexCANBasicOps"></a>
|
|
FlexCAN Basic Operation</h2>
|
|
<p>This function group enables/disables the FlexCAN module, FlexCAN module interrupt, and FlexCAN message buffer interrupt and DMA. It also gets the receive FIFO head address for the receive FIFO DMA transfer.</p>
|
|
<h2><a class="anchor" id="FlexCANTransOps"></a>
|
|
FlexCAN Transfer Operation</h2>
|
|
<p>This function group controls the transfer action including writing the transfer message buffer, reading the receive message buffer, and reading the receive FIFO.</p>
|
|
<h2><a class="anchor" id="FlexCANStatusOps"></a>
|
|
FlexCAN Status Operation</h2>
|
|
<p>This function group gets/clears the FlexCAN module status the FlexCAN message buffer/receive FIFO status.</p>
|
|
<h2><a class="anchor" id="FlexCANBlockTrans"></a>
|
|
FlexCAN Block Transfer Operation</h2>
|
|
<p>This function group transfers a block of data, gets the transfer status, and aborts the transfer.</p>
|
|
<h1><a class="anchor" id="FlexCANTpyUC"></a>
|
|
Typical use case</h1>
|
|
<h2><a class="anchor" id="FlexCANMbSendOps"></a>
|
|
Message Buffer Send Operation</h2>
|
|
<div class="fragment"><div class="line"><a class="code" href="group__flexcan.html#structflexcan__config__t">flexcan_config_t</a> flexcanConfig;</div><div class="line"><a class="code" href="group__flexcan.html#structflexcan__frame__t">flexcan_frame_t</a> txFrame;</div><div class="line"></div><div class="line"><span class="comment">/* Init FlexCAN module. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga4eafdb971a92f517c69a80c15a216342">FLEXCAN_GetDefaultConfig</a>(&flexcanConfig);</div><div class="line"><a class="code" href="group__flexcan.html#ga8d7ebf086fb294130fa30a0f75a5f340">FLEXCAN_Init</a>(EXAMPLE_CAN, &flexcanConfig);</div><div class="line"></div><div class="line"><span class="comment">/* Enable FlexCAN module. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga20f79302d5fad90306a26b667f58fe4d">FLEXCAN_Enable</a>(EXAMPLE_CAN, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"><span class="comment">/* Sets up the transmit message buffer. */</span></div><div class="line"><a class="code" href="group__flexcan.html#gadbf35cc05ed0d9a73eda5ac4fbb30ff0">FLEXCAN_SetTxMbConfig</a>(EXAMPLE_CAN, TX_MESSAGE_BUFFER_INDEX, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"><span class="comment">/* Prepares the transmit frame for sending. */</span></div><div class="line">txFrame.format = KFLEXCAN_FrameFormatStandard;</div><div class="line">txFrame.type = KFLEXCAN_FrameTypeData;</div><div class="line">txFrame.id = FLEXCAN_ID_STD(0x123);</div><div class="line">txFrame.length = 8;</div><div class="line">txFrame.dataWord0 = CAN_WORD0_DATA_BYTE_0(0x11) |</div><div class="line"> CAN_WORD0_DATA_BYTE_1(0x22) |</div><div class="line"> CAN_WORD0_DATA_BYTE_2(0x33) |</div><div class="line"> CAN_WORD0_DATA_BYTE_3(0x44);</div><div class="line">txFrame.dataWord1 = CAN_WORD1_DATA_BYTE_4(0x55) |</div><div class="line"> CAN_WORD1_DATA_BYTE_5(0x66) |</div><div class="line"> CAN_WORD1_DATA_BYTE_6(0x77) |</div><div class="line"> CAN_WORD1_DATA_BYTE_7(0x88);</div><div class="line"><span class="comment">/* Writes a transmit message buffer to send a CAN Message. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga9ee9d599069a88a50cb7c7a894c87c69">FLEXCAN_WriteTxMb</a>(EXAMPLE_CAN, TX_MESSAGE_BUFFER_INDEX, &txFrame);</div><div class="line"></div><div class="line"><span class="comment">/* Waits until the transmit message buffer is empty. */</span></div><div class="line"><span class="keywordflow">while</span> (!<a class="code" href="group__flexcan.html#gab6ed94b8a36d174fb30d3256e3b2d975">FLEXCAN_GetMbStatusFlags</a>(EXAMPLE_CAN, 1 << TX_MESSAGE_BUFFER_INDEX));</div><div class="line"></div><div class="line"><span class="comment">/* Cleans the transmit message buffer empty status. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga800056b1b1ee4748d086329535e78274">FLEXCAN_ClearMbStatusFlags</a>(EXAMPLE_CAN, 1 << TX_MESSAGE_BUFFER_INDEX);</div></div><!-- fragment --><h2><a class="anchor" id="FlexCANMbReceiveOps"></a>
|
|
Message Buffer Receive Operation</h2>
|
|
<div class="fragment"><div class="line"><a class="code" href="group__flexcan.html#structflexcan__config__t">flexcan_config_t</a> flexcanConfig;</div><div class="line"><a class="code" href="group__flexcan.html#structflexcan__frame__t">flexcan_frame_t</a> rxFrame;</div><div class="line"></div><div class="line"><span class="comment">/* Initializes the FlexCAN module. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga4eafdb971a92f517c69a80c15a216342">FLEXCAN_GetDefaultConfig</a>(&flexcanConfig);</div><div class="line"><a class="code" href="group__flexcan.html#ga8d7ebf086fb294130fa30a0f75a5f340">FLEXCAN_Init</a>(EXAMPLE_CAN, &flexcanConfig);</div><div class="line"></div><div class="line"><span class="comment">/* Enables the FlexCAN module. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga20f79302d5fad90306a26b667f58fe4d">FLEXCAN_Enable</a>(EXAMPLE_CAN, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"><span class="comment">/* Sets up the receive message buffer. */</span></div><div class="line">mbConfig.format = KFLEXCAN_FrameFormatStandard;</div><div class="line">mbConfig.type = KFLEXCAN_FrameTypeData;</div><div class="line">mbConfig.id = FLEXCAN_ID_STD(0x123);</div><div class="line"><a class="code" href="group__flexcan.html#gaf335daf0156fab50571e55d2898bccb2">FLEXCAN_SetRxMbConfig</a>(EXAMPLE_CAN, RX_MESSAGE_BUFFER_INDEX, &mbConfig, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"><span class="comment">/* Waits until the receive message buffer is full. */</span></div><div class="line"><span class="keywordflow">while</span> (!<a class="code" href="group__flexcan.html#gab6ed94b8a36d174fb30d3256e3b2d975">FLEXCAN_GetMbStatusFlags</a>(EXAMPLE_CAN, 1 << RX_MESSAGE_BUFFER_INDEX));</div><div class="line"></div><div class="line"><span class="comment">/* Reads the received message from the receive message buffer. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga93600de1691b5e6d8cc01e06efee7b68">FLEXCAN_ReadRxMb</a>(EXAMPLE_CAN, RX_MESSAGE_BUFFER_INDEX, &rxFrame);</div><div class="line"></div><div class="line"><span class="comment">/* Cleans the receive message buffer full status. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga800056b1b1ee4748d086329535e78274">FLEXCAN_ClearMbStatusFlags</a>(EXAMPLE_CAN, 1 << RX_MESSAGE_BUFFER_INDEX);</div></div><!-- fragment --><h2><a class="anchor" id="FlexCANFifoReceiveOps"></a>
|
|
Receive FIFO Operation</h2>
|
|
<div class="fragment"><div class="line">uint32_t rxFifoFilter[] = {FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(0x321, 0, 0),</div><div class="line"> FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(0x321, 1, 0),</div><div class="line"> FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(0x123, 0, 0),</div><div class="line"> FLEXCAN_RX_FIFO_STD_FILTER_TYPE_A(0x123, 1, 0)};</div><div class="line"></div><div class="line"><a class="code" href="group__flexcan.html#structflexcan__config__t">flexcan_config_t</a> flexcanConfig;</div><div class="line"><a class="code" href="group__flexcan.html#structflexcan__frame__t">flexcan_frame_t</a> rxFrame;</div><div class="line"></div><div class="line"><span class="comment">/* Initializes the FlexCAN module. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga4eafdb971a92f517c69a80c15a216342">FLEXCAN_GetDefaultConfig</a>(&flexcanConfig);</div><div class="line"><a class="code" href="group__flexcan.html#ga8d7ebf086fb294130fa30a0f75a5f340">FLEXCAN_Init</a>(EXAMPLE_CAN, &flexcanConfig);</div><div class="line"></div><div class="line"><span class="comment">/* Enables the FlexCAN module. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga20f79302d5fad90306a26b667f58fe4d">FLEXCAN_Enable</a>(EXAMPLE_CAN, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"><span class="comment">/* Sets up the receive FIFO. */</span></div><div class="line">rxFifoConfig.idFilterTable = rxFifoFilter;</div><div class="line">rxFifoConfig.idFilterType = KFLEXCAN_RxFifoFilterTypeA;</div><div class="line">rxFifoConfig.idFilterNum = <span class="keyword">sizeof</span>(rxFifoFilter) / <span class="keyword">sizeof</span>(rxFifoFilter[0]);</div><div class="line">rxFifoConfig.priority = KFLEXCAN_RxFifoPrioHigh;</div><div class="line"><a class="code" href="group__flexcan.html#ga40140a86bc8481442286a61aa668d508">FlEXCAN_SetRxFifoConfig</a>(EXAMPLE_CAN, &rxFifoConfig, <span class="keyword">true</span>);</div><div class="line"></div><div class="line"><span class="comment">/* Waits until the receive FIFO becomes available. */</span></div><div class="line"><span class="keywordflow">while</span> (!<a class="code" href="group__flexcan.html#gab6ed94b8a36d174fb30d3256e3b2d975">FLEXCAN_GetMbStatusFlags</a>(EXAMPLE_CAN, KFLEXCAN_RxFifoFrameAvlFlag));</div><div class="line"></div><div class="line"><span class="comment">/* Reads the message from the receive FIFO. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga0f74840527f5e882c72746315bc06576">FlEXCAN_ReadRxFifo</a>(EXAMPLE_CAN, &rxFrame);</div><div class="line"></div><div class="line"><span class="comment">/* Cleans the receive FIFO available status. */</span></div><div class="line"><a class="code" href="group__flexcan.html#ga800056b1b1ee4748d086329535e78274">FLEXCAN_ClearMbStatusFlags</a>(EXAMPLE_CAN, KFLEXCAN_RxFifoFrameAvlFlag);</div></div><!-- fragment --> </div><!-- contents -->
|
|
</div><!-- doc-content -->
|
|
<!-- start footer part -->
|
|
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
|
<ul>
|
|
<li class="footer">Generated on Mon Mar 7 2016 16:48:23 for Kinetis Bootloader by
|
|
<a href="http://www.doxygen.org/index.html">
|
|
<img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.11 </li>
|
|
</ul>
|
|
</div>
|
|
</body>
|
|
</html>
|