// ----------------------------------------------------------------------------------------
//
//  avr/sensors/sca3000/sca3000.h
//    
//  Bob Cook Development, Robotics Library
//  http://www.bobcookdev.com/rl/
//    
//  This file implements support for the VTI SCA3000-D01 accelerometer via SPI.
//
//  Copyright (C) 2008 Bob Cook
//
//      This program is free software; you can redistribute it and/or modify it
//      under the terms of the GNU General Public License as published by the
//      Free Software Foundation; either version 2 of the License, or (at your
//      option) any later version.
//    
//      This program is distributed in the hope that it will be useful, but 
//      WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 
//      or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License 
//      for more details.
//    
//      You should have received a copy of the GNU General Public License along
//      with this program; if not, write to the Free Software Foundation, Inc., 
//      51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
//
// ----------------------------------------------------------------------------------------


#if !defined( BCDRL_AVR_SENSORS_SCA3000_H )
#define BCDRL_AVR_SENSORS_SCA3000_H


#include <stdint.h>


// ----------------------------------------------------------------------------------------
//  definitions from "project_defs.h"
//
//  enable SCA3000 support with:
//
//      + PRJ_SCA3000_ENABLE
//
//  specify the SELECT pin for SPI communications with:
//
//      + PRJ_SCA3000_SELECT_DDR
//      + PRJ_SCA3000_SELECT_PORT
//      + PRJ_SCA3000_SELECT_PIN
//
//  specify the (optional) RESET pin with:
//
//      + PRJ_SCA3000_USE_HW_RESET
//      + PRJ_SCA3000_RESET_DDR
//      + PRJ_SCA3000_RESET_PORT
//      + PRJ_SCA3000_RESET_PIN
//
//  enable the debug support with:
//
//      + PRJ_SCA3000_ENABLE_DEBUG
//
// ----------------------------------------------------------------------------------------


// ----------------------------------------------------------------------------------------
//  sca3000_init
//
//      Initialize the SCA3000 h/w according to the project_defs.h specification.
//
//      Returns true if the initialization was successful.
//

bool sca3000_init();

    
// ----------------------------------------------------------------------------------------
//  SCA3000_reset
//
//      Reset the SCA3000 h/w.
//
//      Only compiled if PRJ_SCA3000_USE_HW_RESET is defined.
//

void sca3000_reset();


// ----------------------------------------------------------------------------------------
//  sca3000_read_x
//
//      Return the current value of the X axis.
//
//      The result is in units of 1/10,000 gravities. For example, a result of 20,000
//      indicates a +2g acceleration on this axis. Negative values indicate an opposite
//      orientation of the sensor, with similar acceleration.
//

int16_t sca3000_read_x();


// ----------------------------------------------------------------------------------------
//  sca3000_read_y
//
//      Return the current value of the Y axis. Refer to sca3000_read_x() for details of
//      the result.
//

int16_t sca3000_read_y();


// ----------------------------------------------------------------------------------------
//  sca3000_read_z
//
//      Return the current value of the Z axis. Refer to sca3000_read_x() for details of
//      the result.
//

int16_t sca3000_read_z();


// ----------------------------------------------------------------------------------------
//  sca3000_read_temp
//
//      Return the current temperature value, in units of 1/100 degrees celicus. For
//      example, a result of 2,308 indicates 23.08 degrees celcius.
//

int16_t sca3000_read_temp();


// ----------------------------------------------------------------------------------------
//  sca3000_debug_print_registers
//
//      Print the current state of the SCA3000 h/w registers to stdout.
//
//      Only compiled if PRJ_SCA3000_ENABLE_DEBUG is defined.
//

void sca3000_debug_print_registers();


#endif  // #if defined( BCDRL_AVR_SENSORS_SCA3000_H )
// ----------------------------------------------------------------------------------------
//  end of sca3000.h
// ----------------------------------------------------------------------------------------

