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 * Includes <System Includes> , "Project Includes" 9 **********************************************************************************************************************/ 10 #include "bsp_api.h" 11 12 /*********************************************************************************************************************** 13 * Macro definitions 14 **********************************************************************************************************************/ 15 16 /* Private definition to set enumeration values. */ 17 #define BSP_PRV_SYTSEMFEN_ENABLE (0x00000001U) 18 #define BSP_PRV_RESOURCE_NOT_USED (0x00000001U) 19 #define BSP_SEMAPHORE_RESOURCE_MAX (8U) 20 #define BSP_PRV_SEMRCEN_ENABLE (0xFFU) 21 22 /*********************************************************************************************************************** 23 * Typedef definitions 24 **********************************************************************************************************************/ 25 26 /*********************************************************************************************************************** 27 * Exported global variables (to be accessed by other files) 28 **********************************************************************************************************************/ 29 30 /*********************************************************************************************************************** 31 * Private global variables and functions 32 **********************************************************************************************************************/ 33 34 /*******************************************************************************************************************//** 35 * Semaphore initialization. 36 **********************************************************************************************************************/ bsp_semaphore_init(void)37void bsp_semaphore_init (void) 38 { 39 #if BSP_FEATURE_BSP_SEMAPHORE_SUPPORTED 40 #if BSP_FEATURE_SEM_SUPPORTED 41 uint32_t sem_num; 42 43 /* Disable register protection for semaphore related registers. */ 44 R_BSP_RegisterProtectDisable(BSP_REG_PROTECT_SYSTEM); 45 46 /* Enable read clear function. */ 47 R_SEM->SYTSEMFEN = BSP_PRV_SYTSEMFEN_ENABLE; 48 49 for (sem_num = 0; sem_num < BSP_SEMAPHORE_RESOURCE_MAX; sem_num++) 50 { 51 /* Set the semaphore state not being used. */ 52 R_SEM->SYTSEMF[sem_num] = BSP_PRV_RESOURCE_NOT_USED; 53 } 54 55 /* Enable register protection for semaphore related registers. */ 56 R_BSP_RegisterProtectEnable(BSP_REG_PROTECT_SYSTEM); 57 #endif 58 59 #if BSP_FEATURE_MAILBOX_SEM_SUPPORTED 60 uint32_t sem_num; 61 62 /* Disable register protection for semaphore related registers. */ 63 R_BSP_RegisterProtectDisable(BSP_REG_PROTECT_SYSTEM); 64 65 /* Enable read clear function. */ 66 R_MBXSEM->SEMRCEN = BSP_PRV_SEMRCEN_ENABLE; 67 68 for (sem_num = 0; sem_num < BSP_SEMAPHORE_RESOURCE_MAX; sem_num++) 69 { 70 /* Set the semaphore state not being used. */ 71 R_MBXSEM->SEM[sem_num] = BSP_PRV_RESOURCE_NOT_USED; 72 } 73 74 /* Enable register protection for semaphore related registers. */ 75 R_BSP_RegisterProtectEnable(BSP_REG_PROTECT_SYSTEM); 76 #endif 77 #endif 78 } 79