Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@ esp_err_t meshtastic_app_start(void) {
mt_region_t region = mt_region_current();
uint32_t freq_hz = mt_region_freq_for_channel(region, MT_PRIMARY_CHANNEL, p_info->bw_hz);

sx1262_deinit();

sx1262_config_t cfg = {0};
ret = sx1262_hal_create(&cfg.hal);
if (ret != ESP_OK) {
Expand Down
13 changes: 0 additions & 13 deletions firmware_p4/components/Drivers/sx1262/include/sx1262.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,19 +35,6 @@ extern "C" {
*/
esp_err_t sx1262_init(const sx1262_config_t *config);

/**
* @brief Tear down the SX1262 driver so the next sx1262_init() starts clean.
*
* Stops the IRQ task (if running), destroys the HAL (removes the SPI device
* and mutex; SPI3 bus is preserved for shared peripherals), and clears
* driver state.
*
* Safe to call when nothing is initialized — no-op.
*
* @return ESP_OK on success.
*/
esp_err_t sx1262_deinit(void);

/**
* @brief Start the IRQ processing task.
*
Expand Down
13 changes: 0 additions & 13 deletions firmware_p4/components/Drivers/sx1262/include/sx1262_hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -132,19 +132,6 @@ typedef struct sx1262_hal {
*/
esp_err_t sx1262_hal_create(sx1262_hal_t *out_hal);

/**
* @brief Tear down the HAL so the next sx1262_hal_create() rebuilds it.
*
* Removes the SX1262 SPI device, deletes the SPI mutex, and clears the
* internal initialized flag. The SPI3 bus itself is left initialized
* because it is shared with the ST7789 display.
*
* Safe to call when the HAL is not initialized — returns ESP_OK as a no-op.
*
* @return ESP_OK.
*/
esp_err_t sx1262_hal_destroy(void);

#ifdef __cplusplus
}
#endif
Expand Down
7 changes: 0 additions & 7 deletions firmware_p4/components/Drivers/sx1262/sx1262.c
Original file line number Diff line number Diff line change
Expand Up @@ -402,13 +402,6 @@ void sx1262_stop(void) {
ESP_LOGI(TAG, "Stopped");
}

esp_err_t sx1262_deinit(void) {
sx1262_stop();
esp_err_t ret = sx1262_hal_destroy();
s_is_initialized = false;
return ret;
}

esp_err_t sx1262_set_callbacks(const sx1262_callbacks_t *cbs) {
if (cbs == NULL) {
return ESP_ERR_INVALID_ARG;
Expand Down
28 changes: 2 additions & 26 deletions firmware_p4/components/Drivers/sx1262/sx1262_hal.c
Original file line number Diff line number Diff line change
Expand Up @@ -202,10 +202,6 @@ esp_err_t sx1262_hal_create(sx1262_hal_t *out_hal) {
};

ret = spi_bus_initialize(SPI_HOST_ID, &bus_cfg, SPI_DMA_CH_AUTO);
if (ret == ESP_ERR_INVALID_STATE) {
/* Bus already initialized by another driver (e.g. ST7789 via kernel spi_init). */
ret = ESP_OK;
}
if (ret != ESP_OK) {
ESP_LOGE(TAG, "SPI bus init failed: %s", esp_err_to_name(ret));
return ret;
Expand All @@ -221,6 +217,7 @@ esp_err_t sx1262_hal_create(sx1262_hal_t *out_hal) {
ret = spi_bus_add_device(SPI_HOST_ID, &dev_cfg, &s_ctx.spi);
if (ret != ESP_OK) {
ESP_LOGE(TAG, "SPI add device failed: %s", esp_err_to_name(ret));
spi_bus_free(SPI_HOST_ID);
return ret;
}

Expand All @@ -229,7 +226,7 @@ esp_err_t sx1262_hal_create(sx1262_hal_t *out_hal) {
if (s_ctx.spi_mutex == NULL) {
ESP_LOGE(TAG, "Failed to create SPI mutex");
spi_bus_remove_device(s_ctx.spi);
s_ctx.spi = NULL;
spi_bus_free(SPI_HOST_ID);
return ESP_ERR_NO_MEM;
}

Expand Down Expand Up @@ -257,24 +254,3 @@ esp_err_t sx1262_hal_create(sx1262_hal_t *out_hal) {

return ESP_OK;
}

esp_err_t sx1262_hal_destroy(void) {
if (!s_ctx.is_initialized) {
return ESP_OK;
}

if (s_ctx.spi != NULL) {
spi_bus_remove_device(s_ctx.spi);
s_ctx.spi = NULL;
}
if (s_ctx.spi_mutex != NULL) {
vSemaphoreDelete(s_ctx.spi_mutex);
s_ctx.spi_mutex = NULL;
}

/* SPI3 bus is shared with ST7789 display; do not free it here. */

s_ctx.is_initialized = false;
ESP_LOGI(TAG, "HAL destroyed (SPI3 bus left intact for shared peripherals)");
return ESP_OK;
}
Loading