Embedded System Design 2 - Project
ADXL362.h
Go to the documentation of this file.
1 /***************************************************************************//**
2  * @file ADXL362.h
3  * @brief All code for the ADXL362 accelerometer.
4  * @version 3.1
5  * @author Brecht Van Eeckhoudt
6  *
7  * ******************************************************************************
8  *
9  * @section License
10  *
11  * **Copyright (C) 2019 - Brecht Van Eeckhoudt**
12  *
13  * This program is free software: you can redistribute it and/or modify
14  * it under the terms of the **GNU General Public License** as published by
15  * the Free Software Foundation, either **version 3** of the License, or
16  * (at your option) any later version.
17  *
18  * This program is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY; without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21  * GNU General Public License for more details.
22  *
23  * *A copy of the GNU General Public License can be found in the `LICENSE`
24  * file along with this source code.*
25  *
26  * @n
27  *
28  * Some methods use code obtained from examples from [Silicon Labs' GitHub](https://github.com/SiliconLabs/peripheral_examples).
29  * These sections are licensed under the Silabs License Agreement. See the file
30  * "Silabs_License_Agreement.txt" for details. Before using this software for
31  * any purpose, you must agree to the terms of that agreement.
32  *
33  ******************************************************************************/
34 
35 
36 /* Include guards prevent multiple inclusions of the same header */
37 #ifndef _ADXL362_H_
38 #define _ADXL362_H_
39 
40 
41 /* Includes necessary for this header file */
42 #include <stdint.h> /* (u)intXX_t */
43 #include <stdbool.h> /* "bool", "true", "false" */
44 
45 
46 /** Enum type for the measurement range */
47 typedef enum adxl_range
48 {
49  ADXL_RANGE_2G, /* +- 2g (reset default) */
50  ADXL_RANGE_4G, /* +- 4g */
51  ADXL_RANGE_8G /* +- 8g */
52 } ADXL_Range_t;
53 
54 /** Enum type for the ODR */
55 typedef enum adxl_odr
56 {
57  ADXL_ODR_12_5_HZ, /* 12.5 Hz */
58  ADXL_ODR_25_HZ, /* 25 Hz */
59  ADXL_ODR_50_HZ, /* 50 Hz */
60  ADXL_ODR_100_HZ, /* 100 Hz (reset default) */
61  ADXL_ODR_200_HZ, /* 200 Hz */
62  ADXL_ODR_400_HZ /* 400 Hz */
63 } ADXL_ODR_t;
64 
65 
66 /* Public prototypes */
67 void initADXL (void);
68 
69 void ADXL_setTriggered (bool triggered);
70 bool ADXL_getTriggered (void);
71 void ADXL_ackInterrupt (void);
72 
73 uint16_t ADXL_getCounter (void);
74 void ADXL_clearCounter (void);
75 
76 void ADXL_enableSPI (bool enabled);
77 void ADXL_enableMeasure (bool enabled);
78 
79 void ADXL_configRange (ADXL_Range_t givenRange);
80 void ADXL_configODR (ADXL_ODR_t givenODR);
81 void ADXL_configActivity (uint8_t gThreshold);
82 
83 void ADXL_readValues (void);
84 
85 void testADXL (void);
86 
87 
88 #endif /* _ADXL362_H_ */
void ADXL_readValues(void)
Read and display "g" values forever with a 100ms interval.
Definition: ADXL362.c:515
bool ADXL_getTriggered(void)
Getter for the ADXL_triggered variable.
Definition: ADXL362.c:216
void ADXL_configODR(ADXL_ODR_t givenODR)
Configure the Output Data Rate (ODR).
Definition: ADXL362.c:411
void ADXL_clearCounter(void)
Method to set the ADXL_triggercounter variable back to zero.
Definition: ADXL362.c:188
uint16_t ADXL_getCounter(void)
Getter for the ADXL_triggercounter variable.
Definition: ADXL362.c:178
void ADXL_enableMeasure(bool enabled)
Enable or disable measurement mode.
Definition: ADXL362.c:310
void testADXL(void)
This method goes through all of the ODR settings to see the influence they have on power usage...
Definition: ADXL362.c:571
void ADXL_setTriggered(bool triggered)
Setter for the ADXL_triggered variable.
Definition: ADXL362.c:202
void initADXL(void)
Initialize the accelerometer.
Definition: ADXL362.c:132
void ADXL_enableSPI(bool enabled)
Enable or disable the SPI pins and USART0/1 clock and peripheral to the accelerometer.
Definition: ADXL362.c:245
adxl_odr
Definition: ADXL362.h:55
void ADXL_ackInterrupt(void)
Acknowledge the interrupt from the accelerometer.
Definition: ADXL362.c:230
adxl_range
Definition: ADXL362.h:47
void ADXL_configRange(ADXL_Range_t givenRange)
Configure the measurement range and store the selected one in a global variable for later (internal) ...
Definition: ADXL362.c:358
void ADXL_configActivity(uint8_t gThreshold)
Configure the accelerometer to work in (referenced) activity threshold mode.
Definition: ADXL362.c:468
enum adxl_range ADXL_Range_t
enum adxl_odr ADXL_ODR_t