/****************************************************************************/
/* Copyright 1992, 1993 MBARI                                               */
/****************************************************************************/
/* Summary  : IBC Dual Vicor Board Functions                                */
/* Filename : vicor.h                                                       */
/* Author   : Andrew Pearce                                                 */
/* Project  : New ROV Data Concentrator                                     */
/* Version  : 1.0                                                           */
/* Created  : 09/28/92                                                      */
/* Modified : 04/01/93                                                      */
/* Archived :                                                               */
/****************************************************************************/
/* Modification History:                                                    */
/* $Header: /usr/tiburon/.cvsroot/micro/h/vicor.h,v 1.2 1997/05/19 23:33:05 audo Exp $
 * $Log: vicor.h,v $
 * Revision 1.2  1997/05/19 23:33:05  audo
 * ibc_card.h -- clean up include paths
 * vicor.h -- Fixed temperature scaling and status
 *
 * Revision 1.1.1.1  1997/05/02 17:15:42  pean
 * Initial release of the microcontroller software after Tiburon
 * Moolpool Dive to test IView, Lapboxes, modified Power can
 * GF/5V using bus capacitance mode.
 *
 * Revision 1.1  93/07/02  09:41:44  09:41:44  pean (Andrew Pearce)
 * Initial revision
 *
 *
*/
/****************************************************************************/

#define DUAL_VICOR_MAX_PSU    2         /* Number of Vicor PSU's per board  */

#define DUAL_VICOR_PSU0       0         /* Vicor PSU 0 Array Index          */
#define DUAL_VICOR_PSU1       1         /* Vicor PSU 1 Array Index          */

#define DUAL_VICOR_ONE_TEMP_WARN    80  /* Temperature warning for one Vicor*/
#define DUAL_VICOR_ONE_TEMP_ALARM   90  /* Temperature alarm for one Vicor  */

#define DUAL_VICOR_TWO_TEMP_WARN    65  /* Temperature alarm for two Vicor's*/
#define DUAL_VICOR_TWO_TEMP_ALARM   75  /* Temperature alarm for two Vicor's*/

#define DUAL_VICOR_TEMP_HYSTERISIS   5  /* Temperature hysteresis: 5 deg C  */
#define DUAL_VICOR_MAX_TEMP        200  /* Maximum Vicor Temperature deg C  */

                                        /* *** Vicor Board 0, Module 0 ***  */
#define DUAL_VICOR0_PSU0_CTRL     0x08  /* Output Enable Port Pin      1.3  */
#define DUAL_VICOR0_PSU0_STATUS   0x80  /* Output Status Port Pin      0.7  */
#define DUAL_VICOR0_PSU0_TEMP        6  /* Temperature sensor A/D chan 0.6  */

                                        /* *** Vicor Board 0, Module 1 ***  */
#define DUAL_VICOR0_PSU1_CTRL     0x04  /* Output Enable Port Pin      1.2  */
#define DUAL_VICOR0_PSU1_STATUS   0x20  /* Output Status Port Pin      0.5  */
#define DUAL_VICOR0_PSU1_TEMP        4  /* Temperature sensor A/D chan 0.4  */

                                        /* *** Vicor Board 1, Module 0 ***  */
                                        /* Output Enable Port Pin HSO4      */
#define DUAL_VICOR1_PSU0_CTRL HSO_CMD_HSO_PIN_4
#define DUAL_VICOR1_PSU0_STATUS   0x08  /* Output Status Port Pin      0.3  */
#define DUAL_VICOR1_PSU0_TEMP        2  /* Temperature sensor A/D chan 0.2  */

                                        /* *** Vicor Board 1, Module 1 ***  */
                                        /* Output Enable Port Pin HSO5      */
#define DUAL_VICOR1_PSU1_CTRL HSO_CMD_HSO_PIN_5
#define DUAL_VICOR1_PSU1_STATUS   0x02  /* Output Status Port Pin      0.1  */
#define DUAL_VICOR1_PSU1_TEMP        0  /* Temperature sensor A/D chan 0.0  */

                                        /* Dual Vicor Board status bit map  */
#define DUAL_VICOR_PSU0_ON        0x01  /* Vicor PSU 0 Desired Status Bit   */
#define DUAL_VICOR_PSU1_ON        0x02  /* Vicor PSU 1 Desired Status Bit   */
#define DUAL_VICOR_PSU0_STATUS    0x04  /* Vicor PSU 0 Actual Status Bit    */
#define DUAL_VICOR_PSU1_STATUS    0x08  /* Vicor PSU 1 Actual Status Bit    */
                                        /* 1.83 degrees kelvin per count   */
                                        /* Temp deg C = raw A/D * 1.83 - 273*/
#define DUAL_VICOR_DEGREES(rawTemp) (( (rawTemp * 18) / 10) - 273 )

typedef enum                            /* Dual Vicor Board configuration   */
{
    DUAL_VICOR_ONE_MINI_MOD,            /* Vicor board - one Mini Mod PSU   */
    DUAL_VICOR_TWO_MINI_MODS            /* Vicor board - two Mini Mod PSU's */
} vicorPsuConfig;

typedef struct                          /* Dual Vicor Board Data Structure  */
{
    IBC_BoardEntry IBC_Board;           /* IBC Board Entry structure        */
    vicorPsuConfig psuConfig;           /* Vicor Board Configuration        */

    struct                              /* Vicor PSU specific data struct   */
    {
        Byte tempWarning;               /* Vicor temperature warning thresh */
        Byte tempAlarm;                 /* Vicor temperature alarm thresh   */

        Int16 filteredTemperature;      /* Filtered Vicor Temperature       */
        filterParam tempFilter;         /* Vicor Temp Filter Parameters     */

        struct                          /* Warning and alarm status bits    */
        {
            unsigned vicorTempAlarm: 2; /* Vicor temperature alarm flag     */
            unsigned vicorEnable   : 1; /* Vicor PSU Enable Signal state    */
            unsigned psuAlarm      : 1; /* PSU Module output state alarm    */
        } status;
    } vicor[DUAL_VICOR_MAX_PSU];        /* Vicor PSU specific parameters    */
} vicorBoardEntry;

#ifdef __STDC__
                                          /* Vicor Board Initialize routine*/
    Int16
dualVicorBoardInit( IBC_BoardEntry *IBC_Boards[], Int16 maxCards,
     Byte *boardBaseAddr, vicorPsuConfig vicorConfig );

Void dualVicorSwitchControlCmd( IBC_BoardEntry* IBC_CardTable[],
     Int16 IBC_CardCount, Byte *commandBuf );

Void dualVicorStatusCmd( IBC_BoardEntry* IBC_CardTable[], Int16 IBC_CardCount,
         Byte *commandBuf );

Void dualVicorTemperatureCmd( IBC_BoardEntry* IBC_CardTable[],
     Int16 IBC_CardCount, Byte *commandBuf );

Void dualVicorSetTempThreshCmd( IBC_BoardEntry* IBC_CardTable[],
     Int16 IBC_CardCount, Byte *commandBuf );

Void dualVicorGetTempThreshCmd( IBC_BoardEntry* IBC_CardTable[],
     Int16 IBC_CardCount, Byte *commandBuf );

Void dualVicorGetAlarmStatusCmd(IBC_BoardEntry* IBC_CardTable[],
    Int16 IBC_CardCount, Byte *commandBuf );

Void dualVicorFunctions( vicorBoardEntry* vicorBoard );

#endif

