altos/stm32f103-nucleo: Use more bits
authorKeith Packard <keithp@keithp.com>
Sun, 19 Feb 2023 23:45:29 +0000 (15:45 -0800)
committerKeith Packard <keithp@keithp.com>
Thu, 1 Feb 2024 01:50:19 +0000 (17:50 -0800)
Get the OS running, use the serial for console

Signed-off-by: Keith Packard <keithp@keithp.com>
src/stm32f103-nucleo/.gitignore [new file with mode: 0644]
src/stm32f103-nucleo/Makefile
src/stm32f103-nucleo/ao_pins.h
src/stm32f103-nucleo/hello.c

diff --git a/src/stm32f103-nucleo/.gitignore b/src/stm32f103-nucleo/.gitignore
new file mode 100644 (file)
index 0000000..5c7fb91
--- /dev/null
@@ -0,0 +1,2 @@
+ao_product.h
+nucleo-*.elf
index 3adc4acf300f2f5b5c3b9d05482b5946828170ec..b6abf8c45caa81b0a1cab86e101e25a53fda474b 100644 (file)
@@ -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)
 
index 37adc39920accbe11c0e3e44652972b559e8ca02..62e50edc0330e41a536c2843f0768d7597658b24 100644 (file)
 #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
index 938afd2d706ba3767343c7c8f744b159f26822e3..1571eae4f5427c457ba3b352c0dd6ce7796daeef 100644 (file)
 
 #include <ao.h>
 
-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();
 }