Microchip® Advanced Software Framework

pmm.c File Reference

This is the implementation of LoRaWAN power management module.

Copyright (c) 2018 Microchip Technology Inc. and its subsidiaries.

Copyright (c) 2019 Microchip Technology Inc. and its subsidiaries.

Copyright (c) 2019-2020 Microchip Technology Inc. and its subsidiaries.

#include <stdint.h>
#include "pmm.h"
#include "conf_pmm.h"
#include "hw_timer.h"
#include "sw_timer.h"
#include "sleep_timer.h"
#include "sleep.h"
#include "atomic.h"
#include "system_task_manager.h"

Macros

#define SW_TIMER_ERROR_CORRECTION_TICKS   2
 

Functions

PMM_Status_t PMM_Sleep (PMM_SleepReq_t *req)
 This function puts the system to sleep if possible. More...
 
void PMM_Wakeup (void)
 Wakeup from sleep. More...
 
static bool validateSleepDuration (uint32_t durationMs)
 

Variables

static PMM_State_t pmmState = PMM_STATE_ACTIVE
 
static PMM_SleepReq_tsleepReq = NULL
 

#define SW_TIMER_ERROR_CORRECTION_TICKS   2

PMM_Status_t PMM_Sleep ( PMM_SleepReq_t req)

This function puts the system to sleep if possible.

Parameters
[in]*req- pointer to PMM_SleepReq_t request structure
Returns
value of type PMM_Status_t PMM_SLEEP_REQ_DENIED – when sleep is not possible at the instance PMM_SLEEP_REQ_PROCESSED – when sleep is possible and have already done

References HAL_Sleep(), MS_TO_SLEEP_TICKS, PMM_SLEEP_REQ_DENIED, PMM_SLEEP_REQ_PROCESSED, PMM_SLEEPTIME_MAX_MS, PMM_STATE_ACTIVE, PMM_STATE_SLEEP, PMM_Wakeup(), PMM_WAKEUPTIME_MS, pmmState, _PMM_SleepReq_t::sleep_mode, _PMM_SleepReq_t::sleepTimeMs, SleepTimerStart(), SWTIMER_INVALID_TIMEOUT, SwTimerNextExpiryDuration(), SYSTEM_ReadyToSleep(), SystemTimerSuspend(), US_TO_MS, and validateSleepDuration().

Referenced by processJoinAndSend().

static bool validateSleepDuration ( uint32_t  durationMs)
inlinestatic

PMM_State_t pmmState = PMM_STATE_ACTIVE
static

Referenced by PMM_Sleep(), and PMM_Wakeup().

PMM_SleepReq_t* sleepReq = NULL
static

Referenced by processJoinAndSend().