efm32_common.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /***************************************************************************//**
  2. * @file
  3. * @brief EFM32 general purpose utilities.
  4. * @author Energy Micro AS
  5. * @version 2.0.0
  6. *******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2011 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * This source code is the property of Energy Micro AS. The source and compiled
  12. * code may only be used on Energy Micro "EFM32" microcontrollers.
  13. *
  14. * This copyright notice may not be removed from the source code nor changed.
  15. *
  16. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  17. * obligation to support this Software. Energy Micro AS is providing the
  18. * Software "AS IS", with no express or implied warranties of any kind,
  19. * including, but not limited to, any implied warranties of merchantability
  20. * or fitness for any particular purpose or warranties against infringement
  21. * of any proprietary rights of a third party.
  22. *
  23. * Energy Micro AS will not be liable for any consequential, incidental, or
  24. * special damages, or any other relief, or for any claim by any third party,
  25. * arising from your use of this Software.
  26. *
  27. ******************************************************************************/
  28. #ifndef __EFM32_COMMON_H
  29. #define __EFM32_COMMON_H
  30. #include <stdint.h>
  31. #include <stdbool.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. /***************************************************************************//**
  36. * @addtogroup EFM32_Library
  37. * @{
  38. ******************************************************************************/
  39. /***************************************************************************//**
  40. * @addtogroup COMMON
  41. * @brief EFM32 general purpose utilities.
  42. * @{
  43. ******************************************************************************/
  44. #if !defined(__GNUC__)
  45. /** Macro for getting minimum value. */
  46. #define EFM32_MIN(a, b) ((a) < (b) ? (a) : (b))
  47. /** Macro for getting maximum value. */
  48. #define EFM32_MAX(a, b) ((a) > (b) ? (a) : (b))
  49. #else
  50. /** Macro for getting minimum value. No sideeffects, a and b are evaluated once only. */
  51. #define EFM32_MIN(a, b) ({ typeof(a)_a = (a); typeof(b)_b = (b); _a < _b ? _a : _b; })
  52. /** Macro for getting maximum value. No sideeffects, a and b are evaluated once only. */
  53. #define EFM32_MAX(a, b) ({ typeof(a)_a = (a); typeof(b)_b = (b); _a > _b ? _a : _b; })
  54. #endif
  55. /** @} (end addtogroup COMMON) */
  56. /** @} (end addtogroup EFM32_Library) */
  57. #ifdef __cplusplus
  58. }
  59. #endif
  60. #endif /* __EFM32_COMMON_H */