Changeset 4a4c7900 in rtems
- Timestamp:
- 08/13/06 15:58:46 (17 years ago)
- Branches:
- 4.10, 4.11, 4.8, 4.9, 5, master
- Children:
- ea3839aa
- Parents:
- 7db4805e
- 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 107 107 #include <rtems/clockdrv.h> 108 108 #include <i2cdrv.h> 109 #include <bsp/irq.h> 110 #include <bsp/vectors.h> 109 111 110 112 #if defined(HAS_UBOOT) -
c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.c
r7db4805e r4a4c7900 24 24 #include <rtems/libio.h> 25 25 #include <string.h> 26 #include <bsp.h>26 #include "../include/bsp.h" 27 27 #include "../irq/irq.h" 28 28 #include "../include/mpc5200.h" … … 34 34 35 35 struct mpc5200_rx_cntrl mpc5200_mscan_rx_cntrl[MPC5200_CAN_NO]; 36 volatilestatic struct mscan_channel_info chan_info[MPC5200_CAN_NO];36 static struct mscan_channel_info chan_info[MPC5200_CAN_NO]; 37 37 38 38 /* time segmant table */ … … 64 64 * MPC5x00 MSCAN tx ring buffer function to get a can message buffer from the head of the tx ring buffer 65 65 */ 66 volatilestatic struct can_message * get_tx_buffer(struct mscan_channel_info *chan)66 static struct can_message * get_tx_buffer(struct mscan_channel_info *chan) 67 67 { 68 68 /* define a temp. mess ptr. */ 69 volatilestruct can_message * tmp_mess_ptr = NULL, *temp_head_ptr;69 struct can_message * tmp_mess_ptr = NULL, *temp_head_ptr; 70 70 71 71 /* set temp. head pointer */ … … 102 102 * MPC5x00 MSCAN tx ring buffer function to write a can message buffer to the tail of the tx ring buffer 103 103 */ 104 volatilestatic struct can_message * fill_tx_buffer(struct mscan_channel_info *chan, struct can_message * mess_ptr)104 static struct can_message * fill_tx_buffer(struct mscan_channel_info *chan, struct can_message * mess_ptr) 105 105 { 106 106 /* define a temp. mess ptr. to the entry which follows the current tail entry */ … … 721 721 722 722 /* local variables */ 723 uint8_t tq_no_min_dev= 0;724 uint32_t frq_tq, frq_dev, frq_dev_min = 0xFFFFFFFF;723 uint8_t presc_val, tq_no_dev_min = 0; 724 uint32_t bit_rate, bit_rate_dev, frq_tq, bit_rate_dev_min = 0xFFFFFFFF; 725 725 726 726 /* loop through all values of time quantas */ … … 730 730 frq_tq = *tq_no * can_bit_rate; 731 731 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 } 734 749 735 750 /* check the deviation freq. */ 736 if( frq_dev == 0) {751 if(bit_rate_dev == 0) { 737 752 738 753 /* return if best match (zero deviation) */ 739 return (uint8_t)( can_clock_frq/frq_tq);754 return (uint8_t)(presc_val); 740 755 } 741 756 else 742 757 { 743 758 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) { 746 761 747 762 /* recognize the minimum freq. deviation */ 748 frq_dev_min = frq_dev;763 bit_rate_dev_min = bit_rate_dev; 749 764 750 765 /* recognize the no. of time quantas */ 751 tq_no_ min_dev= *tq_no;766 tq_no_dev_min = *tq_no; 752 767 } 753 768 } 754 769 } 755 770 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); 759 779 } 760 780 -
c/src/lib/libbsp/powerpc/gen5200/mscan/mscan.h
r7db4805e r4a4c7900 257 257 }; 258 258 259 volatilestruct ring_buf259 struct ring_buf 260 260 { 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; 264 264 }; 265 265 … … 280 280 uint8_t mode; 281 281 uint8_t tx_buf_no; 282 volatilestruct ring_buf tx_ring_buf;282 struct ring_buf tx_ring_buf; 283 283 }; 284 284
Note: See TracChangeset
for help on using the changeset viewer.