esp32_port.h 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /* Copyright 2020-2023 Espressif Systems (Shanghai) CO LTD
  2. *
  3. * Licensed under the Apache License, Version 2.0 (the "License");
  4. * you may not use this file except in compliance with the License.
  5. * You may obtain a copy of the License at
  6. *
  7. * http://www.apache.org/licenses/LICENSE-2.0
  8. *
  9. * Unless required by applicable law or agreed to in writing, software
  10. * distributed under the License is distributed on an "AS IS" BASIS,
  11. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. * See the License for the specific language governing permissions and
  13. * limitations under the License.
  14. */
  15. #pragma once
  16. #include "esp_loader_io.h"
  17. #include "freertos/FreeRTOS.h"
  18. #include "freertos/queue.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. typedef struct
  23. {
  24. uint32_t baud_rate; /*!< Initial baud rate, can be changed later */
  25. uint32_t uart_port; /*!< UART port */
  26. uint32_t uart_rx_pin; /*!< This pin will be configured as UART Rx pin */
  27. uint32_t uart_tx_pin; /*!< This pin will be configured as UART Tx pin */
  28. uint32_t reset_trigger_pin; /*!< This pin will be used to reset target chip */
  29. uint32_t gpio0_trigger_pin; /*!< This pin will be used to toggle set IO0 of target chip */
  30. uint32_t rx_buffer_size; /*!< Set to zero for default RX buffer size */
  31. uint32_t tx_buffer_size; /*!< Set to zero for default TX buffer size */
  32. uint32_t queue_size; /*!< Set to zero for default UART queue size */
  33. QueueHandle_t *uart_queue; /*!< Set to NULL, if UART queue handle is not
  34. necessary. Otherwise, it will be assigned here */
  35. } loader_esp32_config_t;
  36. /**
  37. * @brief Initializes serial interface.
  38. *
  39. * @param baud_rate[in] Communication speed.
  40. *
  41. * @return
  42. * - ESP_LOADER_SUCCESS Success
  43. * - ESP_LOADER_ERROR_FAIL Initialization failure
  44. */
  45. esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t *config);
  46. /**
  47. * @brief Deinitialize serial interface.
  48. */
  49. void loader_port_esp32_deinit(void);
  50. #ifdef __cplusplus
  51. }
  52. #endif