?? headset_pio.c
字號:
/****************************************************************************
Copyright (C) Cambridge Silicon Radio Ltd. 2004
FILE NAME
headset_LEDs.c
DESCRIPTION
*/
#include "headset_pio.h"
#include "headset_private.h"
#include <pio.h>
#ifdef DEBUG_PIO
#define PIO_DEBUG(x) DEBUG (x)
#else
#define PIO_DEBUG(x)
#endif
/****************************************************************************
NAME
LEDManagerSetPowerPin
DESCRIPTION
controls the internal regulators to latch / remove the power on state
RETURNS
void
*/
void PioSetPowerPin ( hsTaskData * pApp , PowerPin_t pEnable )
{
bool lVal = (bool) pEnable ;
if ( pApp->features.PowerOnSMPS)
{
/*this is the power regulator PIO*/
PioSetPsuRegulator ( lVal ) ;
PIO_DEBUG(("PIO : PowerOnSMPS\n")) ;
}
if ( pApp->features.PowerOnLDO)
{
PioSetInternalLDO ( lVal ) ;
PIO_DEBUG(("PIO : PowerOn LDO\n")) ;
}
}
void PioSetLedPin ( LedTaskData * pLedTask , uint16 pPIO , bool pOnOrOff )
{
/*special LED pins are special cases*/
if ( pPIO == 14)
{
PioSetLed0 ( pOnOrOff ) ;
pLedTask->gLED_0_STATE = pOnOrOff ;
}
else if (pPIO == 15 )
{
PioSetLed1 ( pOnOrOff ) ;
pLedTask->gLED_1_STATE = pOnOrOff ;
}
else
{
PioSetPin (pPIO , pOnOrOff) ;
}
}
/****************************************************************************
NAME
LEDManagerUpdateLED
DESCRIPTION
Fn to change an individual LED state
RETURNS
void
*/
void PioSetPin ( uint16 pPIO , bool pOnOrOff )
{
uint16 lPinVals = 0 ;
uint16 lWhichPin = 1 << pPIO ;
PIO_DEBUG(("PIO : set[%d][%d] [%x]\n",pPIO, pOnOrOff ,lWhichPin)) ;
if ( pOnOrOff == TRUE )
{
lPinVals = lWhichPin ;
}
else
{
lPinVals = 0x0000;
/*clr the corresponding bit*/
}
PIO_DEBUG(("PIO : set[%x][%x]\n",lWhichPin , lPinVals)) ;
PioSetPinAsOutput(pPIO) ;
PioSet ( lWhichPin , lPinVals ) ;
}
bool PioGetLedPin ( LedTaskData * pLedTask , uint16 pPIO )
{
bool lState = FALSE ;
/*special LED pins are special cases*/
if ( pPIO == 14)
{
lState = pLedTask->gLED_0_STATE ;
}
else if (pPIO == 15 )
{
lState = pLedTask->gLED_1_STATE ;
}
else
{
lState = PioGetPin( pPIO ) ;
}
return lState ;
}
/****************************************************************************
NAME
LEDManagerGetLEDState
DESCRIPTION
Fn to get the state of an individual LED
RETURNS
bool On or OFF
*/
bool PioGetPin ( uint16 pPIO )
{
bool lState = FALSE ;
uint16 lMask = 0;
lMask = PioGet ( ) ;
PIO_DEBUG(("PIO : g[%d] p[%d] [%d] ",lMask , pPIO , (lMask & (1<<pPIO)))) ;
if ( lMask & (1<<pPIO) )
{
lState = TRUE ;
}
PIO_DEBUG(("PIO :get[%d]l[%d]\n" , pPIO,lState)) ;
return lState ;
}
/****************************************************************************
NAME
PioSetPinAsOutput
DESCRIPTION
Fn to set a PIO as an output pin ( DDR)
RETURNS
void
*/
void PioSetPinAsOutput ( uint16 pPIO )
{
/*(mask,bits) setting bit to a '1' sets the corresponding port as an output*/
uint16 lMask = (1<<pPIO) ;
PioSetDir(lMask,lMask);
}
/****************************************************************************
NAME
PioSetInternalLDO
DESCRIPTION
Fn to set the internal LDO pin
RETURNS
void
*/
void PioSetInternalLDO ( bool pEnable)
{
PioSetMicBias ( pEnable ) ;
PIO_DEBUG(("PIO : InternalLDO[%c]\n", pEnable ? 'T' :'F')) ;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -