@@ -71,9 +71,13 @@ static bool debug_fpe=false;
7171bool are_realtime = false;
7272
7373#ifdef PIOS_INCLUDE_SPI
74+ #include <pios_dio.h>
75+
7476int num_spi = 0 ;
7577uintptr_t spi_devs [16 ];
7678
79+ dio_tag_t gyro_int = NULL ;
80+
7781#include "pios_spi_posix_priv.h"
7882#include "pios_ms5611_priv.h"
7983#include "pios_bmm150_priv.h"
@@ -94,7 +98,7 @@ uintptr_t external_i2c_adapter_id;
9498#endif
9599
96100static void Usage (char * cmdName ) {
97- printf ( "usage: %s [-f] [-r] [-m orientation] [-s spibase] [-d drvname:bus:id]\n"
101+ printf ( "usage: %s [-f] [-r] [-g num] [- m orientation] [-s spibase] [-d drvname:bus:id]\n"
98102 "\t\t[-l logfile] [-I i2cdev] [-i drvname:bus]"
99103 "\n"
100104 "\t-f\tEnables floating point exception trapping mode\n"
@@ -105,6 +109,7 @@ static void Usage(char *cmdName) {
105109 "\t\t\tAvailable drivers: gps msp lighttelemetry telemetry\n"
106110#endif
107111#ifdef PIOS_INCLUDE_SPI
112+ "\t-g gpionum\tSpecifies the gyro interrupt is on gpionum\n"
108113 "\t-s spibase\tConfigures a SPI interface on the base path\n"
109114 "\t-d drvname:bus:id\tStarts driver drvname on bus/id\n"
110115 "\t\t\tAvailable drivers: bmm150 bmx055 flyingpio ms5611\n"
@@ -313,6 +318,8 @@ static int handle_device(const char *optarg) {
313318 bmx055_cfg = PIOS_malloc (sizeof (* bmx055_cfg ));
314319 bzero (bmx055_cfg , sizeof (* bmx055_cfg ));
315320
321+ bmx055_cfg -> int_pin = gyro_int ;
322+
316323 int ret = PIOS_BMX055_SPI_Init (& dev , spi_devs [bus_num ], dev_num , dev_num + 1 , bmx055_cfg );
317324
318325 if (ret ) goto fail ;
@@ -426,7 +433,7 @@ void PIOS_SYS_Args(int argc, char *argv[]) {
426433
427434 bool first_arg = true;
428435
429- while ((opt = getopt (argc , argv , "frl :s:d:S:I:i:" )) != -1 ) {
436+ while ((opt = getopt (argc , argv , "frg:l :s:d:S:I:i:" )) != -1 ) {
430437 switch (opt ) {
431438 case 'f' :
432439 debug_fpe = true;
@@ -508,6 +515,29 @@ void PIOS_SYS_Args(int argc, char *argv[]) {
508515 break ;
509516#endif
510517#ifdef PIOS_INCLUDE_SPI
518+ case 'g' :
519+ {
520+ if (!first_arg ) {
521+ printf ("Gyro int must be before hw\n" );
522+ exit (1 );
523+ }
524+
525+ char * endptr ;
526+
527+ int num ;
528+
529+ num = strtol (optarg , & endptr , 10 );
530+
531+ if (!endptr || (* endptr != '\0' )) {
532+ printf ("Invalid gyro int pin\n" );
533+ exit (1 );
534+ }
535+
536+ gyro_int = DIO_MAKE_TAG (num );
537+
538+ break ;
539+ }
540+
511541 case 'd' :
512542 if (handle_device (optarg )) {
513543 printf ("Couldn't init device\n" );
0 commit comments