⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main_8c-source.html

📁 使用AVR单片机控制步进电机的软件代码
💻 HTML
📖 第 1 页 / 共 2 页
字号:
00111                 okCmd = <a class="code" href="global_8h.html#a0">TRUE</a>;00112                 <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"\n\r  "</span>);00113               }00114             }00115           }00116         }00117       }00118       <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[0] == <span class="charliteral">'a'</span>){00119         <span class="comment">// Set acceleration.</span>00120         <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[1] == <span class="charliteral">' '</span>){00121           acceleration = atoi((<span class="keywordtype">char</span> <span class="keyword">const</span> *)<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>+2);00122           okCmd = <a class="code" href="global_8h.html#a0">TRUE</a>;00123         }00124       }00125       <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[0] == <span class="charliteral">'d'</span>){00126         <span class="comment">// Set deceleration.</span>00127         <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[1] == <span class="charliteral">' '</span>){00128           deceleration = atoi((<span class="keywordtype">char</span> <span class="keyword">const</span> *)<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>+2);00129           okCmd = <a class="code" href="global_8h.html#a0">TRUE</a>;00130         }00131       }00132       <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[0] == <span class="charliteral">'s'</span>){00133         <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[1] == <span class="charliteral">' '</span>){00134           speed = atoi((<span class="keywordtype">char</span> <span class="keyword">const</span> *)<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>+2);00135           okCmd = <a class="code" href="global_8h.html#a0">TRUE</a>;00136         }00137       }00138       <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[0] == 13){00139         <a class="code" href="speed__cntr_8h.html#a12">speed_cntr_Move</a>(steps, acceleration, deceleration, speed);00140         okCmd = <a class="code" href="global_8h.html#a0">TRUE</a>;00141       }00142       <span class="keywordflow">else</span> <span class="keywordflow">if</span>(<a class="code" href="uart_8c.html#a1">UART_RxBuffer</a>[0] == <span class="charliteral">'?'</span>){00143         <a class="code" href="main_8c.html#a2">ShowHelp</a>();00144         okCmd = <a class="code" href="global_8h.html#a0">TRUE</a>;00145       }00146 00147       <span class="comment">// Send help if invalid command is received.</span>00148       <span class="keywordflow">if</span>(okCmd != <a class="code" href="global_8h.html#a0">TRUE</a>)00149         <a class="code" href="main_8c.html#a2">ShowHelp</a>();00150 00151       <span class="comment">// Clear RXbuffer.</span>00152       <a class="code" href="main_8c.html#a0">status</a>.<a class="code" href="structGLOBAL__FLAGS.html#o0">cmd</a> = <a class="code" href="global_8h.html#a1">FALSE</a>;00153       <a class="code" href="uart_8c.html#a10">uart_FlushRxBuffer</a>();00154 00155       <span class="keywordflow">if</span>(<a class="code" href="main_8c.html#a0">status</a>.<a class="code" href="structGLOBAL__FLAGS.html#o2">running</a> == <a class="code" href="global_8h.html#a0">TRUE</a>){00156         <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"Running..."</span>);00157         <span class="keywordflow">while</span>(<a class="code" href="main_8c.html#a0">status</a>.<a class="code" href="structGLOBAL__FLAGS.html#o2">running</a> == <a class="code" href="global_8h.html#a0">TRUE</a>);00158         <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"OK\n\r"</span>);00159       }00160 00161       <a class="code" href="main_8c.html#a3">ShowData</a>(<a class="code" href="sm__driver_8c.html#a5">stepPosition</a>, acceleration, deceleration, speed, steps);00162     }<span class="comment">//end if(cmd)</span>00163   }<span class="comment">//end while(1)</span>00164 }00165 <a name="l00167"></a><a class="code" href="main_8c.html#a1">00167</a> __flash <span class="keywordtype">char</span> <a class="code" href="main_8c.html#a1">Help</a>[] = {<span class="stringliteral">"\n\r--------------------------------------------------------------\n\rAtmel AVR446 - Linear speed control of stepper motor\n\r\n\r?        - Show help\n\ra [data] - Set acceleration (range: 71 - 32000)\n\rd [data] - Set deceleration (range: 71 - 32000)\n\rs [data] - Set speed (range: 12 - motor limit)\n\rm [data] - Move [data] steps (range: -64000 - 64000)\n\rmove [steps] [accel] [decel] [speed]\n\r         - Move with all parameters given\n\r&lt;enter&gt;  - Repeat last move\n\r\n\r    acc/dec data given in 0.01*rad/sec^2 (100 = 1 rad/sec^2)\n\r    speed data given in 0.01*rad/sec (100 = 1 rad/sec)\n\r--------------------------------------------------------------\n\r"</span>};00168 <a name="l00173"></a><a class="code" href="main_8c.html#a2">00173</a> <span class="keywordtype">void</span> <a class="code" href="main_8c.html#a2">ShowHelp</a>(<span class="keywordtype">void</span>)00174 {00175   <span class="keywordtype">unsigned</span> <span class="keywordtype">int</span> i = 0;00176   <span class="keywordflow">while</span>(<a class="code" href="main_8c.html#a1">Help</a>[i] != 0)00177     <a class="code" href="uart_8h.html#a8">uart_SendByte</a>(<a class="code" href="main_8c.html#a1">Help</a>[i++]);00178 }00179 <a name="l00190"></a><a class="code" href="main_8c.html#a3">00190</a> <span class="keywordtype">void</span> <a class="code" href="main_8c.html#a3">ShowData</a>(<span class="keywordtype">int</span> position, <span class="keywordtype">int</span> acceleration, <span class="keywordtype">int</span> deceleration, <span class="keywordtype">int</span> speed, <span class="keywordtype">int</span> steps)00191 {00192   <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"\n\r  Motor pos: "</span>);00193   <a class="code" href="uart_8h.html#a10">uart_SendInt</a>(position);00194   <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"    a:"</span>);00195   <a class="code" href="uart_8h.html#a10">uart_SendInt</a>(acceleration);00196   <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"  d:"</span>);00197   <a class="code" href="uart_8h.html#a10">uart_SendInt</a>(deceleration);00198   <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"  s:"</span>);00199   <a class="code" href="uart_8h.html#a10">uart_SendInt</a>(speed);00200   <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"  m:"</span>);00201   <a class="code" href="uart_8h.html#a10">uart_SendInt</a>(steps);00202   <a class="code" href="uart_8h.html#a9">uart_SendString</a>(<span class="stringliteral">"\n\r&gt; "</span>);00203 }00204 </div></pre><hr size="1"><address style="align: right;"><small>Generated on Mon May 8 15:05:03 2006 for AVR446 - Linear speed control of stepper motor by<a href="http://www.doxygen.org/index.html"><img src="doxygen.png" alt="doxygen" align="middle" border=0 ></a> 1.3.7 </small></address></body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -