@@ -74,9 +74,13 @@ static bool debug_fpe=false;
7474bool are_realtime = false;
7575
7676#ifdef PIOS_INCLUDE_SPI
77+ #include <pios_dio.h>
78+
7779int num_spi = 0 ;
7880uintptr_t spi_devs [16 ];
7981
82+ dio_tag_t gyro_int = NULL ;
83+
8084#include "pios_spi_posix_priv.h"
8185#include "pios_ms5611_priv.h"
8286#include "pios_bmm150_priv.h"
@@ -97,7 +101,7 @@ uintptr_t external_i2c_adapter_id;
97101#endif
98102
99103static void Usage (char * cmdName ) {
100- printf ( "usage: %s [-f] [-r] [-m orientation] [-s spibase] [-d drvname:bus:id]\n"
104+ printf ( "usage: %s [-f] [-r] [-g num] [- m orientation] [-s spibase] [-d drvname:bus:id]\n"
101105 "\t\t[-l logfile] [-I i2cdev] [-i drvname:bus]"
102106 "\n"
103107 "\t-f\tEnables floating point exception trapping mode\n"
@@ -108,6 +112,7 @@ static void Usage(char *cmdName) {
108112 "\t\t\tAvailable drivers: gps msp lighttelemetry telemetry\n"
109113#endif
110114#ifdef PIOS_INCLUDE_SPI
115+ "\t-g gpionum\tSpecifies the gyro interrupt is on gpionum\n"
111116 "\t-s spibase\tConfigures a SPI interface on the base path\n"
112117 "\t-d drvname:bus:id\tStarts driver drvname on bus/id\n"
113118 "\t\t\tAvailable drivers: bmm150 bmx055 flyingpio ms5611\n"
@@ -316,6 +321,8 @@ static int handle_device(const char *optarg) {
316321 bmx055_cfg = PIOS_malloc (sizeof (* bmx055_cfg ));
317322 bzero (bmx055_cfg , sizeof (* bmx055_cfg ));
318323
324+ bmx055_cfg -> int_pin = gyro_int ;
325+
319326 int ret = PIOS_BMX055_SPI_Init (& dev , spi_devs [bus_num ], dev_num , dev_num + 1 , bmx055_cfg );
320327
321328 if (ret ) goto fail ;
@@ -429,7 +436,7 @@ void PIOS_SYS_Args(int argc, char *argv[]) {
429436
430437 bool first_arg = true;
431438
432- while ((opt = getopt (argc , argv , "frl :s:d:S:I:i:" )) != -1 ) {
439+ while ((opt = getopt (argc , argv , "frg:l :s:d:S:I:i:" )) != -1 ) {
433440 switch (opt ) {
434441 case 'f' :
435442 debug_fpe = true;
@@ -511,6 +518,29 @@ void PIOS_SYS_Args(int argc, char *argv[]) {
511518 break ;
512519#endif
513520#ifdef PIOS_INCLUDE_SPI
521+ case 'g' :
522+ {
523+ if (!first_arg ) {
524+ printf ("Gyro int must be before hw\n" );
525+ exit (1 );
526+ }
527+
528+ char * endptr ;
529+
530+ int num ;
531+
532+ num = strtol (optarg , & endptr , 10 );
533+
534+ if (!endptr || (* endptr != '\0' )) {
535+ printf ("Invalid gyro int pin\n" );
536+ exit (1 );
537+ }
538+
539+ gyro_int = DIO_MAKE_TAG (num );
540+
541+ break ;
542+ }
543+
514544 case 'd' :
515545 if (handle_device (optarg )) {
516546 printf ("Couldn't init device\n" );
0 commit comments