You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
113 lines
3.2 KiB
113 lines
3.2 KiB
/**
|
|
**************************************************************************************************
|
|
* @file timer.h
|
|
* @author Kerem Yollu & Edwin Koch
|
|
* @date 19.12.2021
|
|
* @version 1.0
|
|
**************************************************************************************************
|
|
* @brief This is the genral interface for timers.
|
|
*
|
|
* **Detailed Description :**
|
|
* This the timer interface and belongs to the interface layer
|
|
*
|
|
* @todo Following functions are to be implmented :
|
|
* timerSetHz
|
|
* timerSetMs
|
|
* timerSetNs
|
|
* timerSetPs
|
|
**************************************************************************************************
|
|
*/
|
|
|
|
#ifndef _TIMER_H_
|
|
#define _TIMER_H_
|
|
|
|
#ifdef __cplusplus
|
|
extern "C" {
|
|
#endif
|
|
|
|
#include "hardwareDescription.h"
|
|
|
|
|
|
/*! Emun of possible Timer Errors */
|
|
typedef enum {
|
|
functionNotSupported, /*!< This Funtion is not awailable on this **HARDWARE** */
|
|
prescalerOutOfRange /*!< Set prescaler value exeeds the Register's **HARDWARE** size */
|
|
} timerError_t;
|
|
|
|
typedef enum {
|
|
upCounting,
|
|
downCounting
|
|
} timerCountDirection_t;
|
|
|
|
typedef enum {
|
|
counter,
|
|
inputCapture,
|
|
outputCompare,
|
|
onePulse
|
|
} timerMode_t;
|
|
|
|
/*!
|
|
* Output compare modes.
|
|
*/
|
|
typedef enum {
|
|
frozen, /*!< Pin update is **de-activated** even when a compare match happens */
|
|
high_on_match, /*!< Pin goes **high** when a compare match occurs */
|
|
low_on_match, /*!< Pin goes **low** when a compare match occurs */
|
|
toggle, /*!< Pin **toggles** when a compare match occurs */
|
|
inactive_force_high, /*!< Pin if forced **high** */
|
|
inactive_force_low, /*!< Pin if forced **low** */
|
|
pwm_normal, /*!< Standart PWM mode */
|
|
pwm_inverted /*!< Inverted PWM mode */
|
|
};
|
|
|
|
/*!
|
|
* Reset the timer to its default state.
|
|
*/
|
|
void timerReset(timerNo_t timer);
|
|
void timerActivateBus(timerNo_t timer);
|
|
void timerEnable(timerNo_t timer);
|
|
void timerDisable(timerNo_t timer);
|
|
void timerSetMode(timerNo_t timer, timerMode_t mode);
|
|
void timerSetCountDirection(timerNo_t timer, timerCountDirection_t direction);
|
|
|
|
/*!
|
|
* Sets the given timer's prescaler value.
|
|
* This fucntion will also check if the entered prascaler value exeeds the register size.
|
|
* If violated the prescalerOutOfRange Error will be generated.
|
|
*/
|
|
void timerSetPrescaler(timerNo_t timer, uint32_t prescaler);
|
|
void timerSetPostscaler(timerNo_t timer, uint32_t postscaler);
|
|
void timerSetAutoReload(timerNo_t timer, uint32_t reload);
|
|
uint8_t timerGetUpdateInterrupt(timerNo_t timer);
|
|
void timerClearUpdateInterrupt(timerNo_t timer);
|
|
void timerClearCounter(timerNo_t timer);
|
|
|
|
/* Second stage configuration */
|
|
void timerInitCounter( timerNo_t timer,
|
|
uint32_t prescaler,
|
|
uint32_t period,
|
|
timerCountDirection_t direction);
|
|
|
|
void timerInitPwm( timerNo_t timer,
|
|
uint32_t prescaler,
|
|
uint32_t period,
|
|
timerCountDirection_t direction);
|
|
|
|
void timerSetHz(timerNo_t timer, uint16_t hz);
|
|
void timerSetMs(timerNo_t timer, uint16_t ms);
|
|
void timerSetNs(timerNo_t timer, uint16_t ns);
|
|
void timerSetPs(timerNo_t timer, uint16_t ps);
|
|
|
|
void timerSart(timerNo_t timer);
|
|
void timerHalt(timerNo_t timer);
|
|
void timerStop(timerNo_t timer);
|
|
uint32_t timerGetCount(timerNo_t timer);
|
|
|
|
void timerThrowError(timerError_t error);
|
|
|
|
#ifdef __cplusplus
|
|
}
|
|
#endif
|
|
|
|
#endif // _TIMER_H_
|