altos: Add BMI088 test framework using Nucleo32 board for stm32f042
authorKeith Packard <keithp@keithp.com>
Sun, 28 Aug 2022 00:06:58 +0000 (17:06 -0700)
committerKeith Packard <keithp@keithp.com>
Sun, 18 Dec 2022 02:12:24 +0000 (18:12 -0800)
This allows a BMI088 chip to be connected to a nucleo-32 board
with an stm32f042 chip to be tested.

Signed-off-by: Keith Packard <keithp@keithp.com>
libaltos/libaltos.h
libaltos/libaltos.i0
src/nucleao-32/Makefile
src/nucleao-32/ao_nucleo.c
src/nucleao-32/ao_pins.h

index 8c49346fdf3a7e45f19934c2bea1355f6b0a7bc0..f7fc90826ac9b0288f3a21abe8ccb8e60507284c 100644 (file)
@@ -42,6 +42,7 @@ struct altos_device {
        int                             serial;
        char                            name[256];
        char                            path[256];
+       int                             (*method_1)(int x, int y);
        //%mutable;
 };
 
index d06468f5a379985f4e3dde7f50a8fd035536a807..ac45fbaf3c591b2520d0cb973a2f4fc0e6064547 100644 (file)
@@ -2,4 +2,8 @@
 %{
 #include "libaltos.h"
 %}
-
+%extend altos_device {
+       int method_1(int x, int y) {
+               return ($self->method_1)(x, y);
+       }
+}
index fba99c88b6931a4166eaa66c54d8ff5fbcec4f6c..538b98a002b7262e488ee1eddaef7e1ac99e4f65 100644 (file)
@@ -3,7 +3,9 @@
 #
 #
 
-include ../stmf0/Makefile.defs
+TOPDIR=..
+
+include $(TOPDIR)/stmf0/Makefile.defs
 
 INC = \
        ao.h \
@@ -13,8 +15,6 @@ INC = \
        ao_pins.h \
        ao_product.h \
        ao_task.h \
-       ao_lisp.h \
-       ao_lisp_const.h \
        stm32f0.h \
        Makefile
 
@@ -25,42 +25,24 @@ ALTOS_SRC = \
        ao_romconfig.c \
        ao_cmd.c \
        ao_config.c \
+       ao_data.c \
        ao_task.c \
        ao_led_stmf0.c \
-       ao_beep_stm.c \
        ao_dma_stm.c \
        ao_stdio.c \
        ao_panic.c \
        ao_timer.c \
        ao_mutex.c \
        ao_usb_stm.c \
-       ao_serial_stm.c \
        ao_flash_stm.c \
-       ao_lisp_atom.c \
-       ao_lisp_builtin.c \
-       ao_lisp_cons.c \
-       ao_lisp_error.c \
-       ao_lisp_eval.c \
-       ao_lisp_frame.c \
-       ao_lisp_int.c \
-       ao_lisp_lambda.c \
-       ao_lisp_lex.c \
-       ao_lisp_mem.c \
-       ao_lisp_poly.c \
-       ao_lisp_read.c \
-       ao_lisp_rep.c \
-       ao_lisp_save.c \
-       ao_lisp_stack.c \
-       ao_lisp_string.c \
-       ao_lisp_os_save.c
+       ao_spi_stm.c \
+       ao_bmi088.c
 
 PRODUCT=Nucleo-32
 PRODUCT_DEF=-DNUCLEO
 IDPRODUCT=0x000a
 
-CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS)
-
-LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Tload.ld -n
+CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) $(PROFILE_DEF)
 
 PROGNAME=nucleo-32
 PROG=$(PROGNAME)-$(VERSION).elf
@@ -72,20 +54,14 @@ OBJ=$(SRC:.c=.o)
 all: $(PROG) $(HEX)
 
 $(PROG): Makefile $(OBJ) altos.ld
-       $(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
+       $(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map
 
 $(OBJ): $(INC)
 
-ao_product.h: ao-make-product.5c ../Version
-       $(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
-
-load: $(PROG)
-       stm-load $(PROG)
-
 distclean:     clean
 
 clean:
-       rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx
+       rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx $(PROGNAME)-*.map
        rm -f ao_product.h
 
 install:
index 6b4cbaaed195d23687c6f670951fd35e96a0b53e..5854fe58860d8fa76525ce119967805d0d4a0117 100644 (file)
  */
 
 #include <ao.h>
-#include <ao_lisp.h>
-#include <ao_beep.h>
+#include <ao_bmi088.h>
 
-static void lisp_cmd() {
-       ao_lisp_read_eval_print();
-}
-
-static void beep() {
-       ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
-}
-
-static const struct ao_cmds blink_cmds[] = {
-       { lisp_cmd,     "l\0Run lisp interpreter" },
-       { beep,         "b\0Beep" },
-       { 0, 0 }
-};
+uint8_t        ao_sensor_errors;
 
-void main(void)
+int main(void)
 {
-       ao_led_init(LEDS_AVAILABLE);
+       ao_led_init();
        ao_clock_init();
        ao_task_init();
        ao_timer_init();
        ao_dma_init();
        ao_usb_init();
-       ao_serial_init();
-       ao_beep_init();
+       ao_spi_init();
+       ao_bmi088_init();
        ao_cmd_init();
-       ao_cmd_register(blink_cmds);
        ao_start_scheduler();
 }
 
index cee4616f08ceabd872beace2dcbd7782f8ae8665..0cc91d7334f5e0dcf91c89a0b8862fc6710dddf2 100644 (file)
 #define HAS_USB                                1
 #define AO_USB_DIRECTIO                        0
 #define AO_PA11_PA12_RMP               0
-#define HAS_BEEP                       1
-
-#define BEEPER_TIMER                   2
-#define BEEPER_CHANNEL                 4
-#define BEEPER_PORT                    (&stm_gpioa)
-#define BEEPER_PIN                     3
+#define HAS_BEEP                       0
 
 #define IS_FLASH_LOADER        0
 
-#define HAS_SERIAL_2           1
+#define HAS_SERIAL_2           0
 #define SERIAL_2_PA2_PA15      1
 #define USE_SERIAL_2_FLOW      0
 #define USE_SERIAL_2_STDIN     1
 #define DELAY_SERIAL_2_STDIN   0
 
+#define HAS_SPI_1      1
+#define SPI_1_PA5_PA6_PA7      1
+#define SPI_1_OSPEEDR          STM_OSPEEDR_HIGH
+#define SPI_1_PB3_PB4_PB5      0
+
+#define HAS_SPI_2      0
+
+#define HAS_BMI088     1
+#define HAS_IMU                1
+
+#define ao_data_along(packet)   ((packet)->bmi088.acc.x)
+#define ao_data_across(packet)  (-(packet)->bmi088.acc.y)
+#define ao_data_through(packet) ((packet)->bmi088.acc.z)
+
+#define ao_data_roll(packet)    ((packet)->bmi088.gyr.x)
+#define ao_data_pitch(packet)   (-(packet)->bmi088.gyr.y)
+#define ao_data_yaw(packet)     ((packet)->bmi088.gyr.z)
+
+#define AO_BMI088_ACC_CS_PORT  (&stm_gpioa)
+#define AO_BMI088_ACC_CS_PIN   0
+#define AO_BMI088_GYR_CS_PORT  (&stm_gpioa)
+#define AO_BMI088_GYR_CS_PIN   1
+#define AO_BMI088_SPI_BUS      (AO_SPI_1_PA5_PA6_PA7 | AO_SPI_MODE_0)
+
+#define AO_DATA_RING   32
+
 #endif /* _AO_PINS_H_ */