From b23ac7ea00ec26779354869765ced9caa2d05738 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 19 Feb 2023 15:45:29 -0800 Subject: [PATCH] altos/stm32f103-nucleo: Use more bits Get the OS running, use the serial for console Signed-off-by: Keith Packard --- src/stm32f103-nucleo/.gitignore | 2 ++ src/stm32f103-nucleo/Makefile | 18 ++++++++++++++++-- src/stm32f103-nucleo/ao_pins.h | 13 +++++++++++++ src/stm32f103-nucleo/hello.c | 24 ++++++++++++++---------- 4 files changed, 45 insertions(+), 12 deletions(-) create mode 100644 src/stm32f103-nucleo/.gitignore diff --git a/src/stm32f103-nucleo/.gitignore b/src/stm32f103-nucleo/.gitignore new file mode 100644 index 00000000..5c7fb91f --- /dev/null +++ b/src/stm32f103-nucleo/.gitignore @@ -0,0 +1,2 @@ +ao_product.h +nucleo-*.elf diff --git a/src/stm32f103-nucleo/Makefile b/src/stm32f103-nucleo/Makefile index 3adc4acf..b6abf8c4 100644 --- a/src/stm32f103-nucleo/Makefile +++ b/src/stm32f103-nucleo/Makefile @@ -5,6 +5,8 @@ INC = \ ao_pins.h \ ao_arch.h \ ao_arch_funcs.h \ + ao_exti.h \ + ao_product.h \ stm32f1.h \ Makefile @@ -12,7 +14,19 @@ ALTOS_SRC = \ ao_clock.c \ ao_timer.c \ ao_interrupt.c \ - ao_led.c + ao_product.c \ + ao_romconfig.c \ + ao_led.c \ + ao_task.c \ + ao_panic.c \ + ao_stdio.c \ + ao_serial_stm.c \ + ao_usb_stm.c \ + ao_cmd.c + +PRODUCT=Nucleo-f103 +PRODUCT_DEF=-DNUCLEO_F103 +IDPRODUCT=0x000a CFLAGS = $(PRODUCT_DEF) $(STM32F1_CFLAGS) @@ -26,7 +40,7 @@ OBJ=$(SRC:.c=.o) all: $(PROG) $(HEX) $(PROG): Makefile $(OBJ) - $(call quiet,CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) --oslib=semihost + $(call quiet,CC) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) $(OBJ): $(INC) diff --git a/src/stm32f103-nucleo/ao_pins.h b/src/stm32f103-nucleo/ao_pins.h index 37adc399..62e50edc 100644 --- a/src/stm32f103-nucleo/ao_pins.h +++ b/src/stm32f103-nucleo/ao_pins.h @@ -33,7 +33,20 @@ #define AO_RCC_CFGR_HPRE_DIV STM_RCC_CFGR_HPRE_DIV_1 #define AO_RCC_CFGR_ADCPRE STM_RCC_CFGR_ADCPRE_6 +#define HAS_BEEP 0 +#define HAS_USB 1 + +#define HAS_USB_PULLUP 1 +#define AO_USB_PULLUP_PORT (&stm_gpiob) +#define AO_USB_PULLUP_PIN 12 + + #define HAS_LED 1 #define LED_0_PORT (&stm_gpioa) #define LED_0_PIN 5 #define AO_LED_GREEN (1 << 0) +#define AO_LED_PANIC AO_LED_GREEN + +#define HAS_SERIAL_1 1 +#define USE_SERIAL_1_STDIN 1 +#define SERIAL_1_PA9_PA10 1 diff --git a/src/stm32f103-nucleo/hello.c b/src/stm32f103-nucleo/hello.c index 938afd2d..1571eae4 100644 --- a/src/stm32f103-nucleo/hello.c +++ b/src/stm32f103-nucleo/hello.c @@ -18,21 +18,25 @@ #include -void -ao_delay(AO_TICK_TYPE ticks) +static void blink(void) { - uint32_t then = ao_time(); - while ((int32_t) (ao_time() - then) < (int32_t) ticks) - ao_arch_nop(); + for (;;) { + ao_led_for(AO_LED_GREEN, 50); + ao_delay(50); + } } +static struct ao_task blink_task; + int main(void) { ao_clock_init(); - ao_timer_init(); ao_led_init(); - for (;;) { - ao_led_for(AO_LED_GREEN, 50); - ao_delay(50); - } + ao_timer_init(); + ao_serial_init(); + ao_usb_init(); + ao_task_init(); + ao_cmd_init(); + ao_add_task(&blink_task, blink, "blink"); + ao_start_scheduler(); } -- 2.30.2