debug.c 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. /**
  2. * @file debug.c
  3. * @brief Debugging facilities
  4. *
  5. * @section License
  6. *
  7. * SPDX-License-Identifier: GPL-2.0-or-later
  8. *
  9. * Copyright (C) 2010-2023 Oryx Embedded SARL. All rights reserved.
  10. *
  11. * This program is free software; you can redistribute it and/or
  12. * modify it under the terms of the GNU General Public License
  13. * as published by the Free Software Foundation; either version 2
  14. * of the License, or (at your option) any later version.
  15. *
  16. * This program is distributed in the hope that it will be useful,
  17. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  18. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  19. * GNU General Public License for more details.
  20. *
  21. * You should have received a copy of the GNU General Public License
  22. * along with this program; if not, write to the Free Software Foundation,
  23. * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  24. *
  25. * @author Oryx Embedded SARL (www.oryx-embedded.com)
  26. * @version 2.2.4
  27. **/
  28. //Dependencies
  29. #include "debug.h"
  30. /**
  31. * @brief Display the contents of an array
  32. * @param[in] stream Pointer to a FILE object that identifies an output stream
  33. * @param[in] prepend String to prepend to the left of each line
  34. * @param[in] data Pointer to the data array
  35. * @param[in] length Number of bytes to display
  36. **/
  37. void debugDisplayArray(FILE *stream,
  38. const char_t *prepend, const void *data, size_t length)
  39. {
  40. uint_t i;
  41. //Dump the contents of the array
  42. for(i = 0; i < length; i++)
  43. {
  44. //Beginning of a new line?
  45. if((i % 16) == 0)
  46. {
  47. TRACE_PRINTF("%s", prepend);
  48. }
  49. //Display current data byte
  50. TRACE_PRINTF("%02" PRIX8 " ", *((const uint8_t *) data + i));
  51. //End of current line?
  52. if((i % 16) == 15 || i == (length - 1))
  53. {
  54. TRACE_PRINTF("\r\n");
  55. }
  56. }
  57. }