Skip to content

Commit 8384b03

Browse files
committed
doxy
1 parent fd273a3 commit 8384b03

File tree

2 files changed

+201
-19
lines changed

2 files changed

+201
-19
lines changed

Adafruit_LSM9DS0.cpp

Lines changed: 152 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,15 +39,35 @@ void Adafruit_LSM9DS0::initI2C(TwoWire *wireBus, int32_t sensorID) {
3939
&Adafruit_LSM9DS0::getTempSensor);
4040
}
4141

42-
// default
42+
/**************************************************************************/
43+
/*!
44+
@brief Instantiate with default hardware I2C interface
45+
@param sensorID Unique identifier you'd like for the sensors
46+
*/
47+
/**************************************************************************/
4348
Adafruit_LSM9DS0::Adafruit_LSM9DS0(int32_t sensorID) {
4449
initI2C(&Wire, sensorID);
4550
}
4651

52+
/**************************************************************************/
53+
/*!
54+
@brief Instantiate with hardware I2C interface
55+
@param wireBus The I2C wire interface you'd like to use
56+
@param sensorID Unique identifier you'd like for the sensors
57+
*/
58+
/**************************************************************************/
4759
Adafruit_LSM9DS0::Adafruit_LSM9DS0(TwoWire *wireBus, int32_t sensorID) {
4860
initI2C(wireBus, sensorID);
4961
}
5062

63+
/**************************************************************************/
64+
/*!
65+
@brief Instantiate with hardware SPI interface
66+
@param xmcs SPI CS pin for accelerometer/mag subchip
67+
@param gcs SPI CS pin for gyro subchip
68+
@param sensorID Unique identifier you'd like for the sensors
69+
*/
70+
/**************************************************************************/
5171
Adafruit_LSM9DS0::Adafruit_LSM9DS0(int8_t xmcs, int8_t gcs, int32_t sensorID) {
5272
_i2c = false;
5373
// hardware SPI!
@@ -72,6 +92,17 @@ Adafruit_LSM9DS0::Adafruit_LSM9DS0(int8_t xmcs, int8_t gcs, int32_t sensorID) {
7292
&Adafruit_LSM9DS0::getTempSensor);
7393
}
7494

95+
/**************************************************************************/
96+
/*!
97+
@brief Instantiate with software SPI interface
98+
@param clk SPI clock pin
99+
@param miso SPI MISO pin
100+
@param mosi SPI MOSI pin
101+
@param xmcs SPI CS pin for accelerometer/mag subchip
102+
@param gcs SPI CS pin for gyro subchip
103+
@param sensorID Unique identifier you'd like for the sensors
104+
*/
105+
/**************************************************************************/
75106
Adafruit_LSM9DS0::Adafruit_LSM9DS0(int8_t clk, int8_t miso, int8_t mosi,
76107
int8_t xmcs, int8_t gcs, int32_t sensorID) {
77108
_i2c = false;
@@ -99,6 +130,12 @@ Adafruit_LSM9DS0::Adafruit_LSM9DS0(int8_t clk, int8_t miso, int8_t mosi,
99130
&Adafruit_LSM9DS0::getTempSensor);
100131
}
101132

133+
/**************************************************************************/
134+
/*!
135+
@brief Initialize I2C or SPI and detect/initialize subsensors
136+
@returns True if both subsensors were detected on the desired interface
137+
*/
138+
/**************************************************************************/
102139
bool Adafruit_LSM9DS0::begin() {
103140
if (_i2c) {
104141
_wire->begin();
@@ -162,6 +199,12 @@ bool Adafruit_LSM9DS0::begin() {
162199
/***************************************************************************
163200
PUBLIC FUNCTIONS
164201
***************************************************************************/
202+
203+
/**************************************************************************/
204+
/*!
205+
@brief Read all four sensor subcomponents
206+
*/
207+
/**************************************************************************/
165208
void Adafruit_LSM9DS0::read() {
166209
/* Read all the sensors. */
167210
readAccel();
@@ -170,6 +213,11 @@ void Adafruit_LSM9DS0::read() {
170213
readTemp();
171214
}
172215

216+
/**************************************************************************/
217+
/*!
218+
@brief Read the sensor accelerometer sensor component
219+
*/
220+
/**************************************************************************/
173221
void Adafruit_LSM9DS0::readAccel() {
174222
// Read the accelerometer
175223
byte buffer[6];
@@ -194,6 +242,11 @@ void Adafruit_LSM9DS0::readAccel() {
194242
accelData.z = zhi;
195243
}
196244

245+
/**************************************************************************/
246+
/*!
247+
@brief Read the sensor magnetometer sensor component
248+
*/
249+
/**************************************************************************/
197250
void Adafruit_LSM9DS0::readMag() {
198251
// Read the magnetometer
199252
byte buffer[6];
@@ -218,6 +271,11 @@ void Adafruit_LSM9DS0::readMag() {
218271
magData.z = zhi;
219272
}
220273

274+
/**************************************************************************/
275+
/*!
276+
@brief Read the sensor gyroscope sensor component
277+
*/
278+
/**************************************************************************/
221279
void Adafruit_LSM9DS0::readGyro() {
222280
// Read gyro
223281
byte buffer[6];
@@ -243,6 +301,11 @@ void Adafruit_LSM9DS0::readGyro() {
243301
gyroData.z = zhi;
244302
}
245303

304+
/**************************************************************************/
305+
/*!
306+
@brief Read the sensor temperature sensor component
307+
*/
308+
/**************************************************************************/
246309
void Adafruit_LSM9DS0::readTemp() {
247310
// Read temp sensor
248311
byte buffer[2];
@@ -257,6 +320,13 @@ void Adafruit_LSM9DS0::readTemp() {
257320
temperature = xhi;
258321
}
259322

323+
/**************************************************************************/
324+
/*!
325+
@brief Configure the accelerometer ranging
326+
@param range Can be LSM9DS0_ACCELRANGE_2G, LSM9DS0_ACCELRANGE_4G,
327+
LSM9DS0_ACCELRANGE_6G, LSM9DS0_ACCELRANGE_8G, LSM9DS0_ACCELRANGE_16G
328+
*/
329+
/**************************************************************************/
260330
void Adafruit_LSM9DS0::setupAccel(lsm9ds0AccelRange_t range) {
261331
uint8_t reg = read8(XMTYPE, LSM9DS0_REGISTER_CTRL_REG2_XM);
262332
reg &= ~(0b00111000);
@@ -282,6 +352,13 @@ void Adafruit_LSM9DS0::setupAccel(lsm9ds0AccelRange_t range) {
282352
}
283353
}
284354

355+
/**************************************************************************/
356+
/*!
357+
@brief Configure the magnetometer gain
358+
@param gain Can be LSM9DS0_MAGGAIN_2GAUSS, LSM9DS0_MAGGAIN_4GAUSS,
359+
LSM9DS0_MAGGAIN_8GAUSS, LSM9DS0_MAGGAIN_12GAUSS
360+
*/
361+
/**************************************************************************/
285362
void Adafruit_LSM9DS0::setupMag(lsm9ds0MagGain_t gain) {
286363
uint8_t reg = read8(XMTYPE, LSM9DS0_REGISTER_CTRL_REG6_XM);
287364
reg &= ~(0b01100000);
@@ -304,6 +381,13 @@ void Adafruit_LSM9DS0::setupMag(lsm9ds0MagGain_t gain) {
304381
}
305382
}
306383

384+
/**************************************************************************/
385+
/*!
386+
@brief Configure the gyroscope scaling
387+
@param scale Can be LSM9DS0_GYROSCALE_245DPS, LSM9DS0_GYROSCALE_500DPS
388+
or LSM9DS0_GYROSCALE_2000DPS
389+
*/
390+
/**************************************************************************/
307391
void Adafruit_LSM9DS0::setupGyro(lsm9ds0GyroScale_t scale) {
308392
uint8_t reg = read8(GYROTYPE, LSM9DS0_REGISTER_CTRL_REG4_G);
309393
reg &= ~(0b00110000);
@@ -329,7 +413,15 @@ void Adafruit_LSM9DS0::setupGyro(lsm9ds0GyroScale_t scale) {
329413

330414
/**************************************************************************/
331415
/*!
332-
@brief Gets the most recent accel sensor event
416+
@brief Gets the most recent accel sensor events for all 4 sensors
417+
@param accelEvent The accelerometer event object we will fill, pass NULL to
418+
skip
419+
@param magEvent The magnetometer event object we will fill, pass NULL to
420+
skip
421+
@param gyroEvent The gyroscope event object we will fill, pass NULL to skip
422+
@param tempEvent The temperature event object we will fill, pass NULL to
423+
skip
424+
@returns True on successful reads
333425
*/
334426
/**************************************************************************/
335427
bool Adafruit_LSM9DS0::getEvent(sensors_event_t *accelEvent,
@@ -355,7 +447,12 @@ bool Adafruit_LSM9DS0::getEvent(sensors_event_t *accelEvent,
355447

356448
/**************************************************************************/
357449
/*!
358-
@brief Gets the sensor_t data
450+
@brief Gets the sensor_t data for all 4 sub-sensors at once call
451+
@param accel The accelerometer sensor_t object we will fill, pass NULL to
452+
skip
453+
@param mag The magnetometer sensor_t object we will fill, pass NULL to skip
454+
@param gyro The gyroscope sensor_t object we will fill, pass NULL to skip
455+
@param temp The temperature sensor_t object we will fill, pass NULL to skip
359456
*/
360457
/**************************************************************************/
361458
void Adafruit_LSM9DS0::getSensor(sensor_t *accel, sensor_t *mag, sensor_t *gyro,
@@ -471,6 +568,13 @@ uint8_t Adafruit_LSM9DS0::spixfer(uint8_t data) {
471568
}
472569
}
473570

571+
/**************************************************************************/
572+
/*!
573+
@brief Fill in the details about the most recent accelerometer data read
574+
@param event The sensor_event_t object we will fill!
575+
@param timestamp Unused
576+
*/
577+
/**************************************************************************/
474578
void Adafruit_LSM9DS0::getAccelEvent(sensors_event_t *event,
475579
uint32_t timestamp) {
476580
memset(event, 0, sizeof(sensors_event_t));
@@ -489,6 +593,13 @@ void Adafruit_LSM9DS0::getAccelEvent(sensors_event_t *event,
489593
event->acceleration.z *= SENSORS_GRAVITY_STANDARD;
490594
}
491595

596+
/**************************************************************************/
597+
/*!
598+
@brief Fill in the details about the most recent magnetometer data read
599+
@param event The sensor_event_t object we will fill!
600+
@param timestamp Unused
601+
*/
602+
/**************************************************************************/
492603
void Adafruit_LSM9DS0::getMagEvent(sensors_event_t *event, uint32_t timestamp) {
493604
memset(event, 0, sizeof(sensors_event_t));
494605
event->version = sizeof(sensors_event_t);
@@ -503,6 +614,13 @@ void Adafruit_LSM9DS0::getMagEvent(sensors_event_t *event, uint32_t timestamp) {
503614
event->magnetic.z /= 1000;
504615
}
505616

617+
/**************************************************************************/
618+
/*!
619+
@brief Fill in the details about the most recent gyroscope data read
620+
@param event The sensor_event_t object we will fill!
621+
@param timestamp The millis timestamp when the read occured
622+
*/
623+
/**************************************************************************/
506624
void Adafruit_LSM9DS0::getGyroEvent(sensors_event_t *event,
507625
uint32_t timestamp) {
508626
memset(event, 0, sizeof(sensors_event_t));
@@ -515,6 +633,13 @@ void Adafruit_LSM9DS0::getGyroEvent(sensors_event_t *event,
515633
event->gyro.z = gyroData.z * _gyro_dps_digit * SENSORS_DPS_TO_RADS;
516634
}
517635

636+
/**************************************************************************/
637+
/*!
638+
@brief Fill in the details about the most recent temperature data read
639+
@param event The sensor_event_t object we will fill!
640+
@param timestamp The millis timestamp when the read occured
641+
*/
642+
/**************************************************************************/
518643
void Adafruit_LSM9DS0::getTempEvent(sensors_event_t *event,
519644
uint32_t timestamp) {
520645
memset(event, 0, sizeof(sensors_event_t));
@@ -527,6 +652,12 @@ void Adafruit_LSM9DS0::getTempEvent(sensors_event_t *event,
527652
// event->temperature /= LSM9DS0_TEMP_LSB_DEGREE_CELSIUS;
528653
}
529654

655+
/**************************************************************************/
656+
/*!
657+
@brief Fill in the details about the accelerometer sensor component
658+
@param sensor The sensor_t object we will fill!
659+
*/
660+
/**************************************************************************/
530661
void Adafruit_LSM9DS0::getAccelSensor(sensor_t *sensor) {
531662
memset(sensor, 0, sizeof(sensor_t));
532663
strncpy(sensor->name, "LSM9DS0_A", sizeof(sensor->name) - 1);
@@ -540,6 +671,12 @@ void Adafruit_LSM9DS0::getAccelSensor(sensor_t *sensor) {
540671
sensor->resolution = 0.0; // ToDo
541672
}
542673

674+
/**************************************************************************/
675+
/*!
676+
@brief Fill in the details about the magnetometer sensor component
677+
@param sensor The sensor_t object we will fill!
678+
*/
679+
/**************************************************************************/
543680
void Adafruit_LSM9DS0::getMagSensor(sensor_t *sensor) {
544681
memset(sensor, 0, sizeof(sensor_t));
545682
strncpy(sensor->name, "LSM9DS0_M", sizeof(sensor->name) - 1);
@@ -553,6 +690,12 @@ void Adafruit_LSM9DS0::getMagSensor(sensor_t *sensor) {
553690
sensor->resolution = 0.0; // ToDo
554691
}
555692

693+
/**************************************************************************/
694+
/*!
695+
@brief Fill in the details about the gyroscope sensor component
696+
@param sensor The sensor_t object we will fill!
697+
*/
698+
/**************************************************************************/
556699
void Adafruit_LSM9DS0::getGyroSensor(sensor_t *sensor) {
557700
memset(sensor, 0, sizeof(sensor_t));
558701
strncpy(sensor->name, "LSM9DS0_G", sizeof(sensor->name) - 1);
@@ -566,6 +709,12 @@ void Adafruit_LSM9DS0::getGyroSensor(sensor_t *sensor) {
566709
sensor->resolution = 0.0; // ToDo
567710
}
568711

712+
/**************************************************************************/
713+
/*!
714+
@brief Fill in the details about the temperature sensor component
715+
@param sensor The sensor_t object we will fill!
716+
*/
717+
/**************************************************************************/
569718
void Adafruit_LSM9DS0::getTempSensor(sensor_t *sensor) {
570719
memset(sensor, 0, sizeof(sensor_t));
571720
strncpy(sensor->name, "LSM9DS0_T", sizeof(sensor->name) - 1);

0 commit comments

Comments
 (0)