app_common.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /* USER CODE BEGIN Header */
  2. /**
  3. ******************************************************************************
  4. * File Name : app_common.h
  5. * Description : App Common application configuration file for STM32WPAN Middleware.
  6. *
  7. ******************************************************************************
  8. * @attention
  9. *
  10. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  11. * All rights reserved.</center></h2>
  12. *
  13. * This software component is licensed by ST under Ultimate Liberty license
  14. * SLA0044, the "License"; You may not use this file except in compliance with
  15. * the License. You may obtain a copy of the License at:
  16. * www.st.com/SLA0044
  17. *
  18. ******************************************************************************
  19. */
  20. /* USER CODE END Header */
  21. /* Define to prevent recursive inclusion -------------------------------------*/
  22. #ifndef APP_COMMON_H
  23. #define APP_COMMON_H
  24. #ifdef __cplusplus
  25. extern "C"{
  26. #endif
  27. #include <stdint.h>
  28. #include <string.h>
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <stdarg.h>
  32. #include "app_conf.h"
  33. /* -------------------------------- *
  34. * Basic definitions *
  35. * -------------------------------- */
  36. #undef NULL
  37. #define NULL 0
  38. #undef FALSE
  39. #define FALSE 0
  40. #undef TRUE
  41. #define TRUE (!0)
  42. /* -------------------------------- *
  43. * Critical Section definition *
  44. * -------------------------------- */
  45. #define BACKUP_PRIMASK() uint32_t primask_bit= __get_PRIMASK()
  46. #define DISABLE_IRQ() __disable_irq()
  47. #define RESTORE_PRIMASK() __set_PRIMASK(primask_bit)
  48. /* -------------------------------- *
  49. * Macro delimiters *
  50. * -------------------------------- */
  51. #define M_BEGIN do {
  52. #define M_END } while(0)
  53. /* -------------------------------- *
  54. * Some useful macro definitions *
  55. * -------------------------------- */
  56. #ifndef MAX
  57. #define MAX( x, y ) (((x)>(y))?(x):(y))
  58. #endif
  59. #ifndef MIN
  60. #define MIN( x, y ) (((x)<(y))?(x):(y))
  61. #endif
  62. #define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
  63. #define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
  64. #define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
  65. #define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
  66. #define PAUSE( t ) M_BEGIN \
  67. __IO int _i; \
  68. for ( _i = t; _i > 0; _i -- ); \
  69. M_END
  70. #define DIVF( x, y ) ((x)/(y))
  71. #define DIVC( x, y ) (((x)+(y)-1)/(y))
  72. #define DIVR( x, y ) (((x)+((y)/2))/(y))
  73. #define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
  74. #define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
  75. #define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
  76. /* -------------------------------- *
  77. * Compiler *
  78. * -------------------------------- */
  79. #define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
  80. #ifdef WIN32
  81. #define ALIGN(n)
  82. #else
  83. #define ALIGN(n) __attribute__((aligned(n)))
  84. #endif
  85. #ifdef __cplusplus
  86. } /* extern "C" */
  87. #endif
  88. #endif /*APP_COMMON_H */
  89. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/