ulp_riscv.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. * SPDX-FileCopyrightText: 2021-2022 Espressif Systems (Shanghai) CO LTD
  3. *
  4. * SPDX-License-Identifier: Apache-2.0
  5. */
  6. #pragma once
  7. #include <stdint.h>
  8. #include <stddef.h>
  9. #include <stdlib.h>
  10. #include "esp_err.h"
  11. #include "ulp_common.h"
  12. #ifdef __cplusplus
  13. extern "C" {
  14. #endif
  15. /**
  16. * @brief Run the program loaded into RTC memory
  17. * @return ESP_OK on success
  18. */
  19. esp_err_t ulp_riscv_run(void);
  20. /**
  21. * @brief Load ULP-RISC-V program binary into RTC memory
  22. *
  23. * Different than ULP FSM, the binary program has no special format, it is the ELF
  24. * file generated by RISC-V toolchain converted to binary format using objcopy.
  25. *
  26. * Linker script in components/ulp/ld/ulp_riscv.ld produces ELF files which
  27. * correspond to this format. This linker script produces binaries with load_addr == 0.
  28. *
  29. * @param program_binary pointer to program binary
  30. * @param program_size_bytes size of the program binary
  31. * @return
  32. * - ESP_OK on success
  33. * - ESP_ERR_INVALID_SIZE if program_size_bytes is more than 8KiB
  34. */
  35. esp_err_t ulp_riscv_load_binary(const uint8_t* program_binary, size_t program_size_bytes);
  36. /**
  37. * @brief Stop the ULP timer
  38. *
  39. * @note This will stop the ULP from waking up if halted, but will not abort any program
  40. * currently executing on the ULP.
  41. */
  42. void ulp_riscv_timer_stop(void);
  43. /**
  44. * @brief Resumes the ULP timer
  45. *
  46. * @note This will resume an already configured timer, but does no other configuration
  47. *
  48. */
  49. void ulp_riscv_timer_resume(void);
  50. /**
  51. * @brief Halts the program currently running on the ULP-RISC-V
  52. *
  53. * @note Program will restart at the next ULP timer trigger if timer is still running.
  54. * If you want to stop the ULP from waking up then call ulp_riscv_timer_stop() first.
  55. */
  56. void ulp_riscv_halt(void);
  57. #ifdef __cplusplus
  58. }
  59. #endif