forked from ZhuYanzhen1/miniFOC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflash_8c_source.html
183 lines (181 loc) · 32.8 KB
/
flash_8c_source.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://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=11"/>
<meta name="generator" content="Doxygen 1.9.4"/>
<meta name="viewport" content="width=device-width, initial-scale=1"/>
<title>miniFOC: hardware/flash.c Source File</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="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>
<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 id="projectrow">
<td id="projectlogo"><img alt="Logo" src="Acme_LOGO.png"/></td>
<td id="projectalign">
<div id="projectname">miniFOC<span id="projectnumber"> 1.0.3</span>
</div>
<div id="projectbrief">This open-source project aims to accomplish a FOC(Field Oriented Control) scheme that is operatable with minimum costs in China.</div>
</td>
</tr>
</tbody>
</table>
</div>
<!-- end header part -->
<!-- Generated by Doxygen 1.9.4 -->
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
var searchBox = new SearchBox("searchBox", "search",'Search','.html');
/* @license-end */
</script>
<script type="text/javascript" src="menudata.js"></script>
<script type="text/javascript" src="menu.js"></script>
<script type="text/javascript">
/* @license magnet:?xt=urn:btih:d3d9a9a6595521f9666a5e94cc830dab83b65699&dn=expat.txt MIT */
$(function() {
initMenu('',true,false,'search.php','Search');
$(document).ready(function() { init_search(); });
});
/* @license-end */
</script>
<div id="main-nav"></div>
<!-- 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 id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="dir_42e555215cde261dd5295a864caa3e52.html">hardware</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="headertitle"><div class="title">flash.c</div></div>
</div><!--header-->
<div class="contents">
<a href="flash_8c.html">Go to the documentation of this file.</a><div class="fragment"><div class="line"><a id="l00001" name="l00001"></a><span class="lineno"> 1</span><span class="comment">/**************************************************************************/</span></div>
<div class="line"><a id="l00011" name="l00011"></a><span class="lineno"> 11</span><span class="preprocessor">#include "<a class="code" href="main_8h.html">main.h</a>"</span></div>
<div class="line"><a id="l00012" name="l00012"></a><span class="lineno"> 12</span> </div>
<div class="line"><a id="l00020" name="l00020"></a><span class="lineno"><a class="line" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292"> 20</a></span><span class="preprocessor">#define JUDGE_AVAILABLE(x, minimum, maximum) if (x > maximum || x < minimum) \</span></div>
<div class="line"><a id="l00021" name="l00021"></a><span class="lineno"> 21</span><span class="preprocessor"> x = 0</span></div>
<div class="line"><a id="l00022" name="l00022"></a><span class="lineno"> 22</span> </div>
<div class="line"><a id="l00026" name="l00026"></a><span class="lineno"><a class="line" href="flash_8c.html#aa281b78d45017220d214a274f0c3e2c9"> 26</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="flash_8c.html#aa281b78d45017220d214a274f0c3e2c9">flash_write_parameters</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00027" name="l00027"></a><span class="lineno"> 27</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> buffer[11] = {<a class="code hl_variable" href="encoder_8c.html#a562eacc7259f25574b1ab8ce9d7c6a3e">machine_angle_offset</a>, <a class="code hl_variable" href="foc_8c.html#ad335385ea3909d9485703d97735b34ca">phase_sequence</a>, 0x00000000UL, 0x00000000UL, 0x00000000UL,</div>
<div class="line"><a id="l00028" name="l00028"></a><span class="lineno"> 28</span> 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL, 0x00000000UL};</div>
<div class="line"><a id="l00029" name="l00029"></a><span class="lineno"> 29</span> buffer[2] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">kp</a>);</div>
<div class="line"><a id="l00030" name="l00030"></a><span class="lineno"> 30</span> buffer[3] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">ki</a>);</div>
<div class="line"><a id="l00031" name="l00031"></a><span class="lineno"> 31</span> buffer[4] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">kd</a>);</div>
<div class="line"><a id="l00032" name="l00032"></a><span class="lineno"> 32</span> buffer[5] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">sum_maximum</a>);</div>
<div class="line"><a id="l00033" name="l00033"></a><span class="lineno"> 33</span> buffer[6] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">kp</a>);</div>
<div class="line"><a id="l00034" name="l00034"></a><span class="lineno"> 34</span> buffer[7] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">ki</a>);</div>
<div class="line"><a id="l00035" name="l00035"></a><span class="lineno"> 35</span> buffer[8] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">kd</a>);</div>
<div class="line"><a id="l00036" name="l00036"></a><span class="lineno"> 36</span> buffer[9] = <a class="code hl_function" href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">sum_maximum</a>);</div>
<div class="line"><a id="l00037" name="l00037"></a><span class="lineno"> 37</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="pid_8c.html#a48934d9569b54761658f7fe0484db10c">pid_parameter_available_flag</a> == 1)</div>
<div class="line"><a id="l00038" name="l00038"></a><span class="lineno"> 38</span> buffer[10] = 0xA5A5A5A5UL;</div>
<div class="line"><a id="l00039" name="l00039"></a><span class="lineno"> 39</span> <a class="code hl_function" href="flash_8c.html#ac0d03d56de1c227449fe6628980cc12f">flash_erase_page</a>();</div>
<div class="line"><a id="l00040" name="l00040"></a><span class="lineno"> 40</span> <a class="code hl_function" href="flash_8c.html#af30bf1694be8902e66ba2f5e30791b48">flash_program_word</a>(0x00000000UL, buffer, 11);</div>
<div class="line"><a id="l00041" name="l00041"></a><span class="lineno"> 41</span>}</div>
<div class="line"><a id="l00042" name="l00042"></a><span class="lineno"> 42</span> </div>
<div class="line"><a id="l00046" name="l00046"></a><span class="lineno"><a class="line" href="flash_8c.html#aaef765344f91439176e3223a0f51f4d0"> 46</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="flash_8c.html#aaef765344f91439176e3223a0f51f4d0">flash_read_parameters</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00047" name="l00047"></a><span class="lineno"> 47</span> <a class="code hl_variable" href="encoder_8c.html#a562eacc7259f25574b1ab8ce9d7c6a3e">machine_angle_offset</a> = <a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000000UL);</div>
<div class="line"><a id="l00048" name="l00048"></a><span class="lineno"> 48</span> <a class="code hl_variable" href="foc_8c.html#ad335385ea3909d9485703d97735b34ca">phase_sequence</a> = <a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000004UL);</div>
<div class="line"><a id="l00049" name="l00049"></a><span class="lineno"> 49</span> <a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">kp</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000008UL));</div>
<div class="line"><a id="l00050" name="l00050"></a><span class="lineno"> 50</span> <a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">ki</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000012UL));</div>
<div class="line"><a id="l00051" name="l00051"></a><span class="lineno"> 51</span> <a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">kd</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000016UL));</div>
<div class="line"><a id="l00052" name="l00052"></a><span class="lineno"> 52</span> <a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">sum_maximum</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000020UL));</div>
<div class="line"><a id="l00053" name="l00053"></a><span class="lineno"> 53</span> <a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">kp</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000024UL));</div>
<div class="line"><a id="l00054" name="l00054"></a><span class="lineno"> 54</span> <a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">ki</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000028UL));</div>
<div class="line"><a id="l00055" name="l00055"></a><span class="lineno"> 55</span> <a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">kd</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000032UL));</div>
<div class="line"><a id="l00056" name="l00056"></a><span class="lineno"> 56</span> <a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">sum_maximum</a> = <a class="code hl_function" href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a>(<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000036UL));</div>
<div class="line"><a id="l00057" name="l00057"></a><span class="lineno"> 57</span> <span class="keywordflow">if</span> (<a class="code hl_variable" href="encoder_8c.html#a562eacc7259f25574b1ab8ce9d7c6a3e">machine_angle_offset</a> > 4096 || <a class="code hl_variable" href="foc_8c.html#ad335385ea3909d9485703d97735b34ca">phase_sequence</a> > 1)</div>
<div class="line"><a id="l00058" name="l00058"></a><span class="lineno"> 58</span> <a class="code hl_variable" href="foc_8c.html#a418bbe3f3019eaefea9f904a87cf0a05">foc_parameter_available_flag</a> = 0;</div>
<div class="line"><a id="l00059" name="l00059"></a><span class="lineno"> 59</span> <span class="keywordflow">if</span> (<a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(0x00000040UL) != 0xA5A5A5A5UL)</div>
<div class="line"><a id="l00060" name="l00060"></a><span class="lineno"> 60</span> <a class="code hl_variable" href="pid_8c.html#a48934d9569b54761658f7fe0484db10c">pid_parameter_available_flag</a> = 0;</div>
<div class="line"><a id="l00061" name="l00061"></a><span class="lineno"> 61</span> </div>
<div class="line"><a id="l00062" name="l00062"></a><span class="lineno"> 62</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">kp</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00063" name="l00063"></a><span class="lineno"> 63</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">ki</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00064" name="l00064"></a><span class="lineno"> 64</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">kd</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00065" name="l00065"></a><span class="lineno"> 65</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">sum_maximum</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00066" name="l00066"></a><span class="lineno"> 66</span> </div>
<div class="line"><a id="l00067" name="l00067"></a><span class="lineno"> 67</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">kp</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00068" name="l00068"></a><span class="lineno"> 68</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">ki</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00069" name="l00069"></a><span class="lineno"> 69</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">kd</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00070" name="l00070"></a><span class="lineno"> 70</span> <a class="code hl_define" href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a>(<a class="code hl_variable" href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a>.<a class="code hl_variable" href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">sum_maximum</a>, 10.0f, -10.0f);</div>
<div class="line"><a id="l00071" name="l00071"></a><span class="lineno"> 71</span>}</div>
<div class="line"><a id="l00072" name="l00072"></a><span class="lineno"> 72</span> </div>
<div class="line"><a id="l00076" name="l00076"></a><span class="lineno"><a class="line" href="flash_8c.html#ac0d03d56de1c227449fe6628980cc12f"> 76</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="flash_8c.html#ac0d03d56de1c227449fe6628980cc12f">flash_erase_page</a>(<span class="keywordtype">void</span>) {</div>
<div class="line"><a id="l00077" name="l00077"></a><span class="lineno"> 77</span> <span class="comment">/* unlock the flash program/erase controller */</span></div>
<div class="line"><a id="l00078" name="l00078"></a><span class="lineno"> 78</span> fmc_unlock();</div>
<div class="line"><a id="l00079" name="l00079"></a><span class="lineno"> 79</span> fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_WPERR | FMC_FLAG_PGERR);</div>
<div class="line"><a id="l00080" name="l00080"></a><span class="lineno"> 80</span> </div>
<div class="line"><a id="l00081" name="l00081"></a><span class="lineno"> 81</span> <span class="comment">/* erase the flash page */</span></div>
<div class="line"><a id="l00082" name="l00082"></a><span class="lineno"> 82</span> fmc_page_erase(<a class="code hl_define" href="config_8h.html#a17c58df3fba73bc0fe08b011bc3d404f">FMC_WRITE_START_ADDR</a>);</div>
<div class="line"><a id="l00083" name="l00083"></a><span class="lineno"> 83</span> fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_WPERR | FMC_FLAG_PGERR);</div>
<div class="line"><a id="l00084" name="l00084"></a><span class="lineno"> 84</span> </div>
<div class="line"><a id="l00085" name="l00085"></a><span class="lineno"> 85</span> <span class="comment">/* lock the main FMC after the erase operation */</span></div>
<div class="line"><a id="l00086" name="l00086"></a><span class="lineno"> 86</span> fmc_lock();</div>
<div class="line"><a id="l00087" name="l00087"></a><span class="lineno"> 87</span>}</div>
<div class="line"><a id="l00088" name="l00088"></a><span class="lineno"> 88</span> </div>
<div class="line"><a id="l00095" name="l00095"></a><span class="lineno"><a class="line" href="flash_8c.html#af30bf1694be8902e66ba2f5e30791b48"> 95</a></span><span class="keywordtype">void</span> <a class="code hl_function" href="flash_8c.html#af30bf1694be8902e66ba2f5e30791b48">flash_program_word</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> addr, <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *data, <span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> counter) {</div>
<div class="line"><a id="l00096" name="l00096"></a><span class="lineno"> 96</span> <span class="comment">/* unlock the flash program/erase controller */</span></div>
<div class="line"><a id="l00097" name="l00097"></a><span class="lineno"> 97</span> fmc_unlock();</div>
<div class="line"><a id="l00098" name="l00098"></a><span class="lineno"> 98</span> </div>
<div class="line"><a id="l00099" name="l00099"></a><span class="lineno"> 99</span> <span class="comment">/* program flash */</span></div>
<div class="line"><a id="l00100" name="l00100"></a><span class="lineno"> 100</span> <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span> data_cnt = 0; data_cnt < counter; data_cnt++) {</div>
<div class="line"><a id="l00101" name="l00101"></a><span class="lineno"> 101</span> fmc_word_program(addr + <a class="code hl_define" href="config_8h.html#a17c58df3fba73bc0fe08b011bc3d404f">FMC_WRITE_START_ADDR</a> + 4 * data_cnt, data[data_cnt]);</div>
<div class="line"><a id="l00102" name="l00102"></a><span class="lineno"> 102</span> fmc_flag_clear(FMC_FLAG_END | FMC_FLAG_WPERR | FMC_FLAG_PGERR);</div>
<div class="line"><a id="l00103" name="l00103"></a><span class="lineno"> 103</span> }</div>
<div class="line"><a id="l00104" name="l00104"></a><span class="lineno"> 104</span> </div>
<div class="line"><a id="l00105" name="l00105"></a><span class="lineno"> 105</span> <span class="comment">/* lock the main FMC after the program operation */</span></div>
<div class="line"><a id="l00106" name="l00106"></a><span class="lineno"> 106</span> fmc_lock();</div>
<div class="line"><a id="l00107" name="l00107"></a><span class="lineno"> 107</span>}</div>
<div class="line"><a id="l00108" name="l00108"></a><span class="lineno"> 108</span> </div>
<div class="line"><a id="l00114" name="l00114"></a><span class="lineno"><a class="line" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c"> 114</a></span><span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> <a class="code hl_function" href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a>(<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> addr) {</div>
<div class="line"><a id="l00115" name="l00115"></a><span class="lineno"> 115</span> <span class="comment">/* redirect the address to access memory */</span></div>
<div class="line"><a id="l00116" name="l00116"></a><span class="lineno"> 116</span> addr = <a class="code hl_define" href="config_8h.html#a17c58df3fba73bc0fe08b011bc3d404f">FMC_WRITE_START_ADDR</a> + addr;</div>
<div class="line"><a id="l00117" name="l00117"></a><span class="lineno"> 117</span> <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *ptrd = (<span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> *) addr;</div>
<div class="line"><a id="l00118" name="l00118"></a><span class="lineno"> 118</span> <span class="keywordflow">return</span> (*ptrd);</div>
<div class="line"><a id="l00119" name="l00119"></a><span class="lineno"> 119</span>}</div>
<div class="ttc" id="aconfig_8h_html_a17c58df3fba73bc0fe08b011bc3d404f"><div class="ttname"><a href="config_8h.html#a17c58df3fba73bc0fe08b011bc3d404f">FMC_WRITE_START_ADDR</a></div><div class="ttdeci">#define FMC_WRITE_START_ADDR</div><div class="ttdoc">User flash space start address, 1KB user flash.</div><div class="ttdef"><b>Definition:</b> <a href="config_8h_source.html#l00044">config.h:44</a></div></div>
<div class="ttc" id="aencoder_8c_html_a562eacc7259f25574b1ab8ce9d7c6a3e"><div class="ttname"><a href="encoder_8c.html#a562eacc7259f25574b1ab8ce9d7c6a3e">machine_angle_offset</a></div><div class="ttdeci">volatile unsigned short machine_angle_offset</div><div class="ttdoc">mechanical angle offset, which is used to align the mechanical angle with the zero point of the elect...</div><div class="ttdef"><b>Definition:</b> <a href="encoder_8c_source.html#l00023">encoder.c:23</a></div></div>
<div class="ttc" id="aflash_8c_html_a1760a04db0927406235efe5f6ebea292"><div class="ttname"><a href="flash_8c.html#a1760a04db0927406235efe5f6ebea292">JUDGE_AVAILABLE</a></div><div class="ttdeci">#define JUDGE_AVAILABLE(x, minimum, maximum)</div><div class="ttdoc">determine whether the read-out variable is within the trusted range</div><div class="ttdef"><b>Definition:</b> <a href="flash_8c_source.html#l00020">flash.c:20</a></div></div>
<div class="ttc" id="aflash_8c_html_a9b7a8ed62067617696d1fa44e1c3117c"><div class="ttname"><a href="flash_8c.html#a9b7a8ed62067617696d1fa44e1c3117c">flash_read_word</a></div><div class="ttdeci">unsigned int flash_read_word(unsigned int addr)</div><div class="ttdoc">read flash word from address</div><div class="ttdef"><b>Definition:</b> <a href="flash_8c_source.html#l00114">flash.c:114</a></div></div>
<div class="ttc" id="aflash_8c_html_aa281b78d45017220d214a274f0c3e2c9"><div class="ttname"><a href="flash_8c.html#aa281b78d45017220d214a274f0c3e2c9">flash_write_parameters</a></div><div class="ttdeci">void flash_write_parameters(void)</div><div class="ttdoc">program all parameters to flash</div><div class="ttdef"><b>Definition:</b> <a href="flash_8c_source.html#l00026">flash.c:26</a></div></div>
<div class="ttc" id="aflash_8c_html_aaef765344f91439176e3223a0f51f4d0"><div class="ttname"><a href="flash_8c.html#aaef765344f91439176e3223a0f51f4d0">flash_read_parameters</a></div><div class="ttdeci">void flash_read_parameters(void)</div><div class="ttdoc">read all parameters from flash</div><div class="ttdef"><b>Definition:</b> <a href="flash_8c_source.html#l00046">flash.c:46</a></div></div>
<div class="ttc" id="aflash_8c_html_ac0d03d56de1c227449fe6628980cc12f"><div class="ttname"><a href="flash_8c.html#ac0d03d56de1c227449fe6628980cc12f">flash_erase_page</a></div><div class="ttdeci">void flash_erase_page(void)</div><div class="ttdoc">erase flash page in last sector</div><div class="ttdef"><b>Definition:</b> <a href="flash_8c_source.html#l00076">flash.c:76</a></div></div>
<div class="ttc" id="aflash_8c_html_af30bf1694be8902e66ba2f5e30791b48"><div class="ttname"><a href="flash_8c.html#af30bf1694be8902e66ba2f5e30791b48">flash_program_word</a></div><div class="ttdeci">void flash_program_word(unsigned int addr, unsigned int *data, unsigned char counter)</div><div class="ttdoc">program flash word to address</div><div class="ttdef"><b>Definition:</b> <a href="flash_8c_source.html#l00095">flash.c:95</a></div></div>
<div class="ttc" id="afoc_8c_html_a418bbe3f3019eaefea9f904a87cf0a05"><div class="ttname"><a href="foc_8c.html#a418bbe3f3019eaefea9f904a87cf0a05">foc_parameter_available_flag</a></div><div class="ttdeci">unsigned char foc_parameter_available_flag</div><div class="ttdoc">flag variable for FOC parameter availability</div><div class="ttdef"><b>Definition:</b> <a href="foc_8c_source.html#l00028">foc.c:28</a></div></div>
<div class="ttc" id="afoc_8c_html_ad335385ea3909d9485703d97735b34ca"><div class="ttname"><a href="foc_8c.html#ad335385ea3909d9485703d97735b34ca">phase_sequence</a></div><div class="ttdeci">volatile unsigned char phase_sequence</div><div class="ttdoc">motor phase sequence flag variable</div><div class="ttdef"><b>Definition:</b> <a href="foc_8c_source.html#l00024">foc.c:24</a></div></div>
<div class="ttc" id="amain_8h_html"><div class="ttname"><a href="main_8h.html">main.h</a></div><div class="ttdoc">main function Header File</div></div>
<div class="ttc" id="apid_8c_html_a48934d9569b54761658f7fe0484db10c"><div class="ttname"><a href="pid_8c.html#a48934d9569b54761658f7fe0484db10c">pid_parameter_available_flag</a></div><div class="ttdeci">unsigned char pid_parameter_available_flag</div><div class="ttdoc">flag variable for PID parameter availability</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00016">pid.c:16</a></div></div>
<div class="ttc" id="apid_8c_html_aaa8f5bad87ffc78a20f06863ab6bad5c"><div class="ttname"><a href="pid_8c.html#aaa8f5bad87ffc78a20f06863ab6bad5c">angle_pid_handler</a></div><div class="ttdeci">volatile PID_Structure_t angle_pid_handler</div><div class="ttdoc">algorithm handler of PID angle loop</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00028">pid.c:28</a></div></div>
<div class="ttc" id="apid_8c_html_ab051c8f4a730b934b146f330514efd95"><div class="ttname"><a href="pid_8c.html#ab051c8f4a730b934b146f330514efd95">speed_pid_handler</a></div><div class="ttdeci">volatile PID_Structure_t speed_pid_handler</div><div class="ttdoc">algorithm handler of PID speed loop</div><div class="ttdef"><b>Definition:</b> <a href="pid_8c_source.html#l00024">pid.c:24</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a050993b7ca6c97e62c1020017f716b91"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a050993b7ca6c97e62c1020017f716b91">PID_Structure_t::ki</a></div><div class="ttdeci">float ki</div><div class="ttdoc">integral term coefficient in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00026">pid.h:26</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a1f7add0f84d583bc2eceb290d6c4cc06"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a1f7add0f84d583bc2eceb290d6c4cc06">PID_Structure_t::kp</a></div><div class="ttdeci">float kp</div><div class="ttdoc">proportional term coefficient in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00025">pid.h:25</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_a51379d672c255e751fb020ef2394a8f0"><div class="ttname"><a href="struct_p_i_d___structure__t.html#a51379d672c255e751fb020ef2394a8f0">PID_Structure_t::sum_maximum</a></div><div class="ttdeci">float sum_maximum</div><div class="ttdoc">maximum of anti saturation integral in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00032">pid.h:32</a></div></div>
<div class="ttc" id="astruct_p_i_d___structure__t_html_ae7a5c6018507bb1361fcca170e069b9c"><div class="ttname"><a href="struct_p_i_d___structure__t.html#ae7a5c6018507bb1361fcca170e069b9c">PID_Structure_t::kd</a></div><div class="ttdeci">float kd</div><div class="ttdoc">differential term coefficient in PID</div><div class="ttdef"><b>Definition:</b> <a href="pid_8h_source.html#l00027">pid.h:27</a></div></div>
<div class="ttc" id="asystem_8c_html_a7bee5a9ca4038926b7fd4c38976d1481"><div class="ttname"><a href="system_8c.html#a7bee5a9ca4038926b7fd4c38976d1481">float_to_int32</a></div><div class="ttdeci">unsigned int float_to_int32(float data0)</div><div class="ttdoc">convert floating point numbers to int32 type data</div><div class="ttdef"><b>Definition:</b> <a href="system_8c_source.html#l00060">system.c:60</a></div></div>
<div class="ttc" id="asystem_8c_html_ade748eddd7c60c3bf4c67bce9c463545"><div class="ttname"><a href="system_8c.html#ade748eddd7c60c3bf4c67bce9c463545">int32_to_float</a></div><div class="ttdeci">float int32_to_float(unsigned int data0)</div><div class="ttdoc">convert int32 to floating point numbers type data</div><div class="ttdef"><b>Definition:</b> <a href="system_8c_source.html#l00070">system.c:70</a></div></div>
</div><!-- fragment --></div><!-- contents -->
<!-- start footer part -->
<hr class="footer"/><address class="footer"><small>
Generated by <a href="https://www.doxygen.org/index.html"><img class="footer" src="doxygen.svg" width="104" height="31" alt="doxygen"/></a> 1.9.4
</small></address>
</body>
</html>