• Navigation überspringen
  • Zur Navigation
  • Zum Seitenende
Organisationsmenü öffnen Organisationsmenü schließen
Friedrich-Alexander-Universität Lehrstuhl für Informatik 4 (Systemsoftware)
  • FAUZur zentralen FAU Website
  1. Friedrich-Alexander-Universität
  2. Technische Fakultät
  3. Department Informatik
Suche öffnen
  • English
  • Campo
  • StudOn
  • FAUdir
  • Stellenangebote
  • Lageplan
  • Hilfe im Notfall
  1. Friedrich-Alexander-Universität
  2. Technische Fakultät
  3. Department Informatik
Friedrich-Alexander-Universität Lehrstuhl für Informatik 4 (Systemsoftware)
Menu Menu schließen
  • Lehrstuhl
    • Team
    • Aktuelles
    • Kontakt und Anfahrt
    • Leitbild
    • 50-jähriges Jubiläum
    Portal Lehrstuhl
  • Forschung
    • Forschungsbereiche
      • Betriebssysteme
      • Confidential Computing
      • Embedded Systems Software
      • Verteilte Systeme
    • Projekte
      • AIMBOS
      • BALu
      • BFT2Chain
      • DOSS
      • Mirador
      • NEON
      • PAVE
      • ResPECT
      • Watwa
    • Projektkampagnen
      • maRE
    • Seminar
      • Systemsoftware
    Portal Forschung
  • Publikationen
  • Lehre
    • Sommersemester 2025
      • Applied Software Architecture
      • Ausgewählte Kapitel der Systemsoftware
      • Betriebssystemtechnik
      • Projekt angewandte Systemsoftwaretechnik
      • System-Level Programming
      • Systemnahe Programmierung in C
      • Systemprogrammierung 1
      • Verteilte Systeme
    • Wintersemester 2024/25
      • Betriebssysteme
      • Middleware – Cloud Computing
      • Systemprogrammierung 2
      • Verlässliche Echtzeitsysteme
      • Virtuelle Maschinen
      • Web-basierte Systeme
    Portal Lehre
  • Examensarbeiten
  1. Startseite
  2. Extern

Extern

Bereichsnavigation: Lehre
  • System-Level Programming
    • Lecture
      • Exercises
        • Slides
        • Assignments
        • libspicboard-doc
          • Linux libc-doc
          • Exam
            • Intern
              • Contact

            libspicboard-doc

            Files | Typedefs | Functions
            Timer module

            The timer module provides an event interface to the hardware timers. More...

            Files

            file  timer.h
             

            Typedefs

            typedef struct ALARM ALARM
             ALARM type. More...
             
            typedef void(* ALARMCALLBACK) (void)
             Type for alarm callback functions. More...
             

            Functions

            int8_t sb_timer_cancelAlarm (ALARM *alrm)
             Cancel an alarm. More...
             
            ALARM * sb_timer_setAlarm (ALARMCALLBACK callback, uint16_t alarmtime, uint16_t cycle)
             Create a new alarm. More...
             
            int8_t sb_timer_delay (uint16_t waittime)
             Waits for a specific number of ms. More...
             
            void sb_timer_abortDelay ()
             Aborts an active sb_timer_delay. More...
             

            Detailed Description

            The timer module provides an event interface to the hardware timers.

            The module uses the 16-bit timer 1 of the ATmega32. The timer is dynamically configured as needed by the registered alarms and should always be clocked as slow as possible to keep the interrupt load low. When no alarms are registered, the timer clock is disabled.

            Note
            The timer module uses dynamic memory management (malloc()/free()) for the allocation of the ALARM types. This is also done from within ISRs. Thus care must be taken when calling malloc()/free() with interrupts enabled.
            Interrupts must be enabled for the timer to work.

            Typedef Documentation

            typedef struct ALARM ALARM

            ALARM type.

            This is type of a struct containing information about an alarm.

            typedef void(* ALARMCALLBACK) (void)

            Type for alarm callback functions.

            Alarm callback functions are invoked on the interrupt level whenever the associated alarm expires. The programming model for callback functions is similar to that of interrupt service routines.

            Function Documentation

            void sb_timer_abortDelay ( )

            Aborts an active sb_timer_delay.

            This function must be invoked on the ISR level.

            See also
            sb_timer_delay
            int8_t sb_timer_cancelAlarm ( ALARM *  alrm)

            Cancel an alarm.

            Parameters
            alrmidentifier of the alarm that should be canceled
            Return values
            0success
            -1an error occurred
            See also
            sb_timer_setAlarm
            Note
            Alarms must not be canceled twice
            int8_t sb_timer_delay ( uint16_t  waittime)

            Waits for a specific number of ms.

            This function must not be invoked with interrupts disabled, i.e. from an interrupt handler (or generally, from the ISR level) or a critical section of the application.

            The CPU is set in sleep mode while waiting.

            Parameters
            waittimewait time in ms
            Return values
            0success
            -1alarm could not be activated
            -2sb_timer_delay invoked while interrupts disabled
            See also
            sb_timer_abortDelay
            ALARM* sb_timer_setAlarm ( ALARMCALLBACK  callback,
            uint16_t  alarmtime,
            uint16_t  cycle 
            )

            Create a new alarm.

            This function can be used to set single shot, as well as repeating timers.

            • Single shot: Set cycle to 0. This alarm must not be canceled after being fired.
            • Repetitive: The first shot can be adjusted be setting alarmtime > 0. Otherwise cycle is used.
            Note
            The callback function is called from within the ISR-context.
            Parameters
            callbackcallback function that will be invoked whenever the alarm expires
            alarmtimetime in ms relative to the current time when the alarm shall expire the first time. If set to 0 cycle time will be used.
            cycletime in ms for alarms that periodically expire after the first regular expiry. Set to 0 for single shot timers.
            Returns
            the identifier of the alarm, or NULL if creating the alarm failed.
            Warning
            Canceling a timer twice or canceling a single shot timer after its expiry may cause unexpected results.
            See also
            sb_timer_cancelAlarm
            Friedrich-Alexander-Universität
            Erlangen-Nürnberg

            Schlossplatz 4
            91054 Erlangen
            • Impressum
            • Datenschutz
            • Barrierefreiheit
            • Facebook
            • RSS Feed
            • Xing
            Nach oben