-ne timer.h Source File
Friedrich-Alexander-Universität UnivisSuche FAU-Logo
Techn. Fakultät Willkommen am Department Informatik FAU-Logo
Logo I4
Lehrstuhl für Informatik 4
GSPiC
 
  Vorlesung
    - UnivIS-Infos
    - Inhalt
    - Folien
 
  Übungen
    - Inhalt
    - Ergänzendes Material
    - Aufgaben
    - UnivIS-Infos
    - libspicboard-Doku
    - FSI-Forum für Fragen
 
  Prüfung
 
  Evaluation
 
  Intern
Department Informatik  >  Informatik 4  >  Lehre  >  SS 2014  >  GSPiC  >  Übungen  >  Doku  >  timer.h Source File

SPiCboard library (libspicboard, revision exportiert) API documentation

Found a bug or something ambiguous? Mail us to get it fixed!

timer.h
Go to the documentation of this file.
1 #ifndef TIMER_H
2 #define TIMER_H
3 #include <stdint.h>
4 
5 /**
6  * \addtogroup Timer Timer module
7  *
8  * \brief The timer module provides an event interface to the hardware timers.
9  *
10  * The module uses the 16-bit <b>timer 1</b> of the ATmega32. The timer is dynamically
11  * configured as needed by the registered alarms and should always be clocked
12  * as slow as possible to keep the interrupt load low. When no alarms are
13  * registered, the timer clock is disabled.
14  *
15  * \note The timer module uses dynamic memory management (malloc()/free()) for the allocation
16  * of the ALARM types. This is also done from within ISRs. Thus care must be taken when
17  * calling malloc()/free() with interrupts enabled.
18  *
19  * \note Interrupts must be enabled for the timer to work.
20  *
21  * @{
22  * \file timer.h
23  * \version \$Rev$
24  */
25 
26 /**
27  * \brief ALARM type
28  * This is type of a struct containing information about an alarm.
29  */
30 typedef struct ALARM ALARM;
31 
32 /**
33  * \brief Type for alarm callback functions.
34  *
35  * Alarm callback functions are invoked on the interrupt
36  * level whenever the associated alarm expires. The
37  * programming model for callback functions is similar
38  * to that of interrupt service routines.
39  */
40 typedef void (*alarmcallback_t) (void);
41 
42 /**
43  * \brief Cancel an alarm.
44  *
45  * \param alrm identifier of the alarm that should be canceled
46  * \retval 0 success
47  * \retval -1 an error occurred
48  * \sa sb_timer_setAlarm
49  * \note alarms must not be canceled twice
50  */
51 int8_t sb_timer_cancelAlarm(ALARM *alrm);
52 
53 /**
54  * \brief Create a new alarm.
55  *
56  * This function can be used to set single shot, as well as repeating timers.
57  *
58  * - <b>Single shot:</b> Set cycle to 0. This alarm <b>must not</b> be canceled after being fired.
59  * - <b>Repetitive:</b> The first shot can be adjusted be setting alarmtime > 0. Otherwise cycle is used.
60  *
61  * \note The callback function is called from within the ISR-context.
62  *
63  * \param callback callback function that will be invoked whenever the alarm expires
64  * \param alarmtime time in ms relative to the current time when the alarm shall expire the first time.
65  * If set to 0 cycle time will be used.
66  * \param cycle time in ms for alarms that periodically expire after the first regular expiry.
67  * Set to 0 for single shot timers.
68  * \return the identifier of the alarm, or NULL if creating the alarm failed.
69  *
70  * \warning Canceling a timer twice or canceling a single shot timer after its expiry may
71  * cause unexpected results.
72  *
73  * \sa sb_timer_cancelAlarm
74  */
75 ALARM *sb_timer_setAlarm(alarmcallback_t callback, uint16_t alarmtime, uint16_t cycle);
76 
77 /**
78  *
79  * \brief waits for a specific number of ms
80  *
81  * This function must not be invoked with interrupts disabled, i.e. from an interrupt
82  * handler (or generally, from the ISR level) or a critical section of the application.
83  *
84  * The CPU is set in sleep mode while waiting.
85  *
86  * \param waittime wait time in ms
87  * \retval 0 success
88  * \retval -1 alarm could not be activated
89  * \retval -2 sb_timer_delay invoked while interrupts disabled
90  * \sa sb_timer_delay_abort
91  *
92  */
93 int8_t sb_timer_delay(uint16_t waittime);
94 
95 /**
96  * \brief Aborts an active sb_timer_delay.
97  *
98  * This function must be invoked on the ISR level.
99  *
100  * \sa sb_timer_delay
101  */
102 void sb_timer_delay_abort();
103 
104 /** @}*/
105 
106 #endif
107 
  Impressum   Datenschutz Stand: 2014-05-23 19:23   MS