![]() |
|
|||
File indexing completed on 2025-05-11 08:23:51
0001 /* SPDX-License-Identifier: BSD-2-Clause */ 0002 0003 /* 0004 * This file provides a template for the clock device driver initialization. 0005 * 0006 * If possible, please use the dev/clock/clockimpl.h method for instantiating 0007 * a clock driver. 0008 */ 0009 0010 /* 0011 * COPYRIGHT (c) 1989-2014. 0012 * On-Line Applications Research Corporation (OAR). 0013 * 0014 * Redistribution and use in source and binary forms, with or without 0015 * modification, are permitted provided that the following conditions 0016 * are met: 0017 * 1. Redistributions of source code must retain the above copyright 0018 * notice, this list of conditions and the following disclaimer. 0019 * 2. Redistributions in binary form must reproduce the above copyright 0020 * notice, this list of conditions and the following disclaimer in the 0021 * documentation and/or other materials provided with the distribution. 0022 * 0023 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 0024 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 0025 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 0026 * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 0027 * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 0028 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 0029 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 0030 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 0031 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 0032 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 0033 * POSSIBILITY OF SUCH DAMAGE. 0034 */ 0035 0036 #include <stdlib.h> 0037 0038 #include <rtems.h> 0039 #include <bsp.h> 0040 0041 void Clock_exit( void ); 0042 rtems_isr Clock_isr( rtems_vector_number vector ); 0043 0044 /* 0045 * The interrupt vector number associated with the clock tick device 0046 * driver. 0047 */ 0048 #define CLOCK_VECTOR 4 0049 0050 /* 0051 * Clock_driver_ticks is a monotonically increasing counter of the 0052 * number of clock ticks since the driver was initialized. 0053 */ 0054 volatile uint32_t Clock_driver_ticks; 0055 0056 /* 0057 * Clock_isrs is the number of clock ISRs until the next invocation of 0058 * the RTEMS clock tick routine. The clock tick device driver 0059 * gets an interrupt once a millisecond and counts down until the 0060 * length of time between the user configured microseconds per tick 0061 * has passed. 0062 */ 0063 uint32_t Clock_isrs; /* ISRs until next tick */ 0064 0065 /* 0066 * The previous ISR on this clock tick interrupt vector. 0067 */ 0068 rtems_isr_entry Old_ticker; 0069 0070 static void Clock_exit( void ); 0071 0072 /* 0073 * Isr Handler 0074 */ 0075 static rtems_isr Clock_isr( 0076 rtems_vector_number vector 0077 ) 0078 { 0079 /* 0080 * bump the number of clock driver ticks since initialization 0081 * 0082 * determine if it is time to announce the passing of tick as configured 0083 * to RTEMS through the rtems_clock_tick directive 0084 * 0085 * perform any timer dependent tasks 0086 */ 0087 } 0088 0089 /* 0090 * Install_clock 0091 * 0092 * Install a clock tick handler and reprograms the chip. This 0093 * is used to initially establish the clock tick. 0094 */ 0095 void Install_clock( 0096 rtems_isr_entry clock_isr 0097 ) 0098 { 0099 /* 0100 * Initialize the clock tick device driver variables 0101 */ 0102 0103 Clock_driver_ticks = 0; 0104 Clock_isrs = rtems_configuration_get_microseconds_per_tick() / 1000; 0105 0106 Old_ticker = (rtems_isr_entry) set_vector( clock_isr, CLOCK_VECTOR, 1 ); 0107 /* 0108 * Hardware specific initialize goes here 0109 */ 0110 0111 /* XXX */ 0112 0113 /* 0114 * Schedule the clock cleanup routine to execute if the application exits. 0115 */ 0116 0117 atexit( Clock_exit ); 0118 } 0119 0120 /* 0121 * Clean up before the application exits 0122 */ 0123 0124 void Clock_exit( void ) 0125 { 0126 /* XXX: turn off the timer interrupts */ 0127 0128 /* XXX: If necessary, restore the old vector */ 0129 } 0130 0131 void _Clock_Initialize( void ) 0132 { 0133 Install_clock( Clock_isr ); 0134 }
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
![]() ![]() |