PX4 Firmware
PX4 Autopilot Software http://px4.io
MappyDot.cpp
Go to the documentation of this file.
1 /****************************************************************************
2  *
3  * Copyright (c) 2018-2019 PX4 Development Team. All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions
7  * are met:
8  *
9  * 1. Redistributions of source code must retain the above copyright
10  * notice, this list of conditions and the following disclaimer.
11  * 2. Redistributions in binary form must reproduce the above copyright
12  * notice, this list of conditions and the following disclaimer in
13  * the documentation and/or other materials provided with the
14  * distribution.
15  * 3. Neither the name PX4 nor the names of its contributors may be
16  * used to endorse or promote products derived from this software
17  * without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
20  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
21  * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
22  * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
23  * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
24  * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
25  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
26  * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
27  * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
28  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
29  * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
30  * POSSIBILITY OF SUCH DAMAGE.
31  *
32  ****************************************************************************/
33 
34 /**
35  * @file MappyDot.cpp
36  * @author Mohammed Kabir (mhkabir@mit.edu)
37  * @author Mark Sauder (mcsauder@gmail.com)
38  *
39  * Driver for Mappydot infrared rangefinders connected via I2C.
40  */
41 
42 #include <string.h>
43 
44 #include <containers/Array.hpp>
45 #include <drivers/device/i2c.h>
47 #include <perf/perf_counter.h>
48 #include <px4_platform_common/getopt.h>
49 #include <px4_platform_common/module_params.h>
50 #include <px4_platform_common/px4_work_queue/ScheduledWorkItem.hpp>
52 
53 /* MappyDot Registers */
54 /* Basics */
55 #define MAPPYDOT_MEASUREMENT_BUDGET 0x42
56 #define MAPPYDOT_READ_ERROR_CODE 0x45
57 #define MAPPYDOT_CHECK_INTERRUPT 0x49
58 #define MAPPYDOT_READ_ACCURACY 0x52
59 #define MAPPYDOT_PERFORM_SINGLE_RANGE 0x53
60 #define MAPPYDOT_SET_CONTINUOUS_RANGING_MODE 0x63
61 #define MAPPYDOT_RANGING_MEASUREMENT_MODE 0x6D
62 #define MAPPYDOT_READ_DISTANCE 0x72
63 #define MAPPYDOT_SET_SINGLE_RANGING_MODE 0x73
64 
65 /* Configuration */
66 #define MAPPYDOT_FILTERING_ENABLE 0x46
67 #define MAPPYDOT_SIGNAL_LIMIT_CHECK_VALUE 0x47
68 #define MAPPYDOT_ENABLE_CROSSTALK_COMPENSATION 0x4B
69 #define MAPPYDOT_SIGMA_LIMIT_CHECK_VALUE 0x4C
70 #define MAPPYDOT_INTERSENSOR_CROSSTALK_MEASUREMENT_DELAY 0x51
71 #define MAPPYDOT_INTERSENSOR_CROSSTALK_REDUCTION_ENABLE 0x54
72 #define MAPPYDOT_AVERAGING_ENABLE 0x56
73 #define MAPPYDOT_INTERSENSOR_SYNC_ENABLE 0x59
74 #define MAPPYDOT_CALIBRATE_DISTANCE_OFFSET 0x61
75 #define MAPPYDOT_SET_LED_THRESHOLD_DISTANCE_IN_MM 0x65
76 #define MAPPYDOT_FILTERING_DISABLE 0x66
77 #define MAPPYDOT_SET_GPIO_MODE 0x67
78 #define MAPPYDOT_AVERAGING_SAMPLES 0x69
79 #define MAPPYDOT_DISABLE_CROSSTALK_COMPENSATION 0x6B
80 #define MAPPYDOT_SET_LED_MODE 0x6C
81 #define MAPPYDOT_SET_GPIO_THRESHOLD_DISTANCE_IN_MM 0x6F
82 #define MAPPYDOT_REGION_OF_INTEREST 0x70
83 #define MAPPYDOT_INTERSENSOR_CROSSTALK_TIMEOUT 0x71
84 #define MAPPYDOT_INTERSENSOR_CROSSTALK_REDUCTION_DISABLE 0x74
85 #define MAPPYDOT_CALIBRATE_SPAD 0x75
86 #define MAPPYDOT_AVERAGING_DISABLE 0x76
87 #define MAPPYDOT_CALIBRATE_CROSSTALK 0x78
88 #define MAPPYDOT_INTERSENSOR_SYNC_DISABLE 0x79
89 
90 /* Settings */
91 #define MAPPYDOT_FIRMWARE_VERSION 0x4E
92 #define MAPPYDOT_READ_CURRENT_SETTINGS 0x62
93 #define MAPPYDOT_DEVICE_NAME 0x64
94 #define MAPPYDOT_NAME_DEVICE 0x6E
95 #define MAPPYDOT_WRITE_CURRENT_SETTINGS_AS_START_UP_DEFAULT 0x77
96 #define MAPPYDOT_RESTORE_FACTORY_DEFAULTS 0x7A
97 
98 /* Advanced */
99 #define MAPPYDOT_AMBIENT_RATE_RETURN 0x41
100 #define MAPPYDOT_VL53L1X_NOT_SHUTDOWN 0x48
101 #define MAPPYDOT_SIGNAL_RATE_RETURN 0x4A
102 #define MAPPYDOT_RESET_VL53L1X_RANGING 0x58
103 #define MAPPYDOT_VL53L1X_SHUTDOWN 0x68
104 #define MAPPYDOT_READ_NONFILTERED_VALUE 0x6A
105 
106 /* Super Advanced */
107 #define MAPPYDOT_ENTER_FACTORY_MODE 0x23 //"#"//"!#!#!#"
108 #define MAPPYDOT_WIPE_ALL_SETTINGS 0x3C //"<"//"><><><" (Must be in factory mode)
109 
110 /* Ranging Modes */
111 #define MAPPYDOT_LONG_RANGE 0x6C
112 #define MAPPYDOT_MED_RANGE 0x6D
113 #define MAPPYDOT_SHORT_RANGE 0x73
114 
115 /* LED Modes */
116 #define MAPPYDOT_LED_OFF 0x66
117 #define MAPPYDOT_LED_MEASUREMENT_OUTPUT 0x6D
118 #define MAPPYDOT_LED_ON 0x6F
119 #define MAPPYDOT_LED_PWM_ENABLED 0x70
120 #define MAPPYDOT_LED_THRESHOLD_ENABLED 0x74
121 
122 /* GPIO Modes */
123 #define MAPPYDOT_GPIO_LOW 0x66
124 #define MAPPYDOT_GPIO_MEASUREMENT_INTERRUPT 0x6D
125 #define MAPPYDOT_GPIO_HIGH 0x6F
126 #define MAPPYDOT_GPIO_PWM_ENABLED 0x70
127 #define MAPPYDOT_GPIO_THRESHOLD_ENABLED 0x74
128 
129 /* I2C Bootloader */
130 #define MAPPYDOT_REBOOT_TO_BOOTLOADER 0x01
131 
132 /* Device limits */
133 #define MAPPYDOT_MIN_DISTANCE (0.2f) // meters
134 #define MAPPYDOT_MAX_DISTANCE (4.f) // meters
135 
136 #define MAPPYDOT_BUS_CLOCK 400000 // 400kHz bus speed
137 #define MAPPYDOT_DEVICE_PATH "/dev/mappydot"
138 
139 /* Configuration Constants */
140 #define MAPPYDOT_BASE_ADDR 0x08
141 #define MAPPYDOT_BUS_DEFAULT PX4_I2C_BUS_EXPANSION
142 #define MAPPYDOT_MEASUREMENT_INTERVAL_USEC 50000 // 50ms measurement interval, 20Hz.
143 
144 using namespace time_literals;
145 
146 class MappyDot : public device::I2C, public ModuleParams, public px4::ScheduledWorkItem
147 {
148 public:
149  MappyDot(const int bus = MAPPYDOT_BUS_DEFAULT);
150  virtual ~MappyDot();
151 
152  /**
153  * Initializes the sensors, advertises uORB topic,
154  * sets device addresses
155  */
156  virtual int init() override;
157 
158  /**
159  * Prints basic diagnostic information about the driver.
160  */
161  void print_info();
162 
163  /**
164  * Initializes the automatic measurement state machine and starts the driver.
165  */
166  void start();
167 
168  /**
169  * Stop the automatic measurement state machine.
170  */
171  void stop();
172 
173 protected:
174 
175 private:
176 
177  /**
178  * Sends an i2c measure command to check for presence of a sensor.
179  */
180  int probe();
181 
182  /**
183  * Collects the most recent sensor measurement data from the i2c bus.
184  */
185  int collect();
186 
187  /**
188  * Performs a poll cycle; collect from the previous measurement and start a new one.
189  */
190  void Run() override;
191 
192  /**
193  * Gets the current sensor rotation value.
194  */
195  int get_sensor_rotation(const size_t index);
196 
199 
200  size_t _sensor_count{0};
201 
202  orb_advert_t _distance_sensor_topic{nullptr};
203 
204  perf_counter_t _comms_errors{perf_alloc(PC_COUNT, "mappydot_comms_err")};
205  perf_counter_t _sample_perf{perf_alloc(PC_ELAPSED, "mappydot_sample_perf")};
206 
207  DEFINE_PARAMETERS(
208  (ParamInt<px4::params::SENS_EN_MPDT>) _p_sensor_enabled,
209  (ParamInt<px4::params::SENS_MPDT0_ROT>) _p_sensor0_rot,
210  (ParamInt<px4::params::SENS_MPDT1_ROT>) _p_sensor1_rot,
211  (ParamInt<px4::params::SENS_MPDT2_ROT>) _p_sensor2_rot,
212  (ParamInt<px4::params::SENS_MPDT3_ROT>) _p_sensor3_rot,
213  (ParamInt<px4::params::SENS_MPDT4_ROT>) _p_sensor4_rot,
214  (ParamInt<px4::params::SENS_MPDT5_ROT>) _p_sensor5_rot,
215  (ParamInt<px4::params::SENS_MPDT6_ROT>) _p_sensor6_rot,
216  (ParamInt<px4::params::SENS_MPDT7_ROT>) _p_sensor7_rot,
217  (ParamInt<px4::params::SENS_MPDT8_ROT>) _p_sensor8_rot,
218  (ParamInt<px4::params::SENS_MPDT9_ROT>) _p_sensor9_rot,
219  (ParamInt<px4::params::SENS_MPDT10_ROT>) _p_sensor10_rot,
220  (ParamInt<px4::params::SENS_MPDT11_ROT>) _p_sensor11_rot
221  );
222 };
223 
224 
225 MappyDot::MappyDot(const int bus) :
227  ModuleParams(nullptr),
228  ScheduledWorkItem(MODULE_NAME, px4::device_bus_to_wq(get_device_id()))
229 {}
230 
232 {
233  // Ensure we are truly inactive.
234  stop();
235 
236  // Unadvertise the distance sensor topic.
237  if (_distance_sensor_topic != nullptr) {
239  }
240 
241  // Free perf counters.
244 }
245 
246 int
248 {
249  uint8_t val[2] = {};
251 
252  // Increment the sensor index, (limited to the number of sensors connected).
253  for (size_t index = 0; index < _sensor_count; index++) {
254 
255  // Set address of the current sensor to collect data from.
256  set_device_address(_sensor_addresses[index]);
257 
258  // Transfer data from the bus.
259  int ret_val = transfer(nullptr, 0, &val[0], 2);
260 
261  if (ret_val < 0) {
262  PX4_ERR("sensor %i read failed, address: 0x%02X", index, _sensor_addresses[index]);
265  return ret_val;
266  }
267 
268  uint16_t distance_mm = uint16_t(val[0]) << 8 | val[1];
269  float distance_m = static_cast<float>(distance_mm) / 1000.f;
270 
271  distance_sensor_s report {};
272  report.current_distance = distance_m;
273  report.id = _sensor_addresses[index];
274  report.max_distance = MAPPYDOT_MAX_DISTANCE;
275  report.min_distance = MAPPYDOT_MIN_DISTANCE;
276  report.orientation = _sensor_rotations[index];
277  report.signal_quality = -1;
278  report.timestamp = hrt_absolute_time();
279  report.type = distance_sensor_s::MAV_DISTANCE_SENSOR_LASER;
280  report.variance = 0;
281 
282  int instance_id;
283  orb_publish_auto(ORB_ID(distance_sensor), &_distance_sensor_topic, &report, &instance_id, ORB_PRIO_DEFAULT);
284 
285  }
286 
288  return PX4_OK;
289 }
290 
291 int
292 MappyDot::get_sensor_rotation(const size_t index)
293 {
294  switch (index) {
295  case 0: return _p_sensor0_rot.get();
296 
297  case 1: return _p_sensor1_rot.get();
298 
299  case 2: return _p_sensor2_rot.get();
300 
301  case 3: return _p_sensor3_rot.get();
302 
303  case 4: return _p_sensor4_rot.get();
304 
305  case 5: return _p_sensor5_rot.get();
306 
307  case 6: return _p_sensor6_rot.get();
308 
309  case 7: return _p_sensor7_rot.get();
310 
311  case 8: return _p_sensor8_rot.get();
312 
313  case 9: return _p_sensor9_rot.get();
314 
315  case 10: return _p_sensor10_rot.get();
316 
317  case 11: return _p_sensor11_rot.get();
318 
319  default: return PX4_ERROR;
320  }
321 }
322 
323 int
325 {
326  if (_p_sensor_enabled.get() == 0) {
327  PX4_WARN("disabled");
328  return PX4_ERROR;
329  }
330 
331  if (I2C::init() != PX4_OK) {
332  return PX4_ERROR;
333  }
334 
335  // Allow for sensor auto-addressing time
336  px4_usleep(1_s);
337 
338  // Check for connected rangefinders on each i2c port,
339  // starting from the base address 0x08 and incrementing
340  for (size_t i = 0; i <= RANGE_FINDER_MAX_SENSORS; i++) {
341  set_device_address(MAPPYDOT_BASE_ADDR + i);
342 
343  // Check if a sensor is present.
344  if (probe() != PX4_OK) {
345  break;
346  }
347 
348  // Store I2C address
351  _sensor_count++;
352 
353  // Configure the sensor
354  // Set measurement budget
355  uint16_t budget_ms = MAPPYDOT_MEASUREMENT_INTERVAL_USEC / 1000;
356  uint8_t budget_cmd[3] = {MAPPYDOT_MEASUREMENT_BUDGET,
357  uint8_t(budget_ms >> 8 & 0xFF),
358  uint8_t(budget_ms & 0xFF)
359  };
360  transfer(&budget_cmd[0], 3, nullptr, 0);
361  px4_usleep(10_ms);
362 
363  // Configure long range mode
364  uint8_t range_cmd[2] = {MAPPYDOT_RANGING_MEASUREMENT_MODE,
366  };
367  transfer(&range_cmd[0], 2, nullptr, 0);
368  px4_usleep(10_ms);
369 
370  // Configure LED threshold
371  uint16_t threshold_mm = 1000; // 1m
372  uint8_t threshold_cmd[3] = {MAPPYDOT_SET_LED_THRESHOLD_DISTANCE_IN_MM,
373  uint8_t(threshold_mm >> 8 & 0xFF),
374  uint8_t(threshold_mm & 0xFF)
375  };
376  transfer(&threshold_cmd[0], 3, nullptr, 0);
377  px4_usleep(10_ms);
378 
379  PX4_INFO("sensor %i at address 0x%02X added", i, get_device_address());
380  }
381 
382  if (_sensor_count == 0) {
383  return PX4_ERROR;
384  }
385 
386  PX4_INFO("%i sensors connected", _sensor_count);
387 
388  return PX4_OK;
389 }
390 
391 int
393 {
394  uint8_t cmd = MAPPYDOT_PERFORM_SINGLE_RANGE;
395  int ret_val = transfer(&cmd, 1, nullptr, 0);
396 
397  return ret_val;
398 }
399 
400 void
402 {
405 }
406 
407 void
409 {
410  // Collect the sensor data.
411  if (collect() != PX4_OK) {
412  PX4_INFO("collection error");
413  // If an error occurred, restart the measurement state machine.
414  start();
415  return;
416  }
417 }
418 
419 void
421 {
422  // Fetch parameter values.
423  ModuleParams::updateParams();
424 
425  // Schedule the driver to run on a set interval
426  ScheduleOnInterval(MAPPYDOT_MEASUREMENT_INTERVAL_USEC, 10000);
427 }
428 
429 void
431 {
432  ScheduleClear();
433 }
434 
435 
436 /**
437  * Local functions in support of the shell command.
438  */
439 namespace mappydot
440 {
441 
443 
444 int start();
445 int start_bus(int i2c_bus);
446 int status();
447 int stop();
448 int usage();
449 
450 /**
451  * Attempt to start driver on all available I2C busses.
452  *
453  * This function will return as soon as the first sensor
454  * is detected on one of the available busses or if no
455  * sensors are detected.
456  */
457 int
459 {
460  if (g_dev != nullptr) {
461  PX4_ERR("already started");
462  return PX4_ERROR;
463  }
464 
465  for (size_t i = 0; i < NUM_I2C_BUS_OPTIONS; i++) {
466  if (start_bus(i2c_bus_options[i]) == PX4_OK) {
467  return PX4_OK;
468  }
469  }
470 
471  return PX4_ERROR;
472 }
473 
474 /**
475  * Start the driver on a specific bus.
476  *
477  * This function only returns if the sensor is up and running
478  * or could not be detected successfully.
479  */
480 int
481 start_bus(int i2c_bus)
482 {
483  if (g_dev != nullptr) {
484  PX4_ERR("already started");
485  return PX4_OK;
486  }
487 
488  // Instantiate the driver.
489  g_dev = new MappyDot(i2c_bus);
490 
491  if (g_dev == nullptr) {
492  delete g_dev;
493  return PX4_ERROR;
494  }
495 
496  // Initialize the sensor.
497  if (g_dev->init() != PX4_OK) {
498  delete g_dev;
499  g_dev = nullptr;
500  return PX4_ERROR;
501  }
502 
503  // Start the driver.
504  g_dev->start();
505 
506  PX4_INFO("driver started");
507  return PX4_OK;
508 }
509 
510 /**
511  * Print the driver status.
512  */
513 int
515 {
516  if (g_dev == nullptr) {
517  PX4_ERR("driver not running");
518  return PX4_ERROR;
519  }
520 
521  g_dev->print_info();
522 
523  return PX4_OK;
524 }
525 
526 /**
527  * Stop the driver.
528  */
529 int
531 {
532  if (g_dev != nullptr) {
533  delete g_dev;
534  g_dev = nullptr;
535 
536  }
537 
538  PX4_INFO("driver stopped");
539  return PX4_OK;
540 }
541 
542 /**
543  * Print usage information about the driver.
544  */
545 int
547 {
548  PX4_INFO("Usage: mappydot <command> [options]");
549  PX4_INFO("options:");
550  PX4_INFO("\t-a --all");
551  PX4_INFO("\t-b --bus i2cbus (%i)", MAPPYDOT_BUS_DEFAULT);
552  PX4_INFO("command:");
553  PX4_INFO("\tstart|start_bus|status|stop");
554  return PX4_OK;
555 }
556 
557 } // namespace mappydot
558 
559 
560 /**
561  * Driver 'main' command.
562  */
563 extern "C" __EXPORT int mappydot_main(int argc, char *argv[])
564 {
565  const char *myoptarg = nullptr;
566 
567  int ch;
568  int i2c_bus = MAPPYDOT_BUS_DEFAULT;
569  int myoptind = 1;
570 
571  bool start_all = false;
572 
573  while ((ch = px4_getopt(argc, argv, "ab:", &myoptind, &myoptarg)) != EOF) {
574  switch (ch) {
575  case 'a':
576  start_all = true;
577  break;
578 
579  case 'b':
580  i2c_bus = atoi(myoptarg);
581  break;
582 
583  default:
584  PX4_WARN("Unknown option!");
585  return mappydot::usage();
586  }
587  }
588 
589  if (myoptind >= argc) {
590  return mappydot::usage();
591  }
592 
593  if (!strcmp(argv[myoptind], "start")) {
594  if (start_all) {
595  return mappydot::start();
596 
597  } else {
598  return mappydot::start_bus(i2c_bus);
599  }
600  }
601 
602  // Print the driver status.
603  if (!strcmp(argv[myoptind], "status")) {
604  return mappydot::status();
605  }
606 
607  // Stop the driver.
608  if (!strcmp(argv[myoptind], "stop")) {
609  return mappydot::stop();
610  }
611 
612  // Print driver usage information.
613  return mappydot::usage();
614 }
int probe()
Sends an i2c measure command to check for presence of a sensor.
Definition: MappyDot.cpp:392
virtual ~MappyDot()
Definition: MappyDot.cpp:231
void Run() override
Performs a poll cycle; collect from the previous measurement and start a new one. ...
Definition: MappyDot.cpp:408
int usage()
Print usage information about the driver.
Definition: MappyDot.cpp:546
measure the time elapsed performing an event
Definition: perf_counter.h:56
void usage(const char *reason)
Print the correct usage.
Definition: Commander.cpp:4238
px4::Array< uint8_t, RANGE_FINDER_MAX_SENSORS > _sensor_addresses
Definition: MappyDot.cpp:197
Definition: I2C.hpp:51
#define MAPPYDOT_BASE_ADDR
Definition: MappyDot.cpp:140
#define MAPPYDOT_DEVICE_PATH
Definition: MappyDot.cpp:137
static void stop()
Definition: dataman.cpp:1491
#define MAPPYDOT_MEASUREMENT_INTERVAL_USEC
Definition: MappyDot.cpp:142
count the number of times an event occurs
Definition: perf_counter.h:55
#define MAPPYDOT_BUS_CLOCK
Definition: MappyDot.cpp:136
MappyDot * g_dev
Definition: MappyDot.cpp:442
#define MAPPYDOT_MEASUREMENT_BUDGET
Definition: MappyDot.cpp:55
#define MAPPYDOT_SET_LED_THRESHOLD_DISTANCE_IN_MM
Definition: MappyDot.cpp:75
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Definition: uORB.h:87
void perf_count(perf_counter_t handle)
Count a performance event.
int status()
Print the driver status.
Definition: MappyDot.cpp:514
orb_advert_t _distance_sensor_topic
Definition: MappyDot.cpp:202
Header common to all counters.
#define MAPPYDOT_MAX_DISTANCE
Definition: MappyDot.cpp:134
void perf_free(perf_counter_t handle)
Free a counter.
int start_bus(int i2c_bus)
Start the driver on a specific bus.
Definition: MappyDot.cpp:481
void init()
Activates/configures the hardware registers.
px4::Array< uint8_t, RANGE_FINDER_MAX_SENSORS > _sensor_rotations
Definition: MappyDot.cpp:198
#define perf_alloc(a, b)
Definition: px4io.h:59
Vector< float, 6 > f(float t, const Matrix< float, 6, 1 > &, const Matrix< float, 3, 1 > &)
Definition: integration.cpp:8
void print_info()
Prints basic diagnostic information about the driver.
Definition: MappyDot.cpp:401
#define MAPPYDOT_BUS_DEFAULT
Definition: MappyDot.cpp:141
void perf_end(perf_counter_t handle)
End a performance event.
void stop()
Stop the automatic measurement state machine.
Definition: MappyDot.cpp:430
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
Definition: uORB.h:134
Local functions in support of the shell command.
Definition: MappyDot.cpp:439
int get_sensor_rotation(const size_t index)
Gets the current sensor rotation value.
Definition: MappyDot.cpp:292
static const int i2c_bus_options[]
Definition: i2c.h:46
static int start()
Definition: dataman.cpp:1452
int collect()
Collects the most recent sensor measurement data from the i2c bus.
Definition: MappyDot.cpp:247
#define MAPPYDOT_MIN_DISTANCE
Definition: MappyDot.cpp:133
__EXPORT int mappydot_main(int argc, char *argv[])
Driver &#39;main&#39; command.
Definition: MappyDot.cpp:563
size_t _sensor_count
Definition: MappyDot.cpp:200
#define MAPPYDOT_LONG_RANGE
Definition: MappyDot.cpp:111
void perf_print_counter(perf_counter_t handle)
Print one performance counter to stdout.
#define MAPPYDOT_RANGING_MEASUREMENT_MODE
Definition: MappyDot.cpp:61
int orb_unadvertise(orb_advert_t handle)
Definition: uORB.cpp:65
Definition: bst.cpp:62
virtual int init() override
Initializes the sensors, advertises uORB topic, sets device addresses.
Definition: MappyDot.cpp:324
#define MAPPYDOT_PERFORM_SINGLE_RANGE
Definition: MappyDot.cpp:59
MappyDot(const int bus=MAPPYDOT_BUS_DEFAULT)
Definition: MappyDot.cpp:225
int stop()
Stop the driver.
Definition: MappyDot.cpp:530
#define NUM_I2C_BUS_OPTIONS
Definition: i2c.h:61
perf_counter_t _comms_errors
Definition: MappyDot.cpp:204
perf_counter_t _sample_perf
Definition: MappyDot.cpp:205
void start()
Initializes the automatic measurement state machine and starts the driver.
Definition: MappyDot.cpp:420
void perf_begin(perf_counter_t handle)
Begin a performance event.
__EXPORT hrt_abstime hrt_absolute_time(void)
Get absolute time in [us] (does not wrap).
static int orb_publish_auto(const struct orb_metadata *meta, orb_advert_t *handle, const void *data, int *instance, int priority)
Advertise as the publisher of a topic.
Definition: uORB.h:177
int start()
Attempt to start driver on all available I2C busses.
Definition: MappyDot.cpp:458
#define RANGE_FINDER_MAX_SENSORS
Performance measuring tools.
Base class for devices connected via I2C.