VSF Documented
esp_system.h
Go to the documentation of this file.
1/*****************************************************************************
2 * Copyright(C)2009-2026 by VSF Team *
3 * *
4 * Licensed under the Apache License, Version 2.0 (the "License"); *
5 * you may not use this file except in compliance with the License. *
6 * You may obtain a copy of the License at *
7 * *
8 * http://www.apache.org/licenses/LICENSE-2.0 *
9 * *
10 * Unless required by applicable law or agreed to in writing, software *
11 * distributed under the License is distributed on an "AS IS" BASIS, *
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
13 * See the License for the specific language governing permissions and *
14 * limitations under the License. *
15 * *
16 ****************************************************************************/
17
18/*
19 * Clean-room re-implementation of ESP-IDF public API "esp_system.h"
20 * (including the stripped-down chip info / reset surface exposed via
21 * esp_chip_info.h, esp_mac.h and esp_random.h).
22 *
23 * Authored from ESP-IDF v5.x public API only. No code or data copied from
24 * the ESP-IDF source tree.
25 */
26
27#ifndef __VSF_ESPIDF_ESP_SYSTEM_H__
28#define __VSF_ESPIDF_ESP_SYSTEM_H__
29
30#include <stdint.h>
31#include <stddef.h>
32
33#include "esp_err.h"
34
35#ifdef __cplusplus
36extern "C" {
37#endif
38
39/*============================ TYPES =========================================*/
40
41typedef enum {
59
60typedef enum {
68 /* VSF host: a synthetic "not a chip" id so downstream code can branch. */
71
72/* Bitmask features exposed through esp_chip_info_t::features. */
73#define CHIP_FEATURE_EMB_FLASH (1 << 0)
74#define CHIP_FEATURE_WIFI_BGN (1 << 1)
75#define CHIP_FEATURE_BLE (1 << 4)
76#define CHIP_FEATURE_BT (1 << 5)
77#define CHIP_FEATURE_IEEE802154 (1 << 6)
78#define CHIP_FEATURE_EMB_PSRAM (1 << 7)
79
80typedef struct {
86
87/*============================ PROTOTYPES ====================================*/
88
89/* Reboot via vsf_arch_reset(). Never returns. */
90#if defined(__GNUC__) || defined(__clang__)
91void esp_restart(void) __attribute__((noreturn));
92#elif defined(_MSC_VER)
93__declspec(noreturn) void esp_restart(void);
94#else
95void esp_restart(void);
96#endif
97
98/* Last reset reason. The VSF port records ESP_RST_SW when a reboot is
99 * initiated via esp_restart(); otherwise returns ESP_RST_POWERON. */
101
102/* Best-effort free heap size reported by vsf_heap_statistics(). Returns 0
103 * if statistics are disabled at VSF build time. */
105
106/* On VSF there is no dedicated low-water tracking; returns the same value
107 * as esp_get_free_heap_size(). */
109
110/* LCG-based PRNG. Not cryptographically secure - ESP-IDF public contract
111 * also does not promise CS quality here, it merely requires uniformity. */
112uint32_t esp_random(void);
113
114/* Fill an arbitrary buffer with pseudo-random bytes. */
115void esp_fill_random(void *buf, size_t len);
116
117/* Version string compatible with ESP-IDF semantics: "v<M>.<m>.<p>-vsf". */
118const char * esp_get_idf_version(void);
119
120/* Lightweight clone of esp_chip_info(). The VSF port declares itself as
121 * CHIP_VSF_HOST with single core and no wireless features. */
122void esp_chip_info(esp_chip_info_t *out_info);
123
124#ifdef __cplusplus
125}
126#endif
127
128#endif // __VSF_ESPIDF_ESP_SYSTEM_H__
uint32_t esp_get_free_heap_size(void)
Definition esp_system_port.c:89
uint32_t esp_get_minimum_free_heap_size(void)
Definition esp_system_port.c:103
void esp_chip_info(esp_chip_info_t *out_info)
Definition esp_system_port.c:241
esp_reset_reason_t
Definition esp_system.h:41
@ ESP_RST_UNKNOWN
Definition esp_system.h:42
@ ESP_RST_EFUSE
Definition esp_system.h:55
@ ESP_RST_BROWNOUT
Definition esp_system.h:51
@ ESP_RST_DEEPSLEEP
Definition esp_system.h:50
@ ESP_RST_SW
Definition esp_system.h:45
@ ESP_RST_SDIO
Definition esp_system.h:52
@ ESP_RST_PWR_GLITCH
Definition esp_system.h:56
@ ESP_RST_USB
Definition esp_system.h:53
@ ESP_RST_CPU_LOCKUP
Definition esp_system.h:57
@ ESP_RST_TASK_WDT
Definition esp_system.h:48
@ ESP_RST_WDT
Definition esp_system.h:49
@ ESP_RST_EXT
Definition esp_system.h:44
@ ESP_RST_POWERON
Definition esp_system.h:43
@ ESP_RST_PANIC
Definition esp_system.h:46
@ ESP_RST_JTAG
Definition esp_system.h:54
@ ESP_RST_INT_WDT
Definition esp_system.h:47
uint32_t esp_random(void)
Definition esp_system_port.c:166
esp_reset_reason_t esp_reset_reason(void)
Definition esp_system_port.c:84
void esp_restart(void)
Definition esp_system_port.c:75
esp_chip_model_t
Definition esp_system.h:60
@ CHIP_ESP32C3
Definition esp_system.h:64
@ CHIP_ESP32C2
Definition esp_system.h:65
@ CHIP_VSF_HOST
Definition esp_system.h:69
@ CHIP_ESP32S3
Definition esp_system.h:63
@ CHIP_ESP32S2
Definition esp_system.h:62
@ CHIP_ESP32H2
Definition esp_system.h:67
@ CHIP_ESP32
Definition esp_system.h:61
@ CHIP_ESP32C6
Definition esp_system.h:66
void esp_fill_random(void *buf, size_t len)
Definition esp_system_port.c:180
const char * esp_get_idf_version(void)
Definition esp_system_port.c:236
__attribute__((weak))
Definition handlers.c:10
unsigned short uint16_t
Definition stdint.h:7
unsigned uint32_t
Definition stdint.h:9
unsigned char uint8_t
Definition stdint.h:5
Definition esp_system.h:80
uint16_t revision
Definition esp_system.h:83
uint8_t cores
Definition esp_system.h:84
esp_chip_model_t model
Definition esp_system.h:81
uint32_t features
Definition esp_system.h:82
Generated from commit: vsfteam/vsf@015f4d1