Beispiel #1
0
/* The following was added for debugging purposes */
void Clock_exit( void )
{
  uint8_t         data;

  /* disable timer
  	data = TCR;
  	TCR = (data & 0xFE); */
  MC68230_READ (MC68230_TCR, data);
  MC68230_WRITE (MC68230_TCR, (data & 0xFE));

  /* do not restore old vector */
}
Beispiel #2
0
int benchmark_timer_read(void)
{
  uint8_t         data;
  uint8_t          msb, osb, lsb;
  uint32_t         remaining, total;

  /* Disable timer so that timer can be read
        data = MC68230_TCR;
        MC68230_TCR = (data & 0xFE); */
  MC68230_READ (MC68230_TCR, data);
  MC68230_WRITE (MC68230_TCR, (data & 0xFE));

  /* Read the counter value
        msb = MC68230_CNTRH;
        osb = MC68230_CNTRM;
        lsb = MC68230_CNTRL; */
  MC68230_READ (MC68230_CNTRH, msb);
  MC68230_READ (MC68230_CNTRM, osb);
  MC68230_READ (MC68230_CNTRL, lsb);

  /* Calculate the time so far */
  remaining = 0x1000000 - ((msb << 16) + (osb << 8) + lsb);
  total = (Ttimer_val * 0x1000000) + remaining;

  /* Enable timer so that timer can continue
	 	MC68230_TCR = 0xA1; */
  MC68230_WRITE (MC68230_TCR, 0xA1);

  /* do not restore old vector */
  if ( benchmark_timer_find_average_overhead == true )
    return total;          /* in countdown units */

  if ( total < LEAST_VALID )
    return 0;            /* below timer resolution */

  /* Clocked at 6.5 Mhz */
  /* Avoid floating point problems, be lazy, and return the total minus
     the average overhead */
  return (total - AVG_OVERHEAD);
}
Beispiel #3
0
void benchmark_timer_initialize(void)
{
  (void) set_vector( timerisr, TIMER_VECTOR, 0 );  /* install ISR */

  Ttimer_val = 0;                          /* clear timer ISR count */

  /* some PI/T initialization stuff here */
  /* Set up the interrupt vector on the MC68230 chip:
     TIVR = TIMER_VECTOR; */
  MC68230_WRITE (MC68230_TIVR, TIMER_VECTOR);

  /* Set CPRH through CPRL to maximum count to reduce interrupt overhead
      CPRH = 0xFF;
      CPRM = 0xFF;
      CPRL = 0xFF; */
  MC68230_WRITE (MC68230_CPRH, 0xFF);
  MC68230_WRITE (MC68230_CPRM, 0xFF);
  MC68230_WRITE (MC68230_CPRL, 0xFF);

  /* Enable timer and use it as an external periodic interrupt generator
      TCR = 0xA1; */
  MC68230_WRITE (MC68230_TCR, 0xA1);

}
Beispiel #4
0
rtems_isr Clock_isr(
  rtems_vector_number vector
)
{
  Clock_driver_ticks += 1;
  /* acknowledge interrupt
  	MC68230_TSR = 1; */
  MC68230_WRITE (MC68230_TSR, 1);

  if ( Clock_isrs == 1 ) {
    rtems_clock_tick();
	/* Cast to an integer so that 68EC040 IDP which doesn't have an FPU doesn't
	   have a heart attack -- if you use newlib1.6 or greater and get
	   libgcc.a for gcc with software floating point support, this is not
	   a problem */
    Clock_isrs =
      (int)(rtems_configuration_get_microseconds_per_tick() / 1000);
  }
  else
    Clock_isrs -= 1;
}
Beispiel #5
0
void Install_clock(
  rtems_isr_entry clock_isr )
{
  Clock_driver_ticks = 0;
  Clock_isrs = (int)(rtems_configuration_get_microseconds_per_tick() / 1000);

/*    led_putnum('c'); * for debugging purposes */
    Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 );

  /* Disable timer for initialization */
  MC68230_WRITE (MC68230_TCR, 0x00);

  /* some PI/T initialization stuff here -- see comment in the ckisr.c
     file in this directory to understand why I use the values that I do */
  /* Set up the interrupt vector on the MC68230 chip:
  MC68230_TIVR = CLOCK_VECTOR; */
  MC68230_WRITE (MC68230_TIVR, CLOCK_VECTOR);

  /* Set CPRH through CPRL to 193 (not 203) decimal for countdown--see ckisr.c
  	CPRH = 0x00;
  	CPRM = 0x00;
  	CPRL = 0xC1; */
  MC68230_WRITE (MC68230_CPRH, 0x00);
  MC68230_WRITE (MC68230_CPRM, 0x00);
  MC68230_WRITE (MC68230_CPRL, 0xC1);

  /* Enable timer and use it as an external periodic interrupt generator
  	MC68230_TCR = 0xA1; */
/*    led_putnum('a'); * for debugging purposes */
  MC68230_WRITE (MC68230_TCR, 0xA1);

  /*
   *  Schedule the clock cleanup routine to execute if the application exits.
   */
  atexit( Clock_exit );
}
Beispiel #6
0
void Disable_clock(void)
{
	/* Disable timer */
	MC68230_WRITE (MC68230_TCR, 0x00);
}
/*#####################################################################
# The volatile routine to initialize the duart -- port a and port b
######################################################################*/
void init_pit()
{
  /*
   *  ports A & B while configuring PIT by:
   *
   *    + disable Interrupt Mask Register
   *    + disable port A transmitter
   *    + disable port A receiver
   *    + disable port B transmitter
   *    + disable port B receiver
   */

  MC68681_WRITE(DUART_ADDR, MC68681_INTERRUPT_MASK_REG, 0x00);
  MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A ,MC68681_MODE_REG_DISABLE_TX);
  MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_DISABLE_RX);
  MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_DISABLE_TX);
  MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_DISABLE_RX);

  /*
   *  install ISR for ports A and B
   */
  set_vector(C_Receive_ISR, (MC68230_VECT+MC68230_H3VECT), 1);

  /*
   *  initialize pit
   *
   *  set mode to 0 -- disable all ports
   *  set up pirq and piack
   *  all pins on port b are input
   *  submode 1x, h3 interrupt enabled
   *  setup pivr
   *  turn on all ports
   */
  MC68230_WRITE(MC68230_PGCR, 0x00);
  MC68230_WRITE(MC68230_PSRR, 0x18);
  MC68230_WRITE(MC68230_PBDDR, 0x00);
  MC68230_WRITE(MC68230_PBCR, 0x82);
  MC68230_WRITE(MC68230_PIVR, MC68230_VECT);
  MC68230_WRITE(MC68230_PGCR, 0x20);

  /*
   *  For some reason, the reset of receiver/transmitter only works for
   *  the first time around -- it garbles the output otherwise
   *  (e.g., sp21)
   */
  if (!Pit_initialized)
  {
    /*
     * initialize the duart registers on port b
     * WARNING:OPTIMIZER MAY ONLY EXECUTE THIRD STATEMENT IF NOT VOLATILE
     *
     *  reset tx, channel b
     *  reset rx, channel b
     *  reset mr pointer, ch
     */
     MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_RESET_TX);
     MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_RESET_RX);
     MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B, MC68681_MODE_REG_RESET_MR_PTR);

    /*
     * initialize the duart registers on port a
     * WARNING:OPTIMIZER MAY ONLY EXECUTE THIRD STATEMENT IF NOT VOLATILE
     *
     *  reset tx, channel a
     *  reset rx, channel a
     *  reset mr pointer, ch
     */
     MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_RESET_TX);
     MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_RESET_RX);
     MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A, MC68681_MODE_REG_RESET_MR_PTR);

     Pit_initialized = 1;
  }

  /*
   * Init the general registers of the duart
   *
   * init ivr
   * init imr
   * init acr
   * init ctur
   * init ctlr
   * init opcr
   * init cts
   */
  MC68681_WRITE(DUART_ADDR, MC68681_INTERRUPT_VECTOR_REG,
                MC68681_INTERRUPT_VECTOR_INIT);
  MC68681_WRITE(DUART_ADDR, MC68681_INTERRUPT_MASK_REG,
                MC68681_IR_RX_READY_A | MC68681_IR_RX_READY_B);
  MC68681_WRITE(DUART_ADDR, MC68681_AUX_CTRL_REG, MC68681_CLEAR);
  MC68681_WRITE(DUART_ADDR, MC68681_COUNTER_TIMER_UPPER_REG, 0x00);
  MC68681_WRITE(DUART_ADDR, MC68681_COUNTER_TIMER_LOWER_REG, 0x02);
  MC68681_WRITE(DUART_ADDR, MC68681_OUTPUT_PORT_CONFIG_REG, MC68681_CLEAR);
  MC68681_WRITE(DUART_ADDR, MC68681_OUTPUT_PORT_SET_REG, 0x01);

  /*
   * init the actual serial port for port a
   *
   * Set Baud Rate to 9600
   * Set Stop bit length of 1
   * enable Transmit and receive
   */
  MC68681_WRITE(DUART_ADDR, MC68681_CLOCK_SELECT_REG_A, MC68681_BAUD_RATE_MASK_9600);
  MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_1A,
                (MC68681_8BIT_CHARS | MC68681_NO_PARITY));
  MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_2A,MC68681_STOP_BIT_LENGTH_1);
  MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_A,
                (MC68681_MODE_REG_ENABLE_TX | MC68681_MODE_REG_ENABLE_RX));

  /*
   * init the actual serial port for port b
   * init csrb -- 9600 baud
   */
  MC68681_WRITE(DUART_ADDR, MC68681_CLOCK_SELECT_REG_B, MC68681_BAUD_RATE_MASK_9600);

#define EIGHT_BITS_NO_PARITY
#ifdef EIGHT_BITS_NO_PARITY
  /*
   * Set 8 Bit characters with no parity
   */
  MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_1B,
                (MC68681_NO_PARITY | MC68681_8BIT_CHARS) );
#else
  /*
   * Set 7 Bit Characters with parity
   */
  MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_1B,
                (MC68681_WITH_PARITY |  MC68681_7BIT_CHARS) );
#endif

  /*
   * Set Stop Bit length to 1
   * Disable Recieve and transmit on B
   */
  MC68681_WRITE(DUART_ADDR, MC68681_MODE_REG_2B,MC68681_STOP_BIT_LENGTH_1);
  MC68681_WRITE(DUART_ADDR, MC68681_COMMAND_REG_B,
                (MC68681_MODE_REG_ENABLE_TX | MC68681_MODE_REG_ENABLE_RX) );
}