esp_loader_io.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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 <stdint.h>
  17. #include "esp_loader.h"
  18. #ifdef __cplusplus
  19. extern "C" {
  20. #endif
  21. /**
  22. * @brief Changes the transmission rate of the used peripheral.
  23. */
  24. esp_loader_error_t loader_port_change_transmission_rate(uint32_t transmission_rate);
  25. /**
  26. * @brief Writes data over the io interface.
  27. *
  28. * @param data[in] Buffer with data to be written.
  29. * @param size[in] Size of data in bytes.
  30. * @param timeout[in] Timeout in milliseconds.
  31. *
  32. * @return
  33. * - ESP_LOADER_SUCCESS Success
  34. * - ESP_LOADER_ERROR_TIMEOUT Timeout elapsed
  35. */
  36. esp_loader_error_t loader_port_write(const uint8_t *data, uint16_t size, uint32_t timeout);
  37. /**
  38. * @brief Reads data from the io interface.
  39. *
  40. * @param data[out] Buffer into which received data will be written.
  41. * @param size[in] Number of bytes to read.
  42. * @param timeout[in] Timeout in milliseconds.
  43. *
  44. * @return
  45. * - ESP_LOADER_SUCCESS Success
  46. * - ESP_LOADER_ERROR_TIMEOUT Timeout elapsed
  47. */
  48. esp_loader_error_t loader_port_read(uint8_t *data, uint16_t size, uint32_t timeout);
  49. /**
  50. * @brief Delay in milliseconds.
  51. *
  52. * @param ms[in] Number of milliseconds.
  53. *
  54. */
  55. void loader_port_delay_ms(uint32_t ms);
  56. /**
  57. * @brief Starts timeout timer.
  58. *
  59. * @param ms[in] Number of milliseconds.
  60. *
  61. */
  62. void loader_port_start_timer(uint32_t ms);
  63. /**
  64. * @brief Returns remaining time since timer was started by calling esp_loader_start_timer.
  65. * 0 if timer has elapsed.
  66. *
  67. * @return Number of milliseconds.
  68. *
  69. */
  70. uint32_t loader_port_remaining_time(void);
  71. /**
  72. * @brief Asserts bootstrap pins to enter boot mode and toggles reset pin.
  73. *
  74. * @note Reset pin should stay asserted for at least 20 milliseconds.
  75. */
  76. void loader_port_enter_bootloader(void);
  77. /**
  78. * @brief Toggles reset pin.
  79. *
  80. * @note Reset pin should stay asserted for at least 20 milliseconds.
  81. */
  82. void loader_port_reset_target(void);
  83. /**
  84. * @brief Function can be defined by user to print debug message.
  85. *
  86. * @note Empty weak function is used, otherwise.
  87. *
  88. */
  89. void loader_port_debug_print(const char *str);
  90. #ifdef SERIAL_FLASHER_INTERFACE_SPI
  91. /**
  92. * @brief Sets the chip select to a defined level
  93. */
  94. void loader_port_spi_set_cs(uint32_t level);
  95. #endif /* SERIAL_FLASHER_INTERFACE_SPI */
  96. #ifdef __cplusplus
  97. }
  98. #endif