Addressed review comments

1. LP ticker limiation note
2. Use read_us in mbed_uptime function
3. Doxygen recommendations
4. Use us_timestamp_t instead uint64_t
5. Astyle changes
pull/6857/head
Deepika 2018-05-15 11:06:21 -05:00
parent 3420ff7f9c
commit 029237b683
4 changed files with 35 additions and 38 deletions

View File

@ -31,14 +31,14 @@
// deep sleep locking counter. A target is allowed to deep sleep if counter == 0
static uint16_t deep_sleep_lock = 0U;
static uint64_t sleep_time = 0;
static uint64_t deep_sleep_time = 0;
static us_timestamp_t sleep_time = 0;
static us_timestamp_t deep_sleep_time = 0;
#if defined(MBED_CPU_STATS_ENABLED) && defined(DEVICE_LOWPOWERTIMER)
static ticker_data_t *sleep_ticker = NULL;
#endif
static inline uint64_t read_us(void)
static inline us_timestamp_t read_us(void)
{
#if defined(MBED_CPU_STATS_ENABLED) && defined(DEVICE_LOWPOWERTIMER)
if (NULL == sleep_ticker) {
@ -50,29 +50,22 @@ static inline uint64_t read_us(void)
#endif
}
uint64_t mbed_time_idle(void)
us_timestamp_t mbed_time_idle(void)
{
return (sleep_time + deep_sleep_time);
}
uint64_t mbed_uptime(void)
us_timestamp_t mbed_uptime(void)
{
#if defined(MBED_CPU_STATS_ENABLED) && defined(DEVICE_LOWPOWERTIMER)
if (NULL == sleep_ticker) {
sleep_ticker = (ticker_data_t*) get_lp_ticker_data();
}
return ticker_read_us(sleep_ticker);
#else
return 0;
#endif
return read_us();
}
uint64_t mbed_time_sleep(void)
us_timestamp_t mbed_time_sleep(void)
{
return sleep_time;
}
uint64_t mbed_time_deepsleep(void)
us_timestamp_t mbed_time_deepsleep(void)
{
return deep_sleep_time;
}
@ -196,7 +189,7 @@ void sleep_manager_sleep_auto(void)
sleep_tracker_print_stats();
#endif
core_util_critical_section_enter();
uint64_t start = read_us();
us_timestamp_t start = read_us();
bool deep = false;
// debug profile should keep debuggers attached, no deep sleep allowed
@ -211,7 +204,7 @@ void sleep_manager_sleep_auto(void)
}
#endif
uint64_t end = read_us();
us_timestamp_t end = read_us();
if (true == deep) {
deep_sleep_time += end - start;
} else {

View File

@ -25,6 +25,7 @@
#include "sleep_api.h"
#include "mbed_toolchain.h"
#include "hal/ticker_api.h"
#include <stdbool.h>
#ifdef __cplusplus
@ -206,31 +207,33 @@ static inline void system_reset(void)
NVIC_SystemReset();
}
/** Provides the time spent in sleep mode, since system is up and running
/** Provides the time spent in sleep mode since boot.
*
* @return Time spent in sleep
* @note Works only if platform supports LP ticker.
*/
uint64_t mbed_time_sleep(void);
us_timestamp_t mbed_time_sleep(void);
/** Provides the time spent in deep sleep mode, since system is up and running
/** Provides the time spent in deep sleep mode since boot.
*
* @return Time spent in deep sleep
* @note Works only if platform supports LP ticker.
*/
uint64_t mbed_time_deepsleep(void);
us_timestamp_t mbed_time_deepsleep(void);
/** Provides the time spent in idle thread since the system is up
/** Provides the time spent in idle mode since boot.
*
* @return Idle thread time.
* @note Works only if platform supports LP ticker.
*/
uint64_t mbed_time_idle(void);
us_timestamp_t mbed_time_idle(void);
/** Provides the time since the system is up and running
/** Provides the time since the system is up i.e. boot.
*
* @return System uptime.
* @note Works only if platform supports LP ticker.
*/
uint64_t mbed_uptime(void);
us_timestamp_t mbed_uptime(void);
#ifdef __cplusplus
}

View File

@ -24,6 +24,7 @@
#define MBED_STATS_H
#include <stdint.h>
#include <stddef.h>
#include "hal/ticker_api.h"
#ifdef __cplusplus
extern "C" {
@ -87,10 +88,10 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
* struct mbed_stats_cpu_t definition
*/
typedef struct {
uint64_t uptime; /**< Time since system is up and running */
uint64_t idle_time; /**< Time spent in idle thread since system is up and running */
uint64_t sleep_time; /**< Time spent in sleep since system is up and running */
uint64_t deep_sleep_time; /**< Time spent in deep sleep since system is up and running */
us_timestamp_t uptime; /**< Time since system is up and running */
us_timestamp_t idle_time; /**< Time spent in idle thread since system is up and running */
us_timestamp_t sleep_time; /**< Time spent in sleep since system is up and running */
us_timestamp_t deep_sleep_time; /**< Time spent in deep sleep since system is up and running */
} mbed_stats_cpu_t;
/**