esp32_port.h 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /* Copyright 2020 Espressif Systems (Shanghai) PTE 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 "serial_io.h"
  17. #include "freertos/FreeRTOS.h"
  18. #include "freertos/queue.h"
  19. typedef struct
  20. {
  21. uint32_t baud_rate; /*!< Initial baud rate, can be changed later */
  22. uint32_t uart_port; /*!< UART port */
  23. uint32_t uart_rx_pin; /*!< This pin will be configured as UART Rx pin */
  24. uint32_t uart_tx_pin; /*!< This pin will be configured as UART Tx pin */
  25. uint32_t reset_trigger_pin; /*!< This pin will be used to reset target chip */
  26. uint32_t gpio0_trigger_pin; /*!< This pin will be used to toggle set IO0 of target chip */
  27. uint32_t rx_buffer_size; /*!< Set to zero for default RX buffer size */
  28. uint32_t tx_buffer_size; /*!< Set to zero for default TX buffer size */
  29. uint32_t queue_size; /*!< Set to zero for default UART queue size */
  30. QueueHandle_t *uart_queue; /*!< Set to NULL, if UART queue handle is not
  31. necessary. Otherwise, it will be assigned here */
  32. } loader_esp32_config_t;
  33. /**
  34. * @brief Initializes serial interface.
  35. *
  36. * @param baud_rate[in] Communication speed.
  37. *
  38. * @return
  39. * - ESP_LOADER_SUCCESS Success
  40. * - ESP_LOADER_ERROR_FAIL Initialization failure
  41. */
  42. esp_loader_error_t loader_port_esp32_init(const loader_esp32_config_t *config);
  43. /**
  44. * @brief Deinitialize serial interface.
  45. */
  46. void loader_port_esp32_deinit(void);