示例#1
0
void
cleanbf ()
{
  int mstat;

  printf ("Clearing MIDI input buffer ...\n");

  /* clear out the buffer by resetting the head and tail indices */

  m_buff->ibufhd = 0;		/* reset the head index */
  m_buff->ibuftl = 0;		/* reset the tail index */

  /* we do this twice because we aren't disabling interrupts ... */

  m_buff->ibufhd = 0;		/* reset the head index */
  m_buff->ibuftl = 0;		/* reset the tail index */

  /* make sure it's really drained */

  mstat = m_stat ();

  while (mstat)
    {

      midi_in ();
      mstat = m_stat ();
    }

  index = 0;
}
示例#2
0
static int
mpu401_intr(struct mpu401 *m)
{
#define MPU_INTR_BUF	16
	MIDI_TYPE b[MPU_INTR_BUF];
	int i;
	int s;

/*
	printf("mpu401_intr\n");
*/
#define RXRDY(m) ( (STATUS(m) & MPU_INPUTBUSY) == 0)
#define TXRDY(m) ( (STATUS(m) & MPU_OUTPUTBUSY) == 0)
#if 0
#define D(x,l) printf("mpu401_intr %d %x %s %s\n",l, x, x&MPU_INPUTBUSY?"RX":"", x&MPU_OUTPUTBUSY?"TX":"")
#else
#define D(x,l)
#endif
	i = 0;
	s = STATUS(m);
	D(s, 1);
	while ((s & MPU_INPUTBUSY) == 0 && i < MPU_INTR_BUF) {
		b[i] = READ(m);
/*
		printf("mpu401_intr in i %d d %d\n", i, b[i]);
*/
		i++;
		s = STATUS(m);
	}
	if (i)
		midi_in(m->mid, b, i);
	i = 0;
	while (!(s & MPU_OUTPUTBUSY) && i < MPU_INTR_BUF) {
		if (midi_out(m->mid, b, 1)) {
/*
			printf("mpu401_intr out i %d d %d\n", i, b[0]);
*/

			WRITE(m, *b);
		} else {
/*
			printf("mpu401_intr write: no output\n");
*/
			return 0;
		}
		i++;
		/* DELAY(100); */
		s = STATUS(m);
	}

	if ((m->flags & M_TXEN) && (m->si)) {
		callout_reset(&m->timer, 1, mpu401_timeout, m);
	}
	return (m->flags & M_TXEN) == M_TXEN;
}