/*! \file 
*	\details Header file of ATMEGA16 peripherals and subsystems initialization library.
*
*	\ingroup WheelchairControl
*	@{
*/

#ifndef _MISC_INITS	//define once
#define _MISC_INITS

//Libraries
#include "Defines.h"

//Functions

/*!
* Initializes TIMER2 (period 2 ms) Measures the range every 50 ms, processes acquired data, PSD motors' regulators are run here. \n\n
*
* \note
* 16-bit timer, R/C generation on OCR1X and TCNT1 match (non-inverting mode), TCNT1 top = ICR1. \n
* R/C signal period 20 ms, positive pulse length: \n
* ---					1.5 ms: Stop motor;				OCR1X = 375. \n
* ---					1 ms:	Full speed backwards;	OCR1X = 250. \n
* ---					2 ms:	Full speed forward;		OCR1X = 500. \n	
* No interrupts enabled for TIMER1. 	
*/
void TIMER1_Init(void);

/*!
* Initializes TIMER2 (period 2 ms) Measures the range every 50 ms, processes acquired data, PSD motors' regulators are run here. \n\n
*
* \note
* 8-bit timer, interrupt flag is set on everflow. \n
* Overflow interrupt period: 16 MHz / 128(prescaler) / 256 (8-bit resolution) = 2 ms.
*/
void TIMER2_Init(void);

/*!
* Initializes TIMER0 (period 1 ms, used clear UART Rx index every 4ms). \n\n
*
* \note
* 8-bit timer, interrupt flag is set on everflow. \n
* Overflow interrupt period: 16 MHz / 64(prescaler) / 256 (8-bit resolution) = 1 ms.
*/
void TIMER0_Init(void);

/*!
* Initializes I/O port A - D (input/output, pull-ups etc.).
*
* \note See this function in MiscInits.c file source code to obtain information about ports' configuration.
*/
void PORTS_Init(void);

/*!
* Disables analog comparator.
*/
void AC_Disable(void);	

/*!
* Initializes A/D converter.
*/
void ADC_Init(void);

/*!
* Initializes registers of external interrupts
*/	
void EXT_INT_Init(void);

/*!
* Initializes inter-ISRs shared structure.
*
* \param sharedStruct t_ISRsSharedStruct to be initialized.  
*
* \see t_ISRsSharedStruct
*/
void Init_ISRsSharedstruct(t_ISRsSharedStruct * sharedStruct);	

#endif //_MISC_INITS
