estop_latch.comp
来自「CNC 的开放码,EMC2 V2.2.8版」· COMP 代码 · 共 34 行
COMP
34 行
component estop_latch "ESTOP latch which sets ok-out true and fault-out false only if ok-in is true, fault-in is false, and a rising edge is seen on reset. While ok-out is true, watchdog toggles, and can be used for chargepumps or similar needs.";pin in bit ok_in;pin in bit fault_in;pin in bit reset;pin out bit ok_out;pin out bit fault_out;pin out bit watchdog;function _ nofp;option data estop_data;license "GPL";;;typedef struct { int old_reset; } estop_data;FUNCTION(_) { /* check inputs */ if ( ok_in && !fault_in) { /* no fault conditions, check for reset edge */ if ( reset && !data.old_reset ) { /* got a rising edge, indicate "OK" on outputs */ ok_out = 1; fault_out = 0; } /* toggle watchdog */ watchdog = !watchdog; } else { /* fault condition exists, trip */ ok_out = 0; fault_out = 1; } /* store state of reset input for next pass (for edge detect) */ data.old_reset = reset;}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?