serial_comm.h 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 <stdint.h>
  17. #include <stdbool.h>
  18. #include "esp_loader.h"
  19. #ifdef __cplusplus
  20. extern "C" {
  21. #endif
  22. /**
  23. * Macro which can be used to check the error code,
  24. * and return in case the code is not ESP_LOADER_SUCCESS.
  25. */
  26. #define RETURN_ON_ERROR(x) do { \
  27. esp_loader_error_t _err_ = (x); \
  28. if (_err_ != ESP_LOADER_SUCCESS) { \
  29. return _err_; \
  30. } \
  31. } while(0)
  32. esp_loader_error_t loader_flash_begin_cmd(uint32_t offset, uint32_t erase_size, uint32_t block_size, uint32_t blocks_to_write);
  33. esp_loader_error_t loader_flash_data_cmd(const uint8_t *data, uint32_t size);
  34. esp_loader_error_t loader_flash_end_cmd(bool stay_in_loader);
  35. esp_loader_error_t loader_write_reg_cmd(uint32_t address, uint32_t value, uint32_t mask, uint32_t delay_us);
  36. esp_loader_error_t loader_read_reg_cmd(uint32_t address, uint32_t *reg);
  37. esp_loader_error_t loader_sync_cmd(void);
  38. esp_loader_error_t loader_spi_attach_cmd(uint32_t config);
  39. esp_loader_error_t loader_change_baudrate_cmd(uint32_t baudrate);
  40. esp_loader_error_t loader_md5_cmd(uint32_t address, uint32_t size, uint8_t *md5_out);
  41. #ifdef __cplusplus
  42. }
  43. #endif