/***********************************************************************************************
* Company: Microsemi Corporation
*
* File: fan_control.h
* File history:
*      Revision: 1.0 Date: July 29, 2011
*
* Description: Header file
*
* Author: Pavan Marisetti
*         pavan.marisetti@microsemi.com
*         Corporate Applications Engineering
*
************************************************************************************************/

#ifndef FAN_CONTROL_H_
#define FAN_CONTROL_H_

#define TACHO_PULSE_COUNT         8
#define NO_OF_POLES               2
#define FABRIC_PWM_BASE_ADDR      0x40050000
#define FABRIC_TACH_BASE_ADDR     0x40050000
#define PCLK_FREQ 				  25000000
#define DESIRED_RPM                           6000
#define MAX_RPM                               6000
#define NEG_EDGE				              0x000000FF
#define POS_EDGE				              0x00000000
#define FIVE_PERSENT_OF_MAX_RMP				  ((MAX_RPM * 5)/100)
#define TEN_PERSENT_OF_MAX_RMP				  ((MAX_RPM * 10)/100)
#define TWENTYFIVE_PERSENT_OF_MAX_RMP		  ((MAX_RPM * 25)/100)
#define FIFTY_PERSENT_OF_MAX_RMP			  ((MAX_RPM * 50)/100)
#define ONE_PERSENT_OF_MAX_RMP                ((MAX_RPM * 1)/100)
#define HALF_PERSENT_OF_MAX_RMP               ((MAX_RPM * 1)/200)
#define QUARTER_PERSENT_OF_MAX_RMP            ((MAX_RPM * 1)/400)
#define VAL_255_32_bit                   0x000000FF
#define VAL_0_32_bit                     0x00000000
#define VAL_1_32_bit                     0x00000001
void fan_control(void);
void init_fan_controller(void);
int xatoi (                                             /* 0:Failed, 1:Successful */
		        uint8_t **str,                          /* Pointer to pointer to the string */
		        uint32_t *res                             /* Pointer to the valiable to store the value */
                );
uint8_t fan_menu_n_action(uint8_t menu_print);
void PWM_init_fan();
void int_to_char(uint32_t num, uint8_t *str);
#endif /* FAN_CONTROL_H_ */
