Changeset 3e1196d in rtems for c/src/lib/libbsp/arm/tms570


Ignore:
Timestamp:
Nov 18, 2015, 5:45:32 PM (4 years ago)
Author:
Premysl Houdek <kom541000@…>
Branches:
master
Children:
9394aa5e
Parents:
74172b7d
git-author:
Premysl Houdek <kom541000@…> (11/18/15 17:45:32)
git-committer:
Gedare Bloom <gedare@…> (11/18/15 18:12:44)
Message:

bsp/tms570: unite code duplication in pinmux and clean SCI close per review remarks.

Signed-off-by: Premysl Houdek <kom541000@…>

Location:
c/src/lib/libbsp/arm/tms570
Files:
3 edited

Legend:

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

    r74172b7d r3e1196d  
    526526  tms570_sci_context *ctx = (tms570_sci_context *) base;
    527527  rtems_interrupt_lock_context lock_context;
     528  rtems_interval tw;
     529  int32_t baudrate;
    528530
    529531  /* Turn off RX interrupts */
     
    532534  rtems_termios_device_lock_release(base, &lock_context);
    533535
    534   if ( 0 /* for flush on close */ ) {
    535     /* Flush device */
    536     while ( ( ctx->regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0 ) {
    537       ;/* Wait until all data has been sent */
    538     }
     536  tw = rtems_clock_get_ticks_per_second();
     537  baudrate = rtems_termios_baud_to_number(cfgetospeed(&tty->termios));
     538  tw = tw * 10 / baudrate + 1;
     539  while ( ( ctx->regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0 ) {
     540     rtems_task_wake_after(tw);
    539541  }
    540542
  • c/src/lib/libbsp/arm/tms570/include/tms570-pinmux.h

    r74172b7d r3e1196d  
    112112void tms570_bsp_pin_clear_function(int pin_num, int pin_fnc);
    113113
     114static inline void
     115tms570_bsp_pin_to_pinmmrx(volatile uint32_t **pinmmrx, unsigned int *pin_shift,
     116                          int pin_num)
     117{
     118  pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT;
     119  *pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0 + (pin_num >> 2);
     120  *pin_shift = (pin_num & 0x3)*8;
     121}
     122
    114123#endif
    115124
  • c/src/lib/libbsp/arm/tms570/pinmux/pinmux.c

    r74172b7d r3e1196d  
    3232 * TMS570_BALL_<column><row> (for example TMS570_BALL_N19).
    3333 * The multiplexer allows to interconnect one pin to multiple
    34  * signal sources/sings in the theory but it is usually bad choice.
     34 * signal sources/sinks in the theory but it is usually bad choice.
    3535 * The function sets only specified function and clears all other
    3636 * connections.
     
    4646{
    4747  unsigned int pin_shift;
    48   typeof(TMS570_IOMM.PINMUX.PINMMR0) *pinmmrx;
     48  volatile uint32_t *pinmmrx;
    4949
    5050  if ( pin_fnc == TMS570_PIN_FNC_AUTO ) {
    5151    pin_fnc = (pin_num & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT;
    5252  }
    53   pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT;
    54 
    55   pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0;
    56   pinmmrx += (pin_num >> 2);
    57   pin_shift = (pin_num & 0x3)*8;
     53  tms570_bsp_pin_to_pinmmrx(&pinmmrx, &pin_shift, pin_num);
    5854  *pinmmrx = (*pinmmrx & ~(0xff << pin_shift)) | (1 << (pin_fnc + pin_shift));
    5955}
     
    7571{
    7672  unsigned int pin_shift;
    77   typeof(TMS570_IOMM.PINMUX.PINMMR0) *pinmmrx;
     73  volatile uint32_t *pinmmrx;
    7874
    7975  if ( pin_fnc == TMS570_PIN_FNC_AUTO ) {
    8076    pin_fnc = (pin_num & TMS570_PIN_FNC_MASK) >> TMS570_PIN_FNC_SHIFT;
    8177  }
    82   pin_num = (pin_num & TMS570_PIN_NUM_MASK) >> TMS570_PIN_NUM_SHIFT;
    83 
    84   pinmmrx = &TMS570_IOMM.PINMUX.PINMMR0;
    85   pinmmrx += (pin_num >> 2);
    86   pin_shift = (pin_num & 0x3)*8;
     78  tms570_bsp_pin_to_pinmmrx(&pinmmrx, &pin_shift, pin_num);
    8779  *pinmmrx = *pinmmrx & ~(1 << (pin_fnc+pin_shift));
    8880}
Note: See TracChangeset for help on using the changeset viewer.