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  * @addtogroup SCE
9  * @{
10  ***********************************************************************************************************************/
11 
12 #ifndef HW_SCE_COMMON_H
13 #define HW_SCE_COMMON_H
14 
15 /**********************************************************************************************************************
16  * Includes
17  ***********************************************************************************************************************/
18 #include "bsp_api.h"
19 #include "r_sce_if.h"
20 
21 /***********************************************************************************************************************
22  * Macro definitions
23  ***********************************************************************************************************************/
24 #define R_SCE_BITS_TO_BYTES(x)     (((x) + 7U) >> 3U)
25 #define R_SCE_BYTES_TO_BITS(x)     ((x) << 3U)
26 #define R_SCE_WORDS_TO_BYTES(x)    ((x) << 2U)
27 #define R_SCE_BYTES_TO_WORDS(x)    (((x) + 3U) >> 2U)
28 
29 /***********************************************************************************************************************
30  * Typedef definitions
31  ***********************************************************************************************************************/
32 
33 /***********************************************************************************************************************
34  * Private function prototypes
35  ***********************************************************************************************************************/
36 
37 /***********************************************************************************************************************
38  * Private global variables
39  ***********************************************************************************************************************/
40 
41 /***********************************************************************************************************************
42  * Private Functions
43  ***********************************************************************************************************************/
44 uint32_t change_endian_long(uint32_t data);
45 
46 /*******************************************************************************************************************//**
47  *
48  **********************************************************************************************************************/
HW_SCE_PowerOn(void)49 __STATIC_INLINE void HW_SCE_PowerOn (void)
50 {
51 #if BSP_FEATURE_TRNG_HAS_MODULE_STOP
52 
53     // RA2 MCU series has separate power control for RNG
54     R_MSTP->MSTPCRC_b.MSTPC28 = 0;
55 #endif
56 
57     // power on the SCE module
58     R_MSTP->MSTPCRC_b.MSTPC31 = 0;
59 }
60 
HW_SCE_PowerOff(void)61 __STATIC_INLINE void HW_SCE_PowerOff (void)
62 {
63 #if BSP_FEATURE_TRNG_HAS_MODULE_STOP
64 
65     // RA2 MCU series has separate power control for RNG
66     R_MSTP->MSTPCRC_b.MSTPC28 = 1;
67 #endif
68 
69     // power off the SCE module
70     R_MSTP->MSTPCRC_b.MSTPC31 = 1;
71 }
72 
73 #endif                                 /* HW_SCE_COMMON_H */
74 
75 /*******************************************************************************************************************//**
76  * @}
77  **********************************************************************************************************************/
78