Changeset 6c64bcc in rtems


Ignore:
Timestamp:
Oct 11, 2007, 12:54:30 PM (12 years ago)
Author:
Joel Sherrill <joel.sherrill@…>
Branches:
4.8
Children:
2e4aab87
Parents:
ad8c2e6
Message:

2007-10-11 Daniel Hellstrom <daniel@…>

  • shared/can/occan.c: Fixes bug in OC-CAN baud rate calculator. The BTR1 8-bit value was swapped.
Location:
c/src/lib/libbsp/sparc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/sparc/ChangeLog

    rad8c2e6 r6c64bcc  
     12007-10-11      Daniel Hellstrom <daniel@gaisler.com>
     2
     3        * shared/can/occan.c: Fixes bug in OC-CAN baud rate calculator. The
     4        BTR1 8-bit value was swapped.
     5
    162007-09-21      Daniel Hellstrom <daniel@gaisler.com>
    27
  • c/src/lib/libbsp/sparc/shared/can/occan.c

    rad8c2e6 r6c64bcc  
    199199#endif
    200200
    201 #define MAX_TSEG1 7
    202 #define MAX_TSEG2 15
     201#define MAX_TSEG2 7
     202#define MAX_TSEG1 15
    203203
    204204#if 0
     
    729729#endif
    730730
    731 /* This function calculates BTR0 BTR1 values for a given bitrate.
    732  * Heavily based on mgt_mscan_bitrate() from peak driver, which
    733  * in turn is based on work by Arnaud Westenberg.
     731/* This function calculates BTR0 and BTR1 values for a given bitrate.
    734732 *
    735733 * Set communication parameters.
    736  * baud rate in Hz
    737  * input clock frequency of can core in Hz (system frequency)
    738  * sjw synchronization jump width (0-3) prescaled clock cycles
    739  * sampl_pt sample point in % (0-100) sets (TSEG1+2)/(TSEG1+TSEG2+3)
    740  *                                                               ratio
     734 * \param clock_hz OC_CAN Core frequency in Hz.
     735 * \param rate Requested baud rate in bits/second.
     736 * \param result Pointer to where resulting BTRs will be stored.
     737 * \return zero if successful to calculate a baud rate.
    741738 */
    742739static int occan_calc_speedregs(unsigned int clock_hz, unsigned int rate, occan_speed_regs *result){
     
    749746        int sampl_pt = 90;
    750747
    751         if ( (rate<10000) || (rate>1000000) ){
     748        if ( (rate<5000) || (rate>1000000) ){
    752749                /* invalid speed mode */
    753750                return -1;
     
    817814                tseg2 = best_tseg - tseg1 - 2;
    818815        }
    819 /*
    820         result->sjw = sjw;
    821         result->brp = best_brp;
    822         result->tseg1 = tseg1;
    823         result->tseg2 = tseg2;
    824 */
     816
    825817        result->btr0 = (sjw<<OCCAN_BUSTIM_SJW_BIT) | (best_brp&OCCAN_BUSTIM_BRP);
    826818        result->btr1 = (0<<7) | (tseg2<<OCCAN_BUSTIM_TSEG2_BIT) | tseg1;
     
    835827        priv->regs->bustim0 = timing->btr0;
    836828        priv->regs->bustim1 = timing->btr1;
    837         /*
    838         priv->regs->bustim0 = (timing->sjw<<OCCAN_BUSTIM_SJW_BIT) | (timing->brp&OCCAN_BUSTIM_BRP);
    839         priv->regs->bustim1 = (timing->sam<<7) | (timing->tseg2<<OCCAN_BUSTIM_TSEG2_BIT) | timing->tseg1;
    840         */
    841829        return 0;
    842830}
Note: See TracChangeset for help on using the changeset viewer.