/* =================================================================================
File name:        SPEED_PR.H  
===================================================================================*/


#ifndef __SPEED_PR_H__
#define __SPEED_PR_H__
#include "IQmathLib.h"
typedef struct {
    long NewTimeStamp;  	// Variable : New 'Timestamp' corresponding to a capture event (Q0) - independently with global Q
    long OldTimeStamp;  	// Variable : Old 'Timestamp' corresponding to a capture event (Q0) - independently with global Q
    long TimeStamp; 	   	// Input : Current 'Timestamp' corresponding to a capture event (Q0) - independently with global Q
    unsigned long SpeedScaler;    	// Parameter :  Scaler converting 1/N cycles to a GLOBAL_Q speed (Q0) - independently with global Q
       long EventPeriod;    	// Input/Variable :  Event Period (Q0) - independently with global Q
       int InputSelect;       // Input : Input selection between TimeStamp (InputSelect=0) and EventPeriod (InputSelect=1)
       _iq Speed;             	// Output :  speed in per-unit
       unsigned long BaseRpm;         	// Parameter : Scaler converting GLOBAL_Q speed to rpm (Q0) speed - independently with global Q
       long SpeedRpm;        	// Output : speed in r.p.m. (Q0) - independently with global Q
       } SPEED_MEAS_CAP;       	// Data type created


/*-----------------------------------------------------------------------------
Default initalizer for the SPEED_MEAS_CAP object.
-----------------------------------------------------------------------------*/                     

#define SPEED_MEAS_CAP_DEFAULTS   { 0, \
                                    0, \
                                    0, \
                                   400, \
                                    0, \
                                    0, \
                                    0, \
                                   3000, \
                                    0, \
                                  }

/*------------------------------------------------------------------------------
	SPEED_PR Macro Definition
------------------------------------------------------------------------------*/

extern void SPEED_PR_MACRO(SPEED_MEAS_CAP *v,unsigned int hall,unsigned int hall_last,unsigned int stall_status);
#endif // __SPEED_PR_H__
