| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- /*
- / _____) _ | |
- ( (____ _____ ____ _| |_ _____ ____| |__
- \____ \| ___ | (_ _) ___ |/ ___) _ \
- _____) ) ____| | | || |_| ____( (___| | | |
- (______/|_____)_|_|_| \__)_____)\____)_| |_|
- (C)2013 Semtech
- Description: Timer objects and scheduling management
- License: Revised BSD License, see LICENSE.TXT file include in the project
- Maintainer: Miguel Luis and Gregory Cristian
- */
- #ifndef __TIMER_H__
- #define __TIMER_H__
- /*!
- * \brief Timer object description
- */
- typedef struct TimerEvent_s
- {
- uint32_t Timestamp; //! Current timer value
- uint32_t ReloadValue; //! Timer delay value
- bool IsRunning; //! Is the timer currently running
- void ( *Callback )( void ); //! Timer IRQ callback function
- struct TimerEvent_s *Next; //! Pointer to the next Timer object.
- }TimerEvent_t;
- /*!
- * \brief Timer time variable definition
- */
- #ifndef TimerTime_t
- typedef uint64_t TimerTime_t;
- #endif
- /*!
- * \brief Enables/Disables low power timers usage
- *
- * \param [IN] enable [true]RTC timer used, [false]Normal timer used
- */
- void TimerSetLowPowerEnable( bool enable );
- /*!
- * \brief Initializes the timer object
- *
- * \retval enable [true]RTC timer used, [false]Normal timer used
- */
- bool TimerGetLowPowerEnable( void );
- /*!
- * \brief Initializes the timer object
- *
- * \remark TimerSetValue function must be called before starting the timer.
- * this function initializes timestamp and reload value at 0.
- *
- * \param [IN] obj Structure containing the timer object parameters
- * \param [IN] callback Function callback called at the end of the timeout
- */
- void TimerInit( TimerEvent_t *obj, void ( *callback )( void ) );
- /*!
- * Timer IRQ event handler
- */
- void TimerIrqHandler( void );
- /*!
- * \brief Starts and adds the timer object to the list of timer events
- *
- * \param [IN] obj Structure containing the timer object parameters
- */
- void TimerStart( TimerEvent_t *obj );
- /*!
- * \brief Stops and removes the timer object from the list of timer events
- *
- * \param [IN] obj Structure containing the timer object parameters
- */
- void TimerStop( TimerEvent_t *obj );
- /*!
- * \brief Resets the timer object
- *
- * \param [IN] obj Structure containing the timer object parameters
- */
- void TimerReset( TimerEvent_t *obj );
- /*!
- * \brief Set timer new timeout value
- *
- * \param [IN] obj Structure containing the timer object parameters
- * \param [IN] value New timer timeout value
- */
- void TimerSetValue( TimerEvent_t *obj, uint32_t value );
- /*!
- * \brief Read the current time
- *
- * \retval time returns current time
- */
- TimerTime_t TimerGetCurrentTime( void );
- /*!
- * \brief Manages the entry into ARM cortex deep-sleep mode
- */
- void TimerLowPowerHandler( void );
- #endif // __TIMER_H__
|