am_hal_global.h 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. //*****************************************************************************
  2. //
  3. // am_hal_global.h
  4. //! @file
  5. //!
  6. //! @brief Locate all HAL global variables here.
  7. //!
  8. //! This module contains global variables that are used throughout the HAL,
  9. //! but not necessarily those designated as const (which typically end up in
  10. //! flash). Consolidating globals here will make it easier to manage them.
  11. //
  12. //*****************************************************************************
  13. //*****************************************************************************
  14. //
  15. // Copyright (c) 2017, Ambiq Micro
  16. // All rights reserved.
  17. //
  18. // Redistribution and use in source and binary forms, with or without
  19. // modification, are permitted provided that the following conditions are met:
  20. //
  21. // 1. Redistributions of source code must retain the above copyright notice,
  22. // this list of conditions and the following disclaimer.
  23. //
  24. // 2. Redistributions in binary form must reproduce the above copyright
  25. // notice, this list of conditions and the following disclaimer in the
  26. // documentation and/or other materials provided with the distribution.
  27. //
  28. // 3. Neither the name of the copyright holder nor the names of its
  29. // contributors may be used to endorse or promote products derived from this
  30. // software without specific prior written permission.
  31. //
  32. // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  33. // AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  34. // IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  35. // ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
  36. // LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
  37. // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
  38. // SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
  39. // INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
  40. // CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
  41. // ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
  42. // POSSIBILITY OF SUCH DAMAGE.
  43. //
  44. // This is part of revision 1.2.9 of the AmbiqSuite Development Package.
  45. //
  46. //*****************************************************************************
  47. #ifndef AM_HAL_GLOBAL_H
  48. #define AM_HAL_GLOBAL_H
  49. #ifdef __cplusplus
  50. extern "C"
  51. {
  52. #endif
  53. //*****************************************************************************
  54. //
  55. // Macro definitions
  56. //
  57. //*****************************************************************************
  58. //******************************************************************************
  59. //
  60. // Macros used to access the bit fields in the flags variable.
  61. //
  62. //******************************************************************************
  63. #define AM_HAL_FLAGS_BFR(flagnm) \
  64. ((g_ui32HALflags & AM_HAL_FLAGS_##flagnm##_M) >> AM_HAL_FLAGS_##flagnm##_S)
  65. #define AM_HAL_FLAGS_BFW(flagnm, value) \
  66. g_ui32HALflags = ((g_ui32HALflags & (~(AM_HAL_FLAGS_##flagnm##_M))) | \
  67. ((value << AM_HAL_FLAGS_##flagnm##_S) & (AM_HAL_FLAGS_##flagnm##_M)) )
  68. //******************************************************************************
  69. //
  70. // ITMSKIPENABLEDISABLE - Set when the ITM is not to be disabled. This is
  71. // typically needed by Keil debug.ini.
  72. //
  73. //******************************************************************************
  74. #define AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_S 0
  75. #define AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_M (1 << AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_S)
  76. #define AM_HAL_FLAGS_ITMSKIPENABLEDISABLE(n) (((n) << AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_S) & AM_HAL_FLAGS_ITMSKIPENABLEDISABLE_M)
  77. //******************************************************************************
  78. //
  79. // ITMBKPT - Breakpoint at the end of itm_enable(), which is needed by
  80. // Keil debug.ini.
  81. //
  82. //******************************************************************************
  83. #define AM_HAL_FLAGS_ITMBKPT_S 1
  84. #define AM_HAL_FLAGS_ITMBKPT_M (1 << AM_HAL_FLAGS_ITMBKPT_S)
  85. #define AM_HAL_FLAGS_ITMBKPT(n) (((n) << AM_HAL_FLAGS_ITMBKPT_S) & AM_HAL_FLAGS_ITMBKPT_M)
  86. //******************************************************************************
  87. //
  88. // Next available flag or bit field.
  89. //
  90. //******************************************************************************
  91. #define AM_HAL_FLAGS_NEXTBITFIELD_S 2
  92. #define AM_HAL_FLAGS_NEXTBITFIELD_M (1 << AM_HAL_FLAGS_NEXTBITFIELD_S)
  93. #define AM_HAL_FLAGS_NEXTBITFIELD(n) (((n) << AM_HAL_FLAGS_NEXTBITFIELD_S) & AM_HAL_FLAGS_NEXTBITFIELD_M)
  94. //*****************************************************************************
  95. //
  96. // Global Variables extern declarations.
  97. //
  98. //*****************************************************************************
  99. extern volatile uint32_t g_ui32HALflags;
  100. #ifdef __cplusplus
  101. }
  102. #endif
  103. #endif // AM_HAL_GLOBAL_H