void lasershark_process_uart_bridge_command() {
	uint32_t u32_temp;
	uint8_t u8_temp;
	//bool lasershark_output_was_enabled;

	IN2Packet[0] = OUT2Packet[0]; // Put the command sent in the "IN" buffer
	IN2Packet[1] = LASERSHARK_UB_CMD_SUCCESS; // Assume output will be success

	//lasershark_output_was_enabled = lasershark_output_is_enabled();
	//if (lasershark_output_was_enabled) {
	//	// Disable output
	//	lasershark_output_enable(false);
	//}

	switch (OUT2Packet[0]) {
	case LASERSHARK_UB_CMD_TX:
		u8_temp = uart_tx_nonblock(OUT2Packet + 2, OUT2Packet[1]);
		IN2Packet[2] = u8_temp; // Return number of bytes copied.
		break;
	case LASERSHARK_UB_CMD_RX:
		u8_temp = uart_rx_nonblock(IN2Packet + 3, OUT2Packet[1]);
		IN2Packet[2] = u8_temp; // Return number of bytes copied.
		break;
	case LASERSHARK_UB_CMD_RX_READY:
		u8_temp =
				uart_rx_ready() ?
						LASERSHARK_UB_RX_READY : LASERSHARK_UB_RX_NOT_READY;
		IN2Packet[2] = u8_temp;
		break;
	case LASERSHARK_UB_CMD_MAX_RX:
		u8_temp = LASERSHARK_UB_MAX_RX_SIZE;
		IN2Packet[2] = u8_temp;
		break;
	case LASERSHARK_UB_CMD_MAX_TX:
		u8_temp = LASERSHARK_UB_MAX_TX_SIZE;
		IN2Packet[2] = u8_temp;
		break;
	case LASERSHARK_UB_CMD_CLEAR_RX_FIFO:
		uart_rx_clear_fifo();
		break;
	case LASERSHARK_UB_CMD_VERSION:
		u32_temp = LASERSHARK_UB_VERSION;
		memcpy(IN2Packet + 2, &u32_temp, sizeof(uint32_t));
		break;
	default:
		IN2Packet[1] = LASERSHARK_UB_CMD_UNKNOWN;
		break;
	}

	//if (!lasershark_output_was_enabled) {
	//	// Re-enable output.
	//	lasershark_output_enable(true);
	//}
	return;

}
Beispiel #2
0
char uart_read_byte (unsigned dev)
{
    while (!uart_rx_ready(dev))
        ;
    switch (dev)
    {
    case 0:
        return URXH0;
        break;
    case 1:
        return URXH1;
        break;
    case 2:
        return URXH2;
        break;
    }
    
    return '\0';
}
Beispiel #3
0
/**
 * The main function.
 */
int main(void) {

    /* Initialization */
    init_qfly();
    log_s("receiver initialization ... ok\n");

    /* Our loop */
    while (1) {

        /* Wait 100ms */
        _delay_ms(100);

#ifdef UART_AVAILABLE
        if (uart_rx_ready()) {
            uart_tx("Echo: ");
            uart_tx(uart_rx());
            uart_tx("\n");
        }
#endif /* UART_AVAILABLE */
    }

    /* Finally. (Never ever) */
    return 0;
}