board.c 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /**
  2. * @file board.c
  3. * @brief ESP32-S3 Generic board implementation
  4. *
  5. * Minimal implementation for generic ESP32-S3 dev boards with external I2S DAC.
  6. * No board-specific initialization required.
  7. */
  8. #include "iot_board.h"
  9. #include "driver/gpio.h"
  10. #include "esp_log.h"
  11. static const char TAG[] = "ESP32S3-Generic";
  12. static bool s_board_initialized = false;
  13. #ifdef CONFIG_MUTE_GPIO
  14. static esp_err_t init_mute_gpio(void) {
  15. if (CONFIG_MUTE_GPIO < 0) {
  16. return ESP_OK;
  17. }
  18. gpio_config_t io_conf = {
  19. .pin_bit_mask = (1ULL << CONFIG_MUTE_GPIO),
  20. .mode = GPIO_MODE_OUTPUT,
  21. .pull_up_en = GPIO_PULLUP_DISABLE,
  22. .pull_down_en = GPIO_PULLDOWN_DISABLE,
  23. .intr_type = GPIO_INTR_DISABLE,
  24. };
  25. esp_err_t err = gpio_config(&io_conf);
  26. if (err != ESP_OK) {
  27. ESP_LOGE(TAG, "Failed to configure mute GPIO: %s", esp_err_to_name(err));
  28. return err;
  29. }
  30. // Initialize to unmuted state — set opposite of active level
  31. gpio_set_level(CONFIG_MUTE_GPIO, !CONFIG_MUTE_GPIO_LEVEL);
  32. ESP_LOGI(TAG, "Mute GPIO %d initialized (active %s, init %s)",
  33. CONFIG_MUTE_GPIO, CONFIG_MUTE_GPIO_LEVEL ? "high" : "low",
  34. CONFIG_MUTE_GPIO_LEVEL ? "low" : "high");
  35. return ESP_OK;
  36. }
  37. #endif
  38. const char *iot_board_get_info(void) {
  39. return BOARD_NAME;
  40. }
  41. bool iot_board_is_init(void) {
  42. return s_board_initialized;
  43. }
  44. board_res_handle_t iot_board_get_handle(int id) {
  45. (void)id;
  46. return NULL;
  47. }
  48. esp_err_t iot_board_init(void) {
  49. if (s_board_initialized) {
  50. ESP_LOGW(TAG, "Board already initialized");
  51. return ESP_OK;
  52. }
  53. #ifdef CONFIG_MUTE_GPIO
  54. esp_err_t err = init_mute_gpio();
  55. if (err != ESP_OK) {
  56. return err;
  57. }
  58. #endif
  59. s_board_initialized = true;
  60. ESP_LOGI(TAG, "Generic board initialized (no board-specific init needed)");
  61. return ESP_OK;
  62. }
  63. esp_err_t iot_board_deinit(void) {
  64. s_board_initialized = false;
  65. return ESP_OK;
  66. }