sdk_macros.h 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. /* Copyright (c) 2013 Nordic Semiconductor. All Rights Reserved.
  2. *
  3. * The information contained herein is property of Nordic Semiconductor ASA.
  4. * Terms and conditions of usage are described in detail in NORDIC
  5. * SEMICONDUCTOR STANDARD SOFTWARE LICENSE AGREEMENT.
  6. *
  7. * Licensees are granted free, non-transferable use of the information. NO
  8. * WARRANTY of ANY KIND is provided. This heading must NOT be removed from
  9. * the file.
  10. *
  11. */
  12. /** @cond */
  13. /**@file
  14. *
  15. * @ingroup sdk_util
  16. * @defgroup sdk_common_macros SDK Common Header
  17. * @breif Macros for parameter checking and similar tasks
  18. * @{
  19. */
  20. #ifndef SDK_MACROS_H__
  21. #define SDK_MACROS_H__
  22. /**@brief Macro for verifying that the module is initialized. It will cause the function to return
  23. * @ref NRF_ERROR_INVALID_STATE if not.
  24. */
  25. #ifdef DISABLE_PARAM_CHECK
  26. #define VERIFY_MODULE_INITIALIZED()
  27. #else
  28. #ifdef MODULE_INITIALIZED
  29. #define VERIFY_MODULE_INITIALIZED() \
  30. do \
  31. { \
  32. if (!MODULE_INITIALIZED) \
  33. { \
  34. return NRF_ERROR_INVALID_STATE; \
  35. } \
  36. } while(0)
  37. #else
  38. #define VERIFY_MODULE_INITIALIZED()
  39. #endif /* MODULE_INITIALIZED */
  40. #endif /* DISABLE_PARAM_CHECK */
  41. /**@brief Macro for verifying that the module is initialized. It will cause the function to return
  42. * if not.
  43. */
  44. #ifdef DISABLE_PARAM_CHECK
  45. #define VERIFY_MODULE_INITIALIZED_VOID()
  46. #else
  47. #ifdef MODULE_INITIALIZED
  48. #define VERIFY_MODULE_INITIALIZED_VOID() \
  49. do \
  50. { \
  51. if (!MODULE_INITIALIZED) \
  52. { \
  53. return; \
  54. } \
  55. } while(0)
  56. #else
  57. #define VERIFY_MODULE_INITIALIZED_VOID()
  58. #endif /* MODULE_INITIALIZED */
  59. #endif /* DISABLE_PARAM_CHECK */
  60. /** @} */
  61. /** @endcond */
  62. #endif // SDK_MACROS_H__