Changeset 4a4c7900 in rtems


Ignore:
Timestamp:
08/13/06 15:58:46 (17 years ago)
Author:
Thomas Doerfler <Thomas.Doerfler@…>
Branches:
4.10, 4.11, 4.8, 4.9, 5, master
Children:
ea3839aa
Parents:
7db4805e
Message:

added vectors.h to bsp.h
fixed bug in mscan

Location:
c/src/lib/libbsp/powerpc/gen5200
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • c/src/lib/libbsp/powerpc/gen5200/include/bsp.h

    r7db4805e r4a4c7900  
    107107#include <rtems/clockdrv.h>
    108108#include <i2cdrv.h>
     109#include <bsp/irq.h>
     110#include <bsp/vectors.h>
    109111
    110112#if defined(HAS_UBOOT)
  • c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.c

    r7db4805e r4a4c7900  
    2424#include <rtems/libio.h>
    2525#include <string.h>
    26 #include <bsp.h>
     26#include "../include/bsp.h"
    2727#include "../irq/irq.h"
    2828#include "../include/mpc5200.h"
     
    3434
    3535struct mpc5200_rx_cntrl mpc5200_mscan_rx_cntrl[MPC5200_CAN_NO];
    36 volatile static struct mscan_channel_info chan_info[MPC5200_CAN_NO];
     36static struct mscan_channel_info chan_info[MPC5200_CAN_NO];
    3737
    3838/* time segmant table  */
     
    6464 * MPC5x00 MSCAN tx ring buffer function to get a can message buffer from the head of the tx ring buffer
    6565 */
    66 volatile static struct can_message * get_tx_buffer(struct mscan_channel_info *chan)
     66static struct can_message * get_tx_buffer(struct mscan_channel_info *chan)
    6767  {
    6868  /* define a temp. mess ptr. */
    69   volatile struct can_message * tmp_mess_ptr = NULL, *temp_head_ptr;
     69  struct can_message * tmp_mess_ptr = NULL, *temp_head_ptr;
    7070
    7171  /* set temp. head pointer */
     
    102102 * MPC5x00 MSCAN tx ring buffer function to write a can message buffer to the tail of the tx ring buffer
    103103 */
    104 volatile static struct can_message * fill_tx_buffer(struct mscan_channel_info *chan, struct can_message * mess_ptr)
     104static struct can_message * fill_tx_buffer(struct mscan_channel_info *chan, struct can_message * mess_ptr)
    105105  {
    106106  /* define a temp. mess ptr. to the entry which follows the current tail entry */
     
    721721
    722722/* local variables */
    723 uint8_t tq_no_min_dev = 0;
    724 uint32_t frq_tq, frq_dev, frq_dev_min = 0xFFFFFFFF;
     723uint8_t presc_val, tq_no_dev_min = 0;
     724uint32_t bit_rate, bit_rate_dev, frq_tq, bit_rate_dev_min = 0xFFFFFFFF;
    725725
    726726/* loop through all values of time quantas */
     
    730730  frq_tq = *tq_no * can_bit_rate;
    731731
    732   /* calculate the deviation from requested tq freq. */
    733   frq_dev = can_clock_frq%frq_tq;
     732  /* calculate the optimized prescal. val. */
     733  presc_val = (can_clock_frq+frq_tq/2)/frq_tq;
     734
     735  /* calculate the bitrate */
     736  bit_rate = can_clock_frq/(*tq_no * presc_val);
     737
     738  /* calculate the bitrate deviation */
     739  if(can_bit_rate >= bit_rate)
     740    {
     741    /* calculate the bitrate deviation */
     742    bit_rate_dev = can_bit_rate - bit_rate;
     743    }
     744  else
     745    {
     746    /* calculate the bitrate deviation */
     747    bit_rate_dev = bit_rate - can_bit_rate;
     748    }
    734749
    735750  /* check the deviation freq. */
    736   if(frq_dev == 0) {
     751  if(bit_rate_dev == 0) {
    737752
    738753    /* return if best match (zero deviation) */
    739    return (uint8_t)(can_clock_frq/frq_tq);
     754   return (uint8_t)(presc_val);
    740755    }
    741756  else
    742757    {
    743758
    744     /* check for minimum of freq. deviation */
    745     if(frq_dev < frq_dev_min) {
     759    /* check for minimum of bit rate deviation */
     760    if(bit_rate_dev < bit_rate_dev_min) {
    746761
    747762      /* recognize the minimum freq. deviation */
    748       frq_dev_min = frq_dev;
     763      bit_rate_dev_min = bit_rate_dev;
    749764
    750765      /* recognize the no. of time quantas */
    751       tq_no_min_dev = *tq_no;
     766      tq_no_dev_min = *tq_no;
    752767          }
    753768        }
    754769  }
    755770
    756 /* return the optimized prescaler value */
    757  *tq_no = tq_no_min_dev;
    758  return (uint8_t)(can_clock_frq/(tq_no_min_dev * can_bit_rate));
     771  /* get the no of tq's */
     772  *tq_no = tq_no_dev_min;
     773
     774  /* calculate time quanta freq. */
     775  frq_tq = *tq_no * can_bit_rate;
     776
     777  /* return the optimized prescaler value */
     778  return (uint8_t)((can_clock_frq+frq_tq/2)/frq_tq);
    759779}
    760780
  • c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.h

    r7db4805e r4a4c7900  
    257257  };
    258258
    259 volatile struct ring_buf
     259struct ring_buf
    260260    {
    261     volatile struct can_message *buf_ptr;
    262     volatile struct can_message *head_ptr;
    263     volatile struct can_message *tail_ptr;
     261    struct can_message * volatile buf_ptr;
     262    struct can_message * volatile head_ptr;
     263    struct can_message * volatile tail_ptr;
    264264    };
    265265
     
    280280  uint8_t    mode;
    281281  uint8_t    tx_buf_no;
    282   volatile struct ring_buf tx_ring_buf;
     282  struct ring_buf tx_ring_buf;
    283283  };
    284284
Note: See TracChangeset for help on using the changeset viewer.