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
34
35#include "esp_err.h"
36
37#ifdef __cplusplus
38extern "C" {
39#endif
40
41/*============================ TYPES =========================================*/
42
43typedef enum {
61
62typedef enum {
70 /* VSF host: a synthetic "not a chip" id so downstream code can branch. */
73
74/* Bitmask features exposed through esp_chip_info_t::features. */
75#define CHIP_FEATURE_EMB_FLASH (1 << 0)
76#define CHIP_FEATURE_WIFI_BGN (1 << 1)
77#define CHIP_FEATURE_BLE (1 << 4)
78#define CHIP_FEATURE_BT (1 << 5)
79#define CHIP_FEATURE_IEEE802154 (1 << 6)
80#define CHIP_FEATURE_EMB_PSRAM (1 << 7)
81
82typedef struct {
88
89/*============================ PROTOTYPES ====================================*/
90
91/* Reboot via vsf_arch_reset(). Never returns. */
92VSF_CAL_NO_RETURN void esp_restart(void);
93
94/* Last reset reason. The VSF port records ESP_RST_SW when a reboot is
95 * initiated via esp_restart(); otherwise returns ESP_RST_POWERON. */
97
98/* Best-effort free heap size reported by vsf_heap_statistics(). Returns 0
99 * if statistics are disabled at VSF build time. */
101
102/* On VSF there is no dedicated low-water tracking; returns the same value
103 * as esp_get_free_heap_size(). */
105
106/* LCG-based PRNG. Not cryptographically secure - ESP-IDF public contract
107 * also does not promise CS quality here, it merely requires uniformity. */
108uint32_t esp_random(void);
109
110/* Fill an arbitrary buffer with pseudo-random bytes. */
111void esp_fill_random(void *buf, size_t len);
112
113/* Version string compatible with ESP-IDF semantics: "v<M>.<m>.<p>-vsf". */
114const char * esp_get_idf_version(void);
115
116/* Lightweight clone of esp_chip_info(). The VSF port declares itself as
117 * CHIP_VSF_HOST with single core and no wireless features. */
118void esp_chip_info(esp_chip_info_t *out_info);
119
120#ifdef __cplusplus
121}
122#endif
123
124#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:43
@ ESP_RST_UNKNOWN
Definition esp_system.h:44
@ ESP_RST_EFUSE
Definition esp_system.h:57
@ ESP_RST_BROWNOUT
Definition esp_system.h:53
@ ESP_RST_DEEPSLEEP
Definition esp_system.h:52
@ ESP_RST_SW
Definition esp_system.h:47
@ ESP_RST_SDIO
Definition esp_system.h:54
@ ESP_RST_PWR_GLITCH
Definition esp_system.h:58
@ ESP_RST_USB
Definition esp_system.h:55
@ ESP_RST_CPU_LOCKUP
Definition esp_system.h:59
@ ESP_RST_TASK_WDT
Definition esp_system.h:50
@ ESP_RST_WDT
Definition esp_system.h:51
@ ESP_RST_EXT
Definition esp_system.h:46
@ ESP_RST_POWERON
Definition esp_system.h:45
@ ESP_RST_PANIC
Definition esp_system.h:48
@ ESP_RST_JTAG
Definition esp_system.h:56
@ ESP_RST_INT_WDT
Definition esp_system.h:49
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
VSF_CAL_NO_RETURN void esp_restart(void)
Definition esp_system_port.c:75
esp_chip_model_t
Definition esp_system.h:62
@ CHIP_ESP32C3
Definition esp_system.h:66
@ CHIP_ESP32C2
Definition esp_system.h:67
@ CHIP_VSF_HOST
Definition esp_system.h:71
@ CHIP_ESP32S3
Definition esp_system.h:65
@ CHIP_ESP32S2
Definition esp_system.h:64
@ CHIP_ESP32H2
Definition esp_system.h:69
@ CHIP_ESP32
Definition esp_system.h:63
@ CHIP_ESP32C6
Definition esp_system.h:68
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
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:82
uint16_t revision
Definition esp_system.h:85
uint8_t cores
Definition esp_system.h:86
esp_chip_model_t model
Definition esp_system.h:83
uint32_t features
Definition esp_system.h:84
Generated from commit: vsfteam/vsf@c3767bf