trcInterval.c 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. /*
  2. * Trace Recorder for Tracealyzer v4.9.2
  3. * Copyright 2023 Percepio AB
  4. * www.percepio.com
  5. *
  6. * SPDX-License-Identifier: Apache-2.0
  7. *
  8. * The implementation of intervals.
  9. */
  10. #include <trcRecorder.h>
  11. #if (TRC_USE_TRACEALYZER_RECORDER == 1) && (TRC_CFG_RECORDER_MODE == TRC_RECORDER_MODE_STREAMING)
  12. /*cstat !MISRAC2004-6.3 !MISRAC2012-Dir-4.6_a Suppress basic char type usage*/
  13. traceResult xTraceIntervalChannelSetCreate(const char* szName, TraceIntervalChannelSetHandle_t* pxIntervalChannelSetHandle)
  14. {
  15. TraceObjectHandle_t xObjectHandle;
  16. /* This should never fail */
  17. TRC_ASSERT(pxIntervalChannelSetHandle != (void*)0);
  18. /* We need to check this */
  19. if (xTraceObjectRegister(PSF_EVENT_INTERVAL_CHANNEL_SET_CREATE, (void*)0, szName, 0u, &xObjectHandle) == TRC_FAIL)
  20. {
  21. return TRC_FAIL;
  22. }
  23. /* This should never fail */
  24. TRC_ASSERT_ALWAYS_EVALUATE(xTraceEntrySetOptions((TraceEntryHandle_t)xObjectHandle, TRC_ENTRY_OPTION_INTERVAL_CHANNEL_SET) == TRC_SUCCESS);
  25. *pxIntervalChannelSetHandle = (TraceIntervalChannelSetHandle_t)xObjectHandle;
  26. return TRC_SUCCESS;
  27. }
  28. /*cstat !MISRAC2004-6.3 !MISRAC2012-Dir-4.6_a Suppress basic char type usage*/
  29. traceResult xTraceIntervalChannelCreate(const char *szName, TraceIntervalChannelSetHandle_t xIntervalChannelSetHandle, TraceIntervalChannelHandle_t *pxIntervalChannelHandle)
  30. {
  31. TraceObjectHandle_t xObjectHandle;
  32. /* This should never fail */
  33. TRC_ASSERT(pxIntervalChannelHandle != (void*)0);
  34. /* This should never fail */
  35. TRC_ASSERT(xIntervalChannelSetHandle != 0);
  36. /* We need to check this */
  37. if (xTraceObjectRegister(PSF_EVENT_INTERVAL_CHANNEL_CREATE, (void*)0, szName, (TraceUnsignedBaseType_t)xIntervalChannelSetHandle, &xObjectHandle) == TRC_FAIL) /*cstat !MISRAC2004-11.3 !MISRAC2012-Rule-11.4 Suppress conversion from pointer to integer check*/
  38. {
  39. return TRC_FAIL;
  40. }
  41. /* This should never fail */
  42. TRC_ASSERT_ALWAYS_EVALUATE(xTraceEntrySetOptions((TraceEntryHandle_t)xObjectHandle, TRC_ENTRY_OPTION_INTERVAL_CHANNEL) == TRC_SUCCESS);
  43. *pxIntervalChannelHandle = (TraceIntervalChannelHandle_t)xObjectHandle;
  44. return TRC_SUCCESS;
  45. }
  46. traceResult xTraceIntervalStart(TraceIntervalChannelHandle_t xIntervalChannelHandle, TraceUnsignedBaseType_t uxValue, TraceIntervalInstanceHandle_t *pxIntervalInstanceHandle)
  47. {
  48. TRC_ASSERT(xIntervalChannelHandle != 0);
  49. TRC_ASSERT(pxIntervalInstanceHandle != (void*)0);
  50. /* We null all of it first in case it's 64-bit and we only write 32-bit */
  51. *pxIntervalInstanceHandle = 0;
  52. TRC_ASSERT_ALWAYS_EVALUATE(xTraceTimestampGet((uint32_t*)pxIntervalInstanceHandle) == TRC_SUCCESS); /*cstat !MISRAC2004-11.4 !MISRAC2012-Rule-11.3 Suppress conversion between pointer types checks*/
  53. (void)xTraceEventCreate3(PSF_EVENT_INTERVAL_START, (TraceUnsignedBaseType_t)xIntervalChannelHandle, (TraceUnsignedBaseType_t)*pxIntervalInstanceHandle, uxValue); /*cstat !MISRAC2004-11.3 !MISRAC2012-Rule-11.4 Suppress conversion from pointer to integer check*/
  54. return TRC_SUCCESS;
  55. }
  56. traceResult xTraceIntervalStop(TraceIntervalChannelHandle_t xIntervalChannelHandle, TraceIntervalInstanceHandle_t xIntervalInstanceHandle)
  57. {
  58. TRC_ASSERT(xIntervalChannelHandle != 0);
  59. (void)xTraceEventCreate2(PSF_EVENT_INTERVAL_STOP, (TraceUnsignedBaseType_t)xIntervalChannelHandle, (TraceUnsignedBaseType_t)xIntervalInstanceHandle); /*cstat !MISRAC2004-11.3 !MISRAC2012-Rule-11.4 Suppress conversion from pointer to integer check*/
  60. return TRC_SUCCESS;
  61. }
  62. #endif