headset_powermanager.c

来自「bluelab的一个很好的例程」· C语言 代码 · 共 113 行

C
113
字号
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004

FILE NAME
    headset_powermanager.c
    
DESCRIPTION
    Module responsible for managing the battery monitoring and battery 
	charging functionaility
    
	BC4-Audio has integrated hardware support for charging LiON batteries.
	BC4-Headset provides software support for the charging of NiMH and
	NiMH battery technologies.  NiMH requires external hardware support.
*/

#include "headset_powermanager.h"
#include "headset_private.h"
#include "headset_battery.h"
#include "headset_charger.h"


#ifdef DEBUG_POWER
    #define PM_DEBUG(x) DEBUG(x)             
#else
    #define PM_DEBUG(x) 
#endif


/****************************************************************************
NAME	
	powerManagerInit

DESCRIPTION
	Initialise power management

RETURNS
	void
    
*/
power_type* powerManagerInit(void) 
{
	/* Allocate memory to hold the power state */
	return (power_type*) mallocPanic(sizeof(power_type));
}


/****************************************************************************
NAME    
    powerManagerConfig
    
DESCRIPTION
  	Configure power management
    
RETURNS
    void
*/
bool powerManagerConfig(power_type* power, const power_config_type* config)
{
	bool success = TRUE;
		
	DEBUG(("PM Config\n"));
	
	if(config)
	{
		/* Store power configuration */
		power->config = *config;
	
		/* Initialise the battery sub-system */		
		batteryInit(power);
		
		/* Initialise the battery charging sub-system */
		chargerInit(power);
	}
	else
	{
		success = FALSE;
	}
	
	return success;
}


/****************************************************************************
NAME    
    powerManagerChargerConnected
    
DESCRIPTION
  	This function is called when the charger is plugged into the headset
    
RETURNS
    void
*/
void powerManagerChargerConnected(power_type* power)
{
	chargerConnected(power);
}


/****************************************************************************
NAME    
    powerManagerChargerDisconnected
    
DESCRIPTION
  	This function is called when the charger is unplugged from the headset
    
RETURNS
    void
*/
void powerManagerChargerDisconnected(power_type* power)
{
	chargerDisconnected(power);
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?