Changeset 8a442b5 in rtems
- Timestamp:
- 10/12/14 15:06:05 (9 years ago)
- Branches:
- 4.11, 5, master
- Children:
- d1347a37
- Parents:
- 767164a
- git-author:
- Joel Sherrill <joel.sherrill@…> (10/12/14 15:06:05)
- git-committer:
- Joel Sherrill <joel.sherrill@…> (10/13/14 15:33:26)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
c/src/lib/libbsp/m68k/gen68340/clock/ckinit.c
r767164a r8a442b5 1 1 /* 2 2 * This routine initializes the MC68340/349 Periodic Interval Timer 3 * 3 */ 4 5 /* 4 6 * Based on the `gen68360' board support package, and covered by the 5 7 * original distribution terms. … … 15 17 16 18 /* 17 * Input parameters: NONE 18 * 19 * Output parameters: NONE 20 * 21 * COPYRIGHT (c) 1989-1999. 19 * COPYRIGHT (c) 1989-2014. 22 20 * On-Line Applications Research Corporation (OAR). 23 21 * … … 27 25 */ 28 26 29 #include <stdlib.h> 27 #include <stdlib.h> /* for atexit() */ 30 28 #include <bsp.h> 31 29 #include <m68340.h> 32 30 33 #define CLOCK_VECTOR 120/* clock isr routine vector in the vbr */34 #define CLOCK_IRQ_LEVEL 6/* clock isr level */31 #define CLOCK_VECTOR 120 /* clock isr routine vector in the vbr */ 32 #define CLOCK_IRQ_LEVEL 6 /* clock isr level */ 35 33 36 34 /* … … 41 39 42 40 /* 43 * These are set by clock driver during its init44 */45 rtems_device_major_number rtems_clock_major = ~0;46 rtems_device_minor_number rtems_clock_minor;47 48 /*49 41 * Periodic interval timer interrupt handler 50 42 */ 51 52 /****************************************************** 53 Name: Clock_isr 54 Input parameters: irq vector 55 Output parameters: none 56 Description: update # of clock ticks 57 *****************************************************/ 58 rtems_isr 43 static rtems_isr 59 44 Clock_isr (rtems_vector_number vector) 60 45 { 61 62 63 64 65 46 /* 47 * Announce the clock tick 48 */ 49 Clock_driver_ticks++; 50 rtems_clock_tick(); 66 51 } 67 52 68 /******************************************************69 Name: clock_exit70 Input parameters: -71 Output parameters: -72 Description: turn off periodic time at shutdown73 *****************************************************/74 53 void 75 54 Clock_exit (void) 76 55 { 77 78 79 80 56 /* 57 * Turn off periodic interval timer 58 */ 59 SIMPITR = 0; 81 60 } 82 61 83 /******************************************************84 Name: Install_clock85 Input parameters: the Clock Interrupt Subroutine86 Output parameters: -87 Description: initialize the periodic interval ticker88 called by Clock_Initialize89 *****************************************************/90 62 static void 91 63 Install_clock (rtems_isr_entry clock_isr) 92 64 { 93 94 65 uint32_t pitr_tmp; 66 uint32_t usecs_per_tick; 95 67 96 68 Clock_driver_ticks = 0; 97 69 98 70 set_vector (clock_isr, CLOCK_VECTOR, 1); 99 71 100 101 /* voir a quoi correspond exactement le Clock Vector */ 72 /* sets the Periodic Interrupt Control Register PICR */ 73 SIMPICR = ( CLOCK_IRQ_LEVEL << 8 ) | ( CLOCK_VECTOR ); 102 74 103 SIMPICR = ( CLOCK_IRQ_LEVEL << 8 ) | ( CLOCK_VECTOR ); 75 /* sets the PITR count value */ 76 /* this assumes a 32.765 kHz crystal */ 104 77 105 /* sets the PITR count value */ 106 /* this assumes a 32.765 kHz crystal */ 78 usecs_per_tick = rtems_configuration_get_microseconds_per_tick(); 79 /* find out whether prescaler should be enabled or not */ 80 if ( usecs_per_tick <= 31128 ) { 81 pitr_tmp = ( usecs_per_tick * 8192 ) / 1000000 ; 82 } else { 83 pitr_tmp = ( usecs_per_tick / 1000000 ) * 16; 84 /* enable it */ 85 pitr_tmp |= 0x100; 86 } 107 87 108 usecs_per_tick = rtems_configuration_get_microseconds_per_tick(); 109 /* find out whether prescaler should be enabled or not */ 110 if ( usecs_per_tick <= 31128 ) { 111 pitr_tmp = ( usecs_per_tick * 8192 ) / 1000000 ; 112 } else { 113 pitr_tmp = ( usecs_per_tick / 1000000 ) * 16; 114 /* enable it */ 115 pitr_tmp |= 0x100; 116 } 88 SIMPITR = (unsigned char) pitr_tmp; 117 89 118 SIMPITR = (unsigned char) pitr_tmp; 119 120 atexit (Clock_exit); 90 atexit (Clock_exit); 121 91 } 122 92 123 /******************************************************124 Name: Clock_initialize125 Input parameters: major & minor numbers126 Output parameters: -127 Description: main entry for clock initialization128 calls the bsp dependant routine129 *****************************************************/130 93 rtems_device_driver 131 94 Clock_initialize( 132 133 134 95 rtems_device_major_number major, 96 rtems_device_minor_number minor, 97 void *pargp 135 98 ) 136 99 { 137 100 Install_clock (Clock_isr); 138 101 139 /* 140 * make major/minor avail to others such as shared memory driver 141 */ 142 rtems_clock_major = major; 143 rtems_clock_minor = minor; 144 145 return RTEMS_SUCCESSFUL; 102 return RTEMS_SUCCESSFUL; 146 103 }
Note: See TracChangeset
for help on using the changeset viewer.