em_assert.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. /***************************************************************************//**
  2. * @file
  3. * @brief EFM32 peripheral API "assert" implementation.
  4. * @author Energy Micro AS
  5. * @version 3.0.0
  6. *
  7. * @details
  8. * By default, EFM32 library assert usage is not included in order to reduce
  9. * footprint and processing overhead. Further, EFM32 assert usage is decoupled
  10. * from ISO C assert handling (NDEBUG usage), to allow a user to use ISO C
  11. * assert without including EFM32 assert statements.
  12. *
  13. * Below are available defines for controlling EFM32 assert inclusion. The defines
  14. * are typically defined for a project to be used by the preprocessor.
  15. *
  16. * @li If DEBUG_EFM is defined, the internal EFM32 library assert handling will
  17. * be used, which may be a quite rudimentary implementation.
  18. *
  19. * @li If DEBUG_EFM_USER is defined instead, the user must provide its own EFM32
  20. * assert handling routine (assertEFM()).
  21. *
  22. * As indicated above, if none of the above defines are used, EFM32 assert
  23. * statements are not compiled.
  24. *******************************************************************************
  25. * @section License
  26. * <b>(C) Copyright 2012 Energy Micro AS, http://www.energymicro.com</b>
  27. *******************************************************************************
  28. *
  29. * Permission is granted to anyone to use this software for any purpose,
  30. * including commercial applications, and to alter it and redistribute it
  31. * freely, subject to the following restrictions:
  32. *
  33. * 1. The origin of this software must not be misrepresented; you must not
  34. * claim that you wrote the original software.
  35. * 2. Altered source versions must be plainly marked as such, and must not be
  36. * misrepresented as being the original software.
  37. * 3. This notice may not be removed or altered from any source distribution.
  38. *
  39. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  40. * obligation to support this Software. Energy Micro AS is providing the
  41. * Software "AS IS", with no express or implied warranties of any kind,
  42. * including, but not limited to, any implied warranties of merchantability
  43. * or fitness for any particular purpose or warranties against infringement
  44. * of any proprietary rights of a third party.
  45. *
  46. * Energy Micro AS will not be liable for any consequential, incidental, or
  47. * special damages, or any other relief, or for any claim by any third party,
  48. * arising from your use of this Software.
  49. *
  50. ******************************************************************************/
  51. #ifndef __EM_ASSERT_H
  52. #define __EM_ASSERT_H
  53. #ifdef __cplusplus
  54. extern "C" {
  55. #endif
  56. /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
  57. #if defined(DEBUG_EFM) || defined(DEBUG_EFM_USER)
  58. /* Due to footprint considerations, we only pass file name and line number, */
  59. /* not the assert expression (nor function name (C99)) */
  60. void assertEFM(const char *file, int line);
  61. #define EFM_ASSERT(expr) ((expr) ? ((void)0) : assertEFM(__FILE__, __LINE__))
  62. #else
  63. #define EFM_ASSERT(expr) ((void)0)
  64. #endif /* defined(DEBUG_EFM) || defined(DEBUG_EFM_USER) */
  65. /** @endcond */
  66. #ifdef __cplusplus
  67. }
  68. #endif
  69. #endif /* __EM_ASSERT_H */