diff options
Diffstat (limited to 'lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/drivers/fsl_dsp.c')
-rw-r--r-- | lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/drivers/fsl_dsp.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/drivers/fsl_dsp.c b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/drivers/fsl_dsp.c new file mode 100644 index 000000000..68eae4ac5 --- /dev/null +++ b/lib/chibios-contrib/ext/mcux-sdk/devices/MIMXRT685S/drivers/fsl_dsp.c | |||
@@ -0,0 +1,107 @@ | |||
1 | /* | ||
2 | * Copyright 2019-2020, NXP | ||
3 | * All rights reserved. | ||
4 | * | ||
5 | * SPDX-License-Identifier: BSD-3-Clause | ||
6 | */ | ||
7 | |||
8 | #include "fsl_dsp.h" | ||
9 | #include "fsl_reset.h" | ||
10 | #include "fsl_common.h" | ||
11 | #include "fsl_power.h" | ||
12 | |||
13 | /******************************************************************************* | ||
14 | * Definitions | ||
15 | ******************************************************************************/ | ||
16 | |||
17 | /* Component ID definition, used by tools. */ | ||
18 | #ifndef FSL_COMPONENT_ID | ||
19 | #define FSL_COMPONENT_ID "platform.drivers.dsp" | ||
20 | #endif | ||
21 | |||
22 | /******************************************************************************* | ||
23 | * Variables | ||
24 | ******************************************************************************/ | ||
25 | |||
26 | /******************************************************************************* | ||
27 | * Prototypes | ||
28 | ******************************************************************************/ | ||
29 | |||
30 | /******************************************************************************* | ||
31 | * Code | ||
32 | ******************************************************************************/ | ||
33 | |||
34 | /*! | ||
35 | * @brief Initializing DSP core. | ||
36 | * | ||
37 | * Power up DSP TCM | ||
38 | * Enable DSP clock | ||
39 | * Reset DSP peripheral | ||
40 | */ | ||
41 | void DSP_Init(void) | ||
42 | { | ||
43 | if ((SYSCTL0->PDRUNCFG1 & (SYSCTL0_PDRUNCFG1_DSPCACHE_REGF_APD_MASK | SYSCTL0_PDRUNCFG1_DSPCACHE_REGF_PPD_MASK | | ||
44 | SYSCTL0_PDRUNCFG1_DSPTCM_REGF_APD_MASK | SYSCTL0_PDRUNCFG1_DSPTCM_REGF_PPD_MASK)) != 0U) | ||
45 | { | ||
46 | /* Not powered on. */ | ||
47 | POWER_DisablePD(kPDRUNCFG_APD_DSP_TCM_REGF); | ||
48 | POWER_DisablePD(kPDRUNCFG_PPD_DSP_TCM_REGF); | ||
49 | POWER_DisablePD(kPDRUNCFG_APD_DSP_CACHE_REGF); | ||
50 | POWER_DisablePD(kPDRUNCFG_PPD_DSP_CACHE_REGF); | ||
51 | POWER_ApplyPD(); | ||
52 | |||
53 | RESET_PeripheralReset(kDSP_RST_SHIFT_RSTn); | ||
54 | } | ||
55 | else if ((RSTCTL0->PRSTCTL0 & RSTCTL0_PRSTCTL0_HIFI_DSP_MASK) != 0U) | ||
56 | { | ||
57 | /* Powered on but not reset. */ | ||
58 | RESET_ClearPeripheralReset(kDSP_RST_SHIFT_RSTn); | ||
59 | } | ||
60 | else | ||
61 | { | ||
62 | /* Already powered on and reset, do nothing. */ | ||
63 | } | ||
64 | } | ||
65 | |||
66 | /*! | ||
67 | * @brief Deinit DSP core. | ||
68 | * | ||
69 | * Power down DSP TCM | ||
70 | * Disable DSP clock | ||
71 | * Set DSP peripheral reset | ||
72 | */ | ||
73 | void DSP_Deinit(void) | ||
74 | { | ||
75 | DSP_Stop(); | ||
76 | |||
77 | POWER_EnablePD(kPDRUNCFG_APD_DSP_TCM_REGF); | ||
78 | POWER_EnablePD(kPDRUNCFG_PPD_DSP_TCM_REGF); | ||
79 | POWER_EnablePD(kPDRUNCFG_APD_DSP_CACHE_REGF); | ||
80 | POWER_EnablePD(kPDRUNCFG_PPD_DSP_CACHE_REGF); | ||
81 | POWER_ApplyPD(); | ||
82 | } | ||
83 | /*! | ||
84 | * @brief Copy DSP image to destination address. | ||
85 | * | ||
86 | * Copy DSP image from source address to destination address with given size. | ||
87 | * | ||
88 | * @param dspCopyImage Structure contains information for DSP copy image to destination address. | ||
89 | */ | ||
90 | void DSP_CopyImage(dsp_copy_image_t *dspCopyImage) | ||
91 | { | ||
92 | assert(dspCopyImage != NULL); | ||
93 | assert(dspCopyImage->srcAddr != NULL); | ||
94 | assert(dspCopyImage->destAddr != NULL); | ||
95 | |||
96 | uint32_t *srcAddr = dspCopyImage->srcAddr; | ||
97 | uint32_t *destAddr = dspCopyImage->destAddr; | ||
98 | uint32_t size = dspCopyImage->size; | ||
99 | |||
100 | assert((size & 3U) == 0U); | ||
101 | |||
102 | while (size > 0U) | ||
103 | { | ||
104 | *destAddr++ = *srcAddr++; | ||
105 | size -= 4U; | ||
106 | } | ||
107 | } | ||