group__peripheral__gr.html 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <title>Peripheral Access</title>
  7. <title>CMSIS-CORE: Peripheral Access</title>
  8. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  9. <link href="cmsis.css" rel="stylesheet" type="text/css" />
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <script type="text/javascript" src="printComponentTabs.js"></script>
  13. <link href="navtree.css" rel="stylesheet" type="text/css"/>
  14. <script type="text/javascript" src="resize.js"></script>
  15. <script type="text/javascript" src="navtree.js"></script>
  16. <script type="text/javascript">
  17. $(document).ready(initResizable);
  18. $(window).load(resizeHeight);
  19. </script>
  20. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  21. <script type="text/javascript" src="search/search.js"></script>
  22. <script type="text/javascript">
  23. $(document).ready(function() { searchBox.OnSelectItem(0); });
  24. </script>
  25. </head>
  26. <body>
  27. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  28. <div id="titlearea">
  29. <table cellspacing="0" cellpadding="0">
  30. <tbody>
  31. <tr style="height: 46px;">
  32. <td id="projectlogo"><img alt="Logo" src="CMSIS_Logo_Final.png"/></td>
  33. <td style="padding-left: 0.5em;">
  34. <div id="projectname">CMSIS-CORE
  35. &#160;<span id="projectnumber">Version 5.0.1</span>
  36. </div>
  37. <div id="projectbrief">CMSIS-CORE support for Cortex-M processor-based devices</div>
  38. </td>
  39. </tr>
  40. </tbody>
  41. </table>
  42. </div>
  43. <!-- end header part -->
  44. <div id="CMSISnav" class="tabs1">
  45. <ul class="tablist">
  46. <script type="text/javascript">
  47. <!--
  48. writeComponentTabs.call(this);
  49. //-->
  50. </script>
  51. </ul>
  52. </div>
  53. <!-- Generated by Doxygen 1.8.6 -->
  54. <script type="text/javascript">
  55. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  56. </script>
  57. <div id="navrow1" class="tabs">
  58. <ul class="tablist">
  59. <li><a href="index.html"><span>Main&#160;Page</span></a></li>
  60. <li><a href="pages.html"><span>Usage&#160;and&#160;Description</span></a></li>
  61. <li><a href="modules.html"><span>Reference</span></a></li>
  62. <li>
  63. <div id="MSearchBox" class="MSearchBoxInactive">
  64. <span class="left">
  65. <img id="MSearchSelect" src="search/mag_sel.png"
  66. onmouseover="return searchBox.OnSearchSelectShow()"
  67. onmouseout="return searchBox.OnSearchSelectHide()"
  68. alt=""/>
  69. <input type="text" id="MSearchField" value="Search" accesskey="S"
  70. onfocus="searchBox.OnSearchFieldFocus(true)"
  71. onblur="searchBox.OnSearchFieldFocus(false)"
  72. onkeyup="searchBox.OnSearchFieldChange(event)"/>
  73. </span><span class="right">
  74. <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.png" alt=""/></a>
  75. </span>
  76. </div>
  77. </li>
  78. </ul>
  79. </div>
  80. </div><!-- top -->
  81. <div id="side-nav" class="ui-resizable side-nav-resizable">
  82. <div id="nav-tree">
  83. <div id="nav-tree-contents">
  84. <div id="nav-sync" class="sync"></div>
  85. </div>
  86. </div>
  87. <div id="splitbar" style="-moz-user-select:none;"
  88. class="ui-resizable-handle">
  89. </div>
  90. </div>
  91. <script type="text/javascript">
  92. $(document).ready(function(){initNavTree('group__peripheral__gr.html','');});
  93. </script>
  94. <div id="doc-content">
  95. <!-- window showing the filter options -->
  96. <div id="MSearchSelectWindow"
  97. onmouseover="return searchBox.OnSearchSelectShow()"
  98. onmouseout="return searchBox.OnSearchSelectHide()"
  99. onkeydown="return searchBox.OnSearchSelectKey(event)">
  100. <a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(0)"><span class="SelectionMark">&#160;</span>All</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(1)"><span class="SelectionMark">&#160;</span>Data Structures</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(2)"><span class="SelectionMark">&#160;</span>Files</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(3)"><span class="SelectionMark">&#160;</span>Functions</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(4)"><span class="SelectionMark">&#160;</span>Variables</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(5)"><span class="SelectionMark">&#160;</span>Enumerations</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(6)"><span class="SelectionMark">&#160;</span>Enumerator</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(7)"><span class="SelectionMark">&#160;</span>Groups</a><a class="SelectItem" href="javascript:void(0)" onclick="searchBox.OnSelectItem(8)"><span class="SelectionMark">&#160;</span>Pages</a></div>
  101. <!-- iframe showing the search results (closed by default) -->
  102. <div id="MSearchResultsWindow">
  103. <iframe src="javascript:void(0)" frameborder="0"
  104. name="MSearchResults" id="MSearchResults">
  105. </iframe>
  106. </div>
  107. <div class="header">
  108. <div class="summary">
  109. <a href="#define-members">Macros</a> </div>
  110. <div class="headertitle">
  111. <div class="title">Peripheral Access</div> </div>
  112. </div><!--header-->
  113. <div class="contents">
  114. <p>Naming conventions and optional features for accessing peripherals.
  115. <a href="#details">More...</a></p>
  116. <table class="memberdecls">
  117. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
  118. Macros</h2></td></tr>
  119. <tr class="memitem:ga286e3b913dbd236c7f48ea70c8821f4e"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__peripheral__gr.html#ga286e3b913dbd236c7f48ea70c8821f4e">_VAL2FLD</a>(field, value)</td></tr>
  120. <tr class="memdesc:ga286e3b913dbd236c7f48ea70c8821f4e"><td class="mdescLeft">&#160;</td><td class="mdescRight">Mask and shift a bit field value for assigning the result to a peripheral register. <a href="#ga286e3b913dbd236c7f48ea70c8821f4e">More...</a><br/></td></tr>
  121. <tr class="separator:ga286e3b913dbd236c7f48ea70c8821f4e"><td class="memSeparator" colspan="2">&#160;</td></tr>
  122. <tr class="memitem:ga139b6e261c981f014f386927ca4a8444"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="group__peripheral__gr.html#ga139b6e261c981f014f386927ca4a8444">_FLD2VAL</a>(field, value)</td></tr>
  123. <tr class="memdesc:ga139b6e261c981f014f386927ca4a8444"><td class="mdescLeft">&#160;</td><td class="mdescRight">Extract from a peripheral register value the a bit field value. <a href="#ga139b6e261c981f014f386927ca4a8444">More...</a><br/></td></tr>
  124. <tr class="separator:ga139b6e261c981f014f386927ca4a8444"><td class="memSeparator" colspan="2">&#160;</td></tr>
  125. </table>
  126. <a name="details" id="details"></a><h2 class="groupheader">Description</h2>
  127. <p>The section below describes the naming conventions, requirements, and optional features for accessing device specific peripherals. Most of the rules also apply to the core peripherals. The <a class="el" href="device_h_pg.html">Device Header File &lt;device.h&gt;</a> contains typically these definition and also includes the core specific header files.</p>
  128. <p>The definitions for <a class="el" href="group__peripheral__gr.html">Peripheral Access</a> can be generated using the <a href="../../SVD/html/index.html"><b>CMSIS-SVD</b></a> System View Description for Peripherals. Refer to <a href="../../SVD/html/svd_SVDConv_pg.html"><b>SVDConv.exe</b></a> for more information.</p>
  129. <p>Each peripheral provides a data type definition with a name that is composed of:</p>
  130. <ul>
  131. <li>an optional prefix <b>&lt;<em>device abbreviation&gt;</em>_</b></li>
  132. <li><b>&lt;<em>peripheral name</em>&gt;</b></li>
  133. <li>postfix <b>_Type</b> or <b>_TypeDef</b> to identify a type definition.</li>
  134. </ul>
  135. <p>Examples:</p>
  136. <ul>
  137. <li><b>UART_TypeDef</b> for the peripheral <b>UART</b>.</li>
  138. <li><b>LPC_UART_TypeDef</b> for the device family <b>LPC</b> and the peripheral <b>UART</b>.</li>
  139. </ul>
  140. <p>The data type definition uses standard C data types defined by the ANSI C header file &lt;stdint.h&gt;.</p>
  141. <ul>
  142. <li>IO Type Qualifiers are used to specify the access to peripheral variables. <table class="doxtable">
  143. <tr>
  144. <th align="left">IO Type Qualifier </th><th align="left">Type </th><th align="left">Description </th></tr>
  145. <tr>
  146. <td align="left"><b>__IM</b> </td><td align="left">Struct member </td><td align="left">Defines 'read only' permissions </td></tr>
  147. <tr>
  148. <td align="left"><b>__OM</b> </td><td align="left">Struct member </td><td align="left">Defines 'write only' permissions </td></tr>
  149. <tr>
  150. <td align="left"><b>__IOM</b> </td><td align="left">Struct member </td><td align="left">Defines 'read / write' permissions </td></tr>
  151. <tr>
  152. <td align="left"><b>__I</b> </td><td align="left">Scalar variable </td><td align="left">Defines 'read only' permissions </td></tr>
  153. <tr>
  154. <td align="left"><b>__O</b> </td><td align="left">Scalar variable </td><td align="left">Defines 'write only' permissions </td></tr>
  155. <tr>
  156. <td align="left"><b>__IO</b> </td><td align="left">Scalar variable </td><td align="left">Defines 'read / write' permissions </td></tr>
  157. </table>
  158. <dl class="section note"><dt>Note</dt><dd><b>__IM</b>, <b>__OM</b>, <b>__IOM</b> are added in CMSIS-Core V4.20 to enhance support for C++. Prior version used <b>__I</b>, <b>__O</b>, <b>__IO</b> also for struct member definitions.</dd></dl>
  159. The typedef <b>&lt;<em>device abbreviation</em>&gt;_UART_TypeDef</b> shown below defines the generic register layout for all UART channels in a device.</li>
  160. </ul>
  161. <div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
  162. <div class="line">{</div>
  163. <div class="line"> <span class="keyword">union </span>{</div>
  164. <div class="line"> __IM uint8_t RBR; <span class="comment">/* Offset: 0x000 (R/ ) Receiver Buffer Register */</span></div>
  165. <div class="line"> __OM uint8_t THR; <span class="comment">/* Offset: 0x000 ( /W) Transmit Holding Register */</span></div>
  166. <div class="line"> __IOM uint8_t DLL; <span class="comment">/* Offset: 0x000 (R/W) Divisor Latch LSB */</span></div>
  167. <div class="line"> uint32_t RESERVED0;</div>
  168. <div class="line"> };</div>
  169. <div class="line"> <span class="keyword">union </span>{</div>
  170. <div class="line"> __IOM uint8_t DLM; <span class="comment">/* Offset: 0x004 (R/W) Divisor Latch MSB */</span></div>
  171. <div class="line"> __IOM uint32_t IER; <span class="comment">/* Offset: 0x004 (R/W) Interrupt Enable Register */</span></div>
  172. <div class="line"> };</div>
  173. <div class="line"> <span class="keyword">union </span>{</div>
  174. <div class="line"> __IM uint32_t IIR; <span class="comment">/* Offset: 0x008 (R/ ) Interrupt ID Register */</span></div>
  175. <div class="line"> __OM uint8_t FCR; <span class="comment">/* Offset: 0x008 ( /W) FIFO Control Register */</span></div>
  176. <div class="line"> };</div>
  177. <div class="line"> __IOM uint8_t LCR; <span class="comment">/* Offset: 0x00C (R/W) Line Control Register */</span></div>
  178. <div class="line"> uint8_t RESERVED1[7];</div>
  179. <div class="line"> __IM uint8_t LSR; <span class="comment">/* Offset: 0x014 (R/ ) Line Status Register */</span></div>
  180. <div class="line"> uint8_t RESERVED2[7];</div>
  181. <div class="line"> __IOM uint8_t SCR; <span class="comment">/* Offset: 0x01C (R/W) Scratch Pad Register */</span></div>
  182. <div class="line"> uint8_t RESERVED3[3];</div>
  183. <div class="line"> __IOM uint32_t ACR; <span class="comment">/* Offset: 0x020 (R/W) Autobaud Control Register */</span></div>
  184. <div class="line"> __IOM uint8_t ICR; <span class="comment">/* Offset: 0x024 (R/W) IrDA Control Register */</span></div>
  185. <div class="line"> uint8_t RESERVED4[3];</div>
  186. <div class="line"> __IOM uint8_t FDR; <span class="comment">/* Offset: 0x028 (R/W) Fractional Divider Register */</span></div>
  187. <div class="line"> uint8_t RESERVED5[7];</div>
  188. <div class="line"> __IOM uint8_t TER; <span class="comment">/* Offset: 0x030 (R/W) Transmit Enable Register */</span></div>
  189. <div class="line"> uint8_t RESERVED6[39];</div>
  190. <div class="line"> __IM uint8_t FIFOLVL; <span class="comment">/* Offset: 0x058 (R/ ) FIFO Level Register */</span></div>
  191. <div class="line">} LPC_UART_TypeDef;</div>
  192. </div><!-- fragment --><p>To access the registers of the UART defined above, pointers to this register structure are defined. If more instances of a peripheral exist, the variables have a postfix (digit or letter) that identifies the peripheral.</p>
  193. <p><b>Example:</b> In this example <b>LPC_UART2</b> and <b>LPC_UART3</b> are two pointers to UARTs defined with above register structure. <br/>
  194. </p>
  195. <div class="fragment"><div class="line"><span class="preprocessor">#define LPC_UART2 ((LPC_UART_TypeDef *) LPC_UART2_BASE )</span></div>
  196. <div class="line"><span class="preprocessor">#define LPC_UART3 ((LPC_UART_TypeDef *) LPC_UART3_BASE )</span></div>
  197. </div><!-- fragment --><dl class="section note"><dt>Note</dt><dd><ul>
  198. <li>The prefix <b>LPC</b> is optional.</li>
  199. </ul>
  200. </dd></dl>
  201. <p>The registers in the various UARTs can now be referred in the user code as shown below:<br/>
  202. </p>
  203. <div class="fragment"><div class="line">val = LPC_UART2-&gt;DR <span class="comment">// is the data register of UART1.</span></div>
  204. </div><!-- fragment --><hr/>
  205. <h1><a class="anchor" id="core_cmsis_pal_min_reqs"></a>
  206. Minimal Requirements</h1>
  207. <p>To access the peripheral registers and related function in a device, the files <b><em>device.h</em></b> and <b>core_cm<em>#</em>.h</b> define as a minimum: <br/>
  208. <br/>
  209. </p>
  210. <ul>
  211. <li>The <b>Register Layout Typedef</b> for each peripheral that defines all register names. RESERVED is used to introduce space into the structure for adjusting the addresses of the peripheral registers. <br/>
  212. <br/>
  213. <b>Example:</b> <div class="fragment"><div class="line"><span class="keyword">typedef</span> <span class="keyword">struct</span></div>
  214. <div class="line">{</div>
  215. <div class="line"> __IOM uint32_t CTRL; <span class="comment">/* Offset: 0x000 (R/W) SysTick Control and Status Register */</span></div>
  216. <div class="line"> __IOM uint32_t LOAD; <span class="comment">/* Offset: 0x004 (R/W) SysTick Reload Value Register */</span></div>
  217. <div class="line"> __IOM uint32_t VAL; <span class="comment">/* Offset: 0x008 (R/W) SysTick Current Value Register */</span></div>
  218. <div class="line"> __IM uint32_t CALIB; <span class="comment">/* Offset: 0x00C (R/ ) SysTick Calibration Register */</span></div>
  219. <div class="line">} <a class="code" href="structSysTick__Type.html">SysTick_Type</a>;</div>
  220. </div><!-- fragment --></li>
  221. <li><b>Base Address</b> for each peripheral (in case of multiple peripherals that use the same <b>register layout typedef</b> multiple base addresses are defined). <br/>
  222. <br/>
  223. <b>Example:</b> <div class="fragment"><div class="line"><span class="preprocessor">#define SysTick_BASE (SCS_BASE + 0x0010) </span><span class="comment">/* SysTick Base Address */</span><span class="preprocessor"></span></div>
  224. </div><!-- fragment --></li>
  225. <li><b>Access Definitions</b> for each peripheral. In case of multiple peripherals that are using the same <b>register layout typdef</b>, multiple access definitions exist (LPC_UART0, LPC_UART2). <br/>
  226. <br/>
  227. <b>Example:</b> <div class="fragment"><div class="line"><span class="preprocessor">#define SysTick ((SysTick_Type *) Systick_BASE) </span><span class="comment">/* SysTick access definition */</span><span class="preprocessor"></span></div>
  228. </div><!-- fragment --></li>
  229. </ul>
  230. <p>These definitions allow accessing peripheral registers with simple assignments.</p>
  231. <ul>
  232. <li><b>Example:</b> <br/>
  233. <div class="fragment"><div class="line">SysTick-&gt;CTRL = 0;</div>
  234. </div><!-- fragment --></li>
  235. </ul>
  236. <hr/>
  237. <h1><a class="anchor" id="core_cmsis_pal_opts"></a>
  238. Optional Features</h1>
  239. <p>Optionally, the file <b><em>device</em>.h</b> may define:</p>
  240. <ul>
  241. <li><a class="el" href="group__peripheral__gr.html#core_cmsis_pal_bitfields">Register Bit Fields</a> and #define constants that simplify access to peripheral registers. These constants may define bit-positions or other specific patterns that are required for programming peripheral registers. The identifiers should start with <b>&lt;<em>device abbreviation</em>&gt;_</b> and <b>&lt;<em>peripheral name</em>&gt;_</b>. It is recommended to use CAPITAL letters for #define constants.</li>
  242. <li>More complex functions (i.e. status query before a sending register is accessed). Again, these functions start with <b>&lt;<em>device abbreviation</em>&gt;_</b> and <b>&lt;<em>peripheral name</em>&gt;_</b>.</li>
  243. </ul>
  244. <hr/>
  245. <h1><a class="anchor" id="core_cmsis_pal_bitfields"></a>
  246. Register Bit Fields</h1>
  247. <p>For Core Register, macros define the position and the mask value for a bit field. It is recommended to create such definitions also for other peripheral registers.</p>
  248. <p><b>Example:</b></p>
  249. <p>Bit field definitions for register CPUID in SCB (System Control Block).</p>
  250. <div class="fragment"><div class="line"><span class="comment">/* SCB CPUID Register Definitions */</span></div>
  251. <div class="line"><span class="preprocessor">#define SCB_CPUID_IMPLEMENTER_Pos 24U </span></div>
  252. <div class="line"><span class="preprocessor">#define SCB_CPUID_IMPLEMENTER_Msk (0xFFUL &lt;&lt; SCB_CPUID_IMPLEMENTER_Pos) </span></div>
  253. <div class="line"><span class="preprocessor">#define SCB_CPUID_VARIANT_Pos 20U </span></div>
  254. <div class="line"><span class="preprocessor">#define SCB_CPUID_VARIANT_Msk (0xFUL &lt;&lt; SCB_CPUID_VARIANT_Pos) </span></div>
  255. <div class="line"><span class="preprocessor">#define SCB_CPUID_ARCHITECTURE_Pos 16U </span></div>
  256. <div class="line"><span class="preprocessor">#define SCB_CPUID_ARCHITECTURE_Msk (0xFUL &lt;&lt; SCB_CPUID_ARCHITECTURE_Pos) </span></div>
  257. <div class="line"><span class="preprocessor">#define SCB_CPUID_PARTNO_Pos 4U </span></div>
  258. <div class="line"><span class="preprocessor">#define SCB_CPUID_PARTNO_Msk (0xFFFUL &lt;&lt; SCB_CPUID_PARTNO_Pos) </span></div>
  259. <div class="line"><span class="preprocessor">#define SCB_CPUID_REVISION_Pos 0U </span></div>
  260. <div class="line"><span class="preprocessor">#define SCB_CPUID_REVISION_Msk (0xFUL </span><span class="comment">/*&lt;&lt; SCB_CPUID_REVISION_Pos*/</span><span class="preprocessor">) </span></div>
  261. </div><!-- fragment --><p>The macros <b><a class="el" href="group__peripheral__gr.html#ga286e3b913dbd236c7f48ea70c8821f4e" title="Mask and shift a bit field value for assigning the result to a peripheral register. ">_VAL2FLD(field, value)</a></b> and <b><a class="el" href="group__peripheral__gr.html#ga139b6e261c981f014f386927ca4a8444" title="Extract from a peripheral register value the a bit field value. ">_FLD2VAL(field, value)</a></b> enable access to bit fields. </p>
  262. <h2 class="groupheader">Macro Definition Documentation</h2>
  263. <a class="anchor" id="ga139b6e261c981f014f386927ca4a8444"></a>
  264. <div class="memitem">
  265. <div class="memproto">
  266. <table class="memname">
  267. <tr>
  268. <td class="memname">#define _FLD2VAL</td>
  269. <td>(</td>
  270. <td class="paramtype">&#160;</td>
  271. <td class="paramname">field, </td>
  272. </tr>
  273. <tr>
  274. <td class="paramkey"></td>
  275. <td></td>
  276. <td class="paramtype">&#160;</td>
  277. <td class="paramname">value&#160;</td>
  278. </tr>
  279. <tr>
  280. <td></td>
  281. <td>)</td>
  282. <td></td><td></td>
  283. </tr>
  284. </table>
  285. </div><div class="memdoc">
  286. <dl class="params"><dt>Parameters</dt><dd>
  287. <table class="params">
  288. <tr><td class="paramname">field</td><td>name of bit field. </td></tr>
  289. <tr><td class="paramname">value</td><td>value of the register. This parameter is interpreted as an uint32_t type.</td></tr>
  290. </table>
  291. </dd>
  292. </dl>
  293. <p>The macro <a class="el" href="group__peripheral__gr.html#ga139b6e261c981f014f386927ca4a8444">_FLD2VAL</a> uses the #define's <em>_Pos</em> and <em>_Msk</em> of the related bit field to extract the value of a bit field from a register.</p>
  294. <p><b>Example:</b> </p>
  295. <div class="fragment"><div class="line"><span class="keywordtype">id</span> = <a class="code" href="group__peripheral__gr.html#ga139b6e261c981f014f386927ca4a8444">_FLD2VAL</a>(SCB_CPUID_REVISION, SCB-&gt;CPUID);</div>
  296. </div><!-- fragment -->
  297. </div>
  298. </div>
  299. <a class="anchor" id="ga286e3b913dbd236c7f48ea70c8821f4e"></a>
  300. <div class="memitem">
  301. <div class="memproto">
  302. <table class="memname">
  303. <tr>
  304. <td class="memname">#define _VAL2FLD</td>
  305. <td>(</td>
  306. <td class="paramtype">&#160;</td>
  307. <td class="paramname">field, </td>
  308. </tr>
  309. <tr>
  310. <td class="paramkey"></td>
  311. <td></td>
  312. <td class="paramtype">&#160;</td>
  313. <td class="paramname">value&#160;</td>
  314. </tr>
  315. <tr>
  316. <td></td>
  317. <td>)</td>
  318. <td></td><td></td>
  319. </tr>
  320. </table>
  321. </div><div class="memdoc">
  322. <dl class="params"><dt>Parameters</dt><dd>
  323. <table class="params">
  324. <tr><td class="paramname">field</td><td>name of bit field. </td></tr>
  325. <tr><td class="paramname">value</td><td>value for the bit field. This parameter is interpreted as an uint32_t type.</td></tr>
  326. </table>
  327. </dd>
  328. </dl>
  329. <p>The macro <a class="el" href="group__peripheral__gr.html#ga286e3b913dbd236c7f48ea70c8821f4e">_VAL2FLD</a> uses the #define's <em>_Pos</em> and <em>_Msk</em> of the related bit field to shift bit-field values for assigning to a register.</p>
  330. <p><b>Example:</b> </p>
  331. <div class="fragment"><div class="line">SCB-&gt;CPUID = <a class="code" href="group__peripheral__gr.html#ga286e3b913dbd236c7f48ea70c8821f4e">_VAL2FLD</a>(SCB_CPUID_REVISION, 0x3) | <a class="code" href="group__peripheral__gr.html#ga286e3b913dbd236c7f48ea70c8821f4e">_VAL2FLD</a>(SCB_CPUID_VARIANT, 0x3);</div>
  332. </div><!-- fragment -->
  333. </div>
  334. </div>
  335. </div><!-- contents -->
  336. </div><!-- doc-content -->
  337. <!-- start footer part -->
  338. <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
  339. <ul>
  340. <li class="footer">Generated on Wed Feb 8 2017 10:20:41 for CMSIS-CORE by ARM Ltd. All rights reserved.
  341. <!--
  342. <a href="http://www.doxygen.org/index.html">
  343. <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.8.6
  344. -->
  345. </li>
  346. </ul>
  347. </div>
  348. </body>
  349. </html>