144 lines
4.4 KiB
C
144 lines
4.4 KiB
C
/*
|
|
* Vecmocon Technologies Private Limited [CONFIDENTIAL]
|
|
* Unpublished Copyright (c) 2019 [Vecmocon Technologies Private Limited], All Rights Reserved.
|
|
*
|
|
*
|
|
* NOTICE: All information contained herein is, and remains the property of COMPANY. The intellectual and technical concepts contained
|
|
* herein are proprietary to COMPANY and may be covered by Indian and Foreign Patents, patents in process, and are protected by trade secret or copyright law.
|
|
* Dissemination of this information or reproduction of this material is strictly forbidden unless prior written permission is obtained
|
|
* from COMPANY. Access to the source code contained herein is hereby forbidden to anyone except current COMPANY employees, managers or contractors who have executed
|
|
* Confidentiality and Non-disclosure agreements explicitly covering such access.
|
|
*
|
|
*
|
|
* The copyright notice above does not evidence any actual or intended publication or disclosure of this source code, which includes
|
|
* information that is confidential and/or proprietary, and is a trade secret, of COMPANY. ANY REPRODUCTION, MODIFICATION, DISTRIBUTION, PUBLIC PERFORMANCE,
|
|
* OR PUBLIC DISPLAY OF OR THROUGH USE OF THIS SOURCE CODE WITHOUT THE EXPRESS WRITTEN CONSENT OF COMPANY IS STRICTLY PROHIBITED, AND IN VIOLATION OF APPLICABLE
|
|
* LAWS AND INTERNATIONAL TREATIES. THE RECEIPT OR POSSESSION OF THIS SOURCE CODE AND/OR RELATED INFORMATION DOES NOT CONVEY OR IMPLY ANY RIGHTS
|
|
* TO REPRODUCE, DISCLOSE OR DISTRIBUTE ITS CONTENTS, OR TO MANUFACTURE, USE, OR SELL ANYTHING THAT IT MAY DESCRIBE, IN WHOLE OR IN PART.
|
|
*/
|
|
|
|
/*!
|
|
* \file gp_timer.h
|
|
* \author Altamash Abdul Rahim
|
|
* \brief This file Software timer functionality.
|
|
*
|
|
* Changelog:
|
|
* 09 February 2019: Created.
|
|
* 28-August-2019: (-) updated variable and function naming convention
|
|
* (-) add comments for auto-documentation generation tool
|
|
*/
|
|
#ifndef __GP_TIMER_H__
|
|
#define __GP_TIMER_H__
|
|
|
|
#include <stdint.h>
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
/// time typedef
|
|
typedef uint32_t tClockTime;
|
|
|
|
/*!
|
|
* \brief Timer structure. Use Timer_Set() to set the timer.
|
|
*/
|
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
|
struct timer {
|
|
#else
|
|
typedef struct {
|
|
#endif
|
|
tClockTime start; /// start time
|
|
tClockTime interval; /// interval for timer
|
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
|
};
|
|
#else
|
|
} gpTimer_t;
|
|
#endif
|
|
|
|
/*!
|
|
* \brief This function sets a timer for a specific time.
|
|
* The function `Timer_Expired()` returns true if
|
|
* the timer has expired.
|
|
*
|
|
* \param[in] t pointer to timer instance
|
|
* \param[in] interval interval after which the timer expires
|
|
* \return void
|
|
*/
|
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
|
void Timer_Set(struct timer *t, tClockTime interval);
|
|
#else
|
|
void GPT_timerSet(gpTimer_t * t, tClockTime interval);
|
|
#endif
|
|
|
|
/*!
|
|
* \brief [DEPRECATED] This function resets the same interval that was
|
|
* given to the Timer_Set() function.
|
|
*
|
|
* The starting point of the interval is the last timer
|
|
* value when timer expired. Using this function
|
|
* makes the timer being stable over time.
|
|
*
|
|
* \param[in] t pointer to timer instance
|
|
* \return void
|
|
*/
|
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
|
void Timer_Reset(struct timer * t);
|
|
#else
|
|
void GPT_timerReset(gpTimer_t * t);
|
|
#endif
|
|
|
|
/*!
|
|
* \brief This function resets the same interval that was
|
|
* given to the Timer_Set() function.
|
|
*
|
|
* The starting point of the interval is the current time.
|
|
* For a stable timer over time, it is recommended to use
|
|
* the Timer_Reset() function.
|
|
*
|
|
* \param[in] t pointer to timer instance
|
|
* \return void
|
|
*/
|
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
|
void Timer_Restart(struct timer * t);
|
|
#else
|
|
void GPT_timerRestart(gpTimer_t * t);
|
|
#endif
|
|
|
|
/*!
|
|
* \brief This function verifies if a timer has expired.
|
|
*
|
|
* \param[in] timer instance
|
|
* \return uint8_t integer result code (1: expired, 0: not expired)
|
|
*/
|
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
|
uint8_t Timer_Expired(struct timer * timer);
|
|
#else
|
|
uint8_t GPT_timerExpired(gpTimer_t * timer);
|
|
#endif
|
|
|
|
/*!
|
|
* \brief This function returns the remaining time before the timer expires.
|
|
*
|
|
* \param[in] timer instance
|
|
* \return tClockTimer time remaining
|
|
*/
|
|
#ifdef USE_DEPRECATED_FUNCTIONS
|
|
tClockTime Timer_Remaining(struct timer *t);
|
|
#else
|
|
tClockTime GPT_timerRemaining(gpTimer_t * timer);
|
|
#endif
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
/*!
|
|
* \brief This function provide a delay for a given amount of time.
|
|
*
|
|
* \param[in] delay ticks to delay for
|
|
* \return void
|
|
*/
|
|
void Timer_Delay(uint32_t delay);
|
|
|
|
#endif /* __GP_TIMER_H__ */
|