/*
  SFBPower.h - The ADC (including power monitoring) handling routines for the SFB.
  Copyright (C) 2009 The Regents of the University of New Mexico.  All rights reserved.

  This library is free software; you can redistribute it and/or
  modify it under the terms of the GNU Lesser General Public
  License as published by the Free Software Foundation; either
  version 2.1 of the License, or (at your option) any later version.

  This library 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
  Lesser General Public License for more details.

  You should have received a copy of the GNU General Public License
  along with this library; if not, write to the Free Software
  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301
  USA

  $Id$
*/

/**
  \file SFBPower.h - The ADC (including power monitoring) handling routines for the SFB.
  \author David H. Ackley.  
  \date (C) 2009 All rights reserved.
  \lgpl
 */

#ifndef SFBPOWER_H
#define SFBPOWER_H

#include "SFBTypes.h"     /* For u8 */
#include "SFBConstants.h" /* For FACE_COUNT */

extern void initADC();

extern int powerDraw();

extern int powerDraw(u32 face);

extern int rawPower(u32 face);

extern int railVoltage();

extern int rawVoltage();

extern void powerOut(u32 face, int on);  /**< Turn on (\a on != 0) or
                                              off (\a on == 0) the
                                              outbound power on \a
                                              face.
                                         */
extern void powerIn(u32 face, int on);

/* Set all outbound power ON */
extern void initPowerOuts();

#define RAIL_SAMPLE_INDEX (FACE_COUNT)
#define ADC_SAMPLE_COUNT (RAIL_SAMPLE_INDEX+1)

#if ADC_SAMPLE_COUNT > 8
#error ADC_SAMPLE_COUNT too large
#endif

extern uv32 adcSamples[ADC_SAMPLE_COUNT];

extern uv16 adcSmooth[ADC_SAMPLE_COUNT];

extern uv16 adcSmoother[ADC_SAMPLE_COUNT];

#endif /* SFBPOWER_H */
