]> begriffs open source - cmsis/blob - v6.1.0/Core_A/system_c_pg.html
Update documentation for branch main
[cmsis] / v6.1.0 / Core_A / system_c_pg.html
1 <!-- HTML header for doxygen 1.9.6-->
2 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
3 <html xmlns="http://www.w3.org/1999/xhtml" lang="en-US">
4 <head>
5 <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
6 <meta http-equiv="X-UA-Compatible" content="IE=11"/>
7 <meta name="viewport" content="width=device-width, initial-scale=1"/>
8 <title>CMSIS-Core (Cortex-A): System Configuration Files system_&lt;Device&gt;.c and system_&lt;Device&gt;.h</title>
9 <link href="doxygen.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="tabs.js"></script>
13 <script type="text/javascript" src="footer.js"></script>
14 <script type="text/javascript" src="navtree.js"></script>
15 <link href="navtree.css" rel="stylesheet" type="text/css"/>
16 <script type="text/javascript" src="resize.js"></script>
17 <script type="text/javascript" src="navtreedata.js"></script>
18 <script type="text/javascript" src="navtree.js"></script>
19 <link href="search/search.css" rel="stylesheet" type="text/css"/>
20 <script type="text/javascript" src="search/searchdata.js"></script>
21 <script type="text/javascript" src="search/search.js"></script>
22 <script type="text/javascript">
23 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
24   $(document).ready(function() { init_search(); });
25 /* @license-end */
26 </script>
27 <script type="text/javascript" src="darkmode_toggle.js"></script>
28 <link href="extra_stylesheet.css" rel="stylesheet" type="text/css"/>
29 <link href="extra_navtree.css" rel="stylesheet" type="text/css"/>
30 <link href="extra_search.css" rel="stylesheet" type="text/css"/>
31 <link href="extra_tabs.css" rel="stylesheet" type="text/css"/>
32 <link href="version.css" rel="stylesheet" type="text/css"/>
33 <script type="text/javascript" src="../../version.js"></script>
34 </head>
35 <body>
36 <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
37 <div id="titlearea">
38 <table cellspacing="0" cellpadding="0">
39  <tbody>
40  <tr style="height: 55px;">
41   <td id="projectlogo" style="padding: 1.5em;"><img alt="Logo" src="cmsis_logo_white_small.png"/></td>
42   <td style="padding-left: 1em; padding-bottom: 1em;padding-top: 1em;">
43    <div id="projectname">CMSIS-Core (Cortex-A)
44    &#160;<span id="projectnumber"><script type="text/javascript">
45      <!--
46      writeHeader.call(this);
47      writeVersionDropdown.call(this, "CMSIS-Core (Cortex-A)");
48      //-->
49     </script>
50    </span>
51    </div>
52    <div id="projectbrief">CMSIS-Core support for Cortex-A processor-based devices</div>
53   </td>
54    <td>        <div id="MSearchBox" class="MSearchBoxInactive">
55         <span class="left">
56           <span id="MSearchSelect"                onmouseover="return searchBox.OnSearchSelectShow()"                onmouseout="return searchBox.OnSearchSelectHide()">&#160;</span>
57           <input type="text" id="MSearchField" value="" placeholder="Search" accesskey="S"
58                onfocus="searchBox.OnSearchFieldFocus(true)" 
59                onblur="searchBox.OnSearchFieldFocus(false)" 
60                onkeyup="searchBox.OnSearchFieldChange(event)"/>
61           </span><span class="right">
62             <a id="MSearchClose" href="javascript:searchBox.CloseResultsWindow()"><img id="MSearchCloseImg" border="0" src="search/close.svg" alt=""/></a>
63           </span>
64         </div>
65 </td>
66   <!--END !PROJECT_NAME-->
67  </tr>
68  </tbody>
69 </table>
70 </div>
71 <!-- end header part -->
72 <div id="CMSISnav" class="tabs1">
73   <ul class="tablist">
74     <script type="text/javascript">
75       writeComponentTabs.call(this);
76     </script>
77   </ul>
78 </div>
79 <script type="text/javascript">
80   writeSubComponentTabs.call(this);
81 </script>
82 <!-- Generated by Doxygen 1.9.6 -->
83 <script type="text/javascript">
84 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
85 var searchBox = new SearchBox("searchBox", "search/",'.html');
86 /* @license-end */
87 </script>
88 </div><!-- top -->
89 <div id="side-nav" class="ui-resizable side-nav-resizable">
90   <div id="nav-tree">
91     <div id="nav-tree-contents">
92       <div id="nav-sync" class="sync"></div>
93     </div>
94   </div>
95   <div id="splitbar" style="-moz-user-select:none;" 
96        class="ui-resizable-handle">
97   </div>
98 </div>
99 <script type="text/javascript">
100 /* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&amp;dn=expat.txt MIT */
101 $(document).ready(function(){initNavTree('system_c_pg.html',''); initResizable(); });
102 /* @license-end */
103 </script>
104 <div id="doc-content">
105 <!-- window showing the filter options -->
106 <div id="MSearchSelectWindow"
107      onmouseover="return searchBox.OnSearchSelectShow()"
108      onmouseout="return searchBox.OnSearchSelectHide()"
109      onkeydown="return searchBox.OnSearchSelectKey(event)">
110 </div>
111
112 <!-- iframe showing the search results (closed by default) -->
113 <div id="MSearchResultsWindow">
114 <div id="MSearchResults">
115 <div class="SRPage">
116 <div id="SRIndex">
117 <div id="SRResults"></div>
118 <div class="SRStatus" id="Loading">Loading...</div>
119 <div class="SRStatus" id="Searching">Searching...</div>
120 <div class="SRStatus" id="NoMatches">No Matches</div>
121 </div>
122 </div>
123 </div>
124 </div>
125
126 <div><div class="header">
127   <div class="headertitle"><div class="title">System Configuration Files system_&lt;Device&gt;.c and system_&lt;Device&gt;.h </div></div>
128 </div><!--header-->
129 <div class="contents">
130 <div class="textblock"><p>The <a class="el" href="system_c_pg.html">System Configuration Files system_&lt;Device&gt;.c and system_&lt;Device&gt;.h</a> provides as a minimum the functions described under <a class="el" href="group__system__init__gr.html">System and Clock Configuration</a>. These functions are device specific and need adaptations. In addition, the file might have configuration settings for the device such as XTAL frequency or PLL prescaler settings.</p>
131 <p>For devices with external memory BUS the system_&lt;Device&gt;.c also configures the BUS system.</p>
132 <p>The silicon vendor might expose other functions (i.e. for power configuration) in the system_&lt;Device&gt;.c file.</p>
133 <p>In case of additional features the function prototypes need to be added to the system_&lt;Device&gt;.h header file.</p>
134 <h1><a class="anchor" id="system_Device_sec"></a>
135 system_Device.c Template File</h1>
136 <p>The <a class="el" href="system_c_pg.html#system_Device_sec">system_Device.c Template File</a> is shown below.</p>
137 <pre class="fragment">/******************************************************************************
138  * @file     system_&lt;Device&gt;.c
139  * @brief    CMSIS Cortex-A Device Peripheral Access Layer 
140  * @version  V1.00
141  * @date     10. January 2018
142  ******************************************************************************/
143 /*
144  * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
145  *
146  * SPDX-License-Identifier: Apache-2.0
147  *
148  * Licensed under the Apache License, Version 2.0 (the License); you may
149  * not use this file except in compliance with the License.
150  * You may obtain a copy of the License at
151  *
152  * www.apache.org/licenses/LICENSE-2.0
153  *
154  * Unless required by applicable law or agreed to in writing, software
155  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
156  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
157  * See the License for the specific language governing permissions and
158  * limitations under the License.
159  */
160
161 #include &lt;stdint.h&gt;
162 #include "&lt;Device&gt;.h" /* ToDo: replace '&lt;Device&gt;' with your device name */
163 #include "irq_ctrl.h"
164
165 /*----------------------------------------------------------------------------
166   Define clocks
167  *----------------------------------------------------------------------------*/
168 /* ToDo: add here your necessary defines for device initialization
169          following is an example for different system frequencies */
170 #define XTAL            (12000000U)       /* Oscillator frequency             */
171
172 #define SYSTEM_CLOCK    (5 * XTAL)
173
174
175 /*----------------------------------------------------------------------------
176   System Core Clock Variable
177  *----------------------------------------------------------------------------*/
178 /* ToDo: initialize SystemCoreClock with the system core clock frequency value
179          achieved after system intitialization.
180          This means system core clock frequency after call to SystemInit() */
181 uint32_t SystemCoreClock = SYSTEM_CLOCK;  /* System Clock Frequency (Core Clock)*/
182
183
184
185 /*----------------------------------------------------------------------------
186   Clock functions
187  *----------------------------------------------------------------------------*/
188
189 void SystemCoreClockUpdate (void)            /* Get Core Clock Frequency      */
190 {
191 /* ToDo: add code to calculate the system frequency based upon the current
192          register settings.
193          This function can be used to retrieve the system core clock frequeny
194          after user changed register sittings. */
195   SystemCoreClock = SYSTEM_CLOCK;
196 }
197
198
199 /*----------------------------------------------------------------------------
200   System Initialization
201  *----------------------------------------------------------------------------*/
202 void SystemInit (void)
203 {
204 /* ToDo: add code to initialize the system
205    Do not use global variables because this function is called before
206    reaching pre-main. RW section may be overwritten afterwards.          */
207   SystemCoreClock = SYSTEM_CLOCK;
208
209   // Invalidate entire Unified TLB
210   __set_TLBIALL(0);
211
212   // Invalidate entire branch predictor array
213   __set_BPIALL(0);
214   __DSB();
215   __ISB();
216
217   //  Invalidate instruction cache and flush branch target cache
218   __set_ICIALLU(0);
219   __DSB();
220   __ISB();
221
222   //  Invalidate data cache
223   L1C_InvalidateDCacheAll();
224   
225   // Create Translation Table
226   MMU_CreateTranslationTable();
227
228   // Enable MMU
229   MMU_Enable();
230
231   // Enable Caches
232   L1C_EnableCaches();
233   L1C_EnableBTAC();
234
235 #if (__L2C_PRESENT == 1) 
236   // Enable GIC
237   L2C_Enable();
238 #endif
239
240 #if ((__FPU_PRESENT == 1) &amp;&amp; (__FPU_USED == 1))
241   // Enable FPU
242   __FPU_Enable();
243 #endif
244
245   // IRQ Initialize
246   IRQ_Initialize();
247 }
248 </pre><h1><a class="anchor" id="system_Device_h_sec"></a>
249 system_Device.h Template File</h1>
250 <p>The system_&lt;Device&gt;.h header file contains prototypes to access the public functions in the system_&lt;device&gt;.c file. The <a class="el" href="system_c_pg.html#system_Device_h_sec">system_Device.h Template File</a> is shown below.</p>
251 <pre class="fragment">/**************************************************************************//**
252  * @file     system_&lt;Device&gt;.h
253  * @brief    CMSIS Cortex-A Device Peripheral Access Layer
254  * @version  V5.00
255  * @date     10. January 2018
256  ******************************************************************************/
257 /*
258  * Copyright (c) 2009-2018 Arm Limited. All rights reserved.
259  *
260  * SPDX-License-Identifier: Apache-2.0
261  *
262  * Licensed under the Apache License, Version 2.0 (the License); you may
263  * not use this file except in compliance with the License.
264  * You may obtain a copy of the License at
265  *
266  * www.apache.org/licenses/LICENSE-2.0
267  *
268  * Unless required by applicable law or agreed to in writing, software
269  * distributed under the License is distributed on an AS IS BASIS, WITHOUT
270  * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
271  * See the License for the specific language governing permissions and
272  * limitations under the License.
273  */
274
275 #ifndef SYSTEM_&lt;Device&gt;_H   /* ToDo: replace '&lt;Device&gt;' with your device name */
276 #define SYSTEM_&lt;Device&gt;_H
277
278 #ifdef __cplusplus
279 extern "C" {
280 #endif
281
282 #include &lt;stdint.h&gt;
283
284 extern uint32_t SystemCoreClock;     /*!&lt; System Clock Frequency (Core Clock)  */
285
286 /**
287   \brief Setup the microcontroller system.
288
289    Initialize the System and update the SystemCoreClock variable.
290  */
291 extern void SystemInit (void);
292
293 /**
294   \brief  Update SystemCoreClock variable.
295
296    Updates the SystemCoreClock with current core Clock retrieved from cpu registers.
297  */
298 extern void SystemCoreClockUpdate (void);
299
300 /**
301   \brief  Create Translation Table.
302
303    Creates Memory Management Unit Translation Table.
304  */
305 extern void MMU_CreateTranslationTable(void);
306
307 #ifdef __cplusplus
308 }
309 #endif
310
311 #endif /* SYSTEM_&lt;Device&gt;_H */
312 </pre> </div></div><!-- contents -->
313 </div><!-- PageDoc -->
314 </div><!-- doc-content -->
315 <!-- start footer part -->
316 <div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
317   <ul>
318     <li class="footer">
319       <script type="text/javascript">
320         <!--
321         writeFooter.call(this);
322         //-->
323       </script> 
324     </li>
325   </ul>
326 </div>
327 </body>
328 </html>