trax.h 1.9 KB

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