Skip to content

Commit f17c291

Browse files
committed
posix/pios_sys: support specifying gyro interrupt line
1 parent 4d9248f commit f17c291

1 file changed

Lines changed: 31 additions & 1 deletion

File tree

flight/PiOS/posix/pios_sys.c

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ static bool debug_fpe=false;
7575
bool are_realtime = false;
7676

7777
#ifdef PIOS_INCLUDE_SPI
78+
#include <pios_dio.h>
79+
7880
int num_spi = 0;
7981
pios_spi_t spi_devs[16];
8082

83+
dio_tag_t gyro_int = NULL;
84+
8185
#include "pios_spi_posix_priv.h"
8286
#include "pios_ms5611_priv.h"
8387
#include "pios_bmm150_priv.h"
@@ -100,7 +104,7 @@ pios_i2c_t external_i2c_adapter_id;
100104
int orig_stdout;
101105

102106
static void Usage(char *cmdName) {
103-
printf( "usage: %s [-f] [-r] [-m orientation] [-s spibase] [-d drvname:bus:id]\n"
107+
printf( "usage: %s [-f] [-r] [-g num] [-m orientation] [-s spibase] [-d drvname:bus:id]\n"
104108
"\t\t[-l logfile] [-I i2cdev] [-i drvname:bus] [-g port]"
105109
"\n"
106110
"\t-f\tEnables floating point exception trapping mode\n"
@@ -113,6 +117,7 @@ static void Usage(char *cmdName) {
113117
"\t\t\tAvailable drivers: gps msp lighttelemetry telemetry omnip\n"
114118
#endif
115119
#ifdef PIOS_INCLUDE_SPI
120+
"\t-g gpionum\tSpecifies the gyro interrupt is on gpionum\n"
116121
"\t-s spibase\tConfigures a SPI interface on the base path\n"
117122
"\t-d drvname:bus:id\tStarts driver drvname on bus/id\n"
118123
"\t\t\tAvailable drivers: bmm150 bmx055 flyingpio ms5611\n"
@@ -341,6 +346,8 @@ static int handle_device(const char *optarg) {
341346
bmx055_cfg = PIOS_malloc(sizeof(*bmx055_cfg));
342347
bzero(bmx055_cfg, sizeof(*bmx055_cfg));
343348

349+
bmx055_cfg->int_pin = gyro_int;
350+
344351
int ret = PIOS_BMX055_SPI_Init(&dev, spi_devs[bus_num], dev_num, dev_num+1, bmx055_cfg);
345352

346353
if (ret) goto fail;
@@ -541,6 +548,29 @@ void PIOS_SYS_Args(int argc, char *argv[]) {
541548
break;
542549
#endif
543550
#ifdef PIOS_INCLUDE_SPI
551+
case 'g':
552+
{
553+
if (!first_arg) {
554+
printf("Gyro int must be before hw\n");
555+
exit(1);
556+
}
557+
558+
char *endptr;
559+
560+
int num;
561+
562+
num = strtol(optarg, &endptr, 10);
563+
564+
if (!endptr || (*endptr != '\0')) {
565+
printf("Invalid gyro int pin\n");
566+
exit(1);
567+
}
568+
569+
gyro_int = DIO_MAKE_TAG(num);
570+
571+
break;
572+
}
573+
544574
case 'd':
545575
if (handle_device(optarg)) {
546576
printf("Couldn't init device\n");

0 commit comments

Comments
 (0)