@@ -78,9 +78,13 @@ static bool debug_fpe=false;
7878bool are_realtime = false;
7979
8080#ifdef PIOS_INCLUDE_SPI
81+ #include <pios_dio.h>
82+
8183int num_spi = 0 ;
8284pios_spi_t spi_devs [16 ];
8385
86+ dio_tag_t gyro_int = NULL ;
87+
8488#include "pios_spi_posix_priv.h"
8589#include "pios_ms5611_priv.h"
8690#include "pios_bmm150_priv.h"
@@ -103,7 +107,7 @@ pios_i2c_t external_i2c_adapter_id;
103107int orig_stdout ;
104108
105109static void Usage (char * cmdName ) {
106- printf ( "usage: %s [-f] [-r] [-m orientation] [-s spibase] [-d drvname:bus:id]\n"
110+ printf ( "usage: %s [-f] [-r] [-g num] [- m orientation] [-s spibase] [-d drvname:bus:id]\n"
107111 "\t\t[-l logfile] [-I i2cdev] [-i drvname:bus] [-g port]"
108112 "\n"
109113 "\t-f\tEnables floating point exception trapping mode\n"
@@ -119,6 +123,7 @@ static void Usage(char *cmdName) {
119123 "\t\t\tAvailable drivers: gps msp lighttelemetry telemetry omnip\n"
120124#endif
121125#ifdef PIOS_INCLUDE_SPI
126+ "\t-g gpionum\tSpecifies the gyro interrupt is on gpionum\n"
122127 "\t-s spibase\tConfigures a SPI interface on the base path\n"
123128 "\t-d drvname:bus:id\tStarts driver drvname on bus/id\n"
124129 "\t\t\tAvailable drivers: bmm150 bmx055 flyingpio ms5611\n"
@@ -347,6 +352,8 @@ static int handle_device(const char *optarg) {
347352 bmx055_cfg = PIOS_malloc (sizeof (* bmx055_cfg ));
348353 bzero (bmx055_cfg , sizeof (* bmx055_cfg ));
349354
355+ bmx055_cfg -> int_pin = gyro_int ;
356+
350357 int ret = PIOS_BMX055_SPI_Init (& dev , spi_devs [bus_num ], dev_num , dev_num + 1 , bmx055_cfg );
351358
352359 if (ret ) goto fail ;
@@ -552,6 +559,29 @@ void PIOS_SYS_Args(int argc, char *argv[]) {
552559 break ;
553560#endif
554561#ifdef PIOS_INCLUDE_SPI
562+ case 'g' :
563+ {
564+ if (!first_arg ) {
565+ printf ("Gyro int must be before hw\n" );
566+ exit (1 );
567+ }
568+
569+ char * endptr ;
570+
571+ int num ;
572+
573+ num = strtol (optarg , & endptr , 10 );
574+
575+ if (!endptr || (* endptr != '\0' )) {
576+ printf ("Invalid gyro int pin\n" );
577+ exit (1 );
578+ }
579+
580+ gyro_int = DIO_MAKE_TAG (num );
581+
582+ break ;
583+ }
584+
555585 case 'd' :
556586 if (handle_device (optarg )) {
557587 printf ("Couldn't init device\n" );
0 commit comments