void xio_queue_RX_char_usart(const uint8_t dev, const char c) { struct xioDEVICE *d = &ds[dev]; // init device struct pointer struct xioUSART *dx = ((struct xioUSART *)(ds[dev].x));// init USART pointer // trap signals - do not insert into RX queue if (c == CHAR_ABORT) { // trap Kill signal d->signal = XIO_SIG_ABORT; // set signal value sig_abort(); // call app-specific sig handler return; } if (c == CHAR_FEEDHOLD) { // trap feedhold signal d->signal = XIO_SIG_FEEDHOLD; sig_feedhold(); return; } if (c == CHAR_CYCLE_START) { // trap cycle start signal d->signal = XIO_SIG_CYCLE_START; sig_cycle_start(); return; } // normal path if ((--dx->rx_buf_head) == 0) { // wrap condition dx->rx_buf_head = RX_BUFFER_SIZE-1; // -1 avoids the off-by-one err } if (dx->rx_buf_head != dx->rx_buf_tail) {// write char unless buffer full dx->rx_buf[dx->rx_buf_head] = c; // FAKE INPUT DATA return; } // buffer-full handling if ((++dx->rx_buf_head) > RX_BUFFER_SIZE-1) { // reset the head dx->rx_buf_head = 1; } }
static void _switch_isr_helper(uint8_t sw_flag, uint8_t axis) { if (sw.lockout_count != 0) return; // exit if you are in a debounce lockout if (cfg.a[axis].switch_mode == SW_MODE_DISABLED) return; sw.lockout_count = SW_LOCKOUT_TICKS; // start the debounce lockout timer sw.thrown = true; // triggers the switch handler tasks sw.flags[sw_flag] = true; if (cm.cycle_state == CYCLE_HOMING) { sig_feedhold(); // do not reset the switch flag array } else { if ((cfg.a[axis].switch_mode == SW_MODE_ENABLED_NO) || (cfg.a[axis].switch_mode == SW_MODE_ENABLED_NC)) { // only fire abort if fully enabled sig_abort(); // do not reset the switch flag array } } }