From c05a259ba09d44b4044807c7f373ac3d405f36ba Mon Sep 17 00:00:00 2001 From: Bdale Garbee Date: Sat, 6 Jul 2024 17:56:33 -0600 Subject: [PATCH] working as USB to serial converter on sn 1 --- src/quantimotor-v1/ao_pins.h | 4 +--- src/quantimotor-v1/ao_quantimotor.c | 17 +++++++++++++++-- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/quantimotor-v1/ao_pins.h b/src/quantimotor-v1/ao_pins.h index cb65a6ab..22a731fe 100644 --- a/src/quantimotor-v1/ao_pins.h +++ b/src/quantimotor-v1/ao_pins.h @@ -29,9 +29,7 @@ #define HAS_USB_VBUS 0 #define HAS_USB_PULLUP 1 #define AO_USB_PULLUP_PORT 0 -/* #define AO_USB_PULLUP_PIN 20 */ -/* following is for use of fctester proto as development device */ -#define AO_USB_PULLUP_PIN 6 +#define AO_USB_PULLUP_PIN 20 /* USART */ diff --git a/src/quantimotor-v1/ao_quantimotor.c b/src/quantimotor-v1/ao_quantimotor.c index 18362c2a..d15f248f 100644 --- a/src/quantimotor-v1/ao_quantimotor.c +++ b/src/quantimotor-v1/ao_quantimotor.c @@ -7,11 +7,12 @@ #include static struct ao_task ao_console_read_task; +static struct ao_task ao_console_write_task; static void ao_console_read(void) { - int c; + int c; for (;;) { ao_arch_block_interrupts(); c = _ao_serial0_pollchar(); @@ -24,6 +25,16 @@ ao_console_read(void) } } +static void +ao_console_write(void) +{ + char c; + for (;;) { + c = ao_usb_getchar(); + ao_serial0_putchar(c); + } +} + int main(void) { @@ -38,9 +49,11 @@ main(void) ao_serial_init(); ao_serial0_set_speed(AO_SERIAL_SPEED_115200); - ao_cmd_init(); + /* the command interpreter could interfere with usb -> serial */ + /* ao_cmd_init(); */ ao_add_task(&ao_console_read_task, ao_console_read, "console_read"); + ao_add_task(&ao_console_write_task, ao_console_write, "console_write"); ao_start_scheduler(); return 0; -- 2.47.2