/*
 * timemgt.h
 *
 *  Created on: Apr 28, 2021
 *      Author: Florian
 */

#ifndef INC_TIMEMGT_H_
#define INC_TIMEMGT_H_

/* Includes */
#include "common.h"
#include "stm32f2xx_hal.h"

/* Constants */
#define cTimeMgtAlarmsNumber 8
#define TIM_ChannelNumberMax_U8 ((uint8_t)8)

/* Typedefs */
typedef void (* pTimeMgtCallback)(void);

typedef struct
{
	uint32_t timeout_u32;
	uint32_t counter_u32;
	BOOL enable_b;
	pTimeMgtCallback callback_p;
} tTimeMgt_Channel;

/* Shared functions */
void TimeMgt_Init (void);
void TimeMgt_Start (void);
void TimeMgt_Stop (void);

void TimeMgt_PeriodicFunction (void);

void TimeMgt_AddCyclicEvent(uint8_t channel_u8, void (* pCallback)(void), uint32_t timeout_u32);
void TimeMgt_RemoveCyclicEvent(uint8_t channel_u8);
void TimeMgt_EnableCyclicEvent(uint8_t channel_u8);
void TimeMgt_DisableCyclicEvent(uint8_t channel_u8);

#endif /* INC_TIMEMGT_H_ */
