Académique Documents
Professionnel Documents
Culture Documents
c
* @brief: ADXL355 accelerometer IC
* @version: $Revision$
* @date: $Date$
*-----------------------------------------------------------------------------
*
Copyright (c) 2016-2017 Analog Devices, Inc.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
- Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
- Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
- Modified versions of the software must be conspicuously marked as such.
- This software is licensed solely and exclusively for use with processors
manufactured by or for Analog Devices, Inc.
- This software may not be combined or merged with other code in any manner
that would cause the software to become subject to terms and conditions
which differ from those listed here.
- Neither the name of Analog Devices, Inc. nor the names of its
contributors may be used to endorse or promote products derived
from this software without specific prior written permission.
- The use of this software may or may not infringe the patent rights of one
or more patent holders. This license does not release you from the
requirement that you obtain separate licenses from these patent holders
to use this software.
#include <ADuCM360.h>
#include <DioLib.h>
#include "ADXL355.h"
#include "Communication.h"
#include "Timer.h"
/**
@brief Initialization the accelerometer sensor
@return none
**/
void ADXL355_Init(void)
{
DioPulPin(CSACC_PORT, CSACC_PIN_NUMBER, 0); /* Disable the internal pull up on
CSACC pin */
DioOenPin(CSACC_PORT, CSACC_PIN_NUMBER, 1); /* Set CSACC pin as output */
DioPulPin(INT1ACC_PORT, INT1ACC_PIN_NUMBER, 0); /* Disable the internal pull up on
INT1ACC pin */
DioOenPin(INT1ACC_PORT, INT1ACC_PIN_NUMBER, 0); /* Set INT1ACC pin as input */
/**
@brief Turns on accelerometer measurement mode.
@return none
**/
void ADXL355_Start_Sensor(void)
{
uint8_t ui8temp;
/**
@brief Puts the accelerometer into standby mode.
@return none
**/
void ADXL355_Stop_Sensor(void)
{
uint8_t ui8temp;
/**
@brief Reads the accelerometer data.
@return none
**/
void ADXL355_Data_Scan(void)
{
/**
@brief Convert the two's complement data in X,Y,Z registers to signed integers
**/
int32_t ADXL355_Acceleration_Data_Conversion (uint32_t ui32SensorData)
{
int32_t volatile i32Conversion = 0;
}
else{
i32Conversion = ui32SensorData;
}
return i32Conversion;
}
/*
* ATmega16_Accelerometer.c
* http://www.electronicwings.com
*
*/
int main(void)
{
char buffer[50];
int ADC_X_VALUE,ADC_Y_VALUE,ADC_Z_VALUE;
USART_Init(9600); /* Initialize USART with 9600 Baud rate */
ADC_Init(); /* Initialize ADC */
while(1)
{
ADC_X_VALUE = ADC_Read(0); /* Read X, Y, Z axis ADC value
*/
ADC_Y_VALUE = ADC_Read(1);
ADC_Z_VALUE = ADC_Read(2);
#include <math.h>
const int x_out = A1; /* connect x_out of module to A1 of UNO board */
const int y_out = A2; /* connect y_out of module to A2 of UNO board */
const int z_out = A3; /* connect z_out of module to A3 of UNO board */
void setup() {
Serial.begin(9600);
}
void loop() {
int x_adc_value, y_adc_value, z_adc_value;
double x_g_value, y_g_value, z_g_value;
double roll, pitch, yaw;
x_adc_value = analogRead(x_out); /* Digital value of voltage on x_out pin
*/
y_adc_value = analogRead(y_out); /* Digital value of voltage on y_out pin
*/
z_adc_value = analogRead(z_out); /* Digital value of voltage on z_out pin
*/
Serial.print("x = ");
Serial.print(x_adc_value);
Serial.print("\t\t");
Serial.print("y = ");
Serial.print(y_adc_value);
Serial.print("\t\t");
Serial.print("z = ");
Serial.print(z_adc_value);
Serial.print("\t\t");
//delay(100);
Serial.print("Roll = ");
Serial.print(roll);
Serial.print("\t");
Serial.print("Pitch = ");
Serial.print(pitch);
Serial.print("\n\n");
delay(1000);
}