efm32_assert.h 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /***************************************************************************//**
  2. * @file
  3. * @brief EFM32 peripheral API "assert" implementation.
  4. * @author Energy Micro AS
  5. * @version 1.3.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 2010 Energy Micro AS, http://www.energymicro.com</b>
  27. *******************************************************************************
  28. *
  29. * This source code is the property of Energy Micro AS. The source and compiled
  30. * code may only be used on Energy Micro "EFM32" microcontrollers.
  31. *
  32. * This copyright notice may not be removed from the source code nor changed.
  33. *
  34. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  35. * obligation to support this Software. Energy Micro AS is providing the
  36. * Software "AS IS", with no express or implied warranties of any kind,
  37. * including, but not limited to, any implied warranties of merchantability
  38. * or fitness for any particular purpose or warranties against infringement
  39. * of any proprietary rights of a third party.
  40. *
  41. * Energy Micro AS will not be liable for any consequential, incidental, or
  42. * special damages, or any other relief, or for any claim by any third party,
  43. * arising from your use of this Software.
  44. *
  45. ******************************************************************************/
  46. #ifndef __EFM32_ASSERT_H
  47. #define __EFM32_ASSERT_H
  48. #ifdef __cplusplus
  49. extern "C" {
  50. #endif
  51. /** @cond DO_NOT_INCLUDE_WITH_DOXYGEN */
  52. #if defined(DEBUG_EFM) || defined(DEBUG_EFM_USER)
  53. /* Due to footprint considerations, we only pass file name and line number, */
  54. /* not the assert expression (nor function name (C99)) */
  55. void assertEFM(const char *file, int line);
  56. #define EFM_ASSERT(expr) ((expr) ? ((void) 0) : assertEFM(__FILE__, __LINE__))
  57. #else
  58. #define EFM_ASSERT(expr) ((void) 0)
  59. #endif /* defined(DEBUG_EFM) || defined(DEBUG_EFM_USER) */
  60. /** @endcond */
  61. #ifdef __cplusplus
  62. }
  63. #endif
  64. #endif /* __EFM32_ASSERT_H */