test public
Dependencies: HttpServer_snapshot_mbed-os
jcu_pl.c
00001 /******************************************************************************* 00002 * DISCLAIMER 00003 * This software is supplied by Renesas Electronics Corporation and is only 00004 * intended for use with Renesas products. No other uses are authorized. This 00005 * software is owned by Renesas Electronics Corporation and is protected under 00006 * all applicable laws, including copyright laws. 00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING 00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT 00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE 00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED. 00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS 00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE 00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR 00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE 00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. 00016 * Renesas reserves the right, without notice, to make changes to this software 00017 * and to discontinue the availability of this software. By using this software, 00018 * you agree to the additional terms and conditions found by accessing the 00019 * following link: 00020 * http://www.renesas.com/disclaimer 00021 * Copyright (C) 2012 - 2014 Renesas Electronics Corporation. All rights reserved. 00022 *******************************************************************************/ 00023 /******************************************************************************* 00024 * $FileName: jcu_pl.c $ 00025 * $Module: JCU $ $PublicVersion: 1.00 $ (=JCU_VERSION) 00026 * $Rev: 35 $ 00027 * $Date:: 2014-02-26 13:18:53 +0900#$ 00028 * Description : JCU driver porting layer 00029 ******************************************************************************/ 00030 00031 00032 /****************************************************************************** 00033 Includes <System Includes> , "Project Includes" 00034 ******************************************************************************/ 00035 #include "r_ospl.h" 00036 #include "iodefine.h" 00037 #include "r_jcu_api.h" 00038 #include "r_jcu_pl.h" 00039 00040 /****************************************************************************** 00041 Typedef definitions 00042 ******************************************************************************/ 00043 typedef struct st_jcu_pl_t jcu_pl_t; 00044 00045 /*[jcu_pl_t]*/ 00046 struct st_jcu_pl_t { 00047 const r_ospl_caller_t *InterruptCallbackCaller; 00048 const jcu_async_status_t *Status; 00049 }; 00050 00051 /*[gs_jcu_pl]*/ 00052 static jcu_pl_t gs_jcu_pl 00053 ; 00054 00055 /****************************************************************************** 00056 Macro definitions 00057 ******************************************************************************/ 00058 enum { JCU_INT_PRI = 2 }; 00059 #define CPG_JCU_CLOCK_POWER_OFF 0x00000002u 00060 00061 /****************************************************************************** 00062 Imported global variables and functions (from other files) 00063 ******************************************************************************/ 00064 00065 /****************************************************************************** 00066 Exported global variables and functions (to be accessed by other files) 00067 ******************************************************************************/ 00068 00069 /****************************************************************************** 00070 Private global variables and functions 00071 ******************************************************************************/ 00072 static void JCU_IRQ_JEDI_Handler(void); 00073 static void JCU_IRQ_JDTI_Handler(void); 00074 00075 /*[gs_jedi_interrupt_context] JEDI interrupt context */ 00076 /*[gs_jdti_interrupt_context] JDTI interrupt context */ 00077 static const r_ospl_interrupt_t gs_jedi_interrupt_context = { BSP_INT_SRC_JEDI, 0 }; 00078 static const r_ospl_interrupt_t gs_jdti_interrupt_context = { BSP_INT_SRC_JDTI, 0 }; 00079 00080 00081 /**************************************************************************//** 00082 * Function Name: [R_JCU_SetDefaultAsync] 00083 * @retval None 00084 ******************************************************************************/ 00085 void R_JCU_SetDefaultAsync( r_ospl_async_t *const Async, r_ospl_async_type_t AsyncType ) 00086 { 00087 IF_DQ( Async == NULL ) { 00088 goto fin; 00089 } 00090 00091 if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_A_Thread ) ) { 00092 Async->A_Thread = NULL; 00093 } 00094 00095 if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_A_EventValue ) ) { 00096 if ( AsyncType == R_OSPL_ASYNC_TYPE_NORMAL ) { 00097 Async->A_EventValue = R_OSPL_A_FLAG; 00098 } else { 00099 Async->A_EventValue = R_OSPL_FINAL_A_FLAG; 00100 } 00101 } else { 00102 ASSERT_D( IS_BIT_SET( Async->Flags, R_F_OSPL_A_Thread ), R_NOOP() ); 00103 } 00104 00105 if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_I_Thread ) ) { 00106 Async->I_Thread = NULL; 00107 } 00108 00109 if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_I_EventValue ) ) { 00110 Async->I_EventValue = R_OSPL_I_FLAG; 00111 } else { 00112 ASSERT_D( IS_BIT_SET( Async->Flags, R_F_OSPL_I_Thread ), R_NOOP() ); 00113 } 00114 00115 if ( IS_BIT_NOT_SET( Async->Flags, R_F_OSPL_InterruptCallback ) ) { 00116 Async->InterruptCallback = &( R_JCU_OnInterruptDefault ); /* MISRA 16.9 */ 00117 } 00118 00119 Async->Flags = R_F_OSPL_A_Thread | R_F_OSPL_A_EventValue | 00120 R_F_OSPL_I_Thread | R_F_OSPL_I_EventValue | 00121 R_F_OSPL_InterruptCallback | R_F_OSPL_Delegate; 00122 fin: 00123 return; 00124 } 00125 00126 00127 /**************************************************************************//** 00128 * Function Name: [R_JCU_OnInitialize] 00129 * @retval Error code, 0=No error 00130 ******************************************************************************/ 00131 errnum_t R_JCU_OnInitialize(void) 00132 { 00133 errnum_t e; 00134 bsp_int_err_t eb; 00135 bsp_int_src_t const num_of_JEDI_IRQ = gs_jedi_interrupt_context.IRQ_Num; 00136 bsp_int_src_t const num_of_JDTI_IRQ = gs_jdti_interrupt_context.IRQ_Num; 00137 jcu_pl_t *const self = &gs_jcu_pl; 00138 00139 self->InterruptCallbackCaller = NULL; 00140 self->Status = NULL; 00141 00142 00143 /* Register "JEDI" */ 00144 eb= R_BSP_InterruptWrite( num_of_JEDI_IRQ, &( JCU_IRQ_JEDI_Handler ) ); /* MISRA 16.9 */ 00145 IF ( eb != 0 ) { 00146 e=E_OTHERS; 00147 goto fin; 00148 } 00149 00150 e= R_OSPL_SetInterruptPriority( num_of_JEDI_IRQ, JCU_INT_PRI ); 00151 IF ( e != 0 ) { 00152 goto fin; 00153 } 00154 00155 00156 /* Register "JDTI" */ 00157 eb= R_BSP_InterruptWrite( num_of_JDTI_IRQ, &( JCU_IRQ_JDTI_Handler ) ); /* MISRA 16.9 */ 00158 IF ( eb != 0 ) { 00159 e=E_OTHERS; 00160 goto fin; 00161 } 00162 00163 e= R_OSPL_SetInterruptPriority( num_of_JDTI_IRQ, JCU_INT_PRI ); 00164 IF ( e != 0 ) { 00165 goto fin; 00166 } 00167 00168 00169 /* start to suuply the clock for JCU */ 00170 { /* ->QAC 0306 */ 00171 #if defined(TARGET_RZ_A1XX) 00172 uint32_t cpg_reg; 00173 cpg_reg = (uint32_t)(CPG.STBCR6) & ~CPG_JCU_CLOCK_POWER_OFF; 00174 CPG.STBCR6 =(uint8_t)cpg_reg; 00175 #elif defined(TARGET_RZ_A2XX) 00176 CPG.STBCR5.BIT.MSTP51 = 0; 00177 #endif 00178 } /* <-QAC 0306 */ 00179 00180 e=0; 00181 fin: 00182 return e; 00183 } 00184 00185 00186 /**************************************************************************//** 00187 * Function Name: [R_JCU_OnFinalize] 00188 * @retval Error code, 0=No error and e=0 00189 ******************************************************************************/ 00190 /* ->QAC 3227 : "e" is usually changed in finalize function. */ 00191 errnum_t R_JCU_OnFinalize( errnum_t e ) 00192 /* <-QAC 3227 */ 00193 { 00194 /* stop to suuply the clock for JCU */ 00195 { /* ->QAC 0306 */ 00196 #if defined(TARGET_RZ_A1XX) 00197 uint32_t cpg_reg; 00198 cpg_reg = (uint32_t)(CPG.STBCR6) | CPG_JCU_CLOCK_POWER_OFF; 00199 CPG.STBCR6 = (uint8_t)cpg_reg; 00200 #elif defined(TARGET_RZ_A2XX) 00201 CPG.STBCR5.BIT.MSTP51 = 1; 00202 #endif 00203 } /* <-QAC 0306 */ 00204 00205 return e; 00206 } 00207 00208 00209 /****************************************************************************** 00210 * Function Name: [R_JCU_SetInterruptCallbackCaller] 00211 * @retval Error code, 0=No error 00212 ******************************************************************************/ 00213 errnum_t R_JCU_SetInterruptCallbackCaller( const r_ospl_caller_t *const Caller ) 00214 { 00215 jcu_pl_t *const self = &gs_jcu_pl; 00216 00217 self->InterruptCallbackCaller = Caller; 00218 00219 return 0; 00220 } 00221 00222 00223 /****************************************************************************** 00224 * Function Name: [R_JCU_OnEnableInterrupt] 00225 * @retval None 00226 ******************************************************************************/ 00227 void R_JCU_OnEnableInterrupt( jcu_interrupt_lines_t const Enables ) 00228 { 00229 bsp_int_err_t eb; 00230 00231 if ( IS_BIT_SET( Enables, JCU_INTERRUPT_LINE_JEDI ) ) { 00232 bsp_int_src_t const num_of_IRQ = gs_jedi_interrupt_context.IRQ_Num; 00233 00234 eb= R_BSP_InterruptControl( num_of_IRQ, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR ); 00235 ASSERT_D( eb == 0, R_NOOP() ); 00236 R_UNREFERENCED_VARIABLE( eb ); /* for Release configuration */ 00237 } 00238 00239 if ( IS_BIT_SET( Enables, JCU_INTERRUPT_LINE_JDTI ) ) { 00240 bsp_int_src_t const num_of_IRQ = gs_jdti_interrupt_context.IRQ_Num; 00241 00242 eb= R_BSP_InterruptControl( num_of_IRQ, BSP_INT_CMD_INTERRUPT_ENABLE, FIT_NO_PTR ); 00243 ASSERT_D( eb == 0, R_NOOP() ); 00244 R_UNREFERENCED_VARIABLE( eb ); /* for Release configuration */ 00245 } 00246 } 00247 00248 00249 /****************************************************************************** 00250 * Function Name: [R_JCU_OnDisableInterrupt] 00251 * @retval None 00252 ******************************************************************************/ 00253 void R_JCU_OnDisableInterrupt( jcu_interrupt_lines_t const Disables1 ) 00254 { 00255 bsp_int_err_t eb; 00256 00257 if ( IS_BIT_SET( Disables1, JCU_INTERRUPT_LINE_JEDI ) ) { 00258 bsp_int_src_t const num_of_IRQ = gs_jedi_interrupt_context.IRQ_Num; 00259 00260 eb= R_BSP_InterruptControl( num_of_IRQ, BSP_INT_CMD_INTERRUPT_DISABLE, FIT_NO_PTR ); 00261 ASSERT_D( eb == 0, R_NOOP() ); 00262 R_UNREFERENCED_VARIABLE( eb ); /* for Release configuration */ 00263 } 00264 00265 if ( IS_BIT_SET( Disables1, JCU_INTERRUPT_LINE_JDTI ) ) { 00266 bsp_int_src_t const num_of_IRQ = gs_jdti_interrupt_context.IRQ_Num; 00267 00268 eb= R_BSP_InterruptControl( num_of_IRQ, BSP_INT_CMD_INTERRUPT_DISABLE, FIT_NO_PTR ); 00269 ASSERT_D( eb == 0, R_NOOP() ); 00270 R_UNREFERENCED_VARIABLE( eb ); /* for Release configuration */ 00271 } 00272 } 00273 00274 00275 /****************************************************************************** 00276 * Function Name: [R_JCU_OnInterruptDefault] 00277 * @retval Error code, 0=No error 00278 ******************************************************************************/ 00279 errnum_t R_JCU_OnInterruptDefault( const r_ospl_interrupt_t *const InterruptSource, 00280 const r_ospl_caller_t *const Caller ) 00281 { 00282 errnum_t e; 00283 errnum_t ee; 00284 r_ospl_async_t *async; 00285 00286 e = 0; 00287 R_AVOID_UNSAFE_ALWAYS_WARNING( e ); 00288 00289 IF_DQ( Caller == NULL ) { 00290 goto fin; 00291 } 00292 00293 ee= R_JCU_OnInterrupting( InterruptSource ); 00294 IF ( (ee != 0) && (e == 0) ) { 00295 e = ee; 00296 } 00297 00298 async = Caller->Async; 00299 00300 if ( async->I_Thread == NULL ) { 00301 ee= R_JCU_OnInterrupted(); 00302 IF ( (ee != 0) && (e == 0) ) { 00303 e = ee; 00304 } 00305 } else { 00306 R_OSPL_EVENT_Set( async->I_Thread, async->I_EventValue ); 00307 } 00308 00309 fin: 00310 return e; 00311 } 00312 00313 00314 /**************************************************************************//** 00315 * Function Name: [JCU_IRQ_JEDI_Handler] 00316 * @brief JEDI (JCU Encode Decode Interrupt) interrupt handler 00317 * @retval None 00318 ******************************************************************************/ 00319 static void JCU_IRQ_JEDI_Handler(void) 00320 { 00321 jcu_pl_t *const self = &gs_jcu_pl; 00322 const r_ospl_interrupt_t *const i_context = &gs_jedi_interrupt_context; 00323 00324 R_OSPL_CallInterruptCallback( self->InterruptCallbackCaller, i_context ); 00325 } 00326 00327 00328 /**************************************************************************//** 00329 * Function Name: [JCU_IRQ_JDTI_Handler] 00330 * @brief JDTI (JCU Data Transfer Interrupt) interrupt handler 00331 * @retval None 00332 ******************************************************************************/ 00333 static void JCU_IRQ_JDTI_Handler(void) 00334 { 00335 jcu_pl_t *const self = &gs_jcu_pl; 00336 const r_ospl_interrupt_t *const i_context = &gs_jdti_interrupt_context; 00337 00338 R_OSPL_CallInterruptCallback( self->InterruptCallbackCaller, i_context ); 00339 } 00340 00341
Generated on Wed Jul 13 2022 05:33:36 by 1.7.2