![]() |
|
|||
File indexing completed on 2025-05-11 08:23:45
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /* 0004 * This routine initializes the MC68340/349 Periodic Interval Timer 0005 */ 0006 0007 /* 0008 * Based on the `gen68360' board support package, and covered by the 0009 * original distribution terms. 0010 * 0011 * Geoffroy Montel 0012 * France Telecom - CNET/DSM/TAM/CAT 0013 * 4, rue du Clos Courtel 0014 * 35512 CESSON-SEVIGNE 0015 * FRANCE 0016 * 0017 * e-mail: g_montel@yahoo.com 0018 */ 0019 0020 /* 0021 * COPYRIGHT (c) 1989-2014. 0022 * On-Line Applications Research Corporation (OAR). 0023 * 0024 * Redistribution and use in source and binary forms, with or without 0025 * modification, are permitted provided that the following conditions 0026 * are met: 0027 * 1. Redistributions of source code must retain the above copyright 0028 * notice, this list of conditions and the following disclaimer. 0029 * 2. Redistributions in binary form must reproduce the above copyright 0030 * notice, this list of conditions and the following disclaimer in the 0031 * documentation and/or other materials provided with the distribution. 0032 * 0033 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0034 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0035 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0036 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0037 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0038 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0039 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0040 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0041 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0042 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0043 * POSSIBILITY OF SUCH DAMAGE. 0044 */ 0045 0046 #include <stdlib.h> /* for atexit() */ 0047 #include <bsp.h> 0048 #include <m68340.h> 0049 #include <rtems/clockdrv.h> 0050 0051 #define CLOCK_VECTOR 120 /* clock isr routine vector in the vbr */ 0052 #define CLOCK_IRQ_LEVEL 6 /* clock isr level */ 0053 0054 /* 0055 * Clock_driver_ticks is a monotonically increasing counter of the 0056 * number of clock ticks since the driver was initialized. 0057 */ 0058 volatile uint32_t Clock_driver_ticks; 0059 0060 /* 0061 * Periodic interval timer interrupt handler 0062 */ 0063 static rtems_isr 0064 Clock_isr (rtems_vector_number vector) 0065 { 0066 /* 0067 * Announce the clock tick 0068 */ 0069 Clock_driver_ticks++; 0070 rtems_clock_tick(); 0071 } 0072 0073 static void 0074 Clock_exit (void) 0075 { 0076 /* 0077 * Turn off periodic interval timer 0078 */ 0079 SIMPITR = 0; 0080 } 0081 0082 static void 0083 Install_clock (rtems_isr_entry clock_isr) 0084 { 0085 uint32_t pitr_tmp; 0086 uint32_t usecs_per_tick; 0087 0088 Clock_driver_ticks = 0; 0089 0090 set_vector (clock_isr, CLOCK_VECTOR, 1); 0091 0092 /* sets the Periodic Interrupt Control Register PICR */ 0093 SIMPICR = ( CLOCK_IRQ_LEVEL << 8 ) | ( CLOCK_VECTOR ); 0094 0095 /* sets the PITR count value */ 0096 /* this assumes a 32.765 kHz crystal */ 0097 0098 usecs_per_tick = rtems_configuration_get_microseconds_per_tick(); 0099 /* find out whether prescaler should be enabled or not */ 0100 if ( usecs_per_tick <= 31128 ) { 0101 pitr_tmp = ( usecs_per_tick * 8192 ) / 1000000 ; 0102 } else { 0103 pitr_tmp = ( usecs_per_tick / 1000000 ) * 16; 0104 /* enable it */ 0105 pitr_tmp |= 0x100; 0106 } 0107 0108 SIMPITR = (unsigned char) pitr_tmp; 0109 0110 atexit (Clock_exit); 0111 } 0112 0113 void _Clock_Initialize( void ) 0114 { 0115 Install_clock (Clock_isr); 0116 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |