TLx493D 3D Hall Sensor Generic Library  1.3
Generic library for the TLx493D 3D Hall sensor family
atomic.h
Go to the documentation of this file.
1 /*
2 *****************************************************************************
3 * Copyright (C) 2019 Infineon Technologies AG. All rights reserved.
4 *
5 * Infineon Technologies AG (INFINEON) is supplying this file for use
6 * exclusively with Infineon's products. This file can be freely
7 * distributed within development tools and software supporting such microcontroller
8 * products.
9 *
10 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
11 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
12 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
13 * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR DIRECT, INDIRECT, INCIDENTAL,
14 * ASPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
15 *
16 ******************************************************************************
17 */
18 
19 
23 #ifndef SRC_XMC1100_ATOMIC_ATOMIC_H_
24 #define SRC_XMC1100_ATOMIC_ATOMIC_H_
25 
26 #include <stdint.h>
27 #include <cmsis_gcc.h>
28 
29 extern uint32_t __atomic_int_flag;
30 
32 static inline void atomic_enter(void)
33 {
34  __atomic_int_flag = __get_PRIMASK();
35  __disable_irq();
36 }
37 
38 
40 static inline void atomic_exit(void)
41 {
42  if (!__atomic_int_flag) {
43  __enable_irq();
44  }
45 }
46 
47 
48 #endif /* SRC_XMC1100_ATOMIC_ATOMIC_H_ */