PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
liblis3dh
setResolution.c
1
/*
2
* @file setResolution.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 Sets 8, 10 or 12 bit resolution mode for 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
void
lis3dh_setResolution
(
lis3dh_t
*device,
int
bits)
22
{
23
24
unsigned
char
r1 =
lis3dh_readByte
(device, LIS3DH_CTRL_REG1);
25
unsigned
char
r4 =
lis3dh_readByte
(device, LIS3DH_CTRL_REG4);
26
27
switch
(bits) {
28
29
case
12 : r1 &= ~0b00001000; r4 |= 0b00001000;
break
;
30
case
10 : r1 &= ~0b00001000; r4 &= ~0b00001000;
break
;
31
default : r1 |= 0b00001000; r4 &= ~0b00001000;
// default to 8-bit mode
32
33
}
34
35
lis3dh_writeByte
(device, LIS3DH_CTRL_REG1, r1);
36
lis3dh_writeByte
(device, LIS3DH_CTRL_REG4, r4);
37
38
}
39
40
lis3dh_setResolution
void lis3dh_setResolution(lis3dh_t *device, int bits)
Sets the bit resolution for the sensor readings. 8-bit, 10-bit or 12-bit.
Definition:
setResolution.c:21
lis3dh_writeByte
void lis3dh_writeByte(lis3dh_t *device, unsigned char address, unsigned char value)
write a byte value to an LIS3DH register
Definition:
writeByte.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