Skip to content

Commit 9d515a0

Browse files
committed
altos: Add BMI088 test framework using Nucleo32 board for stm32f042
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 <[email protected]>
1 parent bc0adb3 commit 9d515a0

File tree

5 files changed

+49
-61
lines changed

5 files changed

+49
-61
lines changed

libaltos/libaltos.h

+1
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ struct altos_device {
4242
int serial;
4343
char name[256];
4444
char path[256];
45+
int (*method_1)(int x, int y);
4546
//%mutable;
4647
};
4748

libaltos/libaltos.i0

+5-1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,8 @@
22
%{
33
#include "libaltos.h"
44
%}
5-
5+
%extend altos_device {
6+
int method_1(int x, int y) {
7+
return ($self->method_1)(x, y);
8+
}
9+
}

src/nucleao-32/Makefile

+9-33
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
#
44
#
55

6-
include ../stmf0/Makefile.defs
6+
TOPDIR=..
7+
8+
include $(TOPDIR)/stmf0/Makefile.defs
79

810
INC = \
911
ao.h \
@@ -13,8 +15,6 @@ INC = \
1315
ao_pins.h \
1416
ao_product.h \
1517
ao_task.h \
16-
ao_lisp.h \
17-
ao_lisp_const.h \
1818
stm32f0.h \
1919
Makefile
2020

@@ -25,42 +25,24 @@ ALTOS_SRC = \
2525
ao_romconfig.c \
2626
ao_cmd.c \
2727
ao_config.c \
28+
ao_data.c \
2829
ao_task.c \
2930
ao_led_stmf0.c \
30-
ao_beep_stm.c \
3131
ao_dma_stm.c \
3232
ao_stdio.c \
3333
ao_panic.c \
3434
ao_timer.c \
3535
ao_mutex.c \
3636
ao_usb_stm.c \
37-
ao_serial_stm.c \
3837
ao_flash_stm.c \
39-
ao_lisp_atom.c \
40-
ao_lisp_builtin.c \
41-
ao_lisp_cons.c \
42-
ao_lisp_error.c \
43-
ao_lisp_eval.c \
44-
ao_lisp_frame.c \
45-
ao_lisp_int.c \
46-
ao_lisp_lambda.c \
47-
ao_lisp_lex.c \
48-
ao_lisp_mem.c \
49-
ao_lisp_poly.c \
50-
ao_lisp_read.c \
51-
ao_lisp_rep.c \
52-
ao_lisp_save.c \
53-
ao_lisp_stack.c \
54-
ao_lisp_string.c \
55-
ao_lisp_os_save.c
38+
ao_spi_stm.c \
39+
ao_bmi088.c
5640

5741
PRODUCT=Nucleo-32
5842
PRODUCT_DEF=-DNUCLEO
5943
IDPRODUCT=0x000a
6044

61-
CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS)
62-
63-
LDFLAGS=$(CFLAGS) -L$(TOPDIR)/stmf0 -Wl,-Tload.ld -n
45+
CFLAGS = $(PRODUCT_DEF) $(STMF0_CFLAGS) $(PROFILE_DEF)
6446

6547
PROGNAME=nucleo-32
6648
PROG=$(PROGNAME)-$(VERSION).elf
@@ -72,20 +54,14 @@ OBJ=$(SRC:.c=.o)
7254
all: $(PROG) $(HEX)
7355

7456
$(PROG): Makefile $(OBJ) altos.ld
75-
$(call quiet,CC) $(LDFLAGS) $(CFLAGS) -o $(PROG) $(OBJ) $(LIBS)
57+
$(call quiet,CC) $(LDFLAGS) -o $(PROG) $(OBJ) $(LIBS) -Wl,-Map=$(PROGNAME)-$(VERSION).map
7658

7759
$(OBJ): $(INC)
7860

79-
ao_product.h: ao-make-product.5c ../Version
80-
$(call quiet,NICKLE,$<) $< -m altusmetrum.org -i $(IDPRODUCT) -p $(PRODUCT) -v $(VERSION) > $@
81-
82-
load: $(PROG)
83-
stm-load $(PROG)
84-
8561
distclean: clean
8662

8763
clean:
88-
rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx
64+
rm -f *.o $(PROGNAME)-*.elf $(PROGNAME)-*.ihx $(PROGNAME)-*.map
8965
rm -f ao_product.h
9066

9167
install:

src/nucleao-32/ao_nucleo.c

+6-20
Original file line numberDiff line numberDiff line change
@@ -13,35 +13,21 @@
1313
*/
1414

1515
#include <ao.h>
16-
#include <ao_lisp.h>
17-
#include <ao_beep.h>
16+
#include <ao_bmi088.h>
1817

19-
static void lisp_cmd() {
20-
ao_lisp_read_eval_print();
21-
}
22-
23-
static void beep() {
24-
ao_beep_for(AO_BEEP_MID, AO_MS_TO_TICKS(200));
25-
}
26-
27-
static const struct ao_cmds blink_cmds[] = {
28-
{ lisp_cmd, "l\0Run lisp interpreter" },
29-
{ beep, "b\0Beep" },
30-
{ 0, 0 }
31-
};
18+
uint8_t ao_sensor_errors;
3219

33-
void main(void)
20+
int main(void)
3421
{
35-
ao_led_init(LEDS_AVAILABLE);
22+
ao_led_init();
3623
ao_clock_init();
3724
ao_task_init();
3825
ao_timer_init();
3926
ao_dma_init();
4027
ao_usb_init();
41-
ao_serial_init();
42-
ao_beep_init();
28+
ao_spi_init();
29+
ao_bmi088_init();
4330
ao_cmd_init();
44-
ao_cmd_register(blink_cmds);
4531
ao_start_scheduler();
4632
}
4733

src/nucleao-32/ao_pins.h

+28-7
Original file line numberDiff line numberDiff line change
@@ -47,19 +47,40 @@
4747
#define HAS_USB 1
4848
#define AO_USB_DIRECTIO 0
4949
#define AO_PA11_PA12_RMP 0
50-
#define HAS_BEEP 1
51-
52-
#define BEEPER_TIMER 2
53-
#define BEEPER_CHANNEL 4
54-
#define BEEPER_PORT (&stm_gpioa)
55-
#define BEEPER_PIN 3
50+
#define HAS_BEEP 0
5651

5752
#define IS_FLASH_LOADER 0
5853

59-
#define HAS_SERIAL_2 1
54+
#define HAS_SERIAL_2 0
6055
#define SERIAL_2_PA2_PA15 1
6156
#define USE_SERIAL_2_FLOW 0
6257
#define USE_SERIAL_2_STDIN 1
6358
#define DELAY_SERIAL_2_STDIN 0
6459

60+
#define HAS_SPI_1 1
61+
#define SPI_1_PA5_PA6_PA7 1
62+
#define SPI_1_OSPEEDR STM_OSPEEDR_HIGH
63+
#define SPI_1_PB3_PB4_PB5 0
64+
65+
#define HAS_SPI_2 0
66+
67+
#define HAS_BMI088 1
68+
#define HAS_IMU 1
69+
70+
#define ao_data_along(packet) ((packet)->bmi088.acc.x)
71+
#define ao_data_across(packet) (-(packet)->bmi088.acc.y)
72+
#define ao_data_through(packet) ((packet)->bmi088.acc.z)
73+
74+
#define ao_data_roll(packet) ((packet)->bmi088.gyr.x)
75+
#define ao_data_pitch(packet) (-(packet)->bmi088.gyr.y)
76+
#define ao_data_yaw(packet) ((packet)->bmi088.gyr.z)
77+
78+
#define AO_BMI088_ACC_CS_PORT (&stm_gpioa)
79+
#define AO_BMI088_ACC_CS_PIN 0
80+
#define AO_BMI088_GYR_CS_PORT (&stm_gpioa)
81+
#define AO_BMI088_GYR_CS_PIN 1
82+
#define AO_BMI088_SPI_BUS (AO_SPI_1_PA5_PA6_PA7 | AO_SPI_MODE_0)
83+
84+
#define AO_DATA_RING 32
85+
6586
#endif /* _AO_PINS_H_ */

0 commit comments

Comments
 (0)