Graphics framework for GR-PEACH. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE
Dependents: ImageZoomInout_Sample ImageRotaion_Sample ImageScroll_Sample GR-PEACH_LCD_4_3inch_Save_to_USB ... more
jcu_reg.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_reg.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 setting register 00029 ******************************************************************************/ 00030 00031 /****************************************************************************** 00032 Includes <System Includes> , "Project Includes" 00033 ******************************************************************************/ 00034 #include <r_typedefs.h> 00035 #include <iodefine.h> 00036 #include <r_jcu_api.h> 00037 #include <r_jcu_local.h> 00038 #include <r_jcu_user.h> 00039 00040 /****************************************************************************** 00041 Typedef definitions 00042 ******************************************************************************/ 00043 00044 /****************************************************************************** 00045 Macro definitions 00046 ******************************************************************************/ 00047 #define NUMBER_OF_QUANTIZATION_TABLE_DATA (64) 00048 #define NUMBER_OF_HUFFMAN_TABLE_DATA_DC (28) 00049 #define NUMBER_OF_HUFFMAN_TABLE_DATA_AC (178) 00050 00051 #define CBCR_OFFSET_NUM (2u) 00052 00053 #define SWAP_NORMAL (0u) 00054 #define SWAP_16BIT_OUTPUT (1u) 00055 #define SWAP_32BIT_OUTPUT (2u) 00056 00057 #define KIND_COLOR_FORMAT (3u) 00058 #define KIND_LINEOFFSET (2u) 00059 #define KIND_TABLE (4u) 00060 00061 00062 /****************************************************************************** 00063 Imported global variables and functions (from other files) 00064 ******************************************************************************/ 00065 00066 /****************************************************************************** 00067 Exported global variables and functions (to be accessed by other files) 00068 ******************************************************************************/ 00069 00070 /****************************************************************************** 00071 Private global variables and functions 00072 ******************************************************************************/ 00073 STATIC_INLINE uint8_t GET_UPPER_BYTE( uint32_t const value ); 00074 STATIC_INLINE uint8_t GET_LOWER_BYTE( uint32_t const value ); 00075 static void JCU_GetRegisterForGetErrorInfo(jcu_detail_error_t *const errorCode); 00076 00077 00078 /**************************************************************************//** 00079 * Function Name: [GET_UPPER_BYTE] 00080 * @brief GET_UPPER_BYTE 00081 * @retval Byte 00082 ******************************************************************************/ 00083 STATIC_INLINE uint8_t GET_UPPER_BYTE( uint32_t const value ) 00084 { 00085 enum { num_8 = 8 }; /* SEC M1.10.1, QAC-3132 */ 00086 return (uint8_t)( value >> num_8 ); 00087 } 00088 00089 /**************************************************************************//** 00090 * Function Name: [GET_LOWER_BYTE] 00091 * @brief GET_LOWER_BYTE 00092 * @retval Byte 00093 ******************************************************************************/ 00094 STATIC_INLINE uint8_t GET_LOWER_BYTE( uint32_t const value ) 00095 { 00096 return (uint8_t)( value ); 00097 } 00098 00099 /**************************************************************************//** 00100 * Function Name: [JCU_SetRegisterForInitialize] 00101 * @brief SetRegisterForInitialize 00102 * @retval jcu_errorcode_t 00103 ******************************************************************************/ 00104 jcu_errorcode_t JCU_SetRegisterForInitialize( 00105 void) 00106 { 00107 return JCU_ERROR_OK; 00108 } 00109 00110 /**************************************************************************//** 00111 * Function Name: [JCU_SetRegisterForCodec] 00112 * @brief SetRegisterForCodec 00113 * @param[out] codec 00114 * @retval None 00115 ******************************************************************************/ 00116 void JCU_SetRegisterForCodec( 00117 const jcu_codec_t codec) 00118 { 00119 volatile uint8_t DummyRead; 00120 00121 /* Reset this IP */ 00122 R_SET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST, REG_F_SET ); 00123 DummyRead = R_GET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST ); 00124 R_UNREFERENCED_VARIABLE( DummyRead ); 00125 00126 R_SET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST, REG_F_CLR ); 00127 DummyRead = R_GET_REG_BIT_FIELD( CPG.SWRSTCR2, SRST ); 00128 R_UNREFERENCED_VARIABLE( DummyRead ); 00129 00130 R_SET_REG_BIT_FIELD( JCU.JCCMD, BRST, REG_F_SET); 00131 00132 /* Enable interrupts in registers (Interrupt lines in INTC are still disabled) */ 00133 /* This registers are set to 0 by reset this IP */ 00134 /* ->QAC 0306 */ 00135 00136 JCU.JINTE1 = JCU_JINTS1_ALL; 00137 /* <-QAC 0306 */ 00138 00139 /* Clear the all of count mode settings */ 00140 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINLC, REG_F_CLR ); 00141 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINRINI, REG_F_CLR ); 00142 /* ->QAC 0306 */ 00143 JCU.JIFESLC = LINES_CLEAR; 00144 /* <-QAC 0306 */ 00145 00146 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTC, REG_F_CLR ); 00147 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTRINI, REG_F_CLR ); 00148 /* ->QAC 0306 */ 00149 JCU.JIFEDDC = JDATAS_CLEAR; 00150 /* <-QAC 0306 */ 00151 00152 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINC, REG_F_CLR ); 00153 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINRINI, REG_F_CLR ); 00154 /* ->QAC 0306 */ 00155 JCU.JIFDSDC = JDATAS_CLEAR; 00156 /* <-QAC 0306 */ 00157 00158 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTLC, REG_F_CLR ); 00159 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTRINI, REG_F_CLR ); 00160 /* ->QAC 0306 */ 00161 JCU.JIFDDLC = LINES_CLEAR; 00162 /* <-QAC 0306 */ 00163 00164 /* Set the which process is select */ 00165 R_SET_REG_BIT_FIELD( JCU.JCMOD, DSP, codec ); 00166 return; 00167 } 00168 00169 /**************************************************************************//** 00170 * Function Name: [JCU_ClearInterruptFlag] 00171 * @brief ClearInterruptFlag 00172 * @retval None 00173 ******************************************************************************/ 00174 void JCU_ClearInterruptFlag( 00175 void) 00176 { 00177 /* Interrupt request clear */ 00178 R_SET_REG_BIT_FIELD( JCU.JCCMD, JEND, REG_F_SET); 00179 00180 /* Clear the JEDI interrupt source flag */ 00181 /* ->QAC 0306 */ 00182 JCU.JINTS0 = (uint8_t) 0u; /* Write 0 only */ 00183 /* <-QAC 0306 */ 00184 00185 /* Clear the JDTI interrupt source flag */ 00186 /* ->QAC 0306 */ 00187 JCU.JINTS1 &= ~JCU_JINTS1_ALL; 00188 /* <-QAC 0306 */ 00189 return; 00190 } 00191 00192 /**************************************************************************//** 00193 * Function Name: [JCU_SetRegisterForStart] 00194 * @brief SetRegisterForStart 00195 * @retval None 00196 ******************************************************************************/ 00197 void JCU_SetRegisterForStart( 00198 const jcu_int_detail_error_t error_filter) 00199 { 00200 uint32_t reg_jinte0; 00201 reg_jinte0 = (uint32_t)JCU.JINTE0 & (uint32_t)(~JCU_INT_ERROR_ALL); 00202 JCU.JINTE0 = (uint8_t)( reg_jinte0 | (uint32_t)error_filter ); 00203 R_SET_REG_BIT_FIELD( JCU.JCCMD, JSRT, REG_F_SET ); 00204 return; 00205 } 00206 00207 /**************************************************************************//** 00208 * Function Name: [JCU_SetRegisterForSetCountMode] 00209 * @brief SetRegisterForSetCountMode 00210 * @param[in] buffer 00211 * @retval None 00212 ******************************************************************************/ 00213 void JCU_SetRegisterForSetCountMode( 00214 const jcu_count_mode_param_t *const buffer) 00215 { 00216 jcu_internal_information_t *const self = R_JCU_GetInternalInformation(); 00217 00218 IF (buffer == NULL) { 00219 goto fin; 00220 } /* end if */ 00221 00222 IF_DQ ( self == NULL ) { 00223 goto fin; 00224 } /* end if */ 00225 00226 switch(self->Codec) { 00227 case JCU_STATUS_ENCODE: 00228 /* ->QAC 0306 */ 00229 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINRINI, buffer->inputBuffer.isInitAddress ); 00230 if ((buffer->inputBuffer.isEnable != false) && (buffer->inputBuffer.isInitAddress != false)) { 00231 JCU.JIFESA = (uint32_t)(buffer->inputBuffer.restartAddress); 00232 } /* end if */ 00233 JCU.JIFESLC = ( LINES_MASK & (buffer->inputBuffer.dataCount) ); 00234 00235 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTRINI ,buffer->outputBuffer.isInitAddress ); 00236 if ((buffer->outputBuffer.isEnable != false) && (buffer->outputBuffer.isInitAddress != false)) { 00237 JCU.JIFEDA = (uint32_t)(buffer->outputBuffer.restartAddress); 00238 } /* end if */ 00239 JCU.JIFEDDC = ( JDATAS_MASK & ( buffer->outputBuffer.dataCount ) ); 00240 /* <-QAC 0306 */ 00241 00242 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINLC ,buffer->inputBuffer.isEnable ); 00243 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTC ,buffer->outputBuffer.isEnable ); 00244 break; 00245 00246 case JCU_STATUS_DECODE: 00247 /* ->QAC 0306 */ 00248 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINRINI ,buffer->inputBuffer.isInitAddress ); 00249 if ((buffer->inputBuffer.isEnable != false) && (buffer->inputBuffer.isInitAddress != false)) { 00250 JCU.JIFDSA = (uint32_t)(buffer->inputBuffer.restartAddress); 00251 } /* end if */ 00252 JCU.JIFDSDC = ( JDATAS_MASK & (buffer->inputBuffer.dataCount ) ); 00253 00254 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTRINI, buffer->outputBuffer.isInitAddress ); 00255 if ((buffer->outputBuffer.isEnable != false) && (buffer->outputBuffer.isInitAddress != false)) { 00256 JCU.JIFDDA = (uint32_t)(buffer->outputBuffer.restartAddress); 00257 } /* end if */ 00258 JCU.JIFDDLC = ( LINES_MASK & ( buffer->outputBuffer.dataCount ) ); 00259 /* <-QAC 0306 */ 00260 00261 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINC, buffer->inputBuffer.isEnable ); 00262 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTLC, buffer->outputBuffer.isEnable ); 00263 break; 00264 00265 case JCU_CODEC_NOT_SELECTED: 00266 /* ->QAC 2018 : For MISRA 15.3, SEC R3.5.2 */ 00267 default: 00268 /* <-QAC 2018 */ 00269 R_NOOP(); /* NOT REACHED */ 00270 break; 00271 } /* end switch */ 00272 fin: 00273 return; 00274 } 00275 00276 /**************************************************************************//** 00277 * Function Name: [JCU_SetRegisterForContinue] 00278 * @brief SetRegisterForContinue 00279 * @param[in] type 00280 * @retval None 00281 ******************************************************************************/ 00282 void JCU_SetRegisterForContinue( 00283 const jcu_continue_type_t type) 00284 { 00285 jcu_internal_information_t *const self = R_JCU_GetInternalInformation(); 00286 00287 IF_DQ ( self == NULL ) { 00288 goto fin; 00289 } /* end if */ 00290 00291 /* Restart register setting */ 00292 switch (type) { 00293 case JCU_INPUT_BUFFER: 00294 if (self->Codec == JCU_STATUS_DECODE) { 00295 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINRCMD, REG_F_SET ); 00296 } else { 00297 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINRCMD, REG_F_SET ); 00298 } /* end if */ 00299 break; 00300 00301 case JCU_OUTPUT_BUFFER: 00302 if (self->Codec == JCU_STATUS_DECODE) { 00303 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTRCMD, REG_F_SET ); 00304 } else { 00305 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTRCMD, REG_F_SET ); 00306 } /* end if */ 00307 break; 00308 00309 case JCU_IMAGE_INFO: 00310 R_SET_REG_BIT_FIELD( JCU.JCCMD, JRST, REG_F_SET ); 00311 break; 00312 00313 /* ->QAC 2018 : For MISRA 15.3, SEC R3.5.2 */ 00314 default: 00315 /* <-QAC 2018 */ 00316 R_NOOP(); /* NOT REACHED */ 00317 break; 00318 } /* end switch */ 00319 00320 fin: 00321 return; 00322 } 00323 00324 /**************************************************************************//** 00325 * Function Name: [JCU_SetRegisterForSetDecodePrm] 00326 * @brief SetRegisterForSetDecod 00327 * @param[in] decode 00328 * @param[in] buffer 00329 * @param[in] interruptKind 00330 * @retval None 00331 ******************************************************************************/ 00332 void JCU_SetRegisterForSetDecodePrm( 00333 const jcu_decode_param_t *const decode, 00334 const jcu_buffer_param_t *const buffer) 00335 { 00336 const uint32_t byteSize[KIND_COLOR_FORMAT] = 00337 /* ->SEC M1.10.1 Table data. */ 00338 { 00339 2u, /* JCU_OUTPUT_YCbCr422 */ 00340 4u, /* JCU_OUTPUT_ARGB8888 */ 00341 2u /* JCU_OUTPUT_RGB565 */ 00342 }; 00343 /* <-SEC M1.10.1 */ 00344 00345 if ((decode == NULL) || (buffer == NULL)) { 00346 goto fin; 00347 } /* end if */ 00348 00349 /* Settings for the cull */ 00350 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, VINTER, decode->verticalSubSampling ); 00351 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, HINTER, decode->horizontalSubSampling ); 00352 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, OPF, decode->decodeFormat ); 00353 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, JINSWAP, buffer->source.swapSetting ); 00354 R_SET_REG_BIT_FIELD( JCU.JIFDCNT, DOUTSWAP, buffer->destination.swapSetting ); 00355 00356 /* Settings for input jpeg file information */ 00357 /* ->QAC 0306 */ 00358 JCU.JIFDSA = (uint32_t)(buffer->source.address); 00359 /* <-QAC 0306 */ 00360 /* Settings for output image data information */ 00361 /* ->QAC 0306 */ 00362 JCU.JIFDDA = (uint32_t)(buffer->destination.address); 00363 /* <-QAC 0306 */ 00364 R_SET_REG_BIT_FIELD( JCU.JIFDDOFST, DDMW, ((uint32_t)buffer->lineOffset * (uint32_t)(byteSize[decode->decodeFormat])) ); 00365 R_SET_REG_BIT_FIELD( JCU.JIFDADT, ALPHA, (uint32_t)(decode->alpha) ); 00366 00367 00368 /* Setting for Cb/Cr offset */ 00369 R_SET_REG_BIT_FIELD( JCU.JIFESHSZ, DOUTYCHG, decode->outputCbCrOffset ); 00370 fin: 00371 return; 00372 00373 } 00374 00375 /**************************************************************************//** 00376 * Function Name: [JCU_SetRegisterForSetQtTable] 00377 * @brief SetRegisterForSetQtTable 00378 * @param[in] tableNo 00379 * @param[in] table 00380 * @retval None 00381 ******************************************************************************/ 00382 void JCU_SetRegisterForSetQtTable( 00383 const jcu_table_no_t tableNo, 00384 const uint8_t *const table) 00385 { 00386 volatile uint8_t *tableAtRegister; 00387 int_fast32_t counter; 00388 00389 /* Select the destination of the Quantization table */ 00390 switch (tableNo) { 00391 /* ->QAC 0306 */ 00392 case JCU_TABLE_NO_0: 00393 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL0; 00394 break; 00395 case JCU_TABLE_NO_1: 00396 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL1; 00397 break; 00398 case JCU_TABLE_NO_2: 00399 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL2; 00400 break; 00401 case JCU_TABLE_NO_3: 00402 tableAtRegister = (volatile uint8_t *)&JCU.JCQTBL3; 00403 break; 00404 /* ->QAC 2018 : For MISRA 15.3, SEC R3.5.2 */ 00405 default: 00406 /* <-QAC 2018 */ 00407 /* NOT REACHED */ 00408 return; 00409 /* <-QAC 0306 */ 00410 } /* end switch */ 00411 00412 IF ((tableAtRegister == NULL) || (table == NULL)) { 00413 goto fin; 00414 } /* end if */ 00415 00416 /* Update the quantization table data */ 00417 for (counter = 0; counter < NUMBER_OF_QUANTIZATION_TABLE_DATA; counter++) { 00418 tableAtRegister[ counter ] = table[ counter ]; 00419 } /* end for */ 00420 fin: 00421 return; 00422 } 00423 00424 /**************************************************************************//** 00425 * Function Name: [JCU_SetRegisterForSetHuffTbl] 00426 * @brief SetRegisterForSetHuffTbl 00427 * @param[in] tableNo 00428 * @param[in] type 00429 * @param[in] table 00430 * @retval None 00431 ******************************************************************************/ 00432 void JCU_SetRegisterForSetHuffTbl( 00433 const jcu_table_no_t tableNo, 00434 const jcu_huff_t type, 00435 const uint8_t *table) 00436 { 00437 volatile uint8_t *tableAtRegister; 00438 int_fast32_t copyCount; 00439 int_fast32_t counter; 00440 00441 /* Select the destination Huffman table and the size of copy data */ 00442 if (tableNo == JCU_TABLE_NO_0) { 00443 /* ->QAC 0306 */ 00444 if (type == JCU_HUFFMAN_DC) { 00445 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBD0; 00446 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_DC; 00447 } else { 00448 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBA0; 00449 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_AC; 00450 } /* end if */ 00451 /* <-QAC 0306 */ 00452 } else { 00453 /* ->QAC 0306 */ 00454 if (type == JCU_HUFFMAN_DC) { 00455 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBD1; 00456 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_DC; 00457 } else { 00458 tableAtRegister = (volatile uint8_t *)&JCU.JCHTBA1; 00459 copyCount = NUMBER_OF_HUFFMAN_TABLE_DATA_AC; 00460 } /* end if */ 00461 /* <-QAC 0306 */ 00462 } /* end if */ 00463 00464 IF(table == NULL) { 00465 goto fin; 00466 } /* end if */ 00467 00468 /* Update the Huffman table */ 00469 for (counter = 0; counter < copyCount; counter++) { 00470 tableAtRegister[ counter ] = table[ counter ]; 00471 } /* end for */ 00472 fin: 00473 return; 00474 } 00475 00476 /**************************************************************************//** 00477 * Function Name: [JCU_SetRegisterForSetEncodePrm] 00478 * @brief SetRegisterForSetEncode 00479 * @param[in] encode 00480 * @param[in] buffer 00481 * @retval None 00482 ******************************************************************************/ 00483 void JCU_SetRegisterForSetEncodePrm( 00484 const jcu_encode_param_t *const encode, 00485 const jcu_buffer_param_t *const buffer) 00486 { 00487 jcu_jpeg_format_t encodeFormatTemp; 00488 const uint32_t byteSize[KIND_LINEOFFSET] = 00489 /* ->SEC M1.10.1 Table data. */ 00490 { 00491 0u, /* Reserved */ 00492 2u /* JCU_JPEG_YCbCr422 */ 00493 }; 00494 /* <-SEC M1.10.1 */ 00495 00496 IF ((encode == NULL) || (buffer == NULL)) { 00497 goto fin; 00498 } /* end if */ 00499 00500 /* Settings for the input image format */ 00501 R_SET_REG_BIT_FIELD( JCU.JCMOD, REDU, encode->encodeFormat ); 00502 00503 /* Settings for the quantization table */ 00504 R_SET_REG_BIT_FIELD( JCU.JCQTN, QT1, encode->QuantizationTable[JCU_ELEMENT_Y] ); 00505 R_SET_REG_BIT_FIELD( JCU.JCQTN, QT2, encode->QuantizationTable[JCU_ELEMENT_Cb] ); 00506 R_SET_REG_BIT_FIELD( JCU.JCQTN, QT3, encode->QuantizationTable[JCU_ELEMENT_Cr] ); 00507 00508 /* Settings for the Huffman table */ 00509 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTA1, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Y]) ); 00510 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTD1, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Y]) ); 00511 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTA2, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cb]) ); 00512 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTD2, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cb]) ); 00513 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTA3, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cr]) ); 00514 R_SET_REG_BIT_FIELD( JCU.JCHTN, HTD3, (uint32_t)(encode->HuffmanTable[JCU_ELEMENT_Cr]) ); 00515 00516 /* ->QAC 0306 */ 00517 JCU.JCDRIU = GET_UPPER_BYTE(encode->DRI_value); 00518 JCU.JCDRID = GET_LOWER_BYTE(encode->DRI_value); 00519 /* Settings for the image size */ 00520 /* width setting */ 00521 JCU.JCHSZU = GET_UPPER_BYTE(encode->width); 00522 JCU.JCHSZD = GET_LOWER_BYTE(encode->width); 00523 /* height setting */ 00524 JCU.JCVSZU = GET_UPPER_BYTE(encode->height); 00525 JCU.JCVSZD = GET_LOWER_BYTE(encode->height); 00526 /* <-QAC 0306 */ 00527 00528 00529 /* Settings for input jpeg file information */ 00530 R_SET_REG_BIT_FIELD( JCU.JIFECNT, DINSWAP, buffer->source.swapSetting ); 00531 00532 /* ->QAC 0306 */ 00533 JCU.JIFESA = (uint32_t)(buffer->source.address); 00534 /* <-QAC 0306 */ 00535 00536 /* Settings for output image data information */ 00537 R_SET_REG_BIT_FIELD( JCU.JIFECNT, JOUTSWAP, buffer->destination.swapSetting ); 00538 00539 /* ->QAC 0306 */ 00540 JCU.JIFEDA = (uint32_t)(buffer->destination.address); 00541 /* <-QAC 0306 */ 00542 00543 encodeFormatTemp = encode->encodeFormat; 00544 if((encodeFormatTemp != JCU_JPEG_YCbCr444) && (encodeFormatTemp != JCU_JPEG_YCbCr422)) { 00545 encodeFormatTemp = JCU_JPEG_YCbCr444; 00546 } /* end if */ 00547 00548 R_SET_REG_BIT_FIELD( JCU.JIFESOFST, ESMW, ((uint32_t)buffer->lineOffset * (uint32_t)(byteSize[encodeFormatTemp])) ); 00549 00550 /* Setting for Cb/Cr offset */ 00551 R_SET_REG_BIT_FIELD( JCU.JIFESVSZ, DINYCHG, encode->inputCbCrOffset ); 00552 fin: 00553 return; 00554 00555 } 00556 00557 /**************************************************************************//** 00558 * Function Name: [JCU_SetRegisterForSetPause] 00559 * @brief 00560 * @param[out] is_stop 00561 * @retval None 00562 ******************************************************************************/ 00563 void JCU_SetRegisterForSetPause( const bool_t is_pause, const jcu_int_detail_errors_t filter ) 00564 { 00565 /* ->QAC 0306 */ 00566 if ( IS( is_pause ) ) { 00567 JCU.JINTE0 = filter | INT3_MASK; 00568 } else { 00569 JCU.JINTE0 = filter; 00570 } 00571 /* <-QAC 0306 */ 00572 } 00573 00574 /**************************************************************************//** 00575 * Function Name: [JCU_GetRegisterForGetImageInfo] 00576 * @brief Get "jcu_image_info_t" type value 00577 * @param[out] buffer :jcu_image_info_t 00578 * @retval None 00579 ******************************************************************************/ 00580 void JCU_GetRegisterForGetImageInfo( 00581 jcu_image_info_t *const buffer) 00582 { 00583 if (buffer == NULL) { 00584 goto fin; 00585 } /* end if */ 00586 00587 /* Set the register value to the variables */ 00588 /* ->QAC 0306 */ 00589 buffer->width = ((uint32_t)JCU.JCHSZU << SHIFT_8BITS); 00590 buffer->width |= (uint32_t)JCU.JCHSZD; 00591 buffer->height = ((uint32_t)JCU.JCVSZU << SHIFT_8BITS); 00592 buffer->height |= (uint32_t)JCU.JCVSZD; 00593 buffer->encodedFormat = (jcu_jpeg_format_t)R_GET_REG_BIT_FIELD( JCU.JCMOD, REDU ); 00594 /* <-QAC 0306 */ 00595 00596 fin: 00597 return; 00598 } 00599 00600 /**************************************************************************//** 00601 * Function Name: [JCU_GetRegisterForGetErrorInfo] 00602 * @brief Get "jcu_detail_error_t" type value 00603 * @param[out] errorCode 00604 * @retval None 00605 ******************************************************************************/ 00606 static void JCU_GetRegisterForGetErrorInfo( 00607 jcu_detail_error_t *const errorCode) 00608 { 00609 if (errorCode != NULL) { 00610 /* ->QAC 0306 */ 00611 uint8_t const code = R_GET_REG_BIT_FIELD( JCU.JCDERR, ERR ); 00612 /* <-QAC 0306 */ 00613 00614 if ( (uint_fast8_t) code == 0u ) { 00615 *errorCode = JCU_JCDERR_OK; 00616 } else { 00617 *errorCode = (jcu_detail_error_t)( (int_t) code + E_CATEGORY_JCU_JCDERR ); 00618 } 00619 } /* end if */ 00620 return; 00621 } 00622 00623 /**************************************************************************//** 00624 * Function Name: [JCU_GetEncodedSize] 00625 * @brief GetEncodedSize 00626 * @param[out] out_Size 00627 * @retval None 00628 ******************************************************************************/ 00629 void JCU_GetEncodedSize( 00630 size_t *const out_Size) 00631 { 00632 if (out_Size != NULL) { 00633 /* ->QAC 0306 */ 00634 *out_Size = (((uint32_t)JCU.JCDTCU) << SHIFT_16BITS); 00635 *out_Size |= (((uint32_t)JCU.JCDTCM) << SHIFT_8BITS); 00636 *out_Size |= ((uint32_t)JCU.JCDTCD); 00637 /* <-QAC 0306 */ 00638 } /* end if */ 00639 return; 00640 } 00641 00642 /**************************************************************************//** 00643 * Function Name: [R_JCU_OnInterrupting] 00644 * @brief Operations on interrupting 00645 * @retval Error code, 0=No error 00646 ******************************************************************************/ 00647 errnum_t R_JCU_OnInterrupting( const r_ospl_interrupt_t *const InterruptSource ) 00648 { 00649 errnum_t e; 00650 uint32_t flags0; 00651 uint32_t flags1; 00652 jcu_internal_information_t *const self = R_JCU_GetInternalInformation(); 00653 00654 R_UNREFERENCED_VARIABLE( InterruptSource ); 00655 IF_DQ( self == NULL ) { 00656 e=E_OTHERS; 00657 goto fin; 00658 } 00659 00660 ASSERT_R( self->AsyncStatus.Status == JCU_STATUS_INTERRUPTING, e=E_STATE; goto fin ); 00661 00662 /* Get interrupt status */ 00663 /* ->QAC 0306 */ 00664 flags0 = JCU.JINTS0; 00665 flags1 = JCU.JINTS1; 00666 R_OSPL_FLAG32_Set( &self->AsyncStatus.InterruptFlags, flags0 ); 00667 R_OSPL_FLAG32_Set( &self->AsyncStatus.InterruptFlags, flags1 << JCU_SHIFT_JINTS1 ); 00668 00669 /* Clear interrupt status "JINTS0" */ 00670 if ( flags0 != 0u ) { 00671 R_SET_REG_BIT_FIELD( JCU.JCCMD, JEND, 1u ); 00672 JCU.JINTS0 = (uint8_t) 0u; /* Write 0 only */ 00673 } 00674 00675 /* Clear interrupt status "JINTS1" */ 00676 JCU.JINTS1 = ~flags1 & JCU_JINTS1_ALL; 00677 /* <-QAC 0306 */ 00678 00679 /* Set state */ 00680 self->AsyncStatus.Status = JCU_STATUS_INTERRUPTED; 00681 00682 e=0; 00683 fin: 00684 return e; 00685 } 00686 00687 /**************************************************************************//** 00688 * Function Name: [R_JCU_OnInterrupted] 00689 * @brief Bottom half operations on interrupting 00690 * @retval Error code, 0=No error 00691 ******************************************************************************/ 00692 errnum_t R_JCU_OnInterrupted(void) 00693 { 00694 bit_flags32_t const sub_status_bits = 00695 ( INS3_MASK ) | 00696 ( JINF_MASK << JCU_SHIFT_JINTS1 ) | 00697 ( DOUTLF_MASK << JCU_SHIFT_JINTS1 ) | 00698 ( DINLF_MASK << JCU_SHIFT_JINTS1 ) | 00699 ( JOUTF_MASK << JCU_SHIFT_JINTS1 ); 00700 00701 errnum_t e; 00702 uint32_t cancel_flag; 00703 uint32_t interrupt_flags; 00704 bool_t was_enabled = false; 00705 bool_t is_end; 00706 bool_t or; 00707 jcu_errorcode_t ej; 00708 r_ospl_async_t *notify_async_1 = NULL; 00709 r_ospl_async_t *notify_async_2 = NULL; 00710 jcu_i_lock_t *const i_lock = R_JCU_GetILockObject(); 00711 jcu_internal_information_t *const self = R_JCU_GetInternalInformation(); 00712 00713 IF_DQ( self == NULL ) { 00714 e=E_OTHERS; 00715 goto fin; 00716 } 00717 00718 was_enabled = self->I_LockVTable->Lock( self->I_Lock ); 00719 00720 ASSERT_R( self->AsyncStatus.Status != JCU_STATUS_UNDEF, e=E_STATE; goto fin ); 00721 00722 interrupt_flags = R_OSPL_FLAG32_GetAndClear( &self->AsyncStatus.InterruptFlags ); 00723 00724 00725 if ( IS_ANY_BITS_SET( interrupt_flags, sub_status_bits ) ) { 00726 if ( IS_BIT_NOT_SET( interrupt_flags, INS6_MASK ) ) { 00727 self->AsyncStatus.IsPaused = true; 00728 self->AsyncStatus.SubStatusFlags = interrupt_flags & sub_status_bits; 00729 } 00730 } 00731 00732 00733 if ( IS_ANY_BITS_SET( interrupt_flags, INS6_MASK ) ) { 00734 is_end = true; 00735 } else { 00736 is_end = false; 00737 } 00738 00739 00740 or = ( (is_end) || (self->AsyncStatus.IsPaused) ); 00741 if (!or) { 00742 or = IS_BIT_SET( interrupt_flags, INS5_MASK ); 00743 } 00744 if (IS( or )) { 00745 /* Set "AsyncStatus" */ 00746 R_OSPL_FLAG32_Clear( &self->AsyncStatus.InterruptEnables, JCU_INTERRUPT_LINE_ALL ); 00747 self->AsyncStatus.Status = JCU_STATUS_READY; 00748 notify_async_1 = self->InterruptCallbackCaller.Async; 00749 } else { 00750 self->AsyncStatus.Status = JCU_STATUS_RUN; 00751 } 00752 00753 00754 IF ( IS_BIT_SET( interrupt_flags, INS5_MASK ) ) { 00755 jcu_detail_error_t ed; 00756 00757 JCU_GetRegisterForGetErrorInfo( &ed ); 00758 e = ed; 00759 goto fin; 00760 } 00761 00762 00763 if ( notify_async_1 != NULL ) { 00764 cancel_flag = R_OSPL_FLAG32_Get( &self->AsyncStatus.CancelFlags ); 00765 if ( IS_BIT_SET( cancel_flag, R_OSPL_FINALIZE_REQUEST ) ) { 00766 notify_async_2 = self->AsyncForFinalize; 00767 ej= R_JCU_TerminateStep2(); 00768 IF ( ej != JCU_ERROR_OK ) { 00769 e=E_OTHERS; 00770 goto fin; 00771 } 00772 } 00773 } 00774 00775 e=0; 00776 fin: 00777 if ( IS( was_enabled ) ) { 00778 /* ->QAC 3353 : "self" is always assigned, if "was_enabled" is true */ 00779 IF_DQ( self == NULL ) {} /* QAC 3353 raises SEC R3.2.2 */ 00780 else { 00781 self->I_LockVTable->Unlock( self->I_Lock ); 00782 00783 if ( IS( self->Is_I_LockMaster ) ) { 00784 IF_DQ( i_lock == NULL ) {} 00785 else { 00786 if ( IS( i_lock->IsRequestedFinalize ) ) { 00787 R_JCU_I_LOCK_Finalize(); 00788 } 00789 } 00790 } 00791 } 00792 /* <-QAC 3353 */ 00793 } 00794 00795 if ( notify_async_1 != NULL ) { 00796 R_OSPL_EVENT_Set( notify_async_1->A_Thread, notify_async_1->A_EventValue ); 00797 } 00798 if ( notify_async_2 != NULL ) { 00799 R_OSPL_EVENT_Set( notify_async_2->A_Thread, notify_async_2->A_EventValue ); 00800 } 00801 00802 return e; 00803 } 00804
Generated on Tue Jul 12 2022 11:15:01 by 1.7.2