/****************************************************************************/
/* Copyright 1996 MBARI                                                     */
/****************************************************************************/
/* Summary  : IBC Hydrophone Power Supply Board Interface for VxWorks       */
/* Filename : hydroPsu.c                                                    */
/* Author   : Andrew Pearce                                                 */
/* Project  : Tiburon ROV                                                   */
/* Version  : Version 1.0                                                   */
/* Created  : 07/09/96                                                      */
/* Modified : 07/09/96                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: $
 * $Log: $
 */
/****************************************************************************/

#include <vxWorks.h>                /* vxWorks system declarations          */
#include <semLib.h>                 /* vxWorks semaphore functions          */
#include <wdLib.h>                  /* vxWorks watch dog timer support decls*/
#include <msgQLib.h>                /* vxWorks Message Queue Library        */

#include <mbariTypes.h>             /* mbari style guide type declarations  */
#include <mbariConst.h>             /* Miscellaneous constants              */

#include <sio32.h>                  /* SIO32 hardware and driver information*/
#include <sio32Server.h>            /* Sio32 server communication services  */
#include <sio32Client.h>            /* Sio32 client communication services  */
#include <microCmd.h>               /* Microcontoller command functions     */

#include "microdef.h"               /* Microcontroller definitions          */
#include "applic.h"                 /* Microcontroller applications         */
#include "microcmd.h"               /* Microcontroller commands             */
#include "ibc_card.h"               /* IBC Card Types                       */
#include "filter.h"                 /* General Filter Routines              */
#include "ibc_cmd.h"                /* IBC Card Serial Commands             */

#include "hydroPsu.h"               /* Application Function Prototypes      */

/****************************************************************************/
/* Function    : IBC_hydroPSUOutputCtrl                                     */
/* Purpose     : Sets state of Hydrophone PSU Output                        */
/* Inputs      : Sio32 channel, IBC Board Address, Desired state            */
/* Outputs     : Returns OK or ERROR                                        */
/****************************************************************************/
    STATUS
IBC_hydroPSUOutputCtrl( sio32Chan *IBC_SerialChan, Word boardAddr,
    MBool desiredState )
{
    Word    status;                 /* Command Result from microcontroller  */

                                    /* Send command to microcontroller      */
    if ( sendMicroCommand( IBC_SerialChan, &status, sizeof(status),
         3, IBC_CPU_APP | HYDRO_PSU_SWITCH_CTRL, boardAddr, desiredState)
         == ERROR ) return(ERROR);

                                    /* Check command result                  */
    return (wordFromBuf(&status, 0) == CMD_OK ? OK : ERROR);
} /* IBC_HydroPSUOutputCtrl() */

