/******************************************************************************/
/* Copyright 1991 to 1995 MBARI                                               */
/******************************************************************************/
/* Summary  : Greenspring IP-Octal Board interface hardware definitions       */
/* Filename : ipOctal.h                                                       */
/* Author   : Andrew Pearce                                                   */
/* Project  : Tiburon ROV - mv162 SIO32 UART Driver for VxWorks               */
/* Version  : Version 1.0                                                     */
/* Created  : 08/30/96                                                        */
/* Modified : 10/22/96                                                        */
/* Archived :                                                                 */
/******************************************************************************/

#ifndef _IP_OCTAL_H
#define _IP_OCTAL_H

#define PS_GOOD_UART 2                  /* PS Good signals are connected to   */
#define PS_GOOD_CHAN 0                  /* UART #2, channel 0                 */

#define PSU1_GOOD_BIT   0x01            /* Breakout board power supply bits */
#define PSU2_GOOD_BIT   0x02
#define PSU3_GOOD_BIT   0x04

#define SIO_PS1_GOOD_BIT 0x02           /* UART PSU Good Bits                 */
#define SIO_PS2_GOOD_BIT 0x08

#define SIO32_IP_MODULES    3           /* Number of IP Modules per card      */
#define SIO32_MAX_UARTS     3           /* Maximum number of uarts per driver */
#define SIO32_CHAN_PER_UART 8           /* Number of serial channels per UART */

MLocal const ipModuleId  sio32IPModuleMap[SIO32_IP_MODULES] =
{
    IP_MODULE_D,                        /* Channels  0 to 7  on IP Module D   */
    IP_MODULE_C,                        /* Channels  8 to 15 on IP Module C   */
    IP_MODULE_A                         /* Channels 16 to 23 on IP Module A   */
};

                                        /* Number of serial channels per card */
#define PORTS_PER_SIO32  SIO32_MAX_UARTS * SIO32_CHAN_PER_UART

#define IP_OCTAL_RS232_ID     0x22      /* IP OCTAL RS232 Module ID           */
#define IP_MODEL_OFFSET       0x0b      /* IP Model No Byte Offset            */
#define IP_MODULE_UART_OFSFET 0x01      /* IP Module Octal UART Offset        */

#define SIO32_REG_OFFSET      0x02      /* UART registers are every 2 bytes   */
#define SIO32_CHAN_OFFSET     0x10      /* Each channel occupies 0x10 bytes   */

                                        /* Return UART's absolute base address*/
#define SIO32_UART_ADDR(uart) \
    ( ((char *) mv162IPModuleMap[sio32IPModuleMap[uart]].ipIOSpaceAddr) + \
    IP_MODULE_UART_OFSFET)

                                        /* Return register's absolute address */
                                        /* given uart #, channel # and reg ID */
#define SIO32_REG(uart, chan, reg) ((__volatile__ Char *) \
    (SIO32_UART_ADDR(uart) + (chan * SIO32_CHAN_OFFSET + \
    (reg * SIO32_REG_OFFSET))))


#ifdef INCLUDE_PROTOTYPES

#ifdef __STDC__

Void IPModuleConfigureInterrupt(ipModuleId ipModule, Nat16 intLevel);
Void IPModuleInterruptEnable(ipModuleId ipModule);
Void IPModuleInterruptDisable(ipModuleId ipModule);
STATUS sio32BoardProbe(Nat32 uart, MBool sio32Debug );
Void IPModuleIntVecSet(ipModuleId ipModule, Byte ipIntVector);

#endif /* __STDC__ */

#endif /* INCLUDE_PROTOTYPES */

#endif /* _IP_OCTAL_H */

