PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
liblis3dh
getResolution.c
1
/*
2
* @file getResolution.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 resolution mode from 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_getResolution
(
lis3dh_t
*device)
22
{
23
24
unsigned
char
r1 = (
lis3dh_readByte
(device, LIS3DH_CTRL_REG1) & 0b00001000) >> 3;
25
unsigned
char
r4 = (
lis3dh_readByte
(device, LIS3DH_CTRL_REG4) & 0b00001000) >> 3;
26
27
if
(r1 == 0 && r4 == 1) {
return
12; }
// 12-bit
28
29
else
if
(r1 == 0 && r4 == 0) {
return
10; }
// 10-bit
30
31
else
if
(r1 == 1 && r4 == 0) {
return
8; }
// 8-bit
32
33
else
{
return
0; }
// Invalid configuration in sensor
34
35
36
}
37
38
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
lis3dh_getResolution
int lis3dh_getResolution(lis3dh_t *device)
Reads the bit resolution setting from the sensor. 8-bit, 10-bit or 12-bit.
Definition:
getResolution.c:21
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17