From: Bdale Garbee Date: Wed, 3 Jul 2024 23:55:32 +0000 (-0600) Subject: quantimotor: serial port receive to usb serial emulation working X-Git-Url: https://git.gag.com/?a=commitdiff_plain;h=5ac03c8e83ac98efe6ff1878057a3f695b40add9;p=fw%2Faltos quantimotor: serial port receive to usb serial emulation working --- diff --git a/src/quantimotor-v1/Makefile b/src/quantimotor-v1/Makefile index c5e56dce..d033f920 100644 --- a/src/quantimotor-v1/Makefile +++ b/src/quantimotor-v1/Makefile @@ -29,9 +29,7 @@ ALTOS_SRC = \ ao_convert_volt.c \ ao_task.c \ ao_cmd.c \ - ao_config.c \ ao_timer_lpc.c \ - ao_exti_lpc.c \ ao_romconfig.c \ ao_adc_lpc.c \ ao_serial_lpc.c \ diff --git a/src/quantimotor-v1/ao_pins.h b/src/quantimotor-v1/ao_pins.h index 963908e1..cb65a6ab 100644 --- a/src/quantimotor-v1/ao_pins.h +++ b/src/quantimotor-v1/ao_pins.h @@ -29,7 +29,9 @@ #define HAS_USB_VBUS 0 #define HAS_USB_PULLUP 1 #define AO_USB_PULLUP_PORT 0 -#define AO_USB_PULLUP_PIN 20 +/* #define AO_USB_PULLUP_PIN 20 */ +/* following is for use of fctester proto as development device */ +#define AO_USB_PULLUP_PIN 6 /* USART */ diff --git a/src/quantimotor-v1/ao_quantimotor.c b/src/quantimotor-v1/ao_quantimotor.c index 5ee30d74..18362c2a 100644 --- a/src/quantimotor-v1/ao_quantimotor.c +++ b/src/quantimotor-v1/ao_quantimotor.c @@ -4,24 +4,44 @@ */ #include -#include #include +static struct ao_task ao_console_read_task; + +static void +ao_console_read(void) +{ + int c; + for (;;) { + ao_arch_block_interrupts(); + c = _ao_serial0_pollchar(); + ao_arch_release_interrupts(); + if (c == AO_READ_AGAIN) { + flush(); + c = ao_serial0_getchar(); + } + ao_usb_putchar((char) c); + } +} + int main(void) { ao_clock_init(); ao_task_init(); ao_timer_init(); - ao_exti_init(); ao_adc_init(); ao_usb_init(); + ao_serial_init(); + ao_serial0_set_speed(AO_SERIAL_SPEED_115200); ao_cmd_init(); - ao_config_init(); + + ao_add_task(&ao_console_read_task, ao_console_read, "console_read"); ao_start_scheduler(); + return 0; }