Deploying to gh-pages from @ Klipper3d/klipper@24a1b50e51 🚀

This commit is contained in:
KevinOConnor 2022-07-08 00:04:20 +00:00
parent 66ddba9ac5
commit eb4bc9d6b8
22 changed files with 233 additions and 233 deletions

View file

@ -1389,7 +1389,7 @@
<h2 id="_3">微处理器的代码流<a class="headerlink" href="#_3" title="Permanent link">&para;</a></h2>
<p>微控制器的代码从对应架构的代码(即<strong>src/avr/main.c</strong>)开始执行,前述代码会持续调用<strong>src/sched.c</strong>中的 sched_main() 函数。sched_main() 代码会先运行经 DECL_INIT() 宏标注的所有函数。之后它将不断重复运行由 DECL_TASK() 宏所标注的函数。</p>
<p>其中一个主要的任务函数为<strong>src/command.c</strong> 中的command_dispatch()。上述函数经由微处理器特定的 输入/输出 代码调用(即<strong>src/avr/serial.c</strong>, <strong>src/generic/serial_irq.c</strong>),并执行输入流中的命令所对应的命令函数。命令函数通过 DECL_COMMAND() 宏进行定义 (详情参照<a href="Protocol.html">协议</a> 文档)。</p>
<p>Task, init, and command functions always run with interrupts enabled (however, they can temporarily disable interrupts if needed). These functions should avoid long pauses, delays, or do work that lasts a significant time. (Long delays in these "task" functions result in scheduling jitter for other "tasks" - delays over 100us may become noticeable, delays over 500us may result in command retransmissions, delays over 100ms may result in watchdog reboots.) These functions schedule work at specific times by scheduling timers.</p>
<p>任务、初始化和命令函数始终在启用中断的情况下运行(但是,如果需要,它们可以暂时禁用中断)。这些函数应避免长时间的暂停、延迟或执行持续很长时间的工作。(这些“任务”功能中的长时间延迟会导致其他“任务”的调度抖动 - 超过100us的延迟可能会变得明显超过500us的延迟可能导致命令重传超过100ms的延迟可能导致看门狗触发重启。这些函数通过调度计时器在特定时间安排工作。</p>
<p>定时函数通过调用sched_add_timer() (即 <strong>src/sched.c</strong>)方法进行注册。调度器会在设定的时间点对注册的函数进行调用。定时器中断会在微处理器架构特定的初始化处理器中处理(例如 <strong>src/avr/timer.c</strong>),该代码会调用 <strong>src/sched.c</strong>中的sched_timer_dispatch()。通过定时器中断执行注册的定时函数。定时函数总在中断禁用下运行。定时函数应总能在数微秒内完成。在定时函数结束时,该函数可对自身进行重新定时。</p>
<p>如果事件中抛出错误, 代码可调用shutdown()<strong>src/sched.c</strong>中的sched_shutdown()。调用shutdown()会导致所有标记为DECL_SHUTDOWN()宏的函数被运行。shutdown()总是在禁用中断的情况下运行。</p>
<p>微控制器的大部分功能涉及到通用输入输出引脚GPIO的操作。为了从高级任务代码中抽象出特定架构底层代码所有的GPIO事件都在特定架构的包装器中实现<strong>src/avr/gpio.c</strong>。代码使用gcc的"-flto -fwhole-program "来优化编译以实现内联函数的高性能交叉编译大多数微小的GPIO操作函数内联到它们的调用器中使用这些GPIO将没有任何运行时成本。</p>