Changeset 0055b65 in rtems for c/src/lib/libbsp/arm/tms570


Ignore:
Timestamp:
Jul 22, 2016, 7:15:55 PM (3 years ago)
Author:
Pavel Pisa <pisa@…>
Branches:
master
Children:
1c62f7ee
Parents:
992494e
Message:

bsp/tms570: ensure that change of SCI baudrate is not applied in the middle of character Tx.

The rtems_monitor_task() setups/updates termios attributes
of the opened TTY and if there is ongoing some other output
it leads to the stuck.

It would be better to use some termios API function which
would call drainOutput() in rtems/cpukit/libcsupport/src/termios.c.
But functionality is not accessible outside of core termios
implementation.

The loop waiting for last character to be sent has to be there anyway
because hardware does not provide Tx machine/shift register empty
interrupt.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/tms570/console/tms570-sci.c

    r992494e r0055b65  
    248248  int32_t bauddiv;
    249249  int32_t baudrate;
     250  uint32_t flr_tx_ready = TMS570_SCI_FLR_TX_EMPTY | TMS570_SCI_FLR_TX_EMPTY;
     251
     252  /* Baud rate */
     253  baudrate = rtems_termios_baud_to_number(cfgetospeed(t));
    250254
    251255  rtems_termios_device_lock_acquire(base, &lock_context);
     256
     257  while ( (ctx->regs->GCR1 & TMS570_SCI_GCR1_TXENA) &&
     258          (ctx->regs->FLR & flr_tx_ready) != flr_tx_ready) {
     259    /*
     260     * There are pending characters in the hardware,
     261     * change in the middle of the character Tx leads
     262     * to disturb of the character and SCI engine
     263     */
     264    rtems_interval tw;
     265
     266    rtems_termios_device_lock_release(base, &lock_context);
     267
     268    tw = rtems_clock_get_ticks_per_second();
     269    tw = tw * 5 / baudrate + 1;
     270    rtems_task_wake_after( tw );
     271
     272    rtems_termios_device_lock_acquire(base, &lock_context);
     273  }
    252274
    253275  ctx->regs->GCR1 &= ~( TMS570_SCI_GCR1_SWnRST | TMS570_SCI_GCR1_TXENA |
     
    277299  }
    278300
    279   /* Baud rate */
    280   baudrate = rtems_termios_baud_to_number(cfgetospeed(t));
     301  /* Apply baudrate to the hardware */
    281302  baudrate *= 2 * 16;
    282303  bauddiv = (BSP_PLL_OUT_CLOCK + baudrate / 2) / baudrate;
Note: See TracChangeset for help on using the changeset viewer.