prefect
Home Engineering Publications
DACS: Mixer Driver Code, mixdrv.c
 
  next up previous contents
Next: Pbus Driver Defines, pbusdefn.h Up: Mixer Unit Previous: Mixer Driver Header, mixdrv.h   Contents

Mixer Driver Code, mixdrv.c

The following code provides the necessary underlying functionality to access the hardware of the mixer unit.
/*****************************************************************************
 * DACS : Distributed Audio Control System
 *============================================================================
 *         File: mixdrv.c
 *       Author: Stephen S. Richardson
 * Date Created: 04.14.97
 *  Environment: ICC11 v4.0, 68HC11 target
 *        Build: library, not standalone
 *============================================================================
 * The code, executables, documentation, firmware images, and all related
 * material of DACS are  
 * Copyright (C) 1997 Stephen S. Richardson - ALL RIGHTS RESERVED
 *****************************************************************************
 * Source code control:
 *
 * $Id: mixdrv.c,v 1.1 1997/07/13 01:22:41 prefect Exp prefect $
 *
 *****************************************************************************/

#include <hc11.h>
#include "pbusdefn.h"
#include "mixdrv.h"
#include "build.h"
#include "lcddefn.h"
#include "stdlcd.h"
#include "serno.h"
#include "romtext.h"
#include "ACIAserial.h"


/*****************************************************************************
 * mix_get_system_config
 *
 * dynamically acquire the system configuration of the mixer unit by polling
 * for cards
 *
 * TODO: make this dynamic and not hardcoded.
 *****************************************************************************/
void mix_get_system_config (void)
{
  int i;
  
  unit.id=0;                         /* this needs to be set by the host */
  strcpy (unit.serno, UNIT_SERNO);
  strcpy (unit.ver, build_info);
  
  unit.mix_brd[0]=MIX_2163x4;
  unit.mix_brd[1]=MIX_2163x4;
  unit.mix_brd[2]=MIX_2163x4;        
  unit.mix_brd[3]=MIX_2163x4;
  for (i=4;i<MAXMIXBRDS;i++) unit.mix_brd[i]=NO_BRD;
  unit.mix_brds=4;


  unit.inp_brd[0]=IN_ANALOG8;
  unit.inp_brd[1]=IN_ANALOG8;
  unit.inp_brd[2]=IN_ANALOG8;
  unit.inp_brd[3]=IN_ANALOG8;
  unit.inp_brds=4;

  unit.out_brd[0]=OUT_ANALOG8;
  unit.out_brd[1]=OUT_ANALOG8;
  unit.out_brds=2;

  unit.opt_brd[0]=OPT_BUSCOMB;
  unit.opt_brd[1]=NO_BRD;
  unit.opt_brds=1;
}


/*****************************************************************************
 * mix_system_init
 *
 * initialize the mixer hardware
 *****************************************************************************/
void mix_system_init (void)
{
  int i,d, brd;
  int hitachi_init[]=HITACHI40x2_INIT;
  unsigned char module,ch;

  stdlcd_init(HITACHI40x2, hitachi_init);           /* init 40x2 LCD */
  stdlcd_out(HITACHI40x2, (char *) lcdmsg_intro);   /* put up intro */

  ACIA_init();    /* initialize the ACIA subsystem */
  pbus_init();   /* initialize pBUS controller */

  PBC_PC^=0x08;

  mix_get_system_config();   /* poll the hardware and obtain config */

  mix_reset_mixers();        /* reset all mixers to max. attenuation */

  /* reset option boards */
  for (i=0;i<MAXOPTBRDS;i++) {
    switch (unit.opt_brd[i]) {
    case OPT_BUSCOMB:
      mix_reset_buscomb();       /* reset the bus combiner board */
      break;
    case OPT_VU:
      mix_reset_vu();            /* reset digital vu board */
      break;
    }
  }

  PBC_PC&=~0x08;

  /* wait around, and make the link LED green/black alternating */
  for (d=0;d<40000;d++) {
    PBC_PC^=0x04;
    PBC_PC&=~0x04;
  }
  
  stdlcd_clrhome(HITACHI40x2);                       /* clear/home the LCD */
}


/*****************************************************************************
 * mix_reset_mixers
 *
 * resets all of the mixer chips to maximum attenuation
 *****************************************************************************/
void mix_reset_mixers (void)
{
  int module, ch, p;

  /* turns on all mixer channels to maximum attenuation */
  for (module=0;module<4;module++) {
    for (ch=0;ch<8;ch++) {
      p=0x98+ch;
      pbus_mwrite (PBADX_MIX0+module, p, p, p, p, CHIPALL);
      pbus_mwrite (PBADX_MIX0+module, 63, 63, 63, 63, CHIPALL);
    }
  }
}


/*****************************************************************************
 * mix_reset_buscomb
 *
 * resets the bus combiner module
 *****************************************************************************/
void mix_reset_buscomb (void)
{
  pbus_lwrite (PBADX_BCOMB,0x04+0x08+0x10);  /* turn off relays */
}

/*****************************************************************************
 * mix_reset_vu
 *
 * resets digital vu module
 *****************************************************************************/
void mix_reset_vu (void)
{
  /* not currently implemented in hw */
}


/*****************************************************************************
 * pbus_mwrite
 *
 * writes to a DACS mixer module containing 4 SSM2163 mixer chips.
 *
 * four separate bytes are blasted in a parallel bitbanged-serial scheme.
 *
 *****************************************************************************/
void pbus_mwrite (unsigned char addx, unsigned char data0,
		  unsigned char data1, unsigned char data2,
		  unsigned char data3, unsigned char mask)
{
  unsigned char i;
  unsigned char dslice;
  unsigned char bitmask_msb[]={0x80,0x40,0x20,0x10,0x08,0x04,0x02,0x01};

  PBC_PA=0xAA;                           /* mix chips ld-/wr- inact */
  PBC_PC|=PB_N_LATCH|PB_N_CLOCK;         /* pBUS latch- and clock- inactive */

  PBC_PB=addx|PB_N_RD_WR;                /* addx on pBUS, write mode */

  PBC_PC&=~PB_N_LATCH;                   /* pBUS latch- active */

  for (i=0;i<8;i++) {
    dslice = (((data0&bitmask_msb[i])<<i)>>7)|
             (((data1&bitmask_msb[i])<<i)>>5)|
             (((data2&bitmask_msb[i])<<i)>>3)|
             (((data3&bitmask_msb[i])<<i)>>1);

    dslice |= mask;

    PBC_PC&=~PB_N_CLOCK;                   /* pBUS clock- active */
    PBC_PA=dslice;                         /* data slice on pBUS */
    PBC_PC|=PB_N_CLOCK;                    /* pBUS clock- inactive */
  }

  PBC_PA=0xAA;                           /* mix chips ld-/wr- inact */
  PBC_PC|=PB_N_LATCH;                    /* pBUS latch- inactive */
}


Steve Richardson 2000-07-06
Table of Contents

[PDF] [Whole document in PDF 1.9MB]

[more photos and information]

 
Page last modified:
Copyright © 1993-2000 prefect - All Rights Reserved.