trax.h 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. #include "sdkconfig.h"
  2. #include "esp_err.h"
  3. #include "eri.h"
  4. #include "xtensa-debug-module.h"
  5. typedef enum {
  6. TRAX_DOWNCOUNT_WORDS,
  7. TRAX_DOWNCOUNT_INSTRUCTIONS
  8. } trax_downcount_unit_t;
  9. typedef enum {
  10. TRAX_ENA_NONE = 0,
  11. TRAX_ENA_PRO,
  12. TRAX_ENA_APP,
  13. TRAX_ENA_PRO_APP,
  14. TRAX_ENA_PRO_APP_SWAP
  15. } trax_ena_select_t;
  16. /**
  17. * @brief Enable the trax memory blocks to be used as Trax memory.
  18. *
  19. * @param pro_cpu_enable : true if Trax needs to be enabled for the pro CPU
  20. * @param app_cpu_enable : true if Trax needs to be enabled for the pro CPU
  21. * @param swap_regions : Normally, the pro CPU writes to Trax mem block 0 while
  22. * the app cpu writes to block 1. Setting this to true
  23. * inverts this.
  24. *
  25. * @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax enable is requested for 2 CPUs
  26. * but memmap only has room for 1, or if Trax memmap is disabled
  27. * entirely.
  28. */
  29. int trax_enable(trax_ena_select_t ena);
  30. /**
  31. * @brief Start a Trax trace on the current CPU
  32. *
  33. * @param units_until_stop : Set the units of the delay that gets passed to
  34. * trax_trigger_traceend_after_delay. One of TRAX_DOWNCOUNT_WORDS
  35. * or TRAX_DOWNCOUNT_INSTRUCTIONS.
  36. *
  37. * @return esp_err_t. Fails with ESP_ERR_NO_MEM if Trax is disabled.
  38. */
  39. int trax_start_trace(trax_downcount_unit_t units_until_stop);
  40. /**
  41. * @brief Trigger a Trax trace stop after the indicated delay. If this is called
  42. * before and the previous delay hasn't ended yet, this will overwrite
  43. * that delay with the new value. The delay will always start at the time
  44. * the function is called.
  45. *
  46. * @param delay : The delay to stop the trace in, in the unit indicated to
  47. * trax_start_trace. Note: the trace memory has 4K words available.
  48. *
  49. * @return esp_err_t
  50. */
  51. int trax_trigger_traceend_after_delay(int delay);