usb_serial.c
uint8_t
serial_read()
{
    uint8_t intr_state, data, ret = SERIAL_NO_DATA;

    if (!usb_configuration)
        return ret;

    intr_state = SREG;
    UENUM = CDC_RX_ENDPOINT;

    usb_wait_io();
    if ((UEBCLX == 0)) { // Empty buffer => flush it
        UEINTX = 0x6B;
        goto exit;
    }

    // take one byte out of the buffer
    data = UEDATX;
    switch (ret) {
        case CMD_STATUS_REPORT:
            bit_true_atomic(sys.execute, EXEC_STATUS_REPORT);
            break; // Set as true
        case CMD_CYCLE_START:
            bit_true_atomic(sys.execute, EXEC_CYCLE_START);
            break; // Set as true
        case CMD_FEED_HOLD:
            bit_true_atomic(sys.execute, EXEC_FEED_HOLD);
            break; // Set as true
        case CMD_RESET:
            mc_reset();
            break; // Call motion control reset routine.
        default:
            ret = data;
            break;
    }


    RXLED1;
    rx_led_pulse = TX_RX_LED_PULSE_MS;
exit:
    SREG = intr_state;

    return ret;
}
// Fetches the first byte in the serial read buffer. Called by main program.
Fetches the first byte in the serial read buffer. Called by main program.
Fetches the first byte in the serial read buffer . Called by main program .
uint8_t
serial_read()
{
    uint8_t intr_state, data, ret = SERIAL_NO_DATA;
    if (!usb_configuration)
        return ret;
    intr_state = SREG;
    UENUM = CDC_RX_ENDPOINT;
    usb_wait_io();
    if ((UEBCLX == 0)) { 
        UEINTX = 0x6B;
        goto exit;
    }
    data = UEDATX;
    switch (ret) {
        case CMD_STATUS_REPORT:
            bit_true_atomic(sys.execute, EXEC_STATUS_REPORT);
            break; 
        case CMD_CYCLE_START:
            bit_true_atomic(sys.execute, EXEC_CYCLE_START);
            break; 
        case CMD_FEED_HOLD:
            bit_true_atomic(sys.execute, EXEC_FEED_HOLD);
            break; 
        case CMD_RESET:
            mc_reset();
            break; 
        default:
            ret = data;
            break;
    }
    RXLED1;
    rx_led_pulse = TX_RX_LED_PULSE_MS;
exit:
    SREG = intr_state;
    return ret;
}
uint8_t serial_read ( ) { uint8_t intr_state , data , ret = SERIAL_NO_DATA ; if ( ! usb_configuration ) return ret ; intr_state = SREG ; UENUM = CDC_RX_ENDPOINT ; usb_wait_io ( ) ; if ( ( UEBCLX == 0 ) ) { UEINTX = 0x6B ; goto exit ; } data = UEDATX ; switch ( ret ) { case CMD_STATUS_REPORT : bit_true_atomic ( sys . execute , EXEC_STATUS_REPORT ) ; break ; case CMD_CYCLE_START : bit_true_atomic ( sys . execute , EXEC_CYCLE_START ) ; break ; case CMD_FEED_HOLD : bit_true_atomic ( sys . execute , EXEC_FEED_HOLD ) ; break ; case CMD_RESET : mc_reset ( ) ; break ; default : ret = data ; break ; } RXLED1 ; rx_led_pulse = TX_RX_LED_PULSE_MS ; exit : SREG = intr_state ; return ret ; }
Fetches the first byte in the serial read buffer.
Fetches the first byte in the serial read buffer .
// Empty buffer => flush it // take one byte out of the buffer // Set as true // Set as true // Set as true // Call motion control reset routine.