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