Changeset 49c1d25d in rtems


Ignore:
Timestamp:
Jul 17, 2015, 3:04:06 PM (4 years ago)
Author:
Premysl Houdek <kom541000@…>
Branches:
4.11
Children:
8b14cbd9
Parents:
9a84f983
git-author:
Premysl Houdek <kom541000@…> (07/17/15 15:04:06)
git-committer:
Chris Johns <chrisj@…> (07/20/15 11:06:55)
Message:

bsp/tms570 Use bitfields instead of hard-coded values

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

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

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/arm/tms570/clock/clock.c

    r9a84f983 r49c1d25d  
    8686  TMS570_RTI.GCTRL = 0;
    8787  TMS570_RTI.CNT[0].CPUCx = tc_prescaler - 1;
    88   TMS570_RTI.TBCTRL = 2;
     88  TMS570_RTI.TBCTRL = TMS570_RTI_TBCTRL_INC;
    8989  TMS570_RTI.CAPCTRL = 0;
    9090  TMS570_RTI.COMPCTRL = 0;
     
    9393  TMS570_RTI.CNT[0].FRCx = 0;
    9494  /* clear interrupts*/
    95   TMS570_RTI.CLEARINTENA = 0x00070f0f;
    96   TMS570_RTI.INTFLAG = 0x0007000f;
     95  TMS570_RTI.CLEARINTENA = TMS570_RTI_CLEARINTENA_CLEAROVL1INT |
     96                           TMS570_RTI_CLEARINTENA_CLEAROVL0INT |
     97                           TMS570_RTI_CLEARINTENA_CLEARTBINT |
     98                           TMS570_RTI_CLEARINTENA_CLEARDMA3 |
     99                           TMS570_RTI_CLEARINTENA_CLEARDMA2 |
     100                           TMS570_RTI_CLEARINTENA_CLEARDMA1 |
     101                           TMS570_RTI_CLEARINTENA_CLEARDMA0 |
     102                           TMS570_RTI_CLEARINTENA_CLEARINT3 |
     103                           TMS570_RTI_CLEARINTENA_CLEARINT2 |
     104                           TMS570_RTI_CLEARINTENA_CLEARINT1 |
     105                           TMS570_RTI_CLEARINTENA_CLEARINT0;
     106  TMS570_RTI.INTFLAG = TMS570_RTI_INTFLAG_OVL1INT |
     107                       TMS570_RTI_INTFLAG_OVL0INT |
     108                       TMS570_RTI_INTFLAG_TBINT |
     109                       TMS570_RTI_INTFLAG_INT3 |
     110                       TMS570_RTI_INTFLAG_INT2 |
     111                       TMS570_RTI_INTFLAG_INT1 |
     112                       TMS570_RTI_INTFLAG_INT0;
    97113  /* set timer */
    98114  TMS570_RTI.CMP[0].COMPx = TMS570_RTI.CNT[0].FRCx + tc_increments_per_tick;
     
    100116  TMS570_RTI.CMP[0].UDCPx = tc_increments_per_tick;
    101117  /* enable interupt */
    102   TMS570_RTI.SETINTENA = 0x1;
     118  TMS570_RTI.SETINTENA = TMS570_RTI_SETINTENA_SETINT0;
    103119  /* enable timer */
    104   TMS570_RTI.GCTRL = 1;
     120  TMS570_RTI.GCTRL = TMS570_RTI_GCTRL_CNT0EN;
    105121  /* set timecounter */
    106122  tms570_rti_tc.tc_get_timecount = tms570_rti_get_timecount;
     
    118134static void tms570_clock_driver_support_at_tick( void )
    119135{
    120   TMS570_RTI.INTFLAG = 0x00000001;
     136  TMS570_RTI.INTFLAG = TMS570_RTI_INTFLAG_INT0;
    121137}
    122138
     
    157173{
    158174  /* turn off the timer interrupts */
    159   TMS570_RTI.CLEARINTENA = 0x20000;
     175  TMS570_RTI.CLEARINTENA = TMS570_RTI_CLEARINTENA_CLEAROVL0INT |
     176                           TMS570_RTI_CLEARINTENA_CLEARINT0; 
    160177}
    161178
  • c/src/lib/libbsp/arm/tms570/console/printk-support.c

    r9a84f983 r49c1d25d  
    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

    r9a84f983 r49c1d25d  
    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  }
  • c/src/lib/libbsp/arm/tms570/pom/tms570-pom.c

    r9a84f983 r49c1d25d  
    3636  int i;
    3737  uint32_t vec_overlay_start = 0x08000000;
     38  uint32_t temp = 0;
    3839
    3940  memcpy((void*)vec_overlay_start, bsp_start_vector_table_begin, 64);
     
    4243
    4344  for ( i = 0; i < TMS570_POM_REGIONS; ++i ) {
    44     TMS570_POM.REG[i].REGSIZE = TMS570_POM_REGSIZE_DISABLED;
     45    TMS570_POM.REG[i].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_DISABLED);
    4546  }
    4647
    47   TMS570_POM.REG[0].PROGSTART = 0x0 & TMS570_POM_REGADDRMASK;
    48   TMS570_POM.REG[0].OVLSTART = vec_overlay_start & TMS570_POM_REGADDRMASK;
    49   TMS570_POM.REG[0].REGSIZE = TMS570_POM_REGSIZE_64B;
    50 
    51   TMS570_POM.GLBCTRL = TMS570_POM_GLBCTRL_ENABLE |
    52                        (vec_overlay_start & ~TMS570_POM_REGADDRMASK);
     48  TMS570_POM.REG[0].PROGSTART = TMS570_POM_PROGSTART_STARTADDRESS(0);
     49  TMS570_POM.REG[0].OVLSTART = TMS570_POM_OVLSTART_STARTADDRESS(vec_overlay_start);
     50  TMS570_POM.REG[0].REGSIZE = TMS570_POM_REGSIZE_SIZE(TMS570_POM_REGSIZE_64B);
     51  TMS570_POM.GLBCTRL = TMS570_POM_GLBCTRL_ON_OFF(0xa) |
     52                       TMS570_POM_GLBCTRL_ETO(0xa) |
     53                       (TMS570_POM_GLBCTRL_OTADDR(~0) & vec_overlay_start);
    5354}
Note: See TracChangeset for help on using the changeset viewer.