app_common.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  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. #define MODINC( a, m ) M_BEGIN (a)++; if ((a)>=(m)) (a)=0; M_END
  57. #define MODDEC( a, m ) M_BEGIN if ((a)==0) (a)=(m); (a)--; M_END
  58. #define MODADD( a, b, m ) M_BEGIN (a)+=(b); if ((a)>=(m)) (a)-=(m); M_END
  59. #define MODSUB( a, b, m ) MODADD( a, (m)-(b), m )
  60. #define PAUSE( t ) M_BEGIN \
  61. __IO int _i; \
  62. for ( _i = t; _i > 0; _i -- ); \
  63. M_END
  64. #define DIVF( x, y ) ((x)/(y))
  65. #define DIVC( x, y ) (((x)+(y)-1)/(y))
  66. #define DIVR( x, y ) (((x)+((y)/2))/(y))
  67. #define SHRR( x, n ) ((((x)>>((n)-1))+1)>>1)
  68. #define BITN( w, n ) (((w)[(n)/32] >> ((n)%32)) & 1)
  69. #define BITNSET( w, n, b ) M_BEGIN (w)[(n)/32] |= ((U32)(b))<<((n)%32); M_END
  70. /* -------------------------------- *
  71. * Compiler *
  72. * -------------------------------- */
  73. #define PLACE_IN_SECTION( __x__ ) __attribute__((section (__x__)))
  74. #ifdef WIN32
  75. #define ALIGN(n)
  76. #else
  77. #define ALIGN(n) __attribute__((aligned(n)))
  78. #endif
  79. #ifdef __cplusplus
  80. } /* extern "C" */
  81. #endif
  82. #endif /*APP_COMMON_H */
  83. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/