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:
11:9bf28e65755e
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 - 2014 Renesas Electronics Corporation. All rights reserved.
dkato 0:37e1e6a45ced 22 *******************************************************************************/
dkato 0:37e1e6a45ced 23 /**
dkato 0:37e1e6a45ced 24 * @file r_ospl_RTX.c
dkato 0:37e1e6a45ced 25 * @brief OS Porting Layer API for RTX
dkato 0:37e1e6a45ced 26 *
dkato 0:37e1e6a45ced 27 * $Module: OSPL $ $PublicVersion: 0.90 $ (=R_OSPL_VERSION)
dkato 0:37e1e6a45ced 28 * $Rev: 35 $
dkato 0:37e1e6a45ced 29 * $Date:: 2014-04-15 21:38:18 +0900#$
dkato 0:37e1e6a45ced 30 */
dkato 0:37e1e6a45ced 31
dkato 0:37e1e6a45ced 32
dkato 0:37e1e6a45ced 33 /******************************************************************************
dkato 0:37e1e6a45ced 34 Includes <System Includes> , "Project Includes"
dkato 0:37e1e6a45ced 35 ******************************************************************************/
dkato 0:37e1e6a45ced 36 #include "r_ospl.h"
dkato 0:37e1e6a45ced 37 #include "r_ospl_os_less_private.h"
dkato 0:37e1e6a45ced 38 #include "r_ospl_private.h"
dkato 0:37e1e6a45ced 39 #include "pl310.h" /* 2nd cache */
dkato 0:37e1e6a45ced 40 #if R_OSPL_IS_PREEMPTION
dkato 0:37e1e6a45ced 41 #include "cmsis_os.h"
dkato 0:37e1e6a45ced 42 #include "gic.h"
dkato 0:37e1e6a45ced 43 #include "r_ospl_RTX_private.h"
dkato 0:37e1e6a45ced 44 #endif
dkato 0:37e1e6a45ced 45
dkato 0:37e1e6a45ced 46
dkato 0:37e1e6a45ced 47 /******************************************************************************
dkato 0:37e1e6a45ced 48 Typedef definitions
dkato 0:37e1e6a45ced 49 ******************************************************************************/
dkato 0:37e1e6a45ced 50
dkato 0:37e1e6a45ced 51 /******************************************************************************
dkato 0:37e1e6a45ced 52 Macro definitions
dkato 0:37e1e6a45ced 53 ******************************************************************************/
dkato 0:37e1e6a45ced 54
dkato 0:37e1e6a45ced 55 /**
dkato 0:37e1e6a45ced 56 * @def OS_ERROR_SIGNAL
dkato 0:37e1e6a45ced 57 * @brief CMSIS-RTOS defined immediate value
dkato 0:37e1e6a45ced 58 * @par Parameters
dkato 0:37e1e6a45ced 59 * None
dkato 0:37e1e6a45ced 60 * @return None.
dkato 0:37e1e6a45ced 61 */
dkato 0:37e1e6a45ced 62 #define OS_ERROR_SIGNAL 0x80000000
dkato 0:37e1e6a45ced 63
dkato 0:37e1e6a45ced 64
dkato 0:37e1e6a45ced 65 /**
dkato 0:37e1e6a45ced 66 * @def R_OSPL_EVENT_WATCH
dkato 0:37e1e6a45ced 67 * @brief Debug tool
dkato 0:37e1e6a45ced 68 * @par Parameters
dkato 0:37e1e6a45ced 69 * None
dkato 0:37e1e6a45ced 70 * @return None.
dkato 0:37e1e6a45ced 71 */
dkato 0:37e1e6a45ced 72 #define R_OSPL_EVENT_WATCH 0 /* [R_OSPL_EVENT_WATCH] 0 or 1 */
dkato 0:37e1e6a45ced 73
dkato 0:37e1e6a45ced 74
dkato 0:37e1e6a45ced 75 /******************************************************************************
dkato 0:37e1e6a45ced 76 Imported global variables and functions (from other files)
dkato 0:37e1e6a45ced 77 ******************************************************************************/
dkato 0:37e1e6a45ced 78
dkato 0:37e1e6a45ced 79 /******************************************************************************
dkato 0:37e1e6a45ced 80 Exported global variables and functions (to be accessed by other files)
dkato 0:37e1e6a45ced 81 ******************************************************************************/
dkato 0:37e1e6a45ced 82
dkato 0:37e1e6a45ced 83 /******************************************************************************
dkato 0:37e1e6a45ced 84 Private global variables and functions
dkato 0:37e1e6a45ced 85 ******************************************************************************/
dkato 0:37e1e6a45ced 86
dkato 0:37e1e6a45ced 87
dkato 0:37e1e6a45ced 88 /***********************************************************************
dkato 0:37e1e6a45ced 89 * Implement: R_OSPL_Initialize
dkato 0:37e1e6a45ced 90 ************************************************************************/
dkato 0:37e1e6a45ced 91 errnum_t R_OSPL_Initialize( const void *const in_NullConfig )
dkato 0:37e1e6a45ced 92 {
dkato 0:37e1e6a45ced 93 R_UNREFERENCED_VARIABLE( in_NullConfig );
dkato 0:37e1e6a45ced 94 return 0;
dkato 0:37e1e6a45ced 95 }
dkato 0:37e1e6a45ced 96
dkato 0:37e1e6a45ced 97
dkato 0:37e1e6a45ced 98 /***********************************************************************
dkato 0:37e1e6a45ced 99 * Implement: R_OSPL_THREAD_GetCurrentId
dkato 0:37e1e6a45ced 100 ************************************************************************/
dkato 0:37e1e6a45ced 101 r_ospl_thread_id_t R_OSPL_THREAD_GetCurrentId(void)
dkato 0:37e1e6a45ced 102 {
dkato 0:37e1e6a45ced 103 return osThreadGetId();
dkato 0:37e1e6a45ced 104 }
dkato 0:37e1e6a45ced 105
dkato 0:37e1e6a45ced 106
dkato 0:37e1e6a45ced 107 /***********************************************************************
dkato 0:37e1e6a45ced 108 * Implement: R_OSPL_EVENT_Set
dkato 0:37e1e6a45ced 109 ************************************************************************/
dkato 0:37e1e6a45ced 110 void R_OSPL_EVENT_Set( r_ospl_thread_id_t const ThreadId, bit_flags32_t const SetFlags )
dkato 0:37e1e6a45ced 111 {
dkato 0:37e1e6a45ced 112 int32_t ret;
dkato 0:37e1e6a45ced 113
dkato 0:37e1e6a45ced 114 if ( ThreadId != NULL ) {
dkato 0:37e1e6a45ced 115 #if R_OSPL_EVENT_WATCH
dkato 0:37e1e6a45ced 116 R_D_AddToIntLog( 0x70100000 + SetFlags );
dkato 0:37e1e6a45ced 117 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
dkato 0:37e1e6a45ced 118 R_D_AddToIntLog( (uintptr_t) ThreadId );
dkato 0:37e1e6a45ced 119 #endif
dkato 0:37e1e6a45ced 120
dkato 0:37e1e6a45ced 121 ret = osSignalSet( (osThreadId) ThreadId, (int32_t) SetFlags );
dkato 0:37e1e6a45ced 122 ASSERT_D( (ret & OS_ERROR_SIGNAL) == 0, R_NOOP() );
dkato 0:37e1e6a45ced 123 R_UNREFERENCED_VARIABLE( ret ); /* for Release configuration */
dkato 0:37e1e6a45ced 124 }
dkato 0:37e1e6a45ced 125 }
dkato 0:37e1e6a45ced 126
dkato 0:37e1e6a45ced 127
dkato 0:37e1e6a45ced 128 /***********************************************************************
dkato 0:37e1e6a45ced 129 * Implement: R_OSPL_EVENT_Clear
dkato 0:37e1e6a45ced 130 ************************************************************************/
dkato 0:37e1e6a45ced 131 void R_OSPL_EVENT_Clear( r_ospl_thread_id_t const ThreadId, bit_flags32_t const ClearFlags1 )
dkato 0:37e1e6a45ced 132 {
dkato 0:37e1e6a45ced 133 int32_t ret;
dkato 0:37e1e6a45ced 134
dkato 0:37e1e6a45ced 135 if ( ThreadId != NULL ) {
dkato 0:37e1e6a45ced 136 IF_D( ( ClearFlags1 & ~0xFFFF ) != 0 ) {
dkato 0:37e1e6a45ced 137 R_NOOP();
dkato 0:37e1e6a45ced 138 }
dkato 0:37e1e6a45ced 139
dkato 0:37e1e6a45ced 140 #if R_OSPL_EVENT_WATCH
dkato 0:37e1e6a45ced 141 R_D_AddToIntLog( 0x70C00000 + ClearFlags1 );
dkato 0:37e1e6a45ced 142 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
dkato 0:37e1e6a45ced 143 R_D_AddToIntLog( (uintptr_t) ThreadId );
dkato 0:37e1e6a45ced 144 #endif
dkato 0:37e1e6a45ced 145
dkato 0:37e1e6a45ced 146 ret = osSignalClear( (osThreadId) ThreadId, (int32_t) ClearFlags1 );
dkato 0:37e1e6a45ced 147 /* "& 0xFFFF" is for avoiding error in osSignalClear */
dkato 0:37e1e6a45ced 148 ASSERT_D( (ret & OS_ERROR_SIGNAL) == 0, R_NOOP() );
dkato 0:37e1e6a45ced 149 R_UNREFERENCED_VARIABLE( ret ); /* for Release configuration */
dkato 0:37e1e6a45ced 150 }
dkato 0:37e1e6a45ced 151 }
dkato 0:37e1e6a45ced 152
dkato 0:37e1e6a45ced 153
dkato 0:37e1e6a45ced 154 /***********************************************************************
dkato 0:37e1e6a45ced 155 * Implement: R_OSPL_EVENT_Get
dkato 0:37e1e6a45ced 156 ************************************************************************/
dkato 0:37e1e6a45ced 157 #if ( ! defined( osCMSIS ) || osCMSIS <= 0x10001 ) && R_OSPL_VERSION < 85
dkato 0:37e1e6a45ced 158 bit_flags32_t R_OSPL_EVENT_Get( r_ospl_thread_id_t const ThreadId )
dkato 0:37e1e6a45ced 159 {
dkato 0:37e1e6a45ced 160 int32_t ret;
dkato 0:37e1e6a45ced 161
dkato 0:37e1e6a45ced 162 if ( ThreadId == NULL ) {
dkato 0:37e1e6a45ced 163 ret = 0;
dkato 0:37e1e6a45ced 164 } else {
dkato 0:37e1e6a45ced 165 ret = osSignalGet( (osThreadId) ThreadId );
dkato 0:37e1e6a45ced 166 ASSERT_D( (ret & OS_ERROR_SIGNAL) == 0, R_NOOP() );
dkato 0:37e1e6a45ced 167 }
dkato 0:37e1e6a45ced 168
dkato 0:37e1e6a45ced 169 return (bit_flags32_t) ret;
dkato 0:37e1e6a45ced 170 }
dkato 0:37e1e6a45ced 171 #endif
dkato 0:37e1e6a45ced 172
dkato 0:37e1e6a45ced 173
dkato 0:37e1e6a45ced 174 /***********************************************************************
dkato 0:37e1e6a45ced 175 * Implement: R_OSPL_EVENT_Wait
dkato 0:37e1e6a45ced 176 ************************************************************************/
dkato 0:37e1e6a45ced 177 errnum_t R_OSPL_EVENT_Wait( bit_flags32_t const WaigingFlags, bit_flags32_t *const out_GotFlags,
dkato 0:37e1e6a45ced 178 uint32_t const Timeout_msec )
dkato 0:37e1e6a45ced 179 {
dkato 0:37e1e6a45ced 180 errnum_t e;
dkato 0:37e1e6a45ced 181 osEvent event;
dkato 0:37e1e6a45ced 182
dkato 11:9bf28e65755e 183 R_STATIC_ASSERT( R_OSPL_INFINITE == osWaitForever, "" );
dkato 0:37e1e6a45ced 184
dkato 0:37e1e6a45ced 185 #if R_OSPL_EVENT_WATCH
dkato 0:37e1e6a45ced 186 R_D_AddToIntLog( 0x70BE0000 + WaigingFlags );
dkato 0:37e1e6a45ced 187 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
dkato 0:37e1e6a45ced 188
dkato 0:37e1e6a45ced 189 {
dkato 0:37e1e6a45ced 190 static int tc;
dkato 0:37e1e6a45ced 191 if ( R_D_Counter( &tc, 0, NULL ) ) {
dkato 0:37e1e6a45ced 192 R_DEBUG_BREAK();
dkato 0:37e1e6a45ced 193 }
dkato 0:37e1e6a45ced 194 }
dkato 0:37e1e6a45ced 195 #endif
dkato 0:37e1e6a45ced 196
dkato 0:37e1e6a45ced 197
dkato 0:37e1e6a45ced 198 event = osSignalWait( (int32_t) WaigingFlags, Timeout_msec );
dkato 0:37e1e6a45ced 199
dkato 0:37e1e6a45ced 200
dkato 0:37e1e6a45ced 201 #if R_OSPL_EVENT_WATCH
dkato 0:37e1e6a45ced 202 R_D_AddToIntLog( 0x70AF0000 );
dkato 0:37e1e6a45ced 203 R_D_AddToIntLog( (uintptr_t) R_OSPL_THREAD_GetCurrentId() );
dkato 0:37e1e6a45ced 204 #endif
dkato 0:37e1e6a45ced 205
dkato 0:37e1e6a45ced 206 if ( (event.status == osOK) || (event.status == osEventTimeout) ) {
dkato 0:37e1e6a45ced 207 if ( out_GotFlags != NULL ) {
dkato 0:37e1e6a45ced 208 *out_GotFlags = R_OSPL_TIMEOUT;
dkato 0:37e1e6a45ced 209 }
dkato 0:37e1e6a45ced 210 IF ( event.status == osEventTimeout ) {
dkato 0:37e1e6a45ced 211 e=E_TIME_OUT;
dkato 0:37e1e6a45ced 212 goto fin;
dkato 0:37e1e6a45ced 213 }
dkato 0:37e1e6a45ced 214 } else {
dkato 0:37e1e6a45ced 215 ASSERT_R( event.status == osEventSignal, e=E_OTHERS; goto fin );
dkato 0:37e1e6a45ced 216
dkato 0:37e1e6a45ced 217 if ( out_GotFlags != NULL ) {
dkato 0:37e1e6a45ced 218 *out_GotFlags = (bit_flags32_t) event.value.signals;
dkato 0:37e1e6a45ced 219 }
dkato 0:37e1e6a45ced 220 }
dkato 0:37e1e6a45ced 221
dkato 0:37e1e6a45ced 222 e=0;
dkato 0:37e1e6a45ced 223 fin:
dkato 0:37e1e6a45ced 224 return e;
dkato 0:37e1e6a45ced 225 }
dkato 0:37e1e6a45ced 226
dkato 0:37e1e6a45ced 227
dkato 0:37e1e6a45ced 228 /***********************************************************************
dkato 0:37e1e6a45ced 229 * Implement: R_OSPL_SetInterruptPriority
dkato 0:37e1e6a45ced 230 ************************************************************************/
dkato 0:37e1e6a45ced 231 errnum_t R_OSPL_SetInterruptPriority( bsp_int_src_t const IRQ_Num, int_fast32_t const Priority )
dkato 0:37e1e6a45ced 232 {
dkato 0:37e1e6a45ced 233 GIC_SetPriority( IRQ_Num, (uint32_t) Priority );
dkato 0:37e1e6a45ced 234 return 0;
dkato 0:37e1e6a45ced 235 }
dkato 0:37e1e6a45ced 236
dkato 0:37e1e6a45ced 237
dkato 0:37e1e6a45ced 238 /***********************************************************************
dkato 0:37e1e6a45ced 239 * Implement: R_OSPL_MEMORY_Flush
dkato 0:37e1e6a45ced 240 ************************************************************************/
dkato 0:37e1e6a45ced 241 void R_OSPL_MEMORY_Flush( r_ospl_flush_t const FlushType )
dkato 0:37e1e6a45ced 242 {
dkato 0:37e1e6a45ced 243 if ( FlushType == R_OSPL_FLUSH_WRITEBACK_INVALIDATE ) {
dkato 0:37e1e6a45ced 244 #if 0
dkato 0:37e1e6a45ced 245 printf( "L1Flush\n" );
dkato 0:37e1e6a45ced 246 #endif
dkato 0:37e1e6a45ced 247
dkato 0:37e1e6a45ced 248 #if IS_RTX_USED
dkato 0:37e1e6a45ced 249 __v7_clean_inv_dcache_all();
dkato 0:37e1e6a45ced 250 #else
dkato 0:37e1e6a45ced 251 #error
dkato 0:37e1e6a45ced 252 #endif
dkato 0:37e1e6a45ced 253 } else if ( FlushType == R_OSPL_FLUSH_WRITEBACK_INVALIDATE_2ND ) {
dkato 0:37e1e6a45ced 254 #if 0
dkato 0:37e1e6a45ced 255 printf( "PL310Flush\n" );
dkato 0:37e1e6a45ced 256 #endif
dkato 0:37e1e6a45ced 257
dkato 0:37e1e6a45ced 258 PL310_CleanInvAllByWay();
dkato 0:37e1e6a45ced 259 } else {
dkato 0:37e1e6a45ced 260 ASSERT_D( false, R_NOOP() );
dkato 0:37e1e6a45ced 261 }
dkato 0:37e1e6a45ced 262 }
dkato 0:37e1e6a45ced 263
dkato 0:37e1e6a45ced 264
dkato 0:37e1e6a45ced 265 /**
dkato 0:37e1e6a45ced 266 * @brief R_OSPL_Is1bitOnly_Fast32_Sub
dkato 0:37e1e6a45ced 267 *
dkato 0:37e1e6a45ced 268 * @par Parameters
dkato 0:37e1e6a45ced 269 * None
dkato 0:37e1e6a45ced 270 * @return None.
dkato 0:37e1e6a45ced 271 */
dkato 0:37e1e6a45ced 272 #ifndef R_OSPL_NDEBUG
dkato 0:37e1e6a45ced 273 static bool_t R_OSPL_Is1bitOnly_Fast32_Sub( uint_fast32_t Value )
dkato 0:37e1e6a45ced 274 {
dkato 0:37e1e6a45ced 275 if ( (Value & 0x0000FFFFu) == 0 ) {
dkato 0:37e1e6a45ced 276 Value >>= 16;
dkato 0:37e1e6a45ced 277 }
dkato 0:37e1e6a45ced 278 if ( (Value & 0x000000FFu) == 0 ) {
dkato 0:37e1e6a45ced 279 Value >>= 8;
dkato 0:37e1e6a45ced 280 }
dkato 0:37e1e6a45ced 281 if ( (Value & 0x0000000Fu) == 0 ) {
dkato 0:37e1e6a45ced 282 Value >>= 4;
dkato 0:37e1e6a45ced 283 }
dkato 0:37e1e6a45ced 284 if ( (Value & 0x00000003u) == 0 ) {
dkato 0:37e1e6a45ced 285 Value >>= 2;
dkato 0:37e1e6a45ced 286 }
dkato 0:37e1e6a45ced 287 if ( (Value & 0x00000001u) == 0 ) {
dkato 0:37e1e6a45ced 288 Value >>= 1;
dkato 0:37e1e6a45ced 289 }
dkato 0:37e1e6a45ced 290 return ( Value == 1 );
dkato 0:37e1e6a45ced 291 }
dkato 0:37e1e6a45ced 292 #endif
dkato 0:37e1e6a45ced 293
dkato 0:37e1e6a45ced 294
dkato 0:37e1e6a45ced 295 /***********************************************************************
dkato 0:37e1e6a45ced 296 * Implement: R_OSPL_MEMORY_RangeFlush
dkato 0:37e1e6a45ced 297 ************************************************************************/
dkato 0:37e1e6a45ced 298 errnum_t R_OSPL_MEMORY_RangeFlush( r_ospl_flush_t const FlushType,
dkato 0:37e1e6a45ced 299 const void *const StartAddress, size_t const Length )
dkato 0:37e1e6a45ced 300 {
dkato 0:37e1e6a45ced 301 errnum_t e;
dkato 0:37e1e6a45ced 302 size_t cache_line_size;
dkato 0:37e1e6a45ced 303 size_t cache_line_mask;
dkato 0:37e1e6a45ced 304 uintptr_t start;
dkato 0:37e1e6a45ced 305 uintptr_t over;
dkato 0:37e1e6a45ced 306
dkato 0:37e1e6a45ced 307 ASSERT_R( FlushType == R_OSPL_FLUSH_INVALIDATE, e=E_BAD_COMMAND_ID; goto fin );
dkato 0:37e1e6a45ced 308
dkato 0:37e1e6a45ced 309 cache_line_size = R_OSPL_MEMORY_GetCacheLineSize();
dkato 0:37e1e6a45ced 310 cache_line_mask = cache_line_size - 1u;
dkato 0:37e1e6a45ced 311 ASSERT_D( R_OSPL_Is1bitOnly_Fast32_Sub( cache_line_size ), e=E_OTHERS; goto fin );
dkato 0:37e1e6a45ced 312
dkato 0:37e1e6a45ced 313 /* ->MISRA 11.3 */ /* ->SEC R2.7.1 */
dkato 0:37e1e6a45ced 314 ASSERT_R( ( (uintptr_t) StartAddress & cache_line_mask ) == 0u, e=E_OTHERS; goto fin );
dkato 0:37e1e6a45ced 315 ASSERT_R( ( Length & cache_line_mask ) == 0u, e=E_OTHERS; goto fin );
dkato 0:37e1e6a45ced 316
dkato 0:37e1e6a45ced 317 start = (uintptr_t) StartAddress;
dkato 0:37e1e6a45ced 318 over = ((uintptr_t) StartAddress + Length) - 1u;
dkato 0:37e1e6a45ced 319 /* <-MISRA 11.3 */ /* <-SEC R2.7.1 */
dkato 0:37e1e6a45ced 320
dkato 0:37e1e6a45ced 321 R_OSPL_MEMORY_RangeFlush_Sub( start, over, cache_line_size );
dkato 0:37e1e6a45ced 322
dkato 0:37e1e6a45ced 323 e=0;
dkato 0:37e1e6a45ced 324 fin:
dkato 0:37e1e6a45ced 325 return e;
dkato 0:37e1e6a45ced 326 }
dkato 0:37e1e6a45ced 327
dkato 0:37e1e6a45ced 328
dkato 0:37e1e6a45ced 329 /***********************************************************************
dkato 0:37e1e6a45ced 330 * Implement: R_OSPL_MEMORY_GetSpecification
dkato 0:37e1e6a45ced 331 ************************************************************************/
dkato 0:37e1e6a45ced 332 void R_OSPL_MEMORY_GetSpecification( r_ospl_memory_spec_t *const out_MemorySpec )
dkato 0:37e1e6a45ced 333 {
dkato 0:37e1e6a45ced 334 IF_DQ( out_MemorySpec == NULL ) {
dkato 0:37e1e6a45ced 335 goto fin;
dkato 0:37e1e6a45ced 336 }
dkato 0:37e1e6a45ced 337
dkato 0:37e1e6a45ced 338 out_MemorySpec->CacheLineSize = R_OSPL_MEMORY_GetCacheLineSize();
dkato 0:37e1e6a45ced 339
dkato 0:37e1e6a45ced 340 fin:
dkato 0:37e1e6a45ced 341 return;
dkato 0:37e1e6a45ced 342 }
dkato 0:37e1e6a45ced 343
dkato 0:37e1e6a45ced 344
dkato 0:37e1e6a45ced 345 /***********************************************************************
dkato 0:37e1e6a45ced 346 * Implement: R_OSPL_Delay
dkato 0:37e1e6a45ced 347 ************************************************************************/
dkato 0:37e1e6a45ced 348 errnum_t R_OSPL_Delay( uint32_t const DelayTime_msec )
dkato 0:37e1e6a45ced 349 {
dkato 0:37e1e6a45ced 350 errnum_t e;
dkato 0:37e1e6a45ced 351 osStatus rs;
dkato 0:37e1e6a45ced 352 bool_t const is_overflow = ( DelayTime_msec > R_OSPL_MAX_TIME_OUT );
dkato 0:37e1e6a45ced 353 uint32_t const delay_parameter = DelayTime_msec + 1u;
dkato 0:37e1e6a45ced 354
dkato 0:37e1e6a45ced 355 ASSERT_D( ! is_overflow, R_NOOP() );
dkato 0:37e1e6a45ced 356 /* RTX 5.16: If delay_parameter = 100000, "osDelay" waits 65534 */
dkato 0:37e1e6a45ced 357
dkato 0:37e1e6a45ced 358 rs= osDelay( delay_parameter );
dkato 0:37e1e6a45ced 359 IF ( rs == osErrorISR ) {
dkato 0:37e1e6a45ced 360 e=E_NOT_THREAD;
dkato 0:37e1e6a45ced 361 R_OSPL_RaiseUnrecoverable( e );
dkato 0:37e1e6a45ced 362 goto fin;
dkato 0:37e1e6a45ced 363 }
dkato 0:37e1e6a45ced 364 IF ( IS( is_overflow ) ) {
dkato 0:37e1e6a45ced 365 e=E_TIME_OUT;
dkato 0:37e1e6a45ced 366 goto fin;
dkato 0:37e1e6a45ced 367 }
dkato 0:37e1e6a45ced 368
dkato 0:37e1e6a45ced 369 IF (
dkato 0:37e1e6a45ced 370 (rs != osOK) && /* for delay_parameter == 0 */
dkato 0:37e1e6a45ced 371 (rs != osEventTimeout) ) { /* for delay_parameter != 0 */
dkato 0:37e1e6a45ced 372 e=E_OTHERS;
dkato 0:37e1e6a45ced 373 goto fin;
dkato 0:37e1e6a45ced 374 }
dkato 0:37e1e6a45ced 375
dkato 0:37e1e6a45ced 376 e=0;
dkato 0:37e1e6a45ced 377 fin:
dkato 0:37e1e6a45ced 378 return e;
dkato 0:37e1e6a45ced 379 }
dkato 0:37e1e6a45ced 380
dkato 0:37e1e6a45ced 381
dkato 0:37e1e6a45ced 382 /***********************************************************************
dkato 0:37e1e6a45ced 383 * Implement: R_OSPL_QUEUE_Create
dkato 0:37e1e6a45ced 384 ************************************************************************/
dkato 0:37e1e6a45ced 385 errnum_t R_OSPL_QUEUE_Create( r_ospl_queue_t **out_self, r_ospl_queue_def_t *QueueDefine )
dkato 0:37e1e6a45ced 386 {
dkato 0:37e1e6a45ced 387 errnum_t e;
dkato 0:37e1e6a45ced 388 r_ospl_queue_t *self = QueueDefine;
dkato 0:37e1e6a45ced 389
dkato 0:37e1e6a45ced 390 self->MailQId = osMailCreate( (osMailQDef_t *) QueueDefine->MailQDef, NULL );
dkato 0:37e1e6a45ced 391 IF ( self->MailQId == NULL ) {
dkato 0:37e1e6a45ced 392 e=E_OTHERS;
dkato 0:37e1e6a45ced 393 goto fin;
dkato 0:37e1e6a45ced 394 }
dkato 0:37e1e6a45ced 395 self->PublicStatus.UsedCount = 0;
dkato 0:37e1e6a45ced 396
dkato 0:37e1e6a45ced 397 *out_self = self;
dkato 0:37e1e6a45ced 398
dkato 0:37e1e6a45ced 399 e=0;
dkato 0:37e1e6a45ced 400 fin:
dkato 0:37e1e6a45ced 401 return e;
dkato 0:37e1e6a45ced 402 }
dkato 0:37e1e6a45ced 403
dkato 0:37e1e6a45ced 404
dkato 0:37e1e6a45ced 405 /***********************************************************************
dkato 0:37e1e6a45ced 406 * Implement: R_OSPL_QUEUE_GetStatus
dkato 0:37e1e6a45ced 407 ************************************************************************/
dkato 0:37e1e6a45ced 408 errnum_t R_OSPL_QUEUE_GetStatus( r_ospl_queue_t *self, const r_ospl_queue_status_t **out_Status )
dkato 0:37e1e6a45ced 409 {
dkato 0:37e1e6a45ced 410 *out_Status = &self->PublicStatus;
dkato 0:37e1e6a45ced 411 return 0;
dkato 0:37e1e6a45ced 412 }
dkato 0:37e1e6a45ced 413
dkato 0:37e1e6a45ced 414
dkato 0:37e1e6a45ced 415 /***********************************************************************
dkato 0:37e1e6a45ced 416 * Implement: R_OSPL_QUEUE_Allocate
dkato 0:37e1e6a45ced 417 ************************************************************************/
dkato 0:37e1e6a45ced 418 errnum_t R_OSPL_QUEUE_Allocate( r_ospl_queue_t *self, void *out_Address, uint32_t Timeout_msec )
dkato 0:37e1e6a45ced 419 {
dkato 0:37e1e6a45ced 420 errnum_t e;
dkato 0:37e1e6a45ced 421 void *address;
dkato 0:37e1e6a45ced 422 bool_t was_all_enabled = false;
dkato 0:37e1e6a45ced 423
dkato 0:37e1e6a45ced 424 address = osMailAlloc( self->MailQId, Timeout_msec );
dkato 0:37e1e6a45ced 425 *(void **) out_Address = address;
dkato 0:37e1e6a45ced 426 IF ( address == NULL && Timeout_msec > 0 ) {
dkato 0:37e1e6a45ced 427 if ( R_OSPL_THREAD_GetCurrentId() == NULL ) {
dkato 0:37e1e6a45ced 428 e=E_NOT_THREAD;
dkato 0:37e1e6a45ced 429 } else {
dkato 0:37e1e6a45ced 430 e=E_TIME_OUT;
dkato 0:37e1e6a45ced 431 }
dkato 0:37e1e6a45ced 432 goto fin;
dkato 0:37e1e6a45ced 433 }
dkato 0:37e1e6a45ced 434
dkato 0:37e1e6a45ced 435 was_all_enabled = R_OSPL_DisableAllInterrupt();
dkato 0:37e1e6a45ced 436 self->PublicStatus.UsedCount += 1;
dkato 0:37e1e6a45ced 437
dkato 0:37e1e6a45ced 438 e=0;
dkato 0:37e1e6a45ced 439 fin:
dkato 0:37e1e6a45ced 440 if ( was_all_enabled ) {
dkato 0:37e1e6a45ced 441 R_OSPL_EnableAllInterrupt();
dkato 0:37e1e6a45ced 442 }
dkato 0:37e1e6a45ced 443 return e;
dkato 0:37e1e6a45ced 444 }
dkato 0:37e1e6a45ced 445
dkato 0:37e1e6a45ced 446
dkato 0:37e1e6a45ced 447 /***********************************************************************
dkato 0:37e1e6a45ced 448 * Implement: R_OSPL_QUEUE_Put
dkato 0:37e1e6a45ced 449 ************************************************************************/
dkato 0:37e1e6a45ced 450 errnum_t R_OSPL_QUEUE_Put( r_ospl_queue_t *self, void *Address )
dkato 0:37e1e6a45ced 451 {
dkato 0:37e1e6a45ced 452 errnum_t e;
dkato 0:37e1e6a45ced 453 osStatus status;
dkato 0:37e1e6a45ced 454
dkato 0:37e1e6a45ced 455 status = osMailPut( self->MailQId, Address );
dkato 0:37e1e6a45ced 456 IF ( status != osOK ) {
dkato 0:37e1e6a45ced 457 e=E_OTHERS;
dkato 0:37e1e6a45ced 458 goto fin;
dkato 0:37e1e6a45ced 459 }
dkato 0:37e1e6a45ced 460
dkato 0:37e1e6a45ced 461 e=0;
dkato 0:37e1e6a45ced 462 fin:
dkato 0:37e1e6a45ced 463 return e;
dkato 0:37e1e6a45ced 464 }
dkato 0:37e1e6a45ced 465
dkato 0:37e1e6a45ced 466
dkato 0:37e1e6a45ced 467 /***********************************************************************
dkato 0:37e1e6a45ced 468 * Implement: R_OSPL_QUEUE_Get
dkato 0:37e1e6a45ced 469 ************************************************************************/
dkato 0:37e1e6a45ced 470 errnum_t R_OSPL_QUEUE_Get( r_ospl_queue_t *self, void *out_Address, uint32_t Timeout_msec )
dkato 0:37e1e6a45ced 471 {
dkato 0:37e1e6a45ced 472 errnum_t e;
dkato 0:37e1e6a45ced 473 osEvent event;
dkato 0:37e1e6a45ced 474
dkato 0:37e1e6a45ced 475 event = osMailGet( self->MailQId, Timeout_msec );
dkato 0:37e1e6a45ced 476
dkato 0:37e1e6a45ced 477 if ( event.status != osOK ) {
dkato 0:37e1e6a45ced 478 IF ( event.status != osEventMail ) {
dkato 0:37e1e6a45ced 479 if ( event.status == osEventTimeout ) {
dkato 0:37e1e6a45ced 480 e = E_TIME_OUT;
dkato 0:37e1e6a45ced 481 } else if ( event.status == osErrorParameter ) {
dkato 0:37e1e6a45ced 482 if ( R_OSPL_THREAD_GetCurrentId() == NULL ) {
dkato 0:37e1e6a45ced 483 e = E_NOT_THREAD;
dkato 0:37e1e6a45ced 484 } else {
dkato 0:37e1e6a45ced 485 e = E_OTHERS;
dkato 0:37e1e6a45ced 486 }
dkato 0:37e1e6a45ced 487 } else {
dkato 0:37e1e6a45ced 488 e = E_OTHERS;
dkato 0:37e1e6a45ced 489 }
dkato 0:37e1e6a45ced 490 goto fin;
dkato 0:37e1e6a45ced 491 }
dkato 0:37e1e6a45ced 492 }
dkato 0:37e1e6a45ced 493
dkato 0:37e1e6a45ced 494 *(void **) out_Address = event.value.p;
dkato 0:37e1e6a45ced 495
dkato 0:37e1e6a45ced 496 e=0;
dkato 0:37e1e6a45ced 497 fin:
dkato 0:37e1e6a45ced 498 return e;
dkato 0:37e1e6a45ced 499 }
dkato 0:37e1e6a45ced 500
dkato 0:37e1e6a45ced 501
dkato 0:37e1e6a45ced 502 /***********************************************************************
dkato 0:37e1e6a45ced 503 * Implement: R_OSPL_QUEUE_Free
dkato 0:37e1e6a45ced 504 ************************************************************************/
dkato 0:37e1e6a45ced 505 errnum_t R_OSPL_QUEUE_Free( r_ospl_queue_t *self, void *Address )
dkato 0:37e1e6a45ced 506 {
dkato 0:37e1e6a45ced 507 errnum_t e;
dkato 0:37e1e6a45ced 508 osStatus status;
dkato 0:37e1e6a45ced 509 bool_t was_all_enabled = false;
dkato 0:37e1e6a45ced 510
dkato 0:37e1e6a45ced 511 status = osMailFree( self->MailQId, Address );
dkato 0:37e1e6a45ced 512 IF ( status != osOK ) {
dkato 0:37e1e6a45ced 513 e=E_OTHERS;
dkato 0:37e1e6a45ced 514 goto fin;
dkato 0:37e1e6a45ced 515 }
dkato 0:37e1e6a45ced 516
dkato 0:37e1e6a45ced 517 was_all_enabled = R_OSPL_DisableAllInterrupt();
dkato 0:37e1e6a45ced 518 self->PublicStatus.UsedCount -= 1;
dkato 0:37e1e6a45ced 519
dkato 0:37e1e6a45ced 520 e=0;
dkato 0:37e1e6a45ced 521 fin:
dkato 0:37e1e6a45ced 522 if ( was_all_enabled ) {
dkato 0:37e1e6a45ced 523 R_OSPL_EnableAllInterrupt();
dkato 0:37e1e6a45ced 524 }
dkato 0:37e1e6a45ced 525 return e;
dkato 0:37e1e6a45ced 526 }
dkato 0:37e1e6a45ced 527
dkato 0:37e1e6a45ced 528