itm_api.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /** \addtogroup hal */
  2. /** @{*/
  3. /* mbed Microcontroller Library
  4. * Copyright (c) 2017 ARM Limited
  5. *
  6. * Licensed under the Apache License, Version 2.0 (the "License");
  7. * you may not use this file except in compliance with the License.
  8. * You may obtain a copy of the License at
  9. *
  10. * http://www.apache.org/licenses/LICENSE-2.0
  11. *
  12. * Unless required by applicable law or agreed to in writing, software
  13. * distributed under the License is distributed on an "AS IS" BASIS,
  14. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  15. * See the License for the specific language governing permissions and
  16. * limitations under the License.
  17. */
  18. #ifndef MBED_ITM_API_H
  19. #define MBED_ITM_API_H
  20. #if defined(DEVICE_ITM)
  21. #include <stdint.h>
  22. #include <stddef.h>
  23. #ifdef __cplusplus
  24. extern "C" {
  25. #endif
  26. /**
  27. * \defgroup itm_hal Instrumented Trace Macrocell HAL API
  28. * @{
  29. */
  30. enum {
  31. ITM_PORT_SWO = 0
  32. };
  33. /**
  34. * @brief Target specific initialization function.
  35. * This function is responsible for initializing and configuring
  36. * the debug clock for the ITM and setting up the SWO pin for
  37. * debug output.
  38. *
  39. * The only Cortex-M register that should be modified is the clock
  40. * prescaler in TPI->ACPR.
  41. *
  42. * The generic mbed_itm_init initialization function will setup:
  43. *
  44. * ITM->LAR
  45. * ITM->TPR
  46. * ITM->TCR
  47. * ITM->TER
  48. * TPI->SPPR
  49. * TPI->FFCR
  50. * DWT->CTRL
  51. *
  52. * for SWO output on stimulus port 0.
  53. */
  54. void itm_init(void);
  55. /**
  56. * @brief Initialization function for both generic registers and target specific clock and pin.
  57. */
  58. void mbed_itm_init(void);
  59. /**
  60. * @brief Send data over ITM stimulus port.
  61. *
  62. * @param[in] port The stimulus port to send data over.
  63. * @param[in] data The 32-bit data to send.
  64. *
  65. * The data is written as a single 32-bit write to the port.
  66. *
  67. * @return value of data sent.
  68. */
  69. uint32_t mbed_itm_send(uint32_t port, uint32_t data);
  70. /**
  71. * @brief Send a block of data over ITM stimulus port.
  72. *
  73. * @param[in] port The stimulus port to send data over.
  74. * @param[in] data The block of data to send.
  75. * @param[in] len The number of bytes of data to send.
  76. *
  77. * The data is written using multiple appropriately-sized port accesses for
  78. * efficient transfer.
  79. */
  80. void mbed_itm_send_block(uint32_t port, const void *data, size_t len);
  81. /**@}*/
  82. #ifdef __cplusplus
  83. }
  84. #endif
  85. #endif
  86. #endif /* MBED_ITM_API_H */
  87. /**@}*/