Files
-
hardware / rev0 / debug_control_connections.sch
-
hardware / rev0 / fpga_configuration.sch
-
hardware / rev0 / host_side.sch
-
hardware / rev0 / luna_rev0.kicad_pcb
-
hardware / rev0 / luna_rev0.sch
-
hardware / rev0 / power_supplies.sch
-
hardware / rev0 / ram_section.sch
-
hardware / rev0 / right_side_indicators.sch
-
hardware / rev0 / sideband_side.sch
-
hardware / rev0 / target_side.sch
Last update 5 years 4 months
by Kate Temkin
Filesfirmwareapollosrc | |
---|---|
.. | |
boards | |
console.c | |
console.h | |
debug_spi.c | |
debug_spi.h | |
fpga.h | |
jtag.c | |
jtag.h | |
jtag_tap.c | |
led.h | |
main.c | |
uart.h | |
vendor.c |
console.c/** * Console handling code. * This file is part of LUNA. */ #include <tusb.h> #include "led.h" #include "uart.h" extern bool uart_active; /** * Pass any data received via UART directly up to the host. */ void uart_byte_received_cb(uint8_t byte) { tud_cdc_write_char(byte); tud_cdc_write_flush(); } /** * Main task that handles console I/O. */ void console_task(void) { if (!tud_cdc_connected()) { return; } // We can send data to the FPGA over UART iff: // - there's data waiting for us to send, and // - the UART has room in its FIFO // // If both conditions are met, send data. while (uart_ready_for_write() && tud_cdc_available()) { uint8_t byte = tud_cdc_read_char(); uart_nonblocking_write(byte); } } // // We defer initializing our UART until we get a CDC connection. // // This prevents contention if the FPGA lines are used for something else, // but makes everything seem to Just Work (TM) once the user starts using // the CDC-ACM connection. // /** * Call-back issued when the host's line-coding changes. */ void tud_cdc_line_coding_cb(uint8_t itf, cdc_line_coding_t const* coding) { uart_init(true, coding->bit_rate); } /** * Other callbacks: if our UART isn't active, initialize it. */ void tud_cdc_rx_wanted_cb(uint8_t itf, char wanted_char) { if (!uart_active) { uart_init(true, 115200); } } void tud_cdc_line_state_cb(uint8_t itf, bool dtr, bool rts) { if (!uart_active) { uart_init(true, 115200); } }