PropWare
3.0.0.229
C++ objects and CMake build system for Parallax Propeller
Simple-Libraries
Learn
Simple Libraries
Sensor
liblis3dh
shutdown.c
1
/*
2
* @file shutdown.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 Clears registers, buffers and disables 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_shutdown
(
lis3dh_t
*device)
22
{
23
24
high
(device->cs_pin);
// CS high (chip inactive)
25
//low(device->sck_pin); // CLK line low
26
27
// If SPI and SDO are set to the same pin then enable 3-wire SPI mode by setting lowest bit of REG4 to 1
28
if
(device->sdi_pin == device->sdo_pin)
29
{
lis3dh_writeByte
(device, LIS3DH_CTRL_REG4, 0b00000001);
/* 3-Wire SPI Mode */
}
30
else
{
lis3dh_writeByte
(device, LIS3DH_CTRL_REG4, 0b00000000);
/* 4-Wire SPI Mode */
}
31
32
pause
(5);
33
34
// Clear all configuration registers back to defaults, except REG4 which holds the SPI-mode
35
36
lis3dh_writeByte
(device, LIS3DH_CTRL_REG2, 0b00000000);
//
37
lis3dh_writeByte
(device, LIS3DH_CTRL_REG3, 0b00000000);
//
38
lis3dh_writeByte
(device, LIS3DH_CTRL_REG5, 0b10000000);
// Reboot (clear) memory buffer contents
39
lis3dh_writeByte
(device, LIS3DH_CTRL_REG6, 0b00000000);
//
40
lis3dh_writeByte
(device, LIS3DH_TEMP_CFG_REG, 0b00000000);
//
41
42
lis3dh_writeByte
(device, LIS3DH_CTRL_REG1, 0b00000000);
// Disable sensor
43
44
}
45
46
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
pause
void pause(int time)
Delay cog from moving on to the next statement for a certain length of time.
Definition:
libws2812.c:125
lis3dh_shutdown
void lis3dh_shutdown(lis3dh_t *device)
Shutdown the sensor, set configuration defaults with sensor disabled and clear buffers.
Definition:
shutdown.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
high
void high(int pin)
Set an I/O pin to output-high.
Definition:
high.c:19
Generated on Fri May 20 2022 16:48:05 for PropWare by
1.8.17