Elevator v2.0
Elevator Documenation
Loading...
Searching...
No Matches
accelerometer.h File Reference

Hardware Application Layer for ADXL335 Accelerometer. More...

#include "driver/adc.h"
#include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
Include dependency graph for accelerometer.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  Accelerometer
 Accelerometer struct for ADXL335. More...
 

Macros

#define ACC_ADC_WIDTH   (adc_bits_width_t)(ADC_WIDTH_BIT_12)
 Accelerometer Macros for modularity. More...
 
#define X_AXIS   (adc1_channel_t)(ADC1_CHANNEL_6)
 
#define Y_AXIS   (adc1_channel_t)(ADC1_CHANNEL_7)
 
#define Z_AXIS   (adc1_channel_t)(ADC1_CHANNEL_4)
 
#define ACC_ADC_ATTEN   (adc_atten_t)(ADC_ATTEN_DB_11)
 

Functions

void adcInit (Accelerometer *acc)
 ADC initialization for the accelerometer. More...
 
int read_axis (Accelerometer *acc, int id)
 Read axis for the accelerometer. More...
 

Detailed Description

Hardware Application Layer for ADXL335 Accelerometer.

Author
Jesus Minjares (https://github.com/jminjares4)
Version
0.1
Date
2021-11-27

Macro Definition Documentation

◆ ACC_ADC_ATTEN

#define ACC_ADC_ATTEN   (adc_atten_t)(ADC_ATTEN_DB_11)

◆ ACC_ADC_WIDTH

#define ACC_ADC_WIDTH   (adc_bits_width_t)(ADC_WIDTH_BIT_12)

Accelerometer Macros for modularity.

Note
Adjustable Macros to channel any of the adc pins of the accelerometer

◆ X_AXIS

#define X_AXIS   (adc1_channel_t)(ADC1_CHANNEL_6)

◆ Y_AXIS

#define Y_AXIS   (adc1_channel_t)(ADC1_CHANNEL_7)

◆ Z_AXIS

#define Z_AXIS   (adc1_channel_t)(ADC1_CHANNEL_4)

Function Documentation

◆ adcInit()

void adcInit ( Accelerometer acc)

ADC initialization for the accelerometer.

Parameters
accpass a Accelerometer by reference
Returns
None
Parameters
accpass a Accelerometer by reference
Returns
None

◆ read_axis()

int read_axis ( Accelerometer acc,
int  id 
)

Read axis for the accelerometer.

Parameters
accpass a Accelerometer by reference
idadc channel raw data
Returns
int adc raw from the desire id
Note
0 X_AXIS, 1 Y_AXIS, 2 Z_AXIS, anything else will return 0
Parameters
accpass a Accelerometer by reference
idadc channel raw data
Returns
int adc raw from the desire id
Note
0 X_AXIS, 1 Y_AXIS, 2 Z_AXIS, anything else will return 0

if 0: read x-axis elif 1: read y-axis elif 2: read z-axis else: 0