Skip to content

Commit

Permalink
Is SPIRAM Available? (skot#626)
Browse files Browse the repository at this point in the history
  • Loading branch information
eandersson authored Jan 21, 2025
1 parent 2f38e20 commit e770835
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 0 deletions.
1 change: 1 addition & 0 deletions main/global_state.h
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,7 @@ typedef struct

int sock;
bool ASIC_initalized;
bool psram_is_available;
} GlobalState;

#endif /* GLOBAL_STATE_H_ */
2 changes: 2 additions & 0 deletions main/http_server/http_server.c
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ static esp_err_t GET_system_info(httpd_req_t * req)

cJSON_AddNumberToObject(root, "isUsingFallbackStratum", GLOBAL_STATE->SYSTEM_MODULE.is_using_fallback);

cJSON_AddNumberToObject(root, "isPSRAMAvailable", GLOBAL_STATE->psram_is_available);

cJSON_AddNumberToObject(root, "freeHeap", esp_get_free_heap_size());
cJSON_AddNumberToObject(root, "coreVoltage", nvs_config_get_u16(NVS_CONFIG_ASIC_VOLTAGE, CONFIG_ASIC_VOLTAGE));
cJSON_AddNumberToObject(root, "coreVoltageActual", VCORE_get_voltage_mv(GLOBAL_STATE));
Expand Down
8 changes: 8 additions & 0 deletions main/main.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@

#include "esp_event.h"
#include "esp_log.h"
#include "esp_psram.h"
#include "nvs_flash.h"

// #include "protocol_examples_common.h"
Expand Down Expand Up @@ -34,6 +35,13 @@ void app_main(void)
{
ESP_LOGI(TAG, "Welcome to the bitaxe - hack the planet!");

if (!esp_psram_is_initialized()) {
ESP_LOGE(TAG, "No PSRAM available on ESP32 device!");
GLOBAL_STATE.psram_is_available = false;
} else {
GLOBAL_STATE.psram_is_available = true;
}

// Init I2C
ESP_ERROR_CHECK(i2c_bitaxe_init());
ESP_LOGI(TAG, "I2C initialized successfully");
Expand Down

0 comments on commit e770835

Please sign in to comment.