2018-09-05 02:39:50 +02:00
|
|
|
/*
|
2019-09-05 13:35:58 +02:00
|
|
|
* Copyright (C) 2019 Gunar Schorcht
|
2018-09-05 02:39:50 +02:00
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup cpu_esp8266
|
|
|
|
* @{
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
* @brief Implementation of required system calls
|
|
|
|
*
|
|
|
|
* @author Gunar Schorcht <gunar@schorcht.net>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
#include "esp_attr.h"
|
2019-12-16 07:42:21 +01:00
|
|
|
#include "esp_common.h"
|
2018-09-05 02:39:50 +02:00
|
|
|
#include "sdk/sdk.h"
|
2021-12-09 11:43:20 +01:00
|
|
|
#include "timex.h"
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
#ifdef MODULE_ESP_IDF_HEAP
|
|
|
|
#include "esp_heap_caps.h"
|
|
|
|
#endif
|
2019-02-03 15:27:59 +01:00
|
|
|
|
2020-10-22 11:34:00 +02:00
|
|
|
#define ENABLE_DEBUG 0
|
2019-09-05 13:35:58 +02:00
|
|
|
#include "debug.h"
|
2019-01-23 19:47:08 +01:00
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
#ifdef MODULE_ESP_IDF_HEAP
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-12-16 07:42:21 +01:00
|
|
|
/* this function is platform specific if module esp_idf_heap is used */
|
2019-09-05 13:35:58 +02:00
|
|
|
void heap_stats(void)
|
|
|
|
{
|
2019-12-16 07:42:21 +01:00
|
|
|
size_t _free = 0;
|
|
|
|
size_t _alloc = 0;
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
extern heap_region_t g_heap_region[HEAP_REGIONS_MAX];
|
|
|
|
|
|
|
|
for (int i = 0; i < HEAP_REGIONS_MAX; i++) {
|
2019-12-16 07:42:21 +01:00
|
|
|
_free += g_heap_region[i].free_bytes;
|
|
|
|
_alloc += g_heap_region[i].total_size - g_heap_region[i].free_bytes;
|
2018-09-05 02:39:50 +02:00
|
|
|
}
|
2019-09-05 13:35:58 +02:00
|
|
|
|
|
|
|
ets_printf("heap: %u (used %u, free %u) [bytes]\n",
|
2019-12-16 07:42:21 +01:00
|
|
|
_alloc + _free, _alloc, _free);
|
2018-09-05 02:39:50 +02:00
|
|
|
}
|
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
#endif /* MODULE_ESP_IDF_HEAP */
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @name Other system functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
uint32_t system_get_time(void)
|
|
|
|
{
|
|
|
|
return phy_get_mactime();
|
|
|
|
}
|
2018-09-05 02:39:50 +02:00
|
|
|
|
2019-09-05 13:35:58 +02:00
|
|
|
uint32_t system_get_time_ms(void)
|
|
|
|
{
|
2021-12-09 11:43:20 +01:00
|
|
|
return system_get_time() / US_PER_MS;
|
2018-09-05 02:39:50 +02:00
|
|
|
}
|
|
|
|
|
2019-12-16 07:42:21 +01:00
|
|
|
void IRAM_ATTR syscalls_init_arch(void)
|
2019-09-05 13:35:58 +02:00
|
|
|
{
|
2018-09-05 02:39:50 +02:00
|
|
|
}
|