Exemplo n.º 1
0
/*FUNCTION**********************************************************************
 *
 * Function Name : OSA_EventCreate
 * Description   : This function is used to create a event object.
 * Return        : Event handle of the new event, or NULL if failed. 
 *
 *END**************************************************************************/
osaEventId_t OSA_EventCreate(bool_t autoClear)
{
#if osNumberOfEvents  
  osaEventId_t eventId;
  osEventStruct_t* pEventStruct; 
  OSA_InterruptDisable();
  eventId = pEventStruct = osObjectAlloc(&osEventInfo);
  OSA_InterruptEnable();
  if(eventId == NULL)
  {
    return NULL;
  }
  
  pEventStruct->event.eventHandler = xEventGroupCreate();
  if (pEventStruct->event.eventHandler)
  {
    pEventStruct->event.autoClear = autoClear;
  }
  else
  {
    OSA_InterruptDisable();
    osObjectFree(&osEventInfo, eventId);
    OSA_InterruptEnable();
    eventId = NULL;
  }
  return eventId;
#else
  (void)autoClear;
  return NULL;
#endif  
}
Exemplo n.º 2
0
/*---------------------------------------------------------------------------
 * Name: PWR_CheckIfDeviceCanGoToSleep
 * Description: -
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
bool_t PWR_CheckIfDeviceCanGoToSleep(void)
{
    bool_t returnValue;
    
    OSA_InterruptDisable();
    returnValue = mLPMFlag == 0 ? TRUE : FALSE;
    OSA_InterruptEnable();
    
    return returnValue;
}
Exemplo n.º 3
0
/*---------------------------------------------------------------------------
 * Name: PWR_AllowXcvrToSleep
 * Description: -
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
void PWR_AllowXcvrToSleep(void)
{
#if (cPWR_UsePowerDownMode)
    OSA_InterruptDisable();
    
    if(mLpmXcvrDisallowCnt != 0)
    {
        mLpmXcvrDisallowCnt--;
    }
    
    OSA_InterruptEnable();
#endif /* (cPWR_UsePowerDownMode) */
}
Exemplo n.º 4
0
/*---------------------------------------------------------------------------
 * Name: PWR_AllowDeviceToSleep
 * Description: -
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
void PWR_AllowDeviceToSleep(void)
{
#if (cPWR_UsePowerDownMode)
    OSA_InterruptDisable();
    
    if(mLPMFlag != 0)
    {
        mLPMFlag--;
    }
    
    OSA_InterruptEnable();
#endif /* (cPWR_UsePowerDownMode) */
}
Exemplo n.º 5
0
/*---------------------------------------------------------------------------
 * Name: PWR_EnterLowPower
 * Description: - 
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
PWRLib_WakeupReason_t PWR_EnterLowPower(void)
{
    PWRLib_WakeupReason_t ReturnValue;
    
#if (gTMR_EnableLowPowerTimers_d) 
    bool_t unlockTMRThread = FALSE;
#endif
    
    ReturnValue.AllBits = 0;
    
    if(PWR_LVD_ReportLevel() == PWR_LEVEL_CRITICAL)
    {
        /* Voltage <= 1.8V so enter power-off state - to disable false Tx'ing(void)*/
        ReturnValue = PWR_CheckForAndEnterNewPowerState(PWR_OFF);
    }
    
    OSA_InterruptDisable();
    
    if (TMR_AreAllTimersOff())  /*No timer running*/
    {
        /* If power lib is enabled */	
#if (cPWR_UsePowerDownMode)
        /* If Low Power Capability is enabled */
#if (gTMR_EnableLowPowerTimers_d) 
        /* If more low power timers are running, stop the hardware timer
         *and save the spend time in ticks that wasn't counted.
         */
        unlockTMRThread = TRUE;
#endif /* (gTMR_EnableLowPowerTimers_d) */
#endif /* (cPWR_UsePowerDownMode) */
        
        ReturnValue = PWR_CheckForAndEnterNewPowerState(PWR_DeepSleep);
    }
    else /* Timers are running */
    {
        ReturnValue = PWR_CheckForAndEnterNewPowerState(PWR_Sleep);
    }
    
    OSA_InterruptEnable();
    
#if (gTMR_EnableLowPowerTimers_d)
    if(unlockTMRThread)
    {
        TMR_MakeTMRThreadReady();
    }
    
#endif    
    return ReturnValue;
}
Exemplo n.º 6
0
/*---------------------------------------------------------------------------
 * Name: PWR_DisallowXcvrToSleep
 * Description: -
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
void PWR_DisallowXcvrToSleep(void)
{
#if (cPWR_UsePowerDownMode)
    uint8_t prot;
    
    OSA_InterruptDisable();
    
    prot = mLpmXcvrDisallowCnt + 1;
    
    if(prot != 0)
    {
        mLpmXcvrDisallowCnt++;
    }
    
    OSA_InterruptEnable();
#endif /* (cPWR_UsePowerDownMode) */
}
Exemplo n.º 7
0
/*---------------------------------------------------------------------------
 * Name: PWR_DisallowDeviceToSleep
 * Description: -
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
void PWR_DisallowDeviceToSleep(void)
{
#if (cPWR_UsePowerDownMode)
    uint8_t prot;
    
    OSA_InterruptDisable();
    
    prot = mLPMFlag + 1;
    
    if(prot != 0)
    {
        mLPMFlag++;
    }
    
    OSA_InterruptEnable();
#endif /* (cPWR_UsePowerDownMode) */
}
Exemplo n.º 8
0
/*FUNCTION**********************************************************************
 *
 * Function Name : OSA_EventDestroy
 * Description   : This function is used to destroy a event object. Return
 * osaStatus_Success if the event object is destroyed successfully, otherwise
 * return osaStatus_Error.
 *
 *END**************************************************************************/
osaStatus_t OSA_EventDestroy(osaEventId_t eventId)
{
#if osNumberOfEvents    
  osEventStruct_t* pEventStruct; 
  if(osObjectIsAllocated(&osEventInfo, eventId) == FALSE)
  {
    return osaStatus_Error;
  }
  pEventStruct = (osEventStruct_t*)eventId;
  if(pEventStruct->event.eventHandler == NULL)
  {
    return osaStatus_Error;
  }
  vEventGroupDelete(pEventStruct->event.eventHandler);
  OSA_InterruptDisable();
  osObjectFree(&osEventInfo, eventId);
  OSA_InterruptEnable();
  return osaStatus_Success;
#else
  (void)eventId;
  return osaStatus_Error;
#endif  
}
Exemplo n.º 9
0
/*---------------------------------------------------------------------------
 * Name: PWR_EnterPowerOff
 * Description: - Radio on Reset, MCU on VLLS1
 * Parameters: -
 * Return: -
 *---------------------------------------------------------------------------*/
void PWR_EnterPowerOff(void)
{
    OSA_InterruptDisable();
    (void)PWR_CheckForAndEnterNewPowerState(PWR_OFF);
    OSA_InterruptEnable();
}