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

License

When you use this library, we judge you have agreed to the following contents.

https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Note

If you import the GraphicsFramework library, please import GR-PEACH_video library and R_BSP library together.



JPEG Converter

The JPEG Converter driver implements encode and decode functionality which uses the JCU of the RZ/A Series.

Hello World!

Import programJCU_HelloWorld

Hello World for JCU(JPEG Codec Unit). JCU is JPEG codec unit of RZ/A1. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

API

Import library

Data Structures

struct bitmap_buff_info_t
Bitmap data setting struct. More...
struct encode_options_t
Encode option setting. More...

Public Types

enum jpeg_conv_error_t {
JPEG_CONV_OK = 0, JPEG_CONV_JCU_ERR = -1, JPEG_CONV_FORMA_ERR = -2, JPEG_CONV_PARAM_ERR = -3,
JPEG_CONV_BUSY = -4, JPEG_CONV_PARAM_RANGE_ERR = -7
}

Error codes.

More...
enum wr_rd_swa_t {
WR_RD_WRSWA_NON = 0, WR_RD_WRSWA_8BIT = 1, WR_RD_WRSWA_16BIT = 2, WR_RD_WRSWA_16_8BIT = 3,
WR_RD_WRSWA_32BIT = 4, WR_RD_WRSWA_32_8BIT = 5, WR_RD_WRSWA_32_16BIT = 6, WR_RD_WRSWA_32_16_8BIT = 7
}

Write/Read image pixcel frame buffer swap setting.

More...
enum wr_rd_format_t { WR_RD_YCbCr422 = 0x00, WR_RD_ARGB8888 = 0x01, WR_RD_RGB565 = 0x02 }

Write/Read image pixcel format selects.

More...
enum sub_sampling_t { SUB_SAMPLING_1_1 = 0x00, SUB_SAMPLING_1_2 = 0x01, SUB_SAMPLING_1_4 = 0x02, SUB_SAMPLING_1_8 = 0x03 }

Thinning output image selects.

More...
enum cbcr_offset_t { CBCR_OFFSET_0 = 0x00, CBCR_OFFSET_128 = 0x01 }

Cb/Cr range selects for decode.

More...

Public Member Functions

JPEG_Converter ()
Constructor method of JPEG converter(encode/decode)
virtual ~JPEG_Converter ()
Destructor method of JPEG converter(encode/decode)
JPEG_Converter::jpeg_conv_error_t decode (void *pJpegBuff, bitmap_buff_info_t *psOutputBuff)
Decode JPEG to rinear data.
JPEG_Converter::jpeg_conv_error_t decode (void *pJpegBuff, bitmap_buff_info_t *psOutputBuff, decode_options_t *pOptions)
JPEG data decode to bitmap.
JPEG_Converter::jpeg_conv_error_t encode ( bitmap_buff_info_t *psInputBuff, void *pJpegBuff, size_t *pEncodeSize)
Encode rinear data to JPEG.
JPEG_Converter::jpeg_conv_error_t encode ( bitmap_buff_info_t *psInputBuff, void *pJpegBuff, size_t *pEncodeSize, encode_options_t *pOptions)
Bitmap data encode to JPEG.
JPEG_Converter::jpeg_conv_error_t SetQuality (const uint8_t qual)
Set encode quality.

Correspondence file

A correspondence file of JPEG Converter is as the following table.

JPEGCorrespondence
Width>0(greater than 0)
Height>0(greater than 0)
Color formatYCbCr444, YCbCr422, YCbCr420, YCbCr411
BitmapCorrespondence
Width>0(greater than 0)
Height>0(greater than 0)
Color formatYCbCr422

Notice

You run JPEG converter once destruction each time.

You set whether these JPEG files aren't input, or it check error setting decode(set in "flag" = true). The JPEG file which becomes correspondence outside will be the following condition.

  • File besides the above-mentioned correspondence file.
  • As information in the JPEG file, WIDTH or HEIGHT is larger than output buffer setting.

Buffer area is used encode/decode, set 8 bytes align and non-cash memory area. The output buffer when decoding, is made beyond the size decided in the size of the JPEG file, the format, setting of thinning out. You make output buffer for decode/encode to enough big size in order to stock this result. JPEG Converter, if you do not particularly perform specified, does not check size against the output data at the time of encoding and decoding. You set the output buffer so that there is no effect of corruption by the output data.

Color format

Color format in case to be converted from Bitmap to JPEG is either ARGB8888 or RGB555, YCbCr422. Color format of the If you want to convert from JPEG file to Bitmap file is YCbCr422. You correct "alpha(member of decode_options_t)" of setting and "output_cb_cr_offset(member of decode_options_t)" according to color format when decoding.

  • example
    decode to ARGB8888(WR_RD_ARGB8888 set in format member of bitmap_buff_info_t)
    alpha = 0x01-0xFF
    output_cb_cr_offset = CBCR_OFFSET_0

    decode to YCbCr422(WR_RD_YCbCr422 set in format member of bitmap_buff_info_t)
    alpha = 0
    output_cb_cr_offset = CBCR_OFFSET_0 or CBCR_OFFSET_128

    decode to RGB565(WR_RD_RGB565 set in format member of bitmap_buff_info_t)
    alpha = 0
    output_cb_cr_offset = CBCR_OFFSET_0

Decode/encode settings are optional

If omitted encode/decode settings, it will work with the following settings.
[Decode option setting (member of decode_options_t)]

  • Vertical sub sampling is thinning output image to 1/1.
  • Horizontal sub sampling is thinning output image to 1/1.
  • Output data of Cb/Cr range is -128 to 127.
  • Output data of swap in 8-bit units: 2-1-4-3-6-5-8-7.
  • Alpha value of 0.
  • JPEG format correspondence outside error check.
  • It decode in a synchronous function.

[Encode option setting (member of encode_options_t)]

  • DRI value is 0.
  • Encoding JPEG file start width offset is 0.
  • Encoding JPEG file start height offset is 0.
  • Input data of Cb/Cr range of input data is -128 to 127.
  • Input data swap in 8-bit units: 2-1-4-3-6-5-8-7.
  • It don't check encode size.
  • Quantization Y use default table(Quality75).
  • Quantization C use default table(Quality75).
  • Huffman Y DC use default table.
  • Huffman C DC use default table.
  • Huffman Y AC use default table.
  • Huffman C AC use default table.
  • It encode in a synchronous function.

Synchronous/asynchronous switching

Decoding and encoding setting to operate asynchronously by setting a callback function(decode_options_t and encode_options_t).

Quality

Quality changes are possible. If you want to change the Quality, please specify the table made of Quality you want to change the address of the setting. If you do not want to change the Quality, it will operate at Quality75.

RGA

The RGA library implements fast drawing functionality which uses the RGA of the RZ/A Series.
Supporting compiler is ARMCC, GCC ARM and IAR.

Hello World!

Import programRGA_HelloWorld

Hello World for RGA(Renesas Graphics Architecture). RGA is the Graphics Library of RZ/A1. When you use this program, we judge you have agreed to the following contents. https://developer.mbed.org/teams/Renesas/wiki/About-LICENSE

Committer:
dkato
Date:
Mon Apr 24 08:16:23 2017 +0000
Revision:
13:1ee2176ef13f
Parent:
0:37e1e6a45ced
Add "SetQuality()" to JCU.
; Bug fixes.

Who changed what in which revision?

UserRevisionLine numberNew contents of line
dkato 0:37e1e6a45ced 1 /*******************************************************************************
dkato 0:37e1e6a45ced 2 * DISCLAIMER
dkato 0:37e1e6a45ced 3 * This software is supplied by Renesas Electronics Corporation and is only
dkato 0:37e1e6a45ced 4 * intended for use with Renesas products. No other uses are authorized. This
dkato 0:37e1e6a45ced 5 * software is owned by Renesas Electronics Corporation and is protected under
dkato 0:37e1e6a45ced 6 * all applicable laws, including copyright laws.
dkato 0:37e1e6a45ced 7 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
dkato 0:37e1e6a45ced 8 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
dkato 0:37e1e6a45ced 9 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
dkato 0:37e1e6a45ced 10 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
dkato 0:37e1e6a45ced 11 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
dkato 0:37e1e6a45ced 12 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
dkato 0:37e1e6a45ced 13 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
dkato 0:37e1e6a45ced 14 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
dkato 0:37e1e6a45ced 15 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
dkato 0:37e1e6a45ced 16 * Renesas reserves the right, without notice, to make changes to this software
dkato 0:37e1e6a45ced 17 * and to discontinue the availability of this software. By using this software,
dkato 0:37e1e6a45ced 18 * you agree to the additional terms and conditions found by accessing the
dkato 0:37e1e6a45ced 19 * following link:
dkato 0:37e1e6a45ced 20 * http://www.renesas.com/disclaimer
dkato 0:37e1e6a45ced 21 * Copyright (C) 2012 - 2015 Renesas Electronics Corporation. All rights reserved.
dkato 0:37e1e6a45ced 22 *******************************************************************************/
dkato 0:37e1e6a45ced 23 /*******************************************************************************
dkato 0:37e1e6a45ced 24 * $FileName: jcu_api.c $
dkato 0:37e1e6a45ced 25 * $Module: JCU $ $PublicVersion: 1.00 $ (=JCU_VERSION)
dkato 0:37e1e6a45ced 26 * $Rev: 35 $
dkato 0:37e1e6a45ced 27 * $Date:: 2014-02-26 13:18:53 +0900#$
dkato 0:37e1e6a45ced 28 * Description : JCU driver API
dkato 0:37e1e6a45ced 29 ******************************************************************************/
dkato 0:37e1e6a45ced 30 /**
dkato 0:37e1e6a45ced 31 * @file jcu_api.c
dkato 0:37e1e6a45ced 32 * @brief JCU (JPEG hardware) driver API. Main Code.
dkato 0:37e1e6a45ced 33 *
dkato 0:37e1e6a45ced 34 * $Module: JCU $ $PublicVersion: 1.00 $ (=JCU_VERSION)
dkato 0:37e1e6a45ced 35 * $Rev: 38 $
dkato 0:37e1e6a45ced 36 * $Date:: 2014-03-18 16:14:45 +0900#$
dkato 0:37e1e6a45ced 37 */
dkato 0:37e1e6a45ced 38
dkato 0:37e1e6a45ced 39 /******************************************************************************
dkato 0:37e1e6a45ced 40 Includes <System Includes> , "Project Includes"
dkato 0:37e1e6a45ced 41 ******************************************************************************/
dkato 0:37e1e6a45ced 42 #include <string.h>
dkato 0:37e1e6a45ced 43 #include "r_typedefs.h"
dkato 0:37e1e6a45ced 44 #include "iodefine.h"
dkato 0:37e1e6a45ced 45 #include "r_ospl.h"
dkato 0:37e1e6a45ced 46 #include "r_jcu_api.h"
dkato 0:37e1e6a45ced 47 #include "r_jcu_local.h"
dkato 0:37e1e6a45ced 48 #include "r_jcu_pl.h"
dkato 0:37e1e6a45ced 49
dkato 0:37e1e6a45ced 50 /******************************************************************************
dkato 0:37e1e6a45ced 51 Typedef definitions
dkato 0:37e1e6a45ced 52 ******************************************************************************/
dkato 0:37e1e6a45ced 53
dkato 0:37e1e6a45ced 54 /******************************************************************************
dkato 0:37e1e6a45ced 55 Macro definitions
dkato 0:37e1e6a45ced 56 ******************************************************************************/
dkato 0:37e1e6a45ced 57
dkato 0:37e1e6a45ced 58 /******************************************************************************
dkato 0:37e1e6a45ced 59 Imported global variables and functions (from other files)
dkato 0:37e1e6a45ced 60 ******************************************************************************/
dkato 0:37e1e6a45ced 61
dkato 0:37e1e6a45ced 62 /******************************************************************************
dkato 0:37e1e6a45ced 63 Exported global variables and functions (to be accessed by other files)
dkato 0:37e1e6a45ced 64 ******************************************************************************/
dkato 0:37e1e6a45ced 65 /* Section: Internal Global */
dkato 0:37e1e6a45ced 66
dkato 0:37e1e6a45ced 67 /** gs_jcu_internal_information */
dkato 0:37e1e6a45ced 68 static jcu_internal_information_t gs_jcu_internal_information;
dkato 0:37e1e6a45ced 69
dkato 0:37e1e6a45ced 70
dkato 0:37e1e6a45ced 71 /** gs_jcu_i_lock */
dkato 0:37e1e6a45ced 72 static jcu_i_lock_t gs_jcu_i_lock;
dkato 0:37e1e6a45ced 73
dkato 0:37e1e6a45ced 74
dkato 0:37e1e6a45ced 75 /******************************************************************************
dkato 0:37e1e6a45ced 76 Private global variables and functions
dkato 0:37e1e6a45ced 77 ******************************************************************************/
dkato 0:37e1e6a45ced 78
dkato 0:37e1e6a45ced 79 /***********************************************************************
dkato 0:37e1e6a45ced 80 * Class: jcu_i_lock_t
dkato 0:37e1e6a45ced 81 ************************************************************************/
dkato 0:37e1e6a45ced 82 static void R_JCU_I_LOCK_Reset( jcu_i_lock_t *const self );
dkato 0:37e1e6a45ced 83 static bool_t R_JCU_I_LOCK_Lock( void *const self_ );
dkato 0:37e1e6a45ced 84 static void R_JCU_I_LOCK_Unlock( void *const self_ );
dkato 0:37e1e6a45ced 85 static void R_JCU_I_LOCK_RequestFinalize( void *const self_ );
dkato 0:37e1e6a45ced 86 static int_fast32_t R_JCU_I_LOCK_GetRootChannelNum( const void *const self_ );
dkato 0:37e1e6a45ced 87
dkato 0:37e1e6a45ced 88
dkato 0:37e1e6a45ced 89 /* Section: Global */
dkato 0:37e1e6a45ced 90 /**
dkato 0:37e1e6a45ced 91 * @brief Initialize the driver
dkato 0:37e1e6a45ced 92 *
dkato 0:37e1e6a45ced 93 * @param NullConfig (in) NULL
dkato 0:37e1e6a45ced 94 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 95 */
dkato 0:37e1e6a45ced 96 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 97 jcu_errorcode_t R_JCU_Initialize( void *const NullConfig )
dkato 0:37e1e6a45ced 98 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 99 {
dkato 0:37e1e6a45ced 100 errnum_t e;
dkato 0:37e1e6a45ced 101 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 102 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 103
dkato 0:37e1e6a45ced 104 static const r_ospl_i_lock_vtable_t gs_I_LockVTable = {
dkato 0:37e1e6a45ced 105 &( R_JCU_I_LOCK_Lock ), /* MISRA 16.9 */
dkato 0:37e1e6a45ced 106 &( R_JCU_I_LOCK_Unlock ),
dkato 0:37e1e6a45ced 107 &( R_JCU_I_LOCK_RequestFinalize ),
dkato 0:37e1e6a45ced 108 &( R_JCU_I_LOCK_GetRootChannelNum )
dkato 0:37e1e6a45ced 109 };
dkato 0:37e1e6a45ced 110
dkato 0:37e1e6a45ced 111 R_UNREFERENCED_VARIABLE( NullConfig );
dkato 0:37e1e6a45ced 112 R_IT_WILL_BE_NOT_CONST( NullConfig );
dkato 0:37e1e6a45ced 113
dkato 0:37e1e6a45ced 114 if ( self->I_Lock == NULL ) {
dkato 0:37e1e6a45ced 115 jcu_i_lock_t *const i_lock = &gs_jcu_i_lock;
dkato 0:37e1e6a45ced 116
dkato 0:37e1e6a45ced 117 self->Is_I_LockMaster = R_JCU_I_LOCK_Replace(
dkato 0:37e1e6a45ced 118 i_lock, &gs_I_LockVTable );
dkato 0:37e1e6a45ced 119 }
dkato 0:37e1e6a45ced 120
dkato 0:37e1e6a45ced 121 if ( IS( self->Is_I_LockMaster ) ) {
dkato 0:37e1e6a45ced 122 R_JCU_I_LOCK_Reset( self->I_Lock );
dkato 0:37e1e6a45ced 123 }
dkato 0:37e1e6a45ced 124 R_OSPL_FLAG32_InitConst( &self->AsyncStatus.InterruptFlags );
dkato 0:37e1e6a45ced 125 R_OSPL_FLAG32_InitConst( &self->AsyncStatus.InterruptEnables );
dkato 0:37e1e6a45ced 126 R_OSPL_FLAG32_InitConst( &self->AsyncStatus.CancelFlags );
dkato 0:37e1e6a45ced 127 self->AsyncStatus.IsEnabledInterrupt = false;
dkato 0:37e1e6a45ced 128
dkato 0:37e1e6a45ced 129 /* Error check */
dkato 0:37e1e6a45ced 130 if (self->AsyncStatus.Status != JCU_STATUS_UNDEF) {
dkato 0:37e1e6a45ced 131 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 132 goto fin;
dkato 0:37e1e6a45ced 133 } /* end if */
dkato 0:37e1e6a45ced 134
dkato 0:37e1e6a45ced 135 /* Run the User-defined function if user set the function */
dkato 0:37e1e6a45ced 136 e= R_JCU_OnInitialize();
dkato 0:37e1e6a45ced 137 IF ( e != 0 ) {
dkato 0:37e1e6a45ced 138 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 139 goto fin;
dkato 0:37e1e6a45ced 140 }
dkato 0:37e1e6a45ced 141
dkato 0:37e1e6a45ced 142 /* Initialize the variable */
dkato 0:37e1e6a45ced 143 self->AsyncStatus.IsPaused = false;
dkato 0:37e1e6a45ced 144 self->AsyncStatus.SubStatusFlags = 0;
dkato 0:37e1e6a45ced 145 self->IsCountMode = false;
dkato 0:37e1e6a45ced 146 self->ErrorFilter = JCU_INT_ERROR_ALL;
dkato 0:37e1e6a45ced 147 self->AsyncForFinalize = NULL;
dkato 0:37e1e6a45ced 148
dkato 0:37e1e6a45ced 149 /* Set the register */
dkato 0:37e1e6a45ced 150 returnValue = JCU_SetRegisterForInitialize();
dkato 0:37e1e6a45ced 151
dkato 0:37e1e6a45ced 152 if (returnValue == JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 153 /* Set the updated status */
dkato 0:37e1e6a45ced 154 self->AsyncStatus.Status = JCU_STATUS_INIT;
dkato 0:37e1e6a45ced 155
dkato 0:37e1e6a45ced 156 /* Initialize the status for the encode */
dkato 0:37e1e6a45ced 157 self->Codec = JCU_CODEC_NOT_SELECTED;
dkato 0:37e1e6a45ced 158 } /* end if */
dkato 0:37e1e6a45ced 159
dkato 0:37e1e6a45ced 160 fin:
dkato 0:37e1e6a45ced 161 return returnValue;
dkato 0:37e1e6a45ced 162 }
dkato 0:37e1e6a45ced 163
dkato 0:37e1e6a45ced 164
dkato 0:37e1e6a45ced 165 /**
dkato 0:37e1e6a45ced 166 * @brief Terminate the driver function
dkato 0:37e1e6a45ced 167 *
dkato 0:37e1e6a45ced 168 * @par Parameters
dkato 0:37e1e6a45ced 169 * None
dkato 0:37e1e6a45ced 170 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 171 */
dkato 0:37e1e6a45ced 172 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 173 jcu_errorcode_t R_JCU_Terminate(void)
dkato 0:37e1e6a45ced 174 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 175 {
dkato 0:37e1e6a45ced 176 errnum_t e;
dkato 0:37e1e6a45ced 177 jcu_errorcode_t ej;
dkato 0:37e1e6a45ced 178 r_ospl_async_t async;
dkato 0:37e1e6a45ced 179 bit_flags32_t got_flags;
dkato 0:37e1e6a45ced 180
dkato 0:37e1e6a45ced 181 async.Flags = R_F_OSPL_A_Thread;
dkato 0:37e1e6a45ced 182 async.A_Thread = R_OSPL_THREAD_GetCurrentId();
dkato 0:37e1e6a45ced 183
dkato 0:37e1e6a45ced 184 ej= R_JCU_TerminateAsync( &async );
dkato 0:37e1e6a45ced 185 IF( ej != JCU_ERROR_OK ) {
dkato 0:37e1e6a45ced 186 goto fin;
dkato 0:37e1e6a45ced 187 }
dkato 0:37e1e6a45ced 188
dkato 0:37e1e6a45ced 189 e= R_OSPL_EVENT_Wait( async.A_EventValue, &got_flags, R_OSPL_INFINITE );
dkato 0:37e1e6a45ced 190 IF(e!=0) {
dkato 0:37e1e6a45ced 191 ej=JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 192 goto fin;
dkato 0:37e1e6a45ced 193 }
dkato 0:37e1e6a45ced 194
dkato 0:37e1e6a45ced 195 e= async.ReturnValue;
dkato 0:37e1e6a45ced 196 IF(e!=0) {
dkato 0:37e1e6a45ced 197 ej=JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 198 goto fin;
dkato 0:37e1e6a45ced 199 }
dkato 0:37e1e6a45ced 200
dkato 0:37e1e6a45ced 201 fin:
dkato 0:37e1e6a45ced 202 return ej;
dkato 0:37e1e6a45ced 203 }
dkato 0:37e1e6a45ced 204
dkato 0:37e1e6a45ced 205
dkato 0:37e1e6a45ced 206 /**
dkato 0:37e1e6a45ced 207 * @brief Terminate the driver function
dkato 0:37e1e6a45ced 208 *
dkato 0:37e1e6a45ced 209 * @param async <r_ospl_async_t>
dkato 0:37e1e6a45ced 210 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 211 */
dkato 0:37e1e6a45ced 212 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 213 jcu_errorcode_t R_JCU_TerminateAsync( r_ospl_async_t *const async )
dkato 0:37e1e6a45ced 214 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 215 {
dkato 0:37e1e6a45ced 216 jcu_errorcode_t returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 217 bool_t was_enabled = false;
dkato 0:37e1e6a45ced 218 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 219
dkato 0:37e1e6a45ced 220 IF_DQ( async == NULL ) {
dkato 0:37e1e6a45ced 221 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 222 goto fin;
dkato 0:37e1e6a45ced 223 }
dkato 0:37e1e6a45ced 224
dkato 0:37e1e6a45ced 225 R_JCU_SetDefaultAsync( async, R_OSPL_ASYNC_TYPE_FINALIZE );
dkato 0:37e1e6a45ced 226 async->ReturnValue = 0;
dkato 0:37e1e6a45ced 227
dkato 0:37e1e6a45ced 228 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 229
dkato 0:37e1e6a45ced 230 /* Check the status */
dkato 0:37e1e6a45ced 231 if ( self->AsyncStatus.Status == JCU_STATUS_UNDEF ) {
dkato 0:37e1e6a45ced 232 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 233 goto fin;
dkato 0:37e1e6a45ced 234 } /* end if */
dkato 0:37e1e6a45ced 235
dkato 0:37e1e6a45ced 236 if ( self->AsyncStatus.Status == JCU_STATUS_RUN ) {
dkato 0:37e1e6a45ced 237 self->AsyncForFinalize = async;
dkato 0:37e1e6a45ced 238
dkato 0:37e1e6a45ced 239 R_OSPL_FLAG32_Set( &self->AsyncStatus.CancelFlags, R_OSPL_FINALIZE_REQUEST );
dkato 0:37e1e6a45ced 240
dkato 0:37e1e6a45ced 241 /* "R_JCU_OnInterrupted" will be called */
dkato 0:37e1e6a45ced 242 } else {
dkato 0:37e1e6a45ced 243 returnValue = R_JCU_TerminateStep2();
dkato 0:37e1e6a45ced 244 R_OSPL_EVENT_Set( async->A_Thread, async->A_EventValue );
dkato 0:37e1e6a45ced 245 } /* end if */
dkato 0:37e1e6a45ced 246
dkato 0:37e1e6a45ced 247 fin:
dkato 0:37e1e6a45ced 248 /* Finalize I-Lock */
dkato 0:37e1e6a45ced 249 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 250 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 251
dkato 0:37e1e6a45ced 252 if ( IS( self->Is_I_LockMaster ) ) {
dkato 0:37e1e6a45ced 253 if ( IS( gs_jcu_i_lock.IsRequestedFinalize ) ) {
dkato 0:37e1e6a45ced 254 R_JCU_I_LOCK_Finalize();
dkato 0:37e1e6a45ced 255 }
dkato 0:37e1e6a45ced 256 }
dkato 0:37e1e6a45ced 257 }
dkato 0:37e1e6a45ced 258 return returnValue;
dkato 0:37e1e6a45ced 259 }
dkato 0:37e1e6a45ced 260
dkato 0:37e1e6a45ced 261
dkato 0:37e1e6a45ced 262 /**
dkato 0:37e1e6a45ced 263 * @brief Terminate the driver function
dkato 0:37e1e6a45ced 264 *
dkato 0:37e1e6a45ced 265 * @par Parameters
dkato 0:37e1e6a45ced 266 * None
dkato 0:37e1e6a45ced 267 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 268 */
dkato 0:37e1e6a45ced 269 jcu_errorcode_t R_JCU_TerminateStep2(void)
dkato 0:37e1e6a45ced 270 {
dkato 0:37e1e6a45ced 271 errnum_t ee;
dkato 0:37e1e6a45ced 272 jcu_errorcode_t returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 273 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 274
dkato 0:37e1e6a45ced 275 R_AVOID_UNSAFE_ALWAYS_WARNING( returnValue );
dkato 0:37e1e6a45ced 276
dkato 0:37e1e6a45ced 277
dkato 0:37e1e6a45ced 278 /* Set the updated status */
dkato 0:37e1e6a45ced 279 R_OSPL_FLAG32_Clear( &self->AsyncStatus.CancelFlags, R_OSPL_FLAG32_ALL_BITS );
dkato 0:37e1e6a45ced 280 self->AsyncStatus.Status = JCU_STATUS_UNDEF;
dkato 0:37e1e6a45ced 281 self->I_LockVTable->RequestFinalize( self->I_Lock );
dkato 0:37e1e6a45ced 282
dkato 0:37e1e6a45ced 283
dkato 0:37e1e6a45ced 284 /* Run the additional function selected by parameter */
dkato 0:37e1e6a45ced 285 ee= R_JCU_OnFinalize( returnValue );
dkato 0:37e1e6a45ced 286 IF ( (ee != 0) && (returnValue == JCU_ERROR_OK) ) {
dkato 0:37e1e6a45ced 287 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 288 }
dkato 0:37e1e6a45ced 289
dkato 0:37e1e6a45ced 290 return returnValue;
dkato 0:37e1e6a45ced 291 }
dkato 0:37e1e6a45ced 292
dkato 0:37e1e6a45ced 293
dkato 0:37e1e6a45ced 294 /**
dkato 0:37e1e6a45ced 295 * @brief Select Codec Type
dkato 0:37e1e6a45ced 296 *
dkato 0:37e1e6a45ced 297 * @param codec <jcu_codec_t>
dkato 0:37e1e6a45ced 298 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 299 */
dkato 0:37e1e6a45ced 300 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 301 jcu_errorcode_t R_JCU_SelectCodec(
dkato 0:37e1e6a45ced 302 const jcu_codec_t codec)
dkato 0:37e1e6a45ced 303 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 304 {
dkato 0:37e1e6a45ced 305 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 306 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 307 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 308
dkato 0:37e1e6a45ced 309 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 310
dkato 0:37e1e6a45ced 311 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 312 IF ((self->AsyncStatus.Status == JCU_STATUS_UNDEF)
dkato 0:37e1e6a45ced 313 || (self->AsyncStatus.Status == JCU_STATUS_RUN)) {
dkato 0:37e1e6a45ced 314 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 315 goto fin;
dkato 0:37e1e6a45ced 316 } /* end if */
dkato 0:37e1e6a45ced 317
dkato 0:37e1e6a45ced 318 returnValue = JCU_ParaCheckSelectCodec(codec);
dkato 0:37e1e6a45ced 319 IF (returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 320 goto fin;
dkato 0:37e1e6a45ced 321 }
dkato 0:37e1e6a45ced 322 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 323
dkato 0:37e1e6a45ced 324 /* Clear the count mode flag */
dkato 0:37e1e6a45ced 325 self->IsCountMode = false;
dkato 0:37e1e6a45ced 326
dkato 0:37e1e6a45ced 327 /* Register set */
dkato 0:37e1e6a45ced 328 JCU_SetRegisterForCodec(codec);
dkato 0:37e1e6a45ced 329
dkato 0:37e1e6a45ced 330 /* Set the updated status */
dkato 0:37e1e6a45ced 331 self->AsyncStatus.Status = JCU_STATUS_SELECTED;
dkato 0:37e1e6a45ced 332
dkato 0:37e1e6a45ced 333 /* Set codec type to internal information variable */
dkato 0:37e1e6a45ced 334 switch (codec) {
dkato 0:37e1e6a45ced 335 case JCU_ENCODE:
dkato 0:37e1e6a45ced 336 self->Codec = JCU_STATUS_ENCODE;
dkato 0:37e1e6a45ced 337 break;
dkato 0:37e1e6a45ced 338 case JCU_DECODE:
dkato 0:37e1e6a45ced 339 self->Codec = JCU_STATUS_DECODE;
dkato 0:37e1e6a45ced 340 break;
dkato 0:37e1e6a45ced 341 /* ->QAC 2018 : For MISRA 15.3, SEC R3.5.2 */
dkato 0:37e1e6a45ced 342 default:
dkato 0:37e1e6a45ced 343 /* <-QAC 2018 */
dkato 0:37e1e6a45ced 344 R_NOOP(); /* NOT REACHED */
dkato 0:37e1e6a45ced 345 break;
dkato 0:37e1e6a45ced 346 } /* end switch */
dkato 0:37e1e6a45ced 347
dkato 0:37e1e6a45ced 348 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 349 fin:
dkato 0:37e1e6a45ced 350 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 351 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 352 }
dkato 0:37e1e6a45ced 353 return returnValue;
dkato 0:37e1e6a45ced 354 }
dkato 0:37e1e6a45ced 355
dkato 0:37e1e6a45ced 356
dkato 0:37e1e6a45ced 357 /**
dkato 0:37e1e6a45ced 358 * @brief Start decoding or encoding. Synchronized.
dkato 0:37e1e6a45ced 359 *
dkato 0:37e1e6a45ced 360 * @par Parameters
dkato 0:37e1e6a45ced 361 * None
dkato 0:37e1e6a45ced 362 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 363 */
dkato 0:37e1e6a45ced 364 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 365 jcu_errorcode_t R_JCU_Start(
dkato 0:37e1e6a45ced 366 void)
dkato 0:37e1e6a45ced 367 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 368 {
dkato 0:37e1e6a45ced 369 errnum_t e;
dkato 0:37e1e6a45ced 370 jcu_errorcode_t ej;
dkato 0:37e1e6a45ced 371 r_ospl_async_t async;
dkato 0:37e1e6a45ced 372 bit_flags32_t got_flags;
dkato 0:37e1e6a45ced 373
dkato 0:37e1e6a45ced 374 async.Flags = R_F_OSPL_A_Thread;
dkato 0:37e1e6a45ced 375 async.A_Thread = R_OSPL_THREAD_GetCurrentId();
dkato 0:37e1e6a45ced 376
dkato 0:37e1e6a45ced 377 ej= R_JCU_StartAsync( &async );
dkato 0:37e1e6a45ced 378 IF( ej != JCU_ERROR_OK ) {
dkato 0:37e1e6a45ced 379 goto fin;
dkato 0:37e1e6a45ced 380 }
dkato 0:37e1e6a45ced 381
dkato 0:37e1e6a45ced 382 e= R_OSPL_EVENT_Wait( async.A_EventValue, &got_flags, R_OSPL_INFINITE );
dkato 0:37e1e6a45ced 383 IF(e!=0) {
dkato 0:37e1e6a45ced 384 ej=e;
dkato 0:37e1e6a45ced 385 goto fin;
dkato 0:37e1e6a45ced 386 }
dkato 0:37e1e6a45ced 387
dkato 0:37e1e6a45ced 388 e= async.ReturnValue;
dkato 0:37e1e6a45ced 389 IF(e!=0) {
dkato 0:37e1e6a45ced 390 ej=e;
dkato 0:37e1e6a45ced 391 goto fin;
dkato 0:37e1e6a45ced 392 }
dkato 0:37e1e6a45ced 393
dkato 0:37e1e6a45ced 394 fin:
dkato 0:37e1e6a45ced 395 return ej;
dkato 0:37e1e6a45ced 396 }
dkato 0:37e1e6a45ced 397
dkato 0:37e1e6a45ced 398
dkato 0:37e1e6a45ced 399 /**
dkato 0:37e1e6a45ced 400 * @brief Start decoding or encoding. Asynchronized.
dkato 0:37e1e6a45ced 401 *
dkato 0:37e1e6a45ced 402 * @par Parameters
dkato 0:37e1e6a45ced 403 * None
dkato 0:37e1e6a45ced 404 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 405 */
dkato 0:37e1e6a45ced 406 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 407 jcu_errorcode_t R_JCU_StartAsync(
dkato 0:37e1e6a45ced 408 r_ospl_async_t *const async)
dkato 0:37e1e6a45ced 409 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 410 {
dkato 0:37e1e6a45ced 411 errnum_t e;
dkato 0:37e1e6a45ced 412 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 413 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 414 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 415
dkato 0:37e1e6a45ced 416 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 417
dkato 0:37e1e6a45ced 418 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 419 IF (self->AsyncStatus.Status != JCU_STATUS_READY) {
dkato 0:37e1e6a45ced 420 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 421 goto fin;
dkato 0:37e1e6a45ced 422 } /* end if */
dkato 0:37e1e6a45ced 423
dkato 0:37e1e6a45ced 424 returnValue = JCU_ParaCheckStart();
dkato 0:37e1e6a45ced 425 IF(returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 426 goto fin;
dkato 0:37e1e6a45ced 427 } /* end if */
dkato 0:37e1e6a45ced 428
dkato 0:37e1e6a45ced 429 IF ( async == NULL ) {
dkato 0:37e1e6a45ced 430 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 431 goto fin;
dkato 0:37e1e6a45ced 432 } /* end if */
dkato 0:37e1e6a45ced 433 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 434
dkato 0:37e1e6a45ced 435 R_JCU_SetDefaultAsync( async, R_OSPL_ASYNC_TYPE_NORMAL );
dkato 0:37e1e6a45ced 436 async->ReturnValue = 0;
dkato 0:37e1e6a45ced 437
dkato 0:37e1e6a45ced 438 /* Attach "Async" to interrupt */
dkato 0:37e1e6a45ced 439 /* ->MISRA 11.4 : Not too big "enum" is same bit count as "int" */ /* ->SEC R2.7.1 */
dkato 0:37e1e6a45ced 440 R_OSPL_CALLER_Initialize( &self->InterruptCallbackCaller,
dkato 0:37e1e6a45ced 441 async, (int_fast32_t *)&self->AsyncStatus.Status, JCU_STATUS_INTERRUPTING,
dkato 0:37e1e6a45ced 442 self->I_Lock, self->I_LockVTable );
dkato 0:37e1e6a45ced 443 /* <-MISRA 11.4 */ /* <-SEC R2.7.1 */
dkato 0:37e1e6a45ced 444 e= R_JCU_SetInterruptCallbackCaller( &self->InterruptCallbackCaller );
dkato 0:37e1e6a45ced 445 IF ( e != 0 ) {
dkato 0:37e1e6a45ced 446 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 447 goto fin;
dkato 0:37e1e6a45ced 448 }
dkato 0:37e1e6a45ced 449 R_OSPL_FLAG32_Set( &self->AsyncStatus.InterruptEnables, JCU_INTERRUPT_LINE_ALL );
dkato 0:37e1e6a45ced 450
dkato 0:37e1e6a45ced 451 /* Clear event flags */
dkato 0:37e1e6a45ced 452 R_OSPL_EVENT_Clear( async->A_Thread, async->A_EventValue );
dkato 0:37e1e6a45ced 453 R_OSPL_EVENT_Clear( async->I_Thread, async->I_EventValue );
dkato 0:37e1e6a45ced 454
dkato 0:37e1e6a45ced 455 /* Set the updated status when register update is finished */
dkato 0:37e1e6a45ced 456 /* Change the status */
dkato 0:37e1e6a45ced 457 self->AsyncStatus.Status = JCU_STATUS_RUN;
dkato 0:37e1e6a45ced 458
dkato 0:37e1e6a45ced 459 /* Register set */
dkato 0:37e1e6a45ced 460 JCU_SetRegisterForStart( self->ErrorFilter );
dkato 0:37e1e6a45ced 461
dkato 0:37e1e6a45ced 462 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 463 fin:
dkato 0:37e1e6a45ced 464 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 465 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 466 }
dkato 0:37e1e6a45ced 467 return returnValue;
dkato 0:37e1e6a45ced 468 }
dkato 0:37e1e6a45ced 469
dkato 0:37e1e6a45ced 470
dkato 0:37e1e6a45ced 471 /**
dkato 0:37e1e6a45ced 472 * @brief Set the count mode (separate operating) parameter
dkato 0:37e1e6a45ced 473 *
dkato 0:37e1e6a45ced 474 * @param buffer <jcu_count_mode_param_t>
dkato 0:37e1e6a45ced 475 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 476 */
dkato 0:37e1e6a45ced 477 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 478 jcu_errorcode_t R_JCU_SetCountMode(
dkato 0:37e1e6a45ced 479 const jcu_count_mode_param_t *const buffer)
dkato 0:37e1e6a45ced 480 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 481 {
dkato 0:37e1e6a45ced 482 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 483 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 484 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 485
dkato 0:37e1e6a45ced 486 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 487
dkato 0:37e1e6a45ced 488 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 489 IF (!((self->AsyncStatus.Status == JCU_STATUS_SELECTED)
dkato 0:37e1e6a45ced 490 || (self->AsyncStatus.Status == JCU_STATUS_READY))) {
dkato 0:37e1e6a45ced 491 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 492 goto fin;
dkato 0:37e1e6a45ced 493 } /* end if */
dkato 0:37e1e6a45ced 494
dkato 0:37e1e6a45ced 495 IF(buffer == NULL) {
dkato 0:37e1e6a45ced 496 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 497 goto fin;
dkato 0:37e1e6a45ced 498 } /* end if */
dkato 0:37e1e6a45ced 499
dkato 0:37e1e6a45ced 500 returnValue = JCU_ParaCheckSetCountMode(buffer);
dkato 0:37e1e6a45ced 501 IF(returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 502 goto fin;
dkato 0:37e1e6a45ced 503 } /* end if */
dkato 0:37e1e6a45ced 504 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 505
dkato 0:37e1e6a45ced 506 /* Set the count mode flag */
dkato 0:37e1e6a45ced 507 if ((buffer->inputBuffer.isEnable != false) || (buffer->outputBuffer.isEnable != false)) {
dkato 0:37e1e6a45ced 508 self->IsCountMode = true;
dkato 0:37e1e6a45ced 509 } else {
dkato 0:37e1e6a45ced 510 self->IsCountMode = false;
dkato 0:37e1e6a45ced 511 } /* end if */
dkato 0:37e1e6a45ced 512
dkato 0:37e1e6a45ced 513 /* Register set */
dkato 0:37e1e6a45ced 514 JCU_SetRegisterForSetCountMode(buffer);
dkato 0:37e1e6a45ced 515
dkato 0:37e1e6a45ced 516 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 517 fin:
dkato 0:37e1e6a45ced 518 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 519 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 520 }
dkato 0:37e1e6a45ced 521 return returnValue;
dkato 0:37e1e6a45ced 522 }
dkato 0:37e1e6a45ced 523
dkato 0:37e1e6a45ced 524
dkato 0:37e1e6a45ced 525 /**
dkato 0:37e1e6a45ced 526 * @brief Restart the processing caused by count mode. Synchronized.
dkato 0:37e1e6a45ced 527 *
dkato 0:37e1e6a45ced 528 * @param type The target to continue
dkato 0:37e1e6a45ced 529 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 530 */
dkato 0:37e1e6a45ced 531 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 532 jcu_errorcode_t R_JCU_Continue(
dkato 0:37e1e6a45ced 533 const jcu_continue_type_t type)
dkato 0:37e1e6a45ced 534 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 535 {
dkato 0:37e1e6a45ced 536 errnum_t e;
dkato 0:37e1e6a45ced 537 jcu_errorcode_t ej;
dkato 0:37e1e6a45ced 538 r_ospl_async_t async;
dkato 0:37e1e6a45ced 539 bit_flags32_t got_flags;
dkato 0:37e1e6a45ced 540
dkato 0:37e1e6a45ced 541 async.Flags = R_F_OSPL_A_Thread;
dkato 0:37e1e6a45ced 542 async.A_Thread = R_OSPL_THREAD_GetCurrentId();
dkato 0:37e1e6a45ced 543
dkato 0:37e1e6a45ced 544 ej= R_JCU_ContinueAsync( type, &async );
dkato 0:37e1e6a45ced 545 IF( ej != JCU_ERROR_OK ) {
dkato 0:37e1e6a45ced 546 goto fin;
dkato 0:37e1e6a45ced 547 }
dkato 0:37e1e6a45ced 548
dkato 0:37e1e6a45ced 549 e= R_OSPL_EVENT_Wait( async.A_EventValue, &got_flags, R_OSPL_INFINITE );
dkato 0:37e1e6a45ced 550 IF(e!=0) {
dkato 0:37e1e6a45ced 551 ej=JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 552 goto fin;
dkato 0:37e1e6a45ced 553 }
dkato 0:37e1e6a45ced 554
dkato 0:37e1e6a45ced 555 e= async.ReturnValue;
dkato 0:37e1e6a45ced 556 IF(e!=0) {
dkato 0:37e1e6a45ced 557 ej=JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 558 goto fin;
dkato 0:37e1e6a45ced 559 }
dkato 0:37e1e6a45ced 560
dkato 0:37e1e6a45ced 561 fin:
dkato 0:37e1e6a45ced 562 return ej;
dkato 0:37e1e6a45ced 563 }
dkato 0:37e1e6a45ced 564
dkato 0:37e1e6a45ced 565
dkato 0:37e1e6a45ced 566 /**
dkato 0:37e1e6a45ced 567 * @brief Restart the processing caused by count mode. Asynchronized.
dkato 0:37e1e6a45ced 568 *
dkato 0:37e1e6a45ced 569 * @param type The target to continue
dkato 0:37e1e6a45ced 570 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 571 */
dkato 0:37e1e6a45ced 572 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 573 jcu_errorcode_t R_JCU_ContinueAsync(
dkato 0:37e1e6a45ced 574 const jcu_continue_type_t type,
dkato 0:37e1e6a45ced 575 r_ospl_async_t *const async)
dkato 0:37e1e6a45ced 576 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 577 {
dkato 0:37e1e6a45ced 578 errnum_t e;
dkato 0:37e1e6a45ced 579 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 580 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 581 bit_flags32_t mask;
dkato 0:37e1e6a45ced 582 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 583
dkato 0:37e1e6a45ced 584 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 585
dkato 0:37e1e6a45ced 586 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 587 IF (self->AsyncStatus.Status != JCU_STATUS_READY) {
dkato 0:37e1e6a45ced 588 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 589 goto fin;
dkato 0:37e1e6a45ced 590 } /* end if */
dkato 0:37e1e6a45ced 591
dkato 0:37e1e6a45ced 592 IF (self->AsyncStatus.IsPaused == false) {
dkato 0:37e1e6a45ced 593 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 594 goto fin;
dkato 0:37e1e6a45ced 595 } /* end if */
dkato 0:37e1e6a45ced 596
dkato 0:37e1e6a45ced 597 IF ( async == NULL ) {
dkato 0:37e1e6a45ced 598 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 599 goto fin;
dkato 0:37e1e6a45ced 600 } /* end if */
dkato 0:37e1e6a45ced 601 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 602
dkato 0:37e1e6a45ced 603 /* Clear the sub status flag */
dkato 0:37e1e6a45ced 604 switch ( type ) {
dkato 0:37e1e6a45ced 605 case JCU_INPUT_BUFFER:
dkato 0:37e1e6a45ced 606 mask = ( ( JINF_MASK | DINLF_MASK ) << JCU_SHIFT_JINTS1 );
dkato 0:37e1e6a45ced 607 break;
dkato 0:37e1e6a45ced 608 case JCU_OUTPUT_BUFFER:
dkato 0:37e1e6a45ced 609 mask = ( ( DOUTLF_MASK | JOUTF_MASK ) << JCU_SHIFT_JINTS1 );
dkato 0:37e1e6a45ced 610 break;
dkato 0:37e1e6a45ced 611 default:
dkato 0:37e1e6a45ced 612 ASSERT_R( type == JCU_IMAGE_INFO, returnValue=E_OTHERS; goto fin );
dkato 0:37e1e6a45ced 613 mask = INS3_MASK;
dkato 0:37e1e6a45ced 614 break;
dkato 0:37e1e6a45ced 615 }
dkato 0:37e1e6a45ced 616 ASSERT_R( IS_ANY_BITS_SET( self->AsyncStatus.SubStatusFlags, mask ), returnValue=E_OTHERS; goto fin );
dkato 0:37e1e6a45ced 617 self->AsyncStatus.SubStatusFlags &= ~mask;
dkato 0:37e1e6a45ced 618
dkato 0:37e1e6a45ced 619
dkato 0:37e1e6a45ced 620 R_JCU_SetDefaultAsync( async, R_OSPL_ASYNC_TYPE_NORMAL );
dkato 0:37e1e6a45ced 621 async->ReturnValue = 0;
dkato 0:37e1e6a45ced 622
dkato 0:37e1e6a45ced 623 /* Clear event flags */
dkato 0:37e1e6a45ced 624 R_OSPL_EVENT_Clear( async->A_Thread, async->A_EventValue );
dkato 0:37e1e6a45ced 625 R_OSPL_EVENT_Clear( async->I_Thread, async->I_EventValue );
dkato 0:37e1e6a45ced 626
dkato 0:37e1e6a45ced 627 /* JCU will restart */
dkato 0:37e1e6a45ced 628 if( self->AsyncStatus.SubStatusFlags == 0 ) {
dkato 0:37e1e6a45ced 629 /* Attach "Async" to interrupt */
dkato 0:37e1e6a45ced 630 /* ->MISRA 11.4 : Not too big "enum" is same bit count as "int" */ /* ->SEC R2.7.1 */
dkato 0:37e1e6a45ced 631 R_OSPL_CALLER_Initialize( &self->InterruptCallbackCaller,
dkato 0:37e1e6a45ced 632 async, (int_fast32_t *)&self->AsyncStatus.Status, JCU_STATUS_INTERRUPTING,
dkato 0:37e1e6a45ced 633 self->I_Lock, self->I_LockVTable );
dkato 0:37e1e6a45ced 634 /* <-MISRA 11.4 */ /* <-SEC R2.7.1 */
dkato 0:37e1e6a45ced 635 e= R_JCU_SetInterruptCallbackCaller( &self->InterruptCallbackCaller );
dkato 0:37e1e6a45ced 636 IF ( e != 0 ) {
dkato 0:37e1e6a45ced 637 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 638 goto fin;
dkato 0:37e1e6a45ced 639 }
dkato 0:37e1e6a45ced 640 R_OSPL_FLAG32_Set( &self->AsyncStatus.InterruptEnables, JCU_INTERRUPT_LINE_ALL );
dkato 0:37e1e6a45ced 641
dkato 0:37e1e6a45ced 642 /* Change the status */
dkato 0:37e1e6a45ced 643 self->AsyncStatus.Status = JCU_STATUS_RUN;
dkato 0:37e1e6a45ced 644 self->AsyncStatus.IsPaused = false;
dkato 0:37e1e6a45ced 645
dkato 0:37e1e6a45ced 646 /* Register set */
dkato 0:37e1e6a45ced 647 JCU_SetRegisterForContinue( type );
dkato 0:37e1e6a45ced 648 }
dkato 0:37e1e6a45ced 649
dkato 0:37e1e6a45ced 650 /* JCU will not restart */
dkato 0:37e1e6a45ced 651 else {
dkato 0:37e1e6a45ced 652 /* Register set */
dkato 0:37e1e6a45ced 653 JCU_SetRegisterForContinue( type );
dkato 0:37e1e6a45ced 654
dkato 0:37e1e6a45ced 655 /* Change the status */
dkato 0:37e1e6a45ced 656 self->AsyncStatus.Status = JCU_STATUS_READY;
dkato 0:37e1e6a45ced 657
dkato 0:37e1e6a45ced 658 /* Set event flags */
dkato 0:37e1e6a45ced 659 R_OSPL_EVENT_Set( async->A_Thread, async->A_EventValue );
dkato 0:37e1e6a45ced 660 R_OSPL_EVENT_Set( async->I_Thread, async->I_EventValue );
dkato 0:37e1e6a45ced 661 }
dkato 0:37e1e6a45ced 662
dkato 0:37e1e6a45ced 663
dkato 0:37e1e6a45ced 664 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 665 fin:
dkato 0:37e1e6a45ced 666 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 667 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 668 }
dkato 0:37e1e6a45ced 669 return returnValue;
dkato 0:37e1e6a45ced 670 }
dkato 0:37e1e6a45ced 671
dkato 0:37e1e6a45ced 672
dkato 0:37e1e6a45ced 673 /**
dkato 0:37e1e6a45ced 674 * @brief R_JCU_GetAsyncStatus.
dkato 0:37e1e6a45ced 675 *
dkato 0:37e1e6a45ced 676 * @par Parameters
dkato 0:37e1e6a45ced 677 * None
dkato 0:37e1e6a45ced 678 * @return None
dkato 0:37e1e6a45ced 679 */
dkato 0:37e1e6a45ced 680 void R_JCU_GetAsyncStatus( const jcu_async_status_t **const out_Status )
dkato 0:37e1e6a45ced 681 {
dkato 0:37e1e6a45ced 682 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 683
dkato 0:37e1e6a45ced 684 IF_DQ( out_Status == NULL ) {
dkato 0:37e1e6a45ced 685 goto fin;
dkato 0:37e1e6a45ced 686 }
dkato 0:37e1e6a45ced 687
dkato 0:37e1e6a45ced 688 *out_Status = &self->AsyncStatus;
dkato 0:37e1e6a45ced 689
dkato 0:37e1e6a45ced 690 fin:
dkato 0:37e1e6a45ced 691 return;
dkato 0:37e1e6a45ced 692 }
dkato 0:37e1e6a45ced 693
dkato 0:37e1e6a45ced 694
dkato 0:37e1e6a45ced 695 /**
dkato 0:37e1e6a45ced 696 * @brief Set parameter for decode.
dkato 0:37e1e6a45ced 697 *
dkato 0:37e1e6a45ced 698 * @param decode Select the encode parameter for decoding. <jcu_decode_param_t>
dkato 0:37e1e6a45ced 699 * @param buffer Buffer settings for decode. <jcu_buffer_param_t>
dkato 0:37e1e6a45ced 700 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 701 */
dkato 0:37e1e6a45ced 702 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 703 jcu_errorcode_t R_JCU_SetDecodeParam(
dkato 0:37e1e6a45ced 704 const jcu_decode_param_t *const decode,
dkato 0:37e1e6a45ced 705 const jcu_buffer_param_t *const buffer)
dkato 0:37e1e6a45ced 706 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 707 {
dkato 0:37e1e6a45ced 708 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 709 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 710 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 711
dkato 0:37e1e6a45ced 712 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 713
dkato 0:37e1e6a45ced 714 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 715 IF (!((self->AsyncStatus.Status == JCU_STATUS_READY)
dkato 0:37e1e6a45ced 716 || (self->AsyncStatus.Status == JCU_STATUS_SELECTED))) {
dkato 0:37e1e6a45ced 717 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 718 goto fin;
dkato 0:37e1e6a45ced 719 } /* end if */
dkato 0:37e1e6a45ced 720
dkato 0:37e1e6a45ced 721 IF(self->Codec != JCU_STATUS_DECODE) {
dkato 0:37e1e6a45ced 722 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 723 goto fin;
dkato 0:37e1e6a45ced 724 } /* end if */
dkato 0:37e1e6a45ced 725
dkato 0:37e1e6a45ced 726 IF((decode == NULL) || (buffer == NULL)) {
dkato 0:37e1e6a45ced 727 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 728 goto fin;
dkato 0:37e1e6a45ced 729 } /* end if */
dkato 0:37e1e6a45ced 730
dkato 0:37e1e6a45ced 731 returnValue = JCU_ParaCheckSetDecodeParam(decode, buffer);
dkato 0:37e1e6a45ced 732 IF(returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 733 goto fin;
dkato 0:37e1e6a45ced 734 } /* end if */
dkato 0:37e1e6a45ced 735
dkato 0:37e1e6a45ced 736 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 737
dkato 0:37e1e6a45ced 738 /* Register set */
dkato 0:37e1e6a45ced 739 JCU_SetRegisterForSetDecodePrm(decode, buffer);
dkato 0:37e1e6a45ced 740
dkato 0:37e1e6a45ced 741 /* Set the updated status */
dkato 0:37e1e6a45ced 742 self->AsyncStatus.Status = JCU_STATUS_READY;
dkato 0:37e1e6a45ced 743
dkato 0:37e1e6a45ced 744 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 745 fin:
dkato 0:37e1e6a45ced 746 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 747 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 748 }
dkato 0:37e1e6a45ced 749 return returnValue;
dkato 0:37e1e6a45ced 750 }
dkato 0:37e1e6a45ced 751
dkato 0:37e1e6a45ced 752
dkato 0:37e1e6a45ced 753 /**
dkato 0:37e1e6a45ced 754 * @brief Whether stop or not stop for R_JCU_GetImageInfo()
dkato 0:37e1e6a45ced 755 *
dkato 0:37e1e6a45ced 756 * @param is_pause Whether stop or not stop
dkato 0:37e1e6a45ced 757 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 758 */
dkato 0:37e1e6a45ced 759 jcu_errorcode_t R_JCU_SetPauseForImageInfo( const bool_t is_pause )
dkato 0:37e1e6a45ced 760 {
dkato 0:37e1e6a45ced 761 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 762 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 763 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 764
dkato 0:37e1e6a45ced 765 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 766
dkato 0:37e1e6a45ced 767 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 768 IF (!((self->AsyncStatus.Status == JCU_STATUS_READY)
dkato 0:37e1e6a45ced 769 || (self->AsyncStatus.Status == JCU_STATUS_SELECTED))) {
dkato 0:37e1e6a45ced 770 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 771 goto fin;
dkato 0:37e1e6a45ced 772 } /* end if */
dkato 0:37e1e6a45ced 773
dkato 0:37e1e6a45ced 774 IF(self->Codec != JCU_STATUS_DECODE) {
dkato 0:37e1e6a45ced 775 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 776 goto fin;
dkato 0:37e1e6a45ced 777 } /* end if */
dkato 0:37e1e6a45ced 778 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 779
dkato 0:37e1e6a45ced 780 /* Register set */
dkato 0:37e1e6a45ced 781 JCU_SetRegisterForSetPause( is_pause, self->ErrorFilter );
dkato 0:37e1e6a45ced 782
dkato 0:37e1e6a45ced 783 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 784 fin:
dkato 0:37e1e6a45ced 785 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 786 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 787 }
dkato 0:37e1e6a45ced 788 return returnValue;
dkato 0:37e1e6a45ced 789 }
dkato 0:37e1e6a45ced 790
dkato 0:37e1e6a45ced 791
dkato 0:37e1e6a45ced 792 /**
dkato 0:37e1e6a45ced 793 * @brief GetImageInfo
dkato 0:37e1e6a45ced 794 *
dkato 0:37e1e6a45ced 795 * @param buffer Image information. <jcu_image_info_t>
dkato 0:37e1e6a45ced 796 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 797 */
dkato 0:37e1e6a45ced 798 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 799 jcu_errorcode_t R_JCU_GetImageInfo(
dkato 0:37e1e6a45ced 800 jcu_image_info_t *const buffer)
dkato 0:37e1e6a45ced 801 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 802 {
dkato 0:37e1e6a45ced 803 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 804 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 805 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 806
dkato 0:37e1e6a45ced 807 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 808
dkato 0:37e1e6a45ced 809 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 810 IF (self->AsyncStatus.Status != JCU_STATUS_READY) {
dkato 0:37e1e6a45ced 811 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 812 goto fin;
dkato 0:37e1e6a45ced 813 } /* end if */
dkato 0:37e1e6a45ced 814
dkato 0:37e1e6a45ced 815 IF (self->Codec != JCU_STATUS_DECODE) {
dkato 0:37e1e6a45ced 816 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 817 goto fin;
dkato 0:37e1e6a45ced 818 } /* end if */
dkato 0:37e1e6a45ced 819
dkato 0:37e1e6a45ced 820 IF (buffer == NULL) {
dkato 0:37e1e6a45ced 821 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 822 goto fin;
dkato 0:37e1e6a45ced 823 } /* end if */
dkato 0:37e1e6a45ced 824
dkato 0:37e1e6a45ced 825 returnValue = JCU_ParaCheckGetImageInfo(buffer);
dkato 0:37e1e6a45ced 826 if(returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 827 goto fin;
dkato 0:37e1e6a45ced 828 } /* end if */
dkato 0:37e1e6a45ced 829 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 830
dkato 0:37e1e6a45ced 831 /* Register set */
dkato 0:37e1e6a45ced 832 JCU_GetRegisterForGetImageInfo(buffer);
dkato 0:37e1e6a45ced 833
dkato 0:37e1e6a45ced 834 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 835 fin:
dkato 0:37e1e6a45ced 836 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 837 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 838 }
dkato 0:37e1e6a45ced 839 return returnValue;
dkato 0:37e1e6a45ced 840 }
dkato 0:37e1e6a45ced 841
dkato 0:37e1e6a45ced 842
dkato 0:37e1e6a45ced 843 /**
dkato 0:37e1e6a45ced 844 * @brief SetErrorFilter
dkato 0:37e1e6a45ced 845 *
dkato 0:37e1e6a45ced 846 * @param filter enable bit of error. <jcu_int_detail_errors_t>
dkato 0:37e1e6a45ced 847 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 848 */
dkato 0:37e1e6a45ced 849 jcu_errorcode_t R_JCU_SetErrorFilter(jcu_int_detail_errors_t filter)
dkato 0:37e1e6a45ced 850 {
dkato 0:37e1e6a45ced 851 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 852 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 853
dkato 0:37e1e6a45ced 854 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 855 IF (!((self->AsyncStatus.Status == JCU_STATUS_INIT)
dkato 0:37e1e6a45ced 856 || (self->AsyncStatus.Status == JCU_STATUS_READY)
dkato 0:37e1e6a45ced 857 || (self->AsyncStatus.Status == JCU_STATUS_SELECTED))) {
dkato 0:37e1e6a45ced 858 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 859 goto fin;
dkato 0:37e1e6a45ced 860 } /* end if */
dkato 0:37e1e6a45ced 861
dkato 0:37e1e6a45ced 862 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 863
dkato 0:37e1e6a45ced 864 IF ( IS_ANY_BITS_SET( filter, ~JCU_INT_ERROR_ALL ) ) {
dkato 0:37e1e6a45ced 865 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 866 goto fin;
dkato 0:37e1e6a45ced 867 } /* end if */
dkato 0:37e1e6a45ced 868
dkato 0:37e1e6a45ced 869 self->ErrorFilter = filter;
dkato 0:37e1e6a45ced 870
dkato 0:37e1e6a45ced 871 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 872 fin:
dkato 0:37e1e6a45ced 873 return returnValue;
dkato 0:37e1e6a45ced 874 }
dkato 0:37e1e6a45ced 875
dkato 0:37e1e6a45ced 876
dkato 0:37e1e6a45ced 877 /**
dkato 0:37e1e6a45ced 878 * @brief SetQuantizationTable
dkato 0:37e1e6a45ced 879 *
dkato 0:37e1e6a45ced 880 * @param tableNo The table number to set the value. <jcu_table_no_t>
dkato 0:37e1e6a45ced 881 * @param table The body of the table to set.
dkato 0:37e1e6a45ced 882 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 883 */
dkato 0:37e1e6a45ced 884 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 885 jcu_errorcode_t R_JCU_SetQuantizationTable(
dkato 0:37e1e6a45ced 886 const jcu_table_no_t tableNo,
dkato 0:37e1e6a45ced 887 const uint8_t *const table)
dkato 0:37e1e6a45ced 888 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 889 {
dkato 0:37e1e6a45ced 890 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 891 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 892 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 893
dkato 0:37e1e6a45ced 894 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 895
dkato 0:37e1e6a45ced 896 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 897 IF (!((self->AsyncStatus.Status == JCU_STATUS_READY)
dkato 0:37e1e6a45ced 898 || (self->AsyncStatus.Status == JCU_STATUS_SELECTED))) {
dkato 0:37e1e6a45ced 899 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 900 goto fin;
dkato 0:37e1e6a45ced 901 } /* end if */
dkato 0:37e1e6a45ced 902
dkato 0:37e1e6a45ced 903 IF (self->Codec != JCU_STATUS_ENCODE) {
dkato 0:37e1e6a45ced 904 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 905 goto fin;
dkato 0:37e1e6a45ced 906 } /* end if */
dkato 0:37e1e6a45ced 907
dkato 0:37e1e6a45ced 908 IF (table == NULL) {
dkato 0:37e1e6a45ced 909 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 910 goto fin;
dkato 0:37e1e6a45ced 911 } /* end if */
dkato 0:37e1e6a45ced 912
dkato 0:37e1e6a45ced 913 returnValue = JCU_ParaCheckSetQuantizationTbl(tableNo);
dkato 0:37e1e6a45ced 914 IF (returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 915 goto fin;
dkato 0:37e1e6a45ced 916 } /* end if */
dkato 0:37e1e6a45ced 917 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 918
dkato 0:37e1e6a45ced 919 /* Register set */
dkato 0:37e1e6a45ced 920 JCU_SetRegisterForSetQtTable(tableNo, table);
dkato 0:37e1e6a45ced 921
dkato 0:37e1e6a45ced 922 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 923 fin:
dkato 0:37e1e6a45ced 924 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 925 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 926 }
dkato 0:37e1e6a45ced 927 return returnValue;
dkato 0:37e1e6a45ced 928 }
dkato 0:37e1e6a45ced 929
dkato 0:37e1e6a45ced 930
dkato 0:37e1e6a45ced 931 /**
dkato 0:37e1e6a45ced 932 * @brief Set the Huffman table
dkato 0:37e1e6a45ced 933 *
dkato 0:37e1e6a45ced 934 * @param tableNo The table number to set the value. <jcu_table_no_t>
dkato 0:37e1e6a45ced 935 * @param type The type of Huffman table type (AC or DC). <jcu_huff_t>
dkato 0:37e1e6a45ced 936 * @param table The body of the table to set
dkato 0:37e1e6a45ced 937 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 938 */
dkato 0:37e1e6a45ced 939 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 940 jcu_errorcode_t R_JCU_SetHuffmanTable(
dkato 0:37e1e6a45ced 941 const jcu_table_no_t tableNo,
dkato 0:37e1e6a45ced 942 const jcu_huff_t type,
dkato 0:37e1e6a45ced 943 const uint8_t *const table)
dkato 0:37e1e6a45ced 944 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 945 {
dkato 0:37e1e6a45ced 946 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 947 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 948 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 949
dkato 0:37e1e6a45ced 950 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 951
dkato 0:37e1e6a45ced 952 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 953 IF (!((self->AsyncStatus.Status == JCU_STATUS_READY)
dkato 0:37e1e6a45ced 954 || (self->AsyncStatus.Status == JCU_STATUS_SELECTED))) {
dkato 0:37e1e6a45ced 955 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 956 goto fin;
dkato 0:37e1e6a45ced 957 } /* end if */
dkato 0:37e1e6a45ced 958
dkato 0:37e1e6a45ced 959 IF (self->Codec != JCU_STATUS_ENCODE) {
dkato 0:37e1e6a45ced 960 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 961 goto fin;
dkato 0:37e1e6a45ced 962 } /* end if */
dkato 0:37e1e6a45ced 963
dkato 0:37e1e6a45ced 964 IF (table == NULL) {
dkato 0:37e1e6a45ced 965 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 966 goto fin;
dkato 0:37e1e6a45ced 967 } /* end if */
dkato 0:37e1e6a45ced 968
dkato 0:37e1e6a45ced 969 returnValue = JCU_ParaCheckSetHuffmanTable(tableNo, type);
dkato 0:37e1e6a45ced 970 IF (returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 971 goto fin;
dkato 0:37e1e6a45ced 972 } /* end if */
dkato 0:37e1e6a45ced 973 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 974
dkato 0:37e1e6a45ced 975 /* Register set */
dkato 0:37e1e6a45ced 976 JCU_SetRegisterForSetHuffTbl(tableNo, type, table);
dkato 0:37e1e6a45ced 977
dkato 0:37e1e6a45ced 978 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 979 fin:
dkato 0:37e1e6a45ced 980 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 981 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 982 }
dkato 0:37e1e6a45ced 983 return returnValue;
dkato 0:37e1e6a45ced 984 }
dkato 0:37e1e6a45ced 985
dkato 0:37e1e6a45ced 986
dkato 0:37e1e6a45ced 987 /**
dkato 0:37e1e6a45ced 988 * @brief Set the parameter fo encoding
dkato 0:37e1e6a45ced 989 *
dkato 0:37e1e6a45ced 990 * @param encode Select the encode parameter for encoding. <jcu_encode_param_t>
dkato 0:37e1e6a45ced 991 * @param buffer Select the buffer settings for encoding. <jcu_buffer_param_t>
dkato 0:37e1e6a45ced 992 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 993 */
dkato 0:37e1e6a45ced 994 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 995 jcu_errorcode_t R_JCU_SetEncodeParam(
dkato 0:37e1e6a45ced 996 const jcu_encode_param_t *const encode,
dkato 0:37e1e6a45ced 997 const jcu_buffer_param_t *const buffer)
dkato 0:37e1e6a45ced 998 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 999 {
dkato 0:37e1e6a45ced 1000 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 1001 bool_t was_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 1002 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 1003
dkato 0:37e1e6a45ced 1004 was_enabled = self->I_LockVTable->Lock( self->I_Lock );
dkato 0:37e1e6a45ced 1005
dkato 0:37e1e6a45ced 1006 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 1007 IF (!((self->AsyncStatus.Status == JCU_STATUS_READY)
dkato 0:37e1e6a45ced 1008 || (self->AsyncStatus.Status == JCU_STATUS_SELECTED))) {
dkato 0:37e1e6a45ced 1009 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 1010 goto fin;
dkato 0:37e1e6a45ced 1011 } /* end if */
dkato 0:37e1e6a45ced 1012
dkato 0:37e1e6a45ced 1013 IF (self->Codec != JCU_STATUS_ENCODE) {
dkato 0:37e1e6a45ced 1014 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 1015 goto fin;
dkato 0:37e1e6a45ced 1016 } /* end if */
dkato 0:37e1e6a45ced 1017
dkato 0:37e1e6a45ced 1018 IF ((encode == NULL) || (buffer == NULL)) {
dkato 0:37e1e6a45ced 1019 returnValue = JCU_ERROR_PARAM;
dkato 0:37e1e6a45ced 1020 goto fin;
dkato 0:37e1e6a45ced 1021 } /* end if */
dkato 0:37e1e6a45ced 1022
dkato 0:37e1e6a45ced 1023 returnValue = JCU_ParaCheckEncodeParam(encode, buffer);
dkato 0:37e1e6a45ced 1024 IF (returnValue != JCU_ERROR_OK) {
dkato 0:37e1e6a45ced 1025 goto fin;
dkato 0:37e1e6a45ced 1026 } /* end if */
dkato 0:37e1e6a45ced 1027 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 1028
dkato 0:37e1e6a45ced 1029 /* Register set */
dkato 0:37e1e6a45ced 1030 JCU_SetRegisterForSetEncodePrm(encode, buffer);
dkato 0:37e1e6a45ced 1031
dkato 0:37e1e6a45ced 1032 /* Set the updated status */
dkato 0:37e1e6a45ced 1033 self->AsyncStatus.Status = JCU_STATUS_READY;
dkato 0:37e1e6a45ced 1034
dkato 0:37e1e6a45ced 1035 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 1036 fin:
dkato 0:37e1e6a45ced 1037 if ( IS( was_enabled ) ) {
dkato 0:37e1e6a45ced 1038 self->I_LockVTable->Unlock( self->I_Lock );
dkato 0:37e1e6a45ced 1039 }
dkato 0:37e1e6a45ced 1040 return returnValue;
dkato 0:37e1e6a45ced 1041 }
dkato 0:37e1e6a45ced 1042
dkato 0:37e1e6a45ced 1043
dkato 0:37e1e6a45ced 1044 /**
dkato 0:37e1e6a45ced 1045 * @brief GetEncodedSize
dkato 0:37e1e6a45ced 1046 *
dkato 0:37e1e6a45ced 1047 * @param out_Size EncodedSize
dkato 0:37e1e6a45ced 1048 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 1049 */
dkato 0:37e1e6a45ced 1050 /* ->SEC M1.1.1 API Function */
dkato 0:37e1e6a45ced 1051 jcu_errorcode_t R_JCU_GetEncodedSize(
dkato 0:37e1e6a45ced 1052 size_t *const out_Size)
dkato 0:37e1e6a45ced 1053 /* <-SEC M1.1.1 */
dkato 0:37e1e6a45ced 1054 {
dkato 0:37e1e6a45ced 1055 JCU_GetEncodedSize(out_Size);
dkato 0:37e1e6a45ced 1056 return JCU_ERROR_OK;
dkato 0:37e1e6a45ced 1057 }
dkato 0:37e1e6a45ced 1058
dkato 0:37e1e6a45ced 1059
dkato 0:37e1e6a45ced 1060 /**
dkato 0:37e1e6a45ced 1061 * @brief Set AXI bus A*CACHE bits for 2nd cache to JCU.
dkato 0:37e1e6a45ced 1062 *
dkato 0:37e1e6a45ced 1063 * @param read_cache_attribute <r_ospl_axi_cache_attribute_t>
dkato 0:37e1e6a45ced 1064 * @param write_cache_attribute <r_ospl_axi_cache_attribute_t>
dkato 0:37e1e6a45ced 1065 * @return <jcu_errorcode_t> type.
dkato 0:37e1e6a45ced 1066 */
dkato 0:37e1e6a45ced 1067 jcu_errorcode_t R_JCU_Set2ndCacheAttribute(
dkato 0:37e1e6a45ced 1068 r_ospl_axi_cache_attribute_t const read_cache_attribute,
dkato 0:37e1e6a45ced 1069 r_ospl_axi_cache_attribute_t const write_cache_attribute )
dkato 0:37e1e6a45ced 1070 {
dkato 0:37e1e6a45ced 1071 static const uint32_t mask_JCU = 0xFFFF0000u;
dkato 0:37e1e6a45ced 1072 jcu_errorcode_t returnValue;
dkato 0:37e1e6a45ced 1073 bool_t was_all_enabled = false;
dkato 0:37e1e6a45ced 1074 uint32_t new_value;
dkato 0:37e1e6a45ced 1075 volatile uint32_t value;
dkato 0:37e1e6a45ced 1076 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 1077
dkato 0:37e1e6a45ced 1078 #ifdef JCU_PARAMETER_CHECK
dkato 0:37e1e6a45ced 1079 IF (!((self->AsyncStatus.Status == JCU_STATUS_READY)
dkato 0:37e1e6a45ced 1080 || (self->AsyncStatus.Status == JCU_STATUS_SELECTED))) {
dkato 0:37e1e6a45ced 1081 returnValue = JCU_ERROR_STATUS;
dkato 0:37e1e6a45ced 1082 goto fin;
dkato 0:37e1e6a45ced 1083 } /* end if */
dkato 0:37e1e6a45ced 1084 #endif /* #Ifdef JCU_PARAMETER_CHECK_ */
dkato 0:37e1e6a45ced 1085
dkato 0:37e1e6a45ced 1086
dkato 0:37e1e6a45ced 1087 new_value = ( read_cache_attribute << 24 ) | ( write_cache_attribute << 16 );
dkato 0:37e1e6a45ced 1088
dkato 0:37e1e6a45ced 1089 was_all_enabled = R_OSPL_DisableAllInterrupt();
dkato 0:37e1e6a45ced 1090
dkato 0:37e1e6a45ced 1091 value = INB.AXIBUSCTL0;
dkato 0:37e1e6a45ced 1092 value = new_value | ( value & ~mask_JCU ); /* Mutual Exclusion from Ether */
dkato 0:37e1e6a45ced 1093 INB.AXIBUSCTL0 = value;
dkato 0:37e1e6a45ced 1094
dkato 0:37e1e6a45ced 1095 returnValue = JCU_ERROR_OK;
dkato 0:37e1e6a45ced 1096 fin:
dkato 0:37e1e6a45ced 1097 if ( was_all_enabled ) {
dkato 0:37e1e6a45ced 1098 R_OSPL_EnableAllInterrupt();
dkato 0:37e1e6a45ced 1099 }
dkato 0:37e1e6a45ced 1100
dkato 0:37e1e6a45ced 1101 return returnValue;
dkato 0:37e1e6a45ced 1102 }
dkato 0:37e1e6a45ced 1103
dkato 0:37e1e6a45ced 1104
dkato 0:37e1e6a45ced 1105 /**
dkato 0:37e1e6a45ced 1106 * @brief EnableInterrupt
dkato 0:37e1e6a45ced 1107 *
dkato 0:37e1e6a45ced 1108 * @par Parameters
dkato 0:37e1e6a45ced 1109 * None
dkato 0:37e1e6a45ced 1110 * @return None
dkato 0:37e1e6a45ced 1111 */
dkato 0:37e1e6a45ced 1112 void R_JCU_EnableInterrupt(void)
dkato 0:37e1e6a45ced 1113 {
dkato 0:37e1e6a45ced 1114 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 1115
dkato 0:37e1e6a45ced 1116 self->AsyncStatus.IsEnabledInterrupt = true;
dkato 0:37e1e6a45ced 1117 R_JCU_OnEnableInterrupt( self->AsyncStatus.InterruptEnables.Flags );
dkato 0:37e1e6a45ced 1118 }
dkato 0:37e1e6a45ced 1119
dkato 0:37e1e6a45ced 1120
dkato 0:37e1e6a45ced 1121 /**
dkato 0:37e1e6a45ced 1122 * @brief DisableInterrupt
dkato 0:37e1e6a45ced 1123 *
dkato 0:37e1e6a45ced 1124 * @par Parameters
dkato 0:37e1e6a45ced 1125 * None
dkato 0:37e1e6a45ced 1126 * @return Was interrupt enabled
dkato 0:37e1e6a45ced 1127 */
dkato 0:37e1e6a45ced 1128 bool_t R_JCU_DisableInterrupt(void)
dkato 0:37e1e6a45ced 1129 {
dkato 0:37e1e6a45ced 1130 bool_t was_interrupted;
dkato 0:37e1e6a45ced 1131 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 1132
dkato 0:37e1e6a45ced 1133 was_interrupted = self->AsyncStatus.IsEnabledInterrupt;
dkato 0:37e1e6a45ced 1134
dkato 0:37e1e6a45ced 1135 R_JCU_OnDisableInterrupt( self->AsyncStatus.InterruptEnables.Flags );
dkato 0:37e1e6a45ced 1136 self->AsyncStatus.IsEnabledInterrupt = false;
dkato 0:37e1e6a45ced 1137
dkato 0:37e1e6a45ced 1138 return was_interrupted;
dkato 0:37e1e6a45ced 1139 }
dkato 0:37e1e6a45ced 1140
dkato 0:37e1e6a45ced 1141
dkato 0:37e1e6a45ced 1142 /**
dkato 0:37e1e6a45ced 1143 * @brief R_JCU_GetInternalInformation
dkato 0:37e1e6a45ced 1144 *
dkato 0:37e1e6a45ced 1145 * @par Parameters
dkato 0:37e1e6a45ced 1146 * None
dkato 0:37e1e6a45ced 1147 * @return <jcu_internal_information_t> type.
dkato 0:37e1e6a45ced 1148 */
dkato 0:37e1e6a45ced 1149 jcu_internal_information_t *R_JCU_GetInternalInformation(void)
dkato 0:37e1e6a45ced 1150 {
dkato 0:37e1e6a45ced 1151 return &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 1152 }
dkato 0:37e1e6a45ced 1153
dkato 0:37e1e6a45ced 1154
dkato 0:37e1e6a45ced 1155 /**
dkato 0:37e1e6a45ced 1156 * @brief R_JCU_GetILockObject
dkato 0:37e1e6a45ced 1157 *
dkato 0:37e1e6a45ced 1158 * @par Parameters
dkato 0:37e1e6a45ced 1159 * None
dkato 0:37e1e6a45ced 1160 * @return <jcu_i_lock_t> type.
dkato 0:37e1e6a45ced 1161 */
dkato 0:37e1e6a45ced 1162 jcu_i_lock_t *R_JCU_GetILockObject(void)
dkato 0:37e1e6a45ced 1163 {
dkato 0:37e1e6a45ced 1164 return &gs_jcu_i_lock;
dkato 0:37e1e6a45ced 1165 }
dkato 0:37e1e6a45ced 1166
dkato 0:37e1e6a45ced 1167
dkato 0:37e1e6a45ced 1168 /**
dkato 0:37e1e6a45ced 1169 * @brief Replace associated I-Lock object
dkato 0:37e1e6a45ced 1170 *
dkato 0:37e1e6a45ced 1171 * @param I_Lock I-Lock object
dkato 0:37e1e6a45ced 1172 * @param I_LockVTable V-Table
dkato 0:37e1e6a45ced 1173 * @return Whether success to replace
dkato 0:37e1e6a45ced 1174 */
dkato 0:37e1e6a45ced 1175 bool_t R_JCU_I_LOCK_Replace( void *const I_Lock, const r_ospl_i_lock_vtable_t *const I_LockVTable )
dkato 0:37e1e6a45ced 1176 {
dkato 0:37e1e6a45ced 1177 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 1178 bool_t ret = false;
dkato 0:37e1e6a45ced 1179
dkato 0:37e1e6a45ced 1180 ASSERT_R( self->AsyncStatus.Status == JCU_STATUS_UNDEF, ret = false; goto fin );
dkato 0:37e1e6a45ced 1181
dkato 0:37e1e6a45ced 1182 if ( I_Lock != NULL ) {
dkato 0:37e1e6a45ced 1183 if ( self->I_Lock == NULL ) {
dkato 0:37e1e6a45ced 1184 self->I_Lock = I_Lock;
dkato 0:37e1e6a45ced 1185 self->I_LockVTable = I_LockVTable;
dkato 0:37e1e6a45ced 1186 ret = true;
dkato 0:37e1e6a45ced 1187 }
dkato 0:37e1e6a45ced 1188 } else {
dkato 0:37e1e6a45ced 1189 self->I_Lock = NULL;
dkato 0:37e1e6a45ced 1190 }
dkato 0:37e1e6a45ced 1191
dkato 0:37e1e6a45ced 1192 fin:
dkato 0:37e1e6a45ced 1193 return ret;
dkato 0:37e1e6a45ced 1194 }
dkato 0:37e1e6a45ced 1195
dkato 0:37e1e6a45ced 1196
dkato 0:37e1e6a45ced 1197 /**
dkato 0:37e1e6a45ced 1198 * @brief Finalize the I-Lock object
dkato 0:37e1e6a45ced 1199 *
dkato 0:37e1e6a45ced 1200 * @par Parameters
dkato 0:37e1e6a45ced 1201 * None
dkato 0:37e1e6a45ced 1202 * @return None
dkato 0:37e1e6a45ced 1203 */
dkato 0:37e1e6a45ced 1204 void R_JCU_I_LOCK_Finalize(void)
dkato 0:37e1e6a45ced 1205 {
dkato 0:37e1e6a45ced 1206 jcu_internal_information_t *const self = &gs_jcu_internal_information;
dkato 0:37e1e6a45ced 1207 bool_t b;
dkato 0:37e1e6a45ced 1208
dkato 0:37e1e6a45ced 1209 ASSERT_D( self->Is_I_LockMaster, R_NOOP() );
dkato 0:37e1e6a45ced 1210
dkato 0:37e1e6a45ced 1211 R_JCU_I_LOCK_Reset( self->I_Lock );
dkato 0:37e1e6a45ced 1212 b= R_JCU_I_LOCK_Replace( NULL, NULL );
dkato 0:37e1e6a45ced 1213 R_UNREFERENCED_VARIABLE( b ); /* QAC 3200 : This is not error information */
dkato 0:37e1e6a45ced 1214 self->Is_I_LockMaster = false;
dkato 0:37e1e6a45ced 1215 }
dkato 0:37e1e6a45ced 1216
dkato 0:37e1e6a45ced 1217
dkato 0:37e1e6a45ced 1218 /**
dkato 0:37e1e6a45ced 1219 * @brief Reset the I-Lock object
dkato 0:37e1e6a45ced 1220 *
dkato 0:37e1e6a45ced 1221 * @param self I-Lock object
dkato 0:37e1e6a45ced 1222 * @return None
dkato 0:37e1e6a45ced 1223 */
dkato 0:37e1e6a45ced 1224 static void R_JCU_I_LOCK_Reset( jcu_i_lock_t *const self )
dkato 0:37e1e6a45ced 1225 {
dkato 0:37e1e6a45ced 1226 IF_DQ( self == NULL ) {
dkato 0:37e1e6a45ced 1227 goto fin;
dkato 0:37e1e6a45ced 1228 }
dkato 0:37e1e6a45ced 1229
dkato 0:37e1e6a45ced 1230 self->IsLock = false;
dkato 0:37e1e6a45ced 1231 R_JCU_OnDisableInterrupt( JCU_INTERRUPT_LINE_ALL );
dkato 0:37e1e6a45ced 1232 JCU_ClearInterruptFlag();
dkato 0:37e1e6a45ced 1233 self->IsRequestedFinalize = false;
dkato 0:37e1e6a45ced 1234
dkato 0:37e1e6a45ced 1235 fin:
dkato 0:37e1e6a45ced 1236 return;
dkato 0:37e1e6a45ced 1237 }
dkato 0:37e1e6a45ced 1238
dkato 0:37e1e6a45ced 1239
dkato 0:37e1e6a45ced 1240 /**
dkato 0:37e1e6a45ced 1241 * @brief Lock the I-Lock object
dkato 0:37e1e6a45ced 1242 *
dkato 0:37e1e6a45ced 1243 * @param self_ I-Lock object
dkato 0:37e1e6a45ced 1244 * @return Was interrupt enabled
dkato 0:37e1e6a45ced 1245 */
dkato 0:37e1e6a45ced 1246 static bool_t R_JCU_I_LOCK_Lock( void *const self_ )
dkato 0:37e1e6a45ced 1247 {
dkato 0:37e1e6a45ced 1248 bool_t is_locked;
dkato 0:37e1e6a45ced 1249 bool_t was_all_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 1250 bool_t b;
dkato 0:37e1e6a45ced 1251 jcu_i_lock_t *const self = (jcu_i_lock_t *) self_;
dkato 0:37e1e6a45ced 1252
dkato 0:37e1e6a45ced 1253 IF_DQ( self == NULL ) {
dkato 0:37e1e6a45ced 1254 is_locked = true;
dkato 0:37e1e6a45ced 1255 goto fin;
dkato 0:37e1e6a45ced 1256 }
dkato 0:37e1e6a45ced 1257
dkato 0:37e1e6a45ced 1258 was_all_enabled = R_OSPL_DisableAllInterrupt();
dkato 0:37e1e6a45ced 1259
dkato 0:37e1e6a45ced 1260 is_locked = self->IsLock;
dkato 0:37e1e6a45ced 1261 if ( ! is_locked ) {
dkato 0:37e1e6a45ced 1262 b= R_JCU_DisableInterrupt();
dkato 0:37e1e6a45ced 1263 R_UNREFERENCED_VARIABLE( b ); /* QAC 3200 : This is not error information */
dkato 0:37e1e6a45ced 1264 self->IsLock = true;
dkato 0:37e1e6a45ced 1265 }
dkato 0:37e1e6a45ced 1266
dkato 0:37e1e6a45ced 1267 if ( IS( was_all_enabled ) ) {
dkato 0:37e1e6a45ced 1268 R_OSPL_EnableAllInterrupt();
dkato 0:37e1e6a45ced 1269 }
dkato 0:37e1e6a45ced 1270
dkato 0:37e1e6a45ced 1271 fin:
dkato 0:37e1e6a45ced 1272 return ! is_locked;
dkato 0:37e1e6a45ced 1273 }
dkato 0:37e1e6a45ced 1274
dkato 0:37e1e6a45ced 1275
dkato 0:37e1e6a45ced 1276 /**
dkato 0:37e1e6a45ced 1277 * @brief Unlock the I-Lock object
dkato 0:37e1e6a45ced 1278 *
dkato 0:37e1e6a45ced 1279 * @param self_ I-Lock object
dkato 0:37e1e6a45ced 1280 * @return None
dkato 0:37e1e6a45ced 1281 */
dkato 0:37e1e6a45ced 1282 static void R_JCU_I_LOCK_Unlock( void *const self_ )
dkato 0:37e1e6a45ced 1283 {
dkato 0:37e1e6a45ced 1284 bool_t was_all_enabled; /* = false; */ /* QAC 3197 */
dkato 0:37e1e6a45ced 1285 jcu_i_lock_t *const self = (jcu_i_lock_t *) self_;
dkato 0:37e1e6a45ced 1286
dkato 0:37e1e6a45ced 1287 IF_DQ( self == NULL ) {
dkato 0:37e1e6a45ced 1288 goto fin;
dkato 0:37e1e6a45ced 1289 }
dkato 0:37e1e6a45ced 1290
dkato 0:37e1e6a45ced 1291 was_all_enabled = R_OSPL_DisableAllInterrupt();
dkato 0:37e1e6a45ced 1292
dkato 0:37e1e6a45ced 1293 R_JCU_EnableInterrupt();
dkato 0:37e1e6a45ced 1294 self->IsLock = false;
dkato 0:37e1e6a45ced 1295
dkato 0:37e1e6a45ced 1296 if ( IS( was_all_enabled ) ) {
dkato 0:37e1e6a45ced 1297 R_OSPL_EnableAllInterrupt();
dkato 0:37e1e6a45ced 1298 }
dkato 0:37e1e6a45ced 1299
dkato 0:37e1e6a45ced 1300 fin:
dkato 0:37e1e6a45ced 1301 return;
dkato 0:37e1e6a45ced 1302 }
dkato 0:37e1e6a45ced 1303
dkato 0:37e1e6a45ced 1304
dkato 0:37e1e6a45ced 1305 /**
dkato 0:37e1e6a45ced 1306 * @brief Request to finalize the I-Lock object
dkato 0:37e1e6a45ced 1307 *
dkato 0:37e1e6a45ced 1308 * @param self_ I-Lock object
dkato 0:37e1e6a45ced 1309 * @return None
dkato 0:37e1e6a45ced 1310 */
dkato 0:37e1e6a45ced 1311 static void R_JCU_I_LOCK_RequestFinalize( void *const self_ )
dkato 0:37e1e6a45ced 1312 {
dkato 0:37e1e6a45ced 1313 jcu_i_lock_t *const self = (jcu_i_lock_t *) self_;
dkato 0:37e1e6a45ced 1314
dkato 0:37e1e6a45ced 1315 IF_DQ( self == NULL ) {
dkato 0:37e1e6a45ced 1316 goto fin;
dkato 0:37e1e6a45ced 1317 }
dkato 0:37e1e6a45ced 1318
dkato 0:37e1e6a45ced 1319 self->IsRequestedFinalize = true;
dkato 0:37e1e6a45ced 1320
dkato 0:37e1e6a45ced 1321 fin:
dkato 0:37e1e6a45ced 1322 return;
dkato 0:37e1e6a45ced 1323 }
dkato 0:37e1e6a45ced 1324
dkato 0:37e1e6a45ced 1325
dkato 0:37e1e6a45ced 1326 /**
dkato 0:37e1e6a45ced 1327 * @brief Get root channel number of I-Lock object
dkato 0:37e1e6a45ced 1328 *
dkato 0:37e1e6a45ced 1329 * @param self_ I-Lock object
dkato 0:37e1e6a45ced 1330 * @return A channel number
dkato 0:37e1e6a45ced 1331 */
dkato 0:37e1e6a45ced 1332 static int_fast32_t R_JCU_I_LOCK_GetRootChannelNum( const void *const self_ )
dkato 0:37e1e6a45ced 1333 {
dkato 0:37e1e6a45ced 1334 R_UNREFERENCED_VARIABLE( self_ );
dkato 0:37e1e6a45ced 1335
dkato 0:37e1e6a45ced 1336 return 0;
dkato 0:37e1e6a45ced 1337 }
dkato 0:37e1e6a45ced 1338
dkato 0:37e1e6a45ced 1339