Skip to content

Commit b1cbef5

Browse files
Dan-Lightsourcecalvinatintel
authored andcommitted
imu: minor tidy-up of documentation for API enumeration values
Signed-off-by: Dan O'Donovan <dan@emutex.com>
1 parent b62bbfc commit b1cbef5

File tree

2 files changed

+124
-81
lines changed

2 files changed

+124
-81
lines changed

libraries/CurieImu/src/BMI160.cpp

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ bool BMI160Class::testConnection()
154154
* </pre>
155155
*
156156
* @return Current sample rate
157-
* @see BMI160_GYRO_RATE_25HZ
158157
* @see BMI160_RA_GYRO_CONF
158+
* @see BMI160GyroRate
159159
*/
160160
uint8_t BMI160Class::getGyroRate() {
161161
return reg_read_bits(BMI160_RA_GYRO_CONF,
@@ -192,8 +192,8 @@ void BMI160Class::setGyroRate(uint8_t rate) {
192192
* </pre>
193193
*
194194
* @return Current sample rate
195-
* @see BMI160_ACCEL_RATE_25HZ
196195
* @see BMI160_RA_ACCEL_CONF
196+
* @see BMI160AccelRate
197197
*/
198198
uint8_t BMI160Class::getAccelRate() {
199199
return reg_read_bits(BMI160_RA_ACCEL_CONF,
@@ -203,8 +203,7 @@ uint8_t BMI160Class::getAccelRate() {
203203

204204
/** Set accelerometer output data rate.
205205
* @param rate New output data rate
206-
* @see getGyroRate()
207-
* @see BMI160_ACCEL_RATE_25HZ
206+
* @see getAccelRate()
208207
* @see BMI160_RA_ACCEL_CONF
209208
*/
210209
void BMI160Class::setAccelRate(uint8_t rate) {
@@ -239,8 +238,8 @@ void BMI160Class::setAccelRate(uint8_t rate) {
239238
* bandwidths above are approximately 4 times smaller.
240239
*
241240
* @return DLFP configuration
242-
* @see BMI160_DLPF_MODE_NORM
243241
* @see BMI160_RA_GYRO_CONF
242+
* @see BMI160DLPFMode
244243
*/
245244
uint8_t BMI160Class::getGyroDLPFMode() {
246245
return reg_read_bits(BMI160_RA_GYRO_CONF,
@@ -285,7 +284,7 @@ void BMI160Class::setGyroDLPFMode(uint8_t mode) {
285284
*
286285
* @return DLFP configuration
287286
* @see BMI160_RA_GYRO_CONF
288-
* @see BMI160_DLPF_MODE_NORM
287+
* @see BMI160DLPFMode
289288
*/
290289
uint8_t BMI160Class::getAccelDLPFMode() {
291290
return reg_read_bits(BMI160_RA_ACCEL_CONF,
@@ -308,16 +307,16 @@ void BMI160Class::setAccelDLPFMode(uint8_t mode) {
308307
* as described in the table below.
309308
*
310309
* <pre>
311-
* 4 = +/- 125 degrees/sec
312-
* 3 = +/- 250 degrees/sec
313-
* 2 = +/- 500 degrees/sec
310+
* 4 = +/- 125 degrees/sec
311+
* 3 = +/- 250 degrees/sec
312+
* 2 = +/- 500 degrees/sec
314313
* 1 = +/- 1000 degrees/sec
315314
* 0 = +/- 2000 degrees/sec
316315
* </pre>
317316
*
318317
* @return Current full-scale gyroscope range setting
319-
* @see BMI160_GYRO_RANGE_125
320318
* @see BMI160_RA_GYRO_RANGE
319+
* @see BMI160GyroRange
321320
*/
322321
uint8_t BMI160Class::getFullScaleGyroRange() {
323322
return reg_read_bits(BMI160_RA_GYRO_RANGE,
@@ -347,10 +346,8 @@ void BMI160Class::setFullScaleGyroRange(uint8_t range) {
347346
* </pre>
348347
*
349348
* @return Current full-scale accelerometer range setting
350-
* @see BMI160_ACCEL_RANGE_2G
351349
* @see BMI160_RA_ACCEL_RANGE
352-
* @see BMI160_ACCEL_RANGE_SEL_BIT
353-
* @see BMI160_ACCEL_RANGE_SEL_LEN
350+
* @see BMI160AccelRange
354351
*/
355352
uint8_t BMI160Class::getFullScaleAccelRange() {
356353
return reg_read_bits(BMI160_RA_ACCEL_RANGE,
@@ -361,6 +358,7 @@ uint8_t BMI160Class::getFullScaleAccelRange() {
361358
/** Set full-scale accelerometer range.
362359
* @param range New full-scale accelerometer range setting
363360
* @see getFullScaleAccelRange()
361+
* @see BMI160AccelRange
364362
*/
365363
void BMI160Class::setFullScaleAccelRange(uint8_t range) {
366364
reg_write_bits(BMI160_RA_ACCEL_RANGE, range,
@@ -820,6 +818,7 @@ void BMI160Class::setShockDetectionDuration(uint8_t duration) {
820818
* @return Set Step Detection mode
821819
* @see BMI160_RA_STEP_CONF_0
822820
* @see BMI160_RA_STEP_CONF_1
821+
* @see BMI160StepMode
823822
*/
824823
void BMI160Class::setStepDetectionMode(BMI160StepMode mode) {
825824
uint8_t step_conf0, min_step_buf;
@@ -1149,7 +1148,7 @@ void BMI160Class::setTapDetectionThreshold(uint8_t threshold) {
11491148
*
11501149
* @return Current tap detection duration threshold value
11511150
* @see BMI160_RA_INT_TAP_0
1152-
* @see BMI160_TAP_SHOCK_BIT
1151+
* @see BMI160TapShockDuration
11531152
*/
11541153
bool BMI160Class::getTapShockDuration() {
11551154
return !!(reg_read_bits(BMI160_RA_INT_TAP_0,
@@ -1162,7 +1161,6 @@ bool BMI160Class::getTapShockDuration() {
11621161
* @param units New tap detection duration threshold value
11631162
* @see getTapShockDetectionDuration()
11641163
* @see BMI160_RA_INT_TAP_0
1165-
* @see BMI160_TAP_SHOCK_BIT
11661164
*/
11671165
void BMI160Class::setTapShockDuration(bool duration) {
11681166
reg_write_bits(BMI160_RA_INT_TAP_0, duration ? 0x1 : 0,
@@ -1188,7 +1186,7 @@ void BMI160Class::setTapShockDuration(bool duration) {
11881186
*
11891187
* @return Current tap quiet detection duration threshold value
11901188
* @see BMI160_RA_INT_TAP_0
1191-
* @see BMI160_TAP_QUIET_BIT
1189+
* @see BMI160TapQuietDuration
11921190
*/
11931191
bool BMI160Class::getTapQuietDuration() {
11941192
return !!(reg_read_bits(BMI160_RA_INT_TAP_0,
@@ -1201,7 +1199,6 @@ bool BMI160Class::getTapQuietDuration() {
12011199
* @param units New tap detection duration threshold value
12021200
* @see getTapQuietDuration()
12031201
* @see BMI160_RA_INT_TAP_0
1204-
* @see BMI160_TAP_QUIET_BIT
12051202
*/
12061203
void BMI160Class::setTapQuietDuration(bool duration) {
12071204
reg_write_bits(BMI160_RA_INT_TAP_0, duration ? 0x1 : 0,
@@ -1234,6 +1231,7 @@ void BMI160Class::setTapQuietDuration(bool duration) {
12341231
*
12351232
* @return Current double-tap detection time window threshold value
12361233
* @see BMI160_RA_INT_TAP_0
1234+
* @see BMI160DoubleTapDuration
12371235
*/
12381236
uint8_t BMI160Class::getDoubleTapDetectionDuration() {
12391237
return reg_read_bits(BMI160_RA_INT_TAP_0,
@@ -2103,7 +2101,7 @@ void BMI160Class::setInterruptDrive(bool drive) {
21032101
*
21042102
* @return Current latch mode
21052103
* @see BMI160_RA_INT_LATCH
2106-
* @see BMI160_LATCH_MODE_BIT
2104+
* @see BMI160InterruptLatchMode
21072105
*/
21082106
uint8_t BMI160Class::getInterruptLatch() {
21092107
return reg_read_bits(BMI160_RA_INT_LATCH,
@@ -2115,7 +2113,7 @@ uint8_t BMI160Class::getInterruptLatch() {
21152113
* @param latch New latch mode
21162114
* @see getInterruptLatch()
21172115
* @see BMI160_RA_INT_LATCH
2118-
* @see BMI160_LATCH_MODE_BIT
2116+
* @see BMI160InterruptLatchMode
21192117
*/
21202118
void BMI160Class::setInterruptLatch(uint8_t mode) {
21212119
reg_write_bits(BMI160_RA_INT_LATCH, mode,

libraries/CurieImu/src/BMI160.h

Lines changed: 107 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -153,23 +153,6 @@ THE SOFTWARE.
153153
#define BMI160_LATCH_MODE_BIT 0
154154
#define BMI160_LATCH_MODE_LEN 4
155155

156-
#define BMI160_LATCH_MODE_NONE 0
157-
#define BMI160_LATCH_MODE_312_5_US 1
158-
#define BMI160_LATCH_MODE_625_US 2
159-
#define BMI160_LATCH_MODE_1_25_MS 3
160-
#define BMI160_LATCH_MODE_2_5_MS 4
161-
#define BMI160_LATCH_MODE_5_MS 5
162-
#define BMI160_LATCH_MODE_10_MS 6
163-
#define BMI160_LATCH_MODE_20_MS 7
164-
#define BMI160_LATCH_MODE_40_MS 8
165-
#define BMI160_LATCH_MODE_80_MS 9
166-
#define BMI160_LATCH_MODE_160_MS 10
167-
#define BMI160_LATCH_MODE_320_MS 11
168-
#define BMI160_LATCH_MODE_640_MS 12
169-
#define BMI160_LATCH_MODE_1_28_S 13
170-
#define BMI160_LATCH_MODE_2_56_S 14
171-
#define BMI160_LATCH_MODE_LATCH 15
172-
173156
#define BMI160_RA_INT_LATCH 0x54
174157
#define BMI160_RA_INT_MAP_0 0x55
175158
#define BMI160_RA_INT_MAP_1 0x56
@@ -251,60 +234,18 @@ THE SOFTWARE.
251234
#define BMI160_GYRO_RANGE_SEL_BIT 0
252235
#define BMI160_GYRO_RANGE_SEL_LEN 3
253236

254-
/* Gyroscope Full-Scale Range Options */
255-
#define BMI160_GYRO_RANGE_125 0x04
256-
#define BMI160_GYRO_RANGE_250 0x03
257-
#define BMI160_GYRO_RANGE_500 0x02
258-
#define BMI160_GYRO_RANGE_1000 0x01
259-
#define BMI160_GYRO_RANGE_2000 0x00
260-
261237
#define BMI160_GYRO_RATE_SEL_BIT 0
262238
#define BMI160_GYRO_RATE_SEL_LEN 4
263239

264-
/* Gyroscope Output Data Rate Options */
265-
#define BMI160_GYRO_RATE_25HZ 0x06
266-
#define BMI160_GYRO_RATE_50HZ 0x07
267-
#define BMI160_GYRO_RATE_100HZ 0x08
268-
#define BMI160_GYRO_RATE_200HZ 0x09
269-
#define BMI160_GYRO_RATE_400HZ 0x0A
270-
#define BMI160_GYRO_RATE_800HZ 0x0B
271-
#define BMI160_GYRO_RATE_1600HZ 0x0C
272-
#define BMI160_GYRO_RATE_3200HZ 0x0D
273-
274240
#define BMI160_GYRO_DLPF_SEL_BIT 4
275241
#define BMI160_GYRO_DLPF_SEL_LEN 2
276242

277243
#define BMI160_ACCEL_DLPF_SEL_BIT 4
278244
#define BMI160_ACCEL_DLPF_SEL_LEN 3
279245

280-
/* Gyroscope Digital Low-Pass Filter Mode Options */
281-
#define BMI160_DLPF_MODE_NORM 0x2
282-
#define BMI160_DLPF_MODE_OSR2 0x1
283-
#define BMI160_DLPF_MODE_OSR4 0x0
284-
285246
#define BMI160_ACCEL_RANGE_SEL_BIT 0
286247
#define BMI160_ACCEL_RANGE_SEL_LEN 4
287248

288-
/* Accelerometer Range Options */
289-
#define BMI160_ACCEL_RANGE_2G 0X03
290-
#define BMI160_ACCEL_RANGE_4G 0X05
291-
#define BMI160_ACCEL_RANGE_8G 0X08
292-
#define BMI160_ACCEL_RANGE_16G 0X0C
293-
294-
/* Accelerometer Output Data Rate Options */
295-
#define BMI160_ACCEL_RATE_25_32HZ 0x01
296-
#define BMI160_ACCEL_RATE_25_16HZ 0x02
297-
#define BMI160_ACCEL_RATE_25_8HZ 0x03
298-
#define BMI160_ACCEL_RATE_25_4HZ 0x04
299-
#define BMI160_ACCEL_RATE_25_2HZ 0x05
300-
#define BMI160_ACCEL_RATE_25HZ 0x06
301-
#define BMI160_ACCEL_RATE_50HZ 0x07
302-
#define BMI160_ACCEL_RATE_100HZ 0x08
303-
#define BMI160_ACCEL_RATE_200HZ 0x09
304-
#define BMI160_ACCEL_RATE_400HZ 0x0A
305-
#define BMI160_ACCEL_RATE_800HZ 0x0B
306-
#define BMI160_ACCEL_RATE_1600HZ 0x0C
307-
308249
#define BMI160_CMD_START_FOC 0x03
309250
#define BMI160_CMD_ACC_MODE_NORMAL 0x11
310251
#define BMI160_CMD_GYR_MODE_NORMAL 0x15
@@ -315,22 +256,129 @@ THE SOFTWARE.
315256

316257
#define BMI160_RA_CMD 0x7E
317258

259+
/**
260+
* Interrupt Latch Mode options
261+
* @see setInterruptLatch()
262+
*/
263+
typedef enum {
264+
BMI160_LATCH_MODE_NONE = 0, /**< Non-latched */
265+
BMI160_LATCH_MODE_312_5_US, /**< Temporary, 312.50 microseconds */
266+
BMI160_LATCH_MODE_625_US, /**< Temporary, 625.00 microseconds */
267+
BMI160_LATCH_MODE_1_25_MS, /**< Temporary, 1.25 milliseconds */
268+
BMI160_LATCH_MODE_2_5_MS, /**< Temporary, 2.50 milliseconds */
269+
BMI160_LATCH_MODE_5_MS, /**< Temporary, 5.00 milliseconds */
270+
BMI160_LATCH_MODE_10_MS, /**< Temporary, 10.00 milliseconds */
271+
BMI160_LATCH_MODE_20_MS, /**< Temporary, 20.00 milliseconds */
272+
BMI160_LATCH_MODE_40_MS, /**< Temporary, 40.00 milliseconds */
273+
BMI160_LATCH_MODE_80_MS, /**< Temporary, 80.00 milliseconds */
274+
BMI160_LATCH_MODE_160_MS, /**< Temporary, 160.00 milliseconds */
275+
BMI160_LATCH_MODE_320_MS, /**< Temporary, 320.00 milliseconds */
276+
BMI160_LATCH_MODE_640_MS, /**< Temporary, 640.00 milliseconds */
277+
BMI160_LATCH_MODE_1_28_S, /**< Temporary, 1.28 seconds */
278+
BMI160_LATCH_MODE_2_56_S, /**< Temporary, 2.56 seconds */
279+
BMI160_LATCH_MODE_LATCH, /**< Latched, @see resetInterrupt() */
280+
} BMI160InterruptLatchMode;
281+
282+
/**
283+
* Digital Low-Pass Filter Mode options
284+
* @see setGyroDLPFMode()
285+
* @see setAccelDLPFMode()
286+
*/
287+
typedef enum {
288+
BMI160_DLPF_MODE_NORM = 0x2,
289+
BMI160_DLPF_MODE_OSR2 = 0x1,
290+
BMI160_DLPF_MODE_OSR4 = 0x0,
291+
} BMI160DLPFMode;
292+
293+
/**
294+
* Accelerometer Sensitivity Range options
295+
* @see setFullScaleAccelRange()
296+
*/
297+
typedef enum {
298+
BMI160_ACCEL_RANGE_2G = 0X03, /**< +/- 2g range */
299+
BMI160_ACCEL_RANGE_4G = 0X05, /**< +/- 4g range */
300+
BMI160_ACCEL_RANGE_8G = 0X08, /**< +/- 8g range */
301+
BMI160_ACCEL_RANGE_16G = 0X0C, /**< +/- 16g range */
302+
} BMI160AccelRange;
303+
304+
/**
305+
* Gyroscope Sensitivity Range options
306+
* @see setFullScaleGyroRange()
307+
*/
308+
typedef enum {
309+
BMI160_GYRO_RANGE_2000 = 0, /**< +/- 2000 degrees/second */
310+
BMI160_GYRO_RANGE_1000, /**< +/- 1000 degrees/second */
311+
BMI160_GYRO_RANGE_500, /**< +/- 500 degrees/second */
312+
BMI160_GYRO_RANGE_250, /**< +/- 250 degrees/second */
313+
BMI160_GYRO_RANGE_125, /**< +/- 125 degrees/second */
314+
} BMI160GyroRange;
315+
316+
/**
317+
* Accelerometer Output Data Rate options
318+
* @see setAccelRate()
319+
*/
320+
typedef enum {
321+
BMI160_ACCEL_RATE_25_32HZ = 1, /**< 25/32 Hz */
322+
BMI160_ACCEL_RATE_25_16HZ, /**< 25/16 Hz */
323+
BMI160_ACCEL_RATE_25_8HZ, /**< 25/8 Hz */
324+
BMI160_ACCEL_RATE_25_4HZ, /**< 25/4 Hz */
325+
BMI160_ACCEL_RATE_25_2HZ, /**< 25/2 Hz */
326+
BMI160_ACCEL_RATE_25HZ, /**< 25 Hz */
327+
BMI160_ACCEL_RATE_50HZ, /**< 50 Hz */
328+
BMI160_ACCEL_RATE_100HZ, /**< 100 Hz */
329+
BMI160_ACCEL_RATE_200HZ, /**< 200 Hz */
330+
BMI160_ACCEL_RATE_400HZ, /**< 400 Hz */
331+
BMI160_ACCEL_RATE_800HZ, /**< 800 Hz */
332+
BMI160_ACCEL_RATE_1600HZ, /**< 1600 Hz */
333+
} BMI160AccelRate;
334+
335+
/**
336+
* Gyroscope Output Data Rate options
337+
* @see setGyroRate()
338+
*/
339+
typedef enum {
340+
BMI160_GYRO_RATE_25HZ = 6, /**< 25 Hz */
341+
BMI160_GYRO_RATE_50HZ, /**< 50 Hz */
342+
BMI160_GYRO_RATE_100HZ, /**< 100 Hz */
343+
BMI160_GYRO_RATE_200HZ, /**< 200 Hz */
344+
BMI160_GYRO_RATE_400HZ, /**< 400 Hz */
345+
BMI160_GYRO_RATE_800HZ, /**< 800 Hz */
346+
BMI160_GYRO_RATE_1600HZ, /**< 1600 Hz */
347+
BMI160_GYRO_RATE_3200HZ, /**< 3200 Hz */
348+
} BMI160GyroRate;
349+
350+
/**
351+
* Step Detection Mode options
352+
* @see setStepDetectionMode()
353+
*/
318354
typedef enum {
319355
BMI160_STEP_MODE_NORMAL = 0,
320356
BMI160_STEP_MODE_SENSITIVE,
321357
BMI160_STEP_MODE_ROBUST,
322358
} BMI160StepMode;
323359

360+
/**
361+
* Tap Detection Shock Duration options
362+
* @see setTapShockDuration()
363+
*/
324364
typedef enum {
325365
BMI160_TAP_SHOCK_DURATION_50MS = 0,
326366
BMI160_TAP_SHOCK_DURATION_75MS,
327367
} BMI160TapShockDuration;
328368

369+
/**
370+
* Tap Detection Quiet Duration options
371+
* @see setTapQuietDuration()
372+
*/
329373
typedef enum {
330374
BMI160_TAP_QUIET_DURATION_30MS = 0,
331375
BMI160_TAP_QUIET_DURATION_20MS,
332376
} BMI160TapQuietDuration;
333377

378+
/**
379+
* Double-Tap Detection Duration options
380+
* @see setDoubleTapDetectionDuration()
381+
*/
334382
typedef enum {
335383
BMI160_DOUBLE_TAP_DURATION_50MS = 0,
336384
BMI160_DOUBLE_TAP_DURATION_100MS,
@@ -517,9 +565,6 @@ class BMI160Class {
517565
uint8_t getRegister(uint8_t reg);
518566
void setRegister(uint8_t reg, uint8_t data);
519567

520-
/* TODO - consider making these protected - not sure if we want to allow use from a sketch
521-
* except perhaps for the latch control functions
522-
*/
523568
bool getIntEnabled();
524569
void setIntEnabled(bool enabled);
525570
bool getInterruptMode();

0 commit comments

Comments
 (0)