1 /*
2 * Copyright (c) 2020 - 2024 Renesas Electronics Corporation and/or its affiliates
3 *
4 * SPDX-License-Identifier: BSD-3-Clause
5 */
6 
7 /**********************************************************************************************************************
8  * File Name    : bsp_irqs.c
9  * Version      : 1.00
10  * Description  : bsp_irq (secure) source code
11  *********************************************************************************************************************/
12 
13 /***********************************************************************************************************************
14  * Includes   <System Includes> , "Project Includes"
15  **********************************************************************************************************************/
16 #include "bsp_api.h"
17 #include "bsp_irq.h"
18 #include "bsp_irqs.h"
19 
20 /***********************************************************************************************************************
21  * Macro definitions
22  **********************************************************************************************************************/
23 #define BSP_PRV_BITS_PER_WORD    (32)
24 
25 /***********************************************************************************************************************
26  * Typedef definitions
27  **********************************************************************************************************************/
28 
29 /***********************************************************************************************************************
30  * Exported global variables (to be accessed by other files)
31  **********************************************************************************************************************/
32 
33 /***********************************************************************************************************************
34  * Private global variables and functions
35  **********************************************************************************************************************/
36 
37 /*******************************************************************************************************************//**
38  * @addtogroup BSP_MCU
39  *
40  * @{
41  **********************************************************************************************************************/
42 
43 /** @} (end addtogroup BSP_MCU) */
44 
45 /*******************************************************************************************************************//**
46  * This function provides clock to DMA Controller (see section 'Precaution when use the peripheral modules
47  * which can initiate DMA Controller.' in the user's manual for detail) and enables IM33.
48  * It also enables any interrupt in a non-secure state.
49  **********************************************************************************************************************/
bsp_irq_cfg_s(void)50 void bsp_irq_cfg_s (void)
51 {
52     R_BSP_MODULE_CLKON(FSP_IP_DMAC, 0);
53     R_BSP_MODULE_RSTOFF(FSP_IP_DMAC, 0);
54     R_BSP_MODULE_CLKON(FSP_IP_DMAC, 1);
55     R_BSP_MODULE_RSTOFF(FSP_IP_DMAC, 1);
56     R_BSP_IM33_ENABLE();
57 
58 #if BSP_NONSECURE_TRANSITION
59  #if FSP_PRIV_TZ_USE_SECURE_REGS
60 
61     /* Place all vectors in non-secure state. */
62     for (uint32_t i = 0U; i < (BSP_ICU_VECTOR_MAX_ENTRIES / BSP_PRV_BITS_PER_WORD); i++)
63     {
64         NVIC->ITNS[i] = UINT32_MAX;
65     }
66  #endif
67 #endif
68 }
69