System Info API addition

API added to get the system information like CPU ID, compiler ID and
compiler version.
pull/6821/head
deepikabhavnani 2018-05-03 16:10:48 -05:00 committed by Deepika
parent 8be2e34390
commit c08b3e3d3d
2 changed files with 52 additions and 3 deletions

View File

@ -1,8 +1,9 @@
#include "mbed_assert.h"
#include "mbed_stats.h"
#include <string.h>
#include <stdlib.h>
#include "mbed_assert.h"
#include "device.h"
#ifdef MBED_CONF_RTOS_PRESENT
#include "cmsis_os2.h"
#elif defined(MBED_STACK_STATS_ENABLED) || defined(MBED_THREAD_STATS_ENABLED)
@ -96,6 +97,29 @@ size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count)
osKernelUnlock();
free(threads);
#endif
return i;
}
void mbed_stats_sys_get(mbed_stats_sys_t *stats)
{
MBED_ASSERT(stats != NULL);
memset(stats, 0, sizeof(mbed_stats_sys_t));
#if defined(MBED_SYS_STATS_ENABLED)
stats->cpu_id = SCB->CPUID;
#if defined(__IAR_SYSTEMS_ICC__)
stats->compiler_id = IAR;
stats->compiler_version = __VER__;
#elif defined(__CC_ARM)
stats->compiler_id = ARM;
stats->compiler_version = __ARMCC_VERSION;
#elif defined(__GNUC__)
stats->compiler_id = GCC_ARM;
stats->compiler_version = (__GNUC__ * 10000 + __GNUC_MINOR__ * 100);
#endif
#endif
return;
}

View File

@ -30,6 +30,7 @@ extern "C" {
#endif
#ifdef MBED_ALL_STATS_ENABLED
#define MBED_SYS_STATS_ENABLED 1
#define MBED_STACK_STATS_ENABLED 1
#define MBED_HEAP_STATS_ENABLED 1
#define MBED_THREAD_STATS_ENABLED 1
@ -85,7 +86,6 @@ size_t mbed_stats_stack_get_each(mbed_stats_stack_t *stats, size_t count);
/**
* struct mbed_stats_thread_t definition
*/
typedef struct {
uint32_t id; /**< Thread Object Identifier */
uint32_t state; /**< Thread Object State */
@ -105,6 +105,31 @@ typedef struct {
*/
size_t mbed_stats_thread_get_each(mbed_stats_thread_t *stats, size_t count);
/**
* enum mbed_compiler_id_t definition
*/
typedef enum {
ARM = 1, /**< ARM */
GCC_ARM, /**< GNU ARM */
IAR /**< IAR */
} mbed_compiler_id_t;
/**
* struct mbed_stats_sys_t definition
*/
typedef struct {
uint32_t cpu_id; /**< CPUID Register data */
mbed_compiler_id_t compiler_id; /**< Compiler ID \ref mbed_compiler_id_t */
uint32_t compiler_version; /**< Compiler version */
} mbed_stats_sys_t;
/**
* Fill the passed in sys stat structure with system stats.
*
* @param stats A pointer to the mbed_stats_sys_t structure to fill
*/
void mbed_stats_sys_get(mbed_stats_sys_t *stats);
#ifdef __cplusplus
}
#endif