MAV'RIC
/home/travis/build/lis-epfl/MAVRIC_Library/hal/analog_monitor.h
00001 /*******************************************************************************
00002  * Copyright (c) 2009-2016, MAV'RIC Development Team
00003  * All rights reserved.
00004  *
00005  * Redistribution and use in source and binary forms, with or without
00006  * modification, are permitted provided that the following conditions are met:
00007  *
00008  * 1. Redistributions of source code must retain the above copyright notice,
00009  * this list of conditions and the following disclaimer.
00010  *
00011  * 2. Redistributions in binary form must reproduce the above copyright notice,
00012  * this list of conditions and the following disclaimer in the documentation
00013  * and/or other materials provided with the distribution.
00014  *
00015  * 3. Neither the name of the copyright holder nor the names of its contributors
00016  * may be used to endorse or promote products derived from this software without
00017  * specific prior written permission.
00018  *
00019  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00020  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00021  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00022  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00023  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00024  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
00025  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
00026  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
00027  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
00028  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
00029  * POSSIBILITY OF SUCH DAMAGE.
00030  ******************************************************************************/
00031 
00032 /*******************************************************************************
00033  * \file analog_monitor.h
00034  *
00035  * \author MAV'RIC Team
00036  * \author Felix Schill
00037  * \author Gregoire Heitz
00038  *
00039  * \brief The driver for the analog monitor module
00040  *
00041  ******************************************************************************/
00042 
00043 
00044 #ifndef ANALOG_MONITOR_H_
00045 #define ANALOG_MONITOR_H_
00046 
00047 #ifdef __cplusplus
00048 extern "C" {
00049 #endif
00050 
00051 #include <stdint.h>
00052 #include <stdbool.h>
00053 
00054 #define MONITOR_CHANNELS 10
00055 #define MONITOR_SAMPLES  10
00056 
00057 
00061 typedef enum
00062 {
00063     ANALOG_RAIL_2,      // ANA connector, pin1
00064     ANALOG_RAIL_3,      // ANA connector, pin2
00065     ANALOG_RAIL_4,      // ANA connector, pin3
00066     ANALOG_RAIL_5,      // ANA connector, pin4
00067     ANALOG_RAIL_6,      // 6V
00068     ANALOG_RAIL_7,      // 5V_ANA
00069     ANALOG_RAIL_10,     // BATTERY_FILTERED
00070     ANALOG_RAIL_11,     // BATTERY
00071     ANALOG_RAIL_12,     // P8 connector, pin 1
00072     ANALOG_RAIL_13      // P9 connector, pin 1
00073 } analog_rails_t;
00074 
00075 
00079 typedef struct
00080 {
00081     bool enable[MONITOR_CHANNELS];          
00082     float conv_factor[MONITOR_CHANNELS];    
00083 } analog_monitor_conf_t;
00084 
00085 
00089 typedef struct
00090 {
00091     bool enable[MONITOR_CHANNELS];                      
00092     float conv_factor[MONITOR_CHANNELS];                
00093     int16_t buffer[MONITOR_CHANNELS][MONITOR_SAMPLES];  
00094     float avg[MONITOR_CHANNELS];                        
00095 } analog_monitor_t;
00096 
00097 
00104 void analog_monitor_init(analog_monitor_t* analog_monitor, const analog_monitor_conf_t config);
00105 
00106 
00114 bool analog_monitor_update(analog_monitor_t* analog_monitor);
00115 
00116 #ifdef __cplusplus
00117 }
00118 #endif
00119 
00120 #endif /* ANALOG_MONITOR_H_ */
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Defines