PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
liblis3dh
getRange.c
1
/*
2
* @file getRange.c
3
*
4
* @author Michael Mulholland
5
*
6
* @version 1.0.0
7
*
8
* @copyright
9
* Copyright (C) Parallax, Inc. 2020. All Rights MIT Licensed.
10
*
11
* @brief Gets g acceleration range of the Parallax LIS3DH 3-Axis Accelerometer Module with ADC.
12
*
13
*/
14
15
16
#include "
simpletools.h
"
17
#include "
lis3dh.h
"
18
19
20
21
int
lis3dh_getRange
(
lis3dh_t
*device) {
22
23
unsigned
char
range = (
lis3dh_readByte
(device, LIS3DH_CTRL_REG4) >> 4) & 0x03;
24
25
switch
(range) {
26
27
case
LIS3DH_RANGE_16 :
return
16;
28
case
LIS3DH_RANGE_8 :
return
8;
29
case
LIS3DH_RANGE_4 :
return
4;
30
//case LIS3DH_RANGE_2 : return 2;
31
32
}
33
34
return
2;
// Default to range 2
35
36
}
37
38
39
lis3dh_getRange
int lis3dh_getRange(lis3dh_t *device)
Reads the g measurement range; one of +/- 2, +/-4, +/- 8, +- 16 g.
Definition:
getRange.c:21
simpletools.h
This library provides convenient functions for a variety of microcontroller I/O, timing,...
lis3dh.h
Simplifies reading Parallax LIS3DH 3-Axis Accelerometer Module with ADC.
lis3dh_st
Definition:
lis3dh.h:122
lis3dh_readByte
unsigned char lis3dh_readByte(lis3dh_t *device, unsigned char address)
Read a value from an LIS3DH register.
Definition:
readByte.c:21
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17