em_int.c 2.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /**************************************************************************//**
  2. * @file
  3. * @brief Interrupt enable/disable unit API
  4. * @author Energy Micro AS
  5. * @version 3.0.0
  6. ******************************************************************************
  7. * @section License
  8. * <b>(C) Copyright 2012 Energy Micro AS, http://www.energymicro.com</b>
  9. *******************************************************************************
  10. *
  11. * Permission is granted to anyone to use this software for any purpose,
  12. * including commercial applications, and to alter it and redistribute it
  13. * freely, subject to the following restrictions:
  14. *
  15. * 1. The origin of this software must not be misrepresented; you must not
  16. * claim that you wrote the original software.
  17. * 2. Altered source versions must be plainly marked as such, and must not be
  18. * misrepresented as being the original software.
  19. * 3. This notice may not be removed or altered from any source distribution.
  20. *
  21. * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Energy Micro AS has no
  22. * obligation to support this Software. Energy Micro AS is providing the
  23. * Software "AS IS", with no express or implied warranties of any kind,
  24. * including, but not limited to, any implied warranties of merchantability
  25. * or fitness for any particular purpose or warranties against infringement
  26. * of any proprietary rights of a third party.
  27. *
  28. * Energy Micro AS will not be liable for any consequential, incidental, or
  29. * special damages, or any other relief, or for any claim by any third party,
  30. * arising from your use of this Software.
  31. *
  32. *****************************************************************************/
  33. #include <stdint.h>
  34. #include "em_int.h"
  35. /***************************************************************************//**
  36. * @addtogroup EM_Library
  37. * @{
  38. ******************************************************************************/
  39. /***************************************************************************//**
  40. * @addtogroup INT
  41. * @brief Safe nesting interrupt disable/enable API
  42. * @details
  43. * This module contains functions to safely disable and enable interrupts
  44. * at cpu level. INT_Disable() disables interrupts and increments a lock
  45. * level counter. INT_Enable() decrements the lock level counter and enable
  46. * interrupts if the counter was decremented to zero.
  47. *
  48. * These functions would normally be used to secure critical regions.
  49. *
  50. * These functions should also be used inside interrupt handlers:
  51. * @verbatim
  52. * void SysTick_Handler(void)
  53. * {
  54. * INT_Disable();
  55. * .
  56. * .
  57. * .
  58. * INT_Enable();
  59. * }
  60. * @endverbatim
  61. ******************************************************************************/
  62. /** Interrupt lock level counter. Set to zero initially as we normally enter
  63. * main with interrupts enabled */
  64. uint32_t INT_LockCnt = 0;
  65. /** @} (end addtogroup INT) */
  66. /** @} (end addtogroup EM_Library) */