1 /**
2 * @file xmc_pau.c
3 * @date 2015-06-20
4 *
5 * @cond
6 *********************************************************************************************************************
7 * XMClib v2.1.24 - XMC Peripheral Driver Library
8 *
9 * Copyright (c) 2015-2019, Infineon Technologies AG
10 * All rights reserved.
11 *
12 * Redistribution and use in source and binary forms, with or without modification,are permitted provided that the
13 * following conditions are met:
14 *
15 * Redistributions of source code must retain the above copyright notice, this list of conditions and the following
16 * disclaimer.
17 *
18 * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
19 * disclaimer in the documentation and/or other materials provided with the distribution.
20 *
21 * Neither the name of the copyright holders nor the names of its contributors may be used to endorse or promote
22 * products derived from this software without specific prior written permission.
23 *
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
25 * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
26 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
27 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29 * WHETHER IN CONTRACT, STRICT LIABILITY,OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
30 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31 *
32 * To improve the quality of the software, users are encouraged to share modifications, enhancements or bug fixes with
33 * Infineon Technologies AG dave@infineon.com).
34 *********************************************************************************************************************
35 *
36 * Change History
37 * --------------
38 *
39 * 2015-02-20:
40 * - Initial <br>
41 *
42 * 2015-06-20:
43 * - Removed GetDriverVersion API
44 * @endcond
45 *
46 */
47
48 /**
49 *
50 * @brief PAU driver for XMC1 microcontroller family.
51 *
52 */
53
54 /*********************************************************************************************************************
55 * HEADER FILES
56 *********************************************************************************************************************/
57 #include "xmc_pau.h"
58
59 #if defined(PAU)
60
61 /**********************************************************************************************************************
62 * API IMPLEMENTATION
63 *********************************************************************************************************************/
64
65 /*
66 * Enable peripheral access
67 */
XMC_PAU_EnablePeripheralAccess(XMC_PAU_PERIPHERAL_t peripheral)68 void XMC_PAU_EnablePeripheralAccess(XMC_PAU_PERIPHERAL_t peripheral)
69 {
70 uint32_t reg_num;
71
72 reg_num = ((uint32_t)peripheral & 0xf0000000U) >> 28U;
73 XMC_PAU->PRIVDIS[reg_num] &= (uint32_t)~((uint32_t)peripheral & 0x0fffffffUL);
74 }
75
76 /*
77 * Disable peripheral access
78 */
XMC_PAU_DisablePeripheralAccess(XMC_PAU_PERIPHERAL_t peripheral)79 void XMC_PAU_DisablePeripheralAccess(XMC_PAU_PERIPHERAL_t peripheral)
80 {
81 uint32_t reg_num;
82
83 reg_num = ((uint32_t)peripheral & 0xf0000000U) >> 28U;
84 XMC_PAU->PRIVDIS[reg_num] |= (uint32_t)((uint32_t)peripheral & 0x0fffffffUL);
85 }
86
87 /*
88 * Check if peripheral access is enabled
89 */
XMC_PAU_IsPeripheralAccessEnabled(XMC_PAU_PERIPHERAL_t peripheral)90 bool XMC_PAU_IsPeripheralAccessEnabled(XMC_PAU_PERIPHERAL_t peripheral)
91 {
92 uint32_t reg_num;
93
94 reg_num = ((uint32_t)peripheral & 0xf0000000U) >> 28U;
95 return (bool)(XMC_PAU->PRIVDIS[reg_num] & ((uint32_t)peripheral & 0x0fffffffUL));
96 }
97
98 /*
99 * Check if peripheral is available
100 */
XMC_PAU_IsPeripheralAvailable(XMC_PAU_PERIPHERAL_t peripheral)101 bool XMC_PAU_IsPeripheralAvailable(XMC_PAU_PERIPHERAL_t peripheral)
102 {
103 uint32_t reg_num;
104
105 reg_num = ((uint32_t)peripheral & 0xf0000000U) >> 28U;
106 return (bool)(XMC_PAU->AVAIL[reg_num] & ((uint32_t)peripheral & 0x0fffffffUL));
107 }
108
109 #endif /* defined(PAU) */
110