//-----------------------------------------------------------------------------
// power.h
//-----------------------------------------------------------------------------
// Copyright 2010 Silicon Laboratories, Inc.
// http://www.silabs.com
//
// Program Description:
//
// Driver for the power management function.
//
// Target:         C8051F99x-C8051F98x
// Tool chain:     Generic
// Command Line:   None
//
// Release 1.0
//    - Initial Revision (FB)
//    - 19 MAY 2010
//


#ifndef _Power_M__H___ 
#define _Power_M__H___

#ifdef  _Power_Mag_
#define  Power_M_C
#else
#define Power_M_C	extern
#endif


#define RTCCLK   32768
	 
// Constants for determining the RTC wake-up interval
#define INTERVAL_SEC   				1000L         // Wakeup-interval in milliseconds
#define WAKE_INTERVAL_TICKS(ticks)  	((RTCCLK * (ticks)*INTERVAL_SEC) / 1000L)
#define ONE_MS_TICKS         			((RTCCLK * 1 ) / 1000L)


//-----------------------------------------------------------------------------
// Register and Bit Definitions
//-----------------------------------------------------------------------------

// Power Management Bit Definitions

#define SLEEP        0x80              //3 Sleep Mode Select

#define SUSPEND   0x40              //3 Suspend Mode Select

#define CLEAR        0x20              //3 Wake-Up Flag Clear

#define RSTWK       0x10              //3 Reset Pin Falling Edge Wake-Up

#define RTCFWK     0x08              //3 SmaRTClock Failure Wake-Up

#define RTCAWK     0x04              //3 SmaRTClock Alarm Wake-Up

#define PMATWK     0x02              //3 Port Match Wake-Up
#define CPT0WK      0x01              //3 Comparator0 Wake-Up

// Friendly names for the LPM function arguments
#define PORT_MATCH   	PMATWK
#define RTC          			RTCFWK + RTCAWK
#define COMPARATOR   	CPT0WK

// FLSCL Bit Definition
#define BYPASS    0x40
#define NON_ZERO  0x01



//-----------------------------------------------------------------------------
// Extern Variable Definitions
//-----------------------------------------------------------------------------
Power_M_C U8 PMU0CF_Local; 


Power_M_C U8 Sleep_Mode_Chk_Timer;
//-----------------------------------------------------------------------------
// Extern Function PROTOTYPES
//-----------------------------------------------------------------------------

Power_M_C void LPM_Init (void);
Power_M_C void LPM(U8 mode);
Power_M_C void LPM_Enable_Wakeup (U8 wakeup);
Power_M_C void LPM_Disable_Wakeup (U8 wakeup);

Power_M_C void Power_Sleep_Mode(void);
Power_M_C void RF_Wakeup(void);

#endif
