Ignore:
Timestamp:
Jul 17, 2015, 3:04:06 PM (5 years ago)
Author:
Premysl Houdek <kom541000@…>
Branches:
master
Children:
579f16ef
Parents:
d6c67ad5
git-author:
Premysl Houdek <kom541000@…> (07/17/15 15:04:06)
git-committer:
Chris Johns <chrisj@…> (07/20/15 10:45:40)
Message:

bsp/tms570 Use bitfields instead of hard-coded values

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

Location:
c/src/lib/libbsp/arm/tms570/console
Files:
2 edited

Legend:

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

    rd6c67ad5 rb2c252b  
    4242
    4343  rtems_interrupt_disable(level);
    44   while ( ( driver_context_table[0].regs->FLR & 0x100 ) == 0) {
     44  while ( ( driver_context_table[0].regs->FLR & TMS570_SCI_FLR_TXRDY ) == 0) {
    4545    rtems_interrupt_flash(level);
    4646  }
     
    7575static int tms570_uart_input( void )
    7676{
    77   if ( driver_context_table[0].regs->FLR & (1<<9) ) {
     77  if ( driver_context_table[0].regs->FLR & TMS570_SCI_FLR_RXRDY ) {
    7878      return driver_context_table[0].regs->RD;
    7979  } else {
  • c/src/lib/libbsp/arm/tms570/console/tms570-sci.c

    rd6c67ad5 rb2c252b  
    156156static void tms570_sci_enable_interrupts(tms570_sci_context * ctx)
    157157{
    158   ctx->regs->SETINT = (1<<9);
     158  ctx->regs->SETINT = TMS570_SCI_SETINT_SET_RX_INT;
    159159}
    160160
     
    170170static void tms570_sci_disable_interrupts(tms570_sci_context * ctx)
    171171{
    172   ctx->regs->CLEARINT = (1<<9);
     172  ctx->regs->CLEARINT = TMS570_SCI_CLEARINT_CLR_RX_INT;
    173173}
    174174
     
    217217  rtems_termios_device_lock_acquire(base, &lock_context);
    218218
    219   ctx->regs->GCR1 &= ~( (1<<7) | (1<<25) | (1<<24) );
    220 
    221   ctx->regs->GCR1 &= ~(1<<4);    /*one stop bit*/
    222   ctx->regs->FORMAT = 0x7;
     219  ctx->regs->GCR1 &= ~( TMS570_SCI_GCR1_SWnRST | TMS570_SCI_GCR1_TXENA |
     220                        TMS570_SCI_GCR1_RXENA );
     221
     222  ctx->regs->GCR1 &= ~TMS570_SCI_GCR1_STOP;    /*one stop bit*/
     223  ctx->regs->FORMAT = TMS570_SCI_FORMAT_CHAR(0x7);
    223224
    224225  switch ( t->c_cflag & ( PARENB|PARODD ) ) {
    225226    case ( PARENB|PARODD ):
    226227      /* Odd parity */
    227       ctx->regs->GCR1 &= ~(1<<3);
    228       ctx->regs->GCR1 |= (1<<2);
     228      ctx->regs->GCR1 &= ~TMS570_SCI_GCR1_PARITY;
     229      ctx->regs->GCR1 |= TMS570_SCI_GCR1_PARITY_ENA;
    229230      break;
    230231
    231232    case PARENB:
    232233      /* Even parity */
    233       ctx->regs->GCR1 |= (1<<3);
    234       ctx->regs->GCR1 |= (1<<2);
     234      ctx->regs->GCR1 |= TMS570_SCI_GCR1_PARITY;
     235      ctx->regs->GCR1 |= TMS570_SCI_GCR1_PARITY_ENA;
    235236      break;
    236237
     
    239240    case PARODD:
    240241      /* No Parity */
    241       ctx->regs->GCR1 &= ~(1<<2);
     242      ctx->regs->GCR1 &= ~TMS570_SCI_GCR1_PARITY_ENA;
    242243  }
    243244
     
    248249  ctx->regs->BRS = bauddiv;
    249250
    250   ctx->regs->GCR1 |= (1<<7) | (1<<25) | (1<<24);
     251  ctx->regs->GCR1 |= TMS570_SCI_GCR1_SWnRST | TMS570_SCI_GCR1_TXENA |
     252                     TMS570_SCI_GCR1_RXENA;
    251253
    252254  rtems_termios_device_lock_release(base, &lock_context);
     
    275277   * Check if we have received something.
    276278   */
    277    if ( (ctx->regs->FLR & (1<<9) ) == (1<<9) ) {
     279   if ( (ctx->regs->FLR & TMS570_SCI_FLR_RXRDY ) == TMS570_SCI_FLR_RXRDY ) {
    278280      n = tms570_sci_read_received_chars(ctx, buf, TMS570_SCI_BUFFER_SIZE);
    279281      if ( n > 0 ) {
     
    285287   * Check if we have something transmitted.
    286288   */
    287   if ( (ctx->regs->FLR & (1<<8) ) == (1<<8) ) {
     289  if ( (ctx->regs->FLR & TMS570_SCI_FLR_TXRDY ) == TMS570_SCI_FLR_TXRDY ) {
    288290    n = tms570_sci_transmitted_chars(ctx);
    289291    if ( n > 0 ) {
     
    356358
    357359  for ( i = 0; i < n; ++i ) {
    358     while ( (ctx->regs->FLR & (1<<11) ) == 0) {
     360    while ( (ctx->regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) == 0) {
    359361      ;
    360362    }
     
    376378)
    377379{
    378   return ctx->regs->FLR & (1<<9);
     380  return ctx->regs->FLR & TMS570_SCI_FLR_RXRDY;
    379381}
    380382
     
    531533
    532534  /* Flush device */
    533   while ( ( ctx->regs->FLR & (1<<11) ) > 0 ) {
     535  while ( ( ctx->regs->FLR & TMS570_SCI_FLR_TX_EMPTY ) > 0 ) {
    534536    ;/* Wait until all data has been sent */
    535537  }
Note: See TracChangeset for help on using the changeset viewer.