Back to home page

LXR

 
 

    


File indexing completed on 2025-05-11 08:23:51

0001 #ifndef BSP_GT_TIMER_H
0002 #define BSP_GT_TIMER_H
0003 
0004 /* Support for hardware timers in the discovery bridge */
0005 
0006 /* 
0007  * Authorship
0008  * ----------
0009  * This software ('beatnik' RTEMS BSP for MVME6100 and MVME5500) was
0010  *     created by Till Straumann <strauman@slac.stanford.edu>, 2005-2007,
0011  *     Stanford Linear Accelerator Center, Stanford University.
0012  * 
0013  * Acknowledgement of sponsorship
0014  * ------------------------------
0015  * The 'beatnik' BSP was produced by
0016  *     the Stanford Linear Accelerator Center, Stanford University,
0017  *     under Contract DE-AC03-76SFO0515 with the Department of Energy.
0018  * 
0019  * Government disclaimer of liability
0020  * ----------------------------------
0021  * Neither the United States nor the United States Department of Energy,
0022  * nor any of their employees, makes any warranty, express or implied, or
0023  * assumes any legal liability or responsibility for the accuracy,
0024  * completeness, or usefulness of any data, apparatus, product, or process
0025  * disclosed, or represents that its use would not infringe privately owned
0026  * rights.
0027  * 
0028  * Stanford disclaimer of liability
0029  * --------------------------------
0030  * Stanford University makes no representations or warranties, express or
0031  * implied, nor assumes any liability for the use of this software.
0032  * 
0033  * Stanford disclaimer of copyright
0034  * --------------------------------
0035  * Stanford University, owner of the copyright, hereby disclaims its
0036  * copyright and all other rights in this software.  Hence, anyone may
0037  * freely use it for any purpose without restriction.  
0038  * 
0039  * Maintenance of notices
0040  * ----------------------
0041  * In the interest of clarity regarding the origin and status of this
0042  * SLAC software, this and all the preceding Stanford University notices
0043  * are to remain affixed to any copy or derivative of this software made
0044  * or distributed by the recipient and are to be affixed to any copy of
0045  * software made or distributed by the recipient that contains a copy or
0046  * derivative of this software.
0047  * 
0048  * ------------------ SLAC Software Notices, Set 4 OTT.002a, 2004 FEB 03
0049  */ 
0050 
0051 #include <stdint.h>
0052 
0053 #ifdef __cplusplus
0054   extern "C" {
0055 #endif
0056 
0057 /* Obtain the number of hardware timers present
0058  * The 'timer' argument in the routines below addresses
0059  * one of 0..(BSP_timer_instances()-1)
0060  */
0061 int BSP_timer_instances(void);
0062 
0063 /* Setup timer but don't start yet; interrupts are enabled if an isr argument is passed
0064  * no interrupts are generated otherwise.
0065  *
0066  * If 'reload' is nonzero then the period is automatically restarted.
0067  *
0068  * RETURNS: 0 on success, nonzero on error (argument error)
0069  *
0070  * NOTE: If an ISR is already connected, it must be removed by passing a NULL isr first.
0071  */
0072 int      BSP_timer_setup(uint32_t timer, void (*isr)(void *arg), void *arg, int reload);
0073 
0074 /* Stop timer;
0075  *
0076  * RETURNS: 0 on success, nonzero on argument error
0077  */
0078 int      BSP_timer_stop(uint32_t timer);
0079 
0080 /* Start timer with 'period' (in ticks)
0081  *
0082  * RETURNS: 0 on success, nonzero on argument error
0083  */
0084 int      BSP_timer_start(uint32_t timer, uint32_t period);
0085 
0086 /* read decrementing timer on the fly
0087  *
0088  * RETURNS: current count in ticks
0089  */
0090 uint32_t BSP_timer_read(uint32_t timer);
0091 
0092 /* get clock rate in Hz */
0093 uint32_t BSP_timer_clock_get(uint32_t timer);
0094 
0095 /* Initialize timer facility -- to be used by BSP implementors only
0096  *
0097  * RETURNS: 0 on success, nonzero if ISR wrapper couldn't be installed
0098  */
0099 int BSP_timers_initialize(void);
0100 
0101 /* WATCHDOG TIMER (resets board if enabled and not 'petted' for
0102  * some time).
0103  */
0104 
0105 /* Enable watchdog and set a timeout (in us)
0106  * RETURNS 0 on success
0107  */
0108 int BSP_watchdog_enable(uint32_t timeout_us);
0109 
0110 /* Disable watchdog
0111  * RETURNS 0 on success
0112  */
0113 int BSP_watchdog_disable(void);
0114 
0115 /* Check status -- unfortunately there seems to be no way
0116  * to read the running value...
0117  *
0118  * RETURNS nonzero if enabled/running, zero if disabled/stopped
0119  */
0120 int BSP_watchdog_status(void);
0121 
0122 /* Pet the watchdog (rearm to configured timeout)
0123  * RETURNS: 0 on success, nonzero on failure (watchdog
0124  * currently not running).
0125  */
0126 int BSP_watchdog_pet(void);
0127 
0128 
0129 #ifdef __cplusplus
0130   }
0131 #endif
0132 
0133 #endif