-
Notifications
You must be signed in to change notification settings - Fork 0
/
system.cpp
68 lines (53 loc) · 2.28 KB
/
system.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "system.h"
#include <esp_system.h>
extern "C" {
#include <esp_heap_caps.h>
}
static esp_chip_info_t ChipInfo;
libesp::System libesp::System::mSelf;
const libesp::System & libesp::System::get() {
return mSelf;
}
libesp::System::System() {
::esp_chip_info(&ChipInfo);
}
libesp::System::~System() {
}
const esp_chip_info_t *libesp::System::getChipInfo() const {
return &ChipInfo;
}
size_t libesp::System::getFreeHeapSize() const {
return heap_caps_get_free_size(MALLOC_CAP_8BIT);
}
const char *libesp::System::getIDFVersion() const {
return ::esp_get_idf_version();
}
size_t libesp::System::getMinimumFreeHeapSize() const {
return heap_caps_get_minimum_free_size(MALLOC_CAP_8BIT);
}
void libesp::System::restart() const {
esp_restart();
}
void libesp::System::logSystemInfo() const {
printf("Free HeapSize: %u\n",System::getFreeHeapSize());
printf("Free Min HeapSize: %u\n",System::getMinimumFreeHeapSize());
printf("Free 32 Bit HeapSize: %u\n",heap_caps_get_free_size(MALLOC_CAP_32BIT));
printf("Free 32 Bit Min HeapSize: %u\n",heap_caps_get_minimum_free_size(MALLOC_CAP_32BIT));
printf("Free DMA HeapSize: %u\n",heap_caps_get_free_size(MALLOC_CAP_DMA));
printf("Free DMA Min HeapSize: %u\n",heap_caps_get_minimum_free_size(MALLOC_CAP_DMA));
printf("Free Internal HeapSize: %u\n",heap_caps_get_free_size(MALLOC_CAP_INTERNAL));
printf("Free Internal Min HeapSize: %u\n",heap_caps_get_minimum_free_size(MALLOC_CAP_INTERNAL));
printf("Free Default HeapSize: %u\n",heap_caps_get_free_size(MALLOC_CAP_DEFAULT));
printf("Free Default Min HeapSize: %u\n",heap_caps_get_minimum_free_size(MALLOC_CAP_DEFAULT));
printf("Free Exec : %u\n",heap_caps_get_free_size(MALLOC_CAP_EXEC));
printf("Free Exec Min: %u\n",heap_caps_get_minimum_free_size(MALLOC_CAP_EXEC));
printf("Model = %d\n", ChipInfo.model);
printf("Features = %d\n", ChipInfo.features);
printf(" EMB_FLASH %d\n", (ChipInfo.features&CHIP_FEATURE_EMB_FLASH)!=0);
printf(" WIFI_BGN %d\n", (ChipInfo.features&CHIP_FEATURE_WIFI_BGN)!=0);
printf(" BLE %d\n", (ChipInfo.features&CHIP_FEATURE_BLE)!=0);
printf(" BT %d\n", (ChipInfo.features&CHIP_FEATURE_BT)!=0);
printf("Cores = %d\n", (int)ChipInfo.cores);
printf("revision = %d\n", (int)ChipInfo.revision);
printf("IDF Version = %s\n", ::esp_get_idf_version());
}