aboutsummaryrefslogtreecommitdiff
path: root/lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/drivers/fsl_reset.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/drivers/fsl_reset.c')
-rw-r--r--lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/drivers/fsl_reset.c112
1 files changed, 112 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/drivers/fsl_reset.c b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/drivers/fsl_reset.c
new file mode 100644
index 000000000..1b6cd56cf
--- /dev/null
+++ b/lib/chibios-contrib/ext/mcux-sdk/devices/LPC844/drivers/fsl_reset.c
@@ -0,0 +1,112 @@
1/*
2 * Copyright 2017, NXP
3 * All rights reserved.
4 *
5 * SPDX-License-Identifier: BSD-3-Clause
6 */
7
8#include "fsl_common.h"
9#include "fsl_reset.h"
10
11/*******************************************************************************
12 * Definitions
13 ******************************************************************************/
14/* Component ID definition, used by tools. */
15#ifndef FSL_COMPONENT_ID
16#define FSL_COMPONENT_ID "platform.drivers.reset"
17#endif
18
19/*******************************************************************************
20 * Variables
21 ******************************************************************************/
22
23/*******************************************************************************
24 * Prototypes
25 ******************************************************************************/
26
27/*!
28* @brief Assert reset to peripheral.
29*
30* Asserts reset signal to specified peripheral module.
31*
32* @param peripheral Assert reset to this peripheral. The enum argument contains encoding of reset register
33* and reset bit position in the reset register.
34*/
35static void RESET_SetPeripheralReset(reset_ip_name_t peripheral);
36
37/*!
38 * @brief Clear reset to peripheral.
39 *
40 * Clears reset signal to specified peripheral module, allows it to operate.
41 *
42 * @param peripheral Clear reset to this peripheral. The enum argument contains encoding of reset register
43 * and reset bit position in the reset register.
44 */
45static void RESET_ClearPeripheralReset(reset_ip_name_t peripheral);
46
47/*******************************************************************************
48 * Code
49 ******************************************************************************/
50
51#if ((defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0)) || \
52 (defined(FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT) && (FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT > 0)))
53
54static void RESET_SetPeripheralReset(reset_ip_name_t peripheral)
55{
56 const uint32_t regIndex = ((uint32_t)peripheral & 0xFFFF0000u) >> 16;
57 const uint32_t bitPos = ((uint32_t)peripheral & 0x0000FFFFu);
58 const uint32_t bitMask = 1UL << bitPos;
59
60 assert(bitPos < 32UL);
61
62 /* reset register is in SYSCON */
63
64 if (0u == regIndex)
65 {
66 /* set bit */
67 SYSCON->PRESETCTRL0 &= ~bitMask;
68 }
69 if (1u == regIndex)
70 {
71 /* set bit */
72 SYSCON->PRESETCTRL1 &= ~bitMask;
73 }
74}
75
76static void RESET_ClearPeripheralReset(reset_ip_name_t peripheral)
77{
78 const uint32_t regIndex = ((uint32_t)peripheral & 0xFFFF0000u) >> 16;
79 const uint32_t bitPos = ((uint32_t)peripheral & 0x0000FFFFu);
80 const uint32_t bitMask = 1UL << bitPos;
81
82 assert(bitPos < 32UL);
83
84 /* reset register is in SYSCON */
85
86 if (0u == regIndex)
87 {
88 /* clear bit */
89 SYSCON->PRESETCTRL0 |= bitMask;
90 }
91 if (1u == regIndex)
92 {
93 /* clear bit */
94 SYSCON->PRESETCTRL1 |= bitMask;
95 }
96}
97
98/*!
99 * brief Reset peripheral module.
100 *
101 * Reset peripheral module.
102 *
103 * param peripheral Peripheral to reset. The enum argument contains encoding of reset register
104 * and reset bit position in the reset register.
105 */
106void RESET_PeripheralReset(reset_ip_name_t peripheral)
107{
108 RESET_SetPeripheralReset(peripheral);
109 RESET_ClearPeripheralReset(peripheral);
110}
111
112#endif /* FSL_FEATURE_SOC_SYSCON_COUNT || FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT */