RZ/A1H CMSIS-RTOS RTX BSP for GR-PEACH.

Dependents:   GR-PEACH_Azure_Speech ImageZoomInout_Sample ImageRotaion_Sample ImageScroll_Sample ... more

Fork of R_BSP by Daiki Kato

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers misratypes.h Source File

misratypes.h

00001 /*******************************************************************************
00002 * DISCLAIMER
00003 * This software is supplied by Renesas Electronics Corporation and is only
00004 * intended for use with Renesas products. No other uses are authorized. This
00005 * software is owned by Renesas Electronics Corporation and is protected under
00006 * all applicable laws, including copyright laws.
00007 * THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
00008 * THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
00009 * LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
00010 * AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
00011 * TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
00012 * ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
00013 * FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
00014 * ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
00015 * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
00016 * Renesas reserves the right, without notice, to make changes to this software
00017 * and to discontinue the availability of this software. By using this software,
00018 * you agree to the additional terms and conditions found by accessing the
00019 * following link:
00020 * http://www.renesas.com/disclaimer*
00021 * Copyright (C) 2009-2012 Renesas Electronics Corporation. All rights reserved.
00022 *******************************************************************************/
00023 
00024 /******************************************************************************
00025  *
00026  *  V. 2.03.00
00027  * $Rev: 1667 $
00028  * $Date:: 2015-05-29 14:01:37 +0900#$
00029  *
00030  * Description : Types for MISRA compliant C code.
00031  *
00032  *****************************************************************************/
00033 
00034 #ifndef _MISRATYPES_H_INCLUDED_
00035 #define _MISRATYPES_H_INCLUDED_
00036 
00037 
00038 /***********************************************************************************
00039  System Includes
00040 ***********************************************************************************/
00041 #include <cmsis_os.h>
00042 
00043 /***********************************************************************************
00044  User Includes
00045 ***********************************************************************************/
00046 #include "r_typedefs.h"
00047 
00048 /***********************************************************************************
00049  Defines
00050 ***********************************************************************************/
00051 #ifdef __cplusplus
00052 extern "C" {
00053 #endif
00054 
00055 
00056 /***********************************************************************************
00057  Constant Macros
00058 ***********************************************************************************/
00059 
00060 
00061 /***********************************************************************************
00062  Function Macros
00063 ***********************************************************************************/
00064 
00065 /* Use this macro for an unused function argument */
00066 #define UNUSED_ARG(var)  (void)unused_arg(&(var))
00067 
00068 /* Use this macro to check is a value of any type is an error code */
00069 #define ISERROR(val) iserror((int32_t)(val))
00070 
00071 /* Use this macro when assigning a function for a task */
00072 #define TO_FP_FUNCTION(val) to_fp_function(val)
00073 
00074 /***********************************************************************************
00075  Typedefs
00076 ***********************************************************************************/
00077 
00078 typedef void (*funcptr_t)(void);
00079 
00080 /***********************************************************************************
00081  Enumerated Types
00082 ***********************************************************************************/
00083 
00084 /***********************************************************************************
00085  Function Prototypes
00086 ***********************************************************************************/
00087 
00088 /* These functions are inlined by the SHC compiler in an optimise=1 build */
00089 static const void* unused_arg(const void* const var);
00090 static void *error_to_ptr(int32_t er);
00091 static bool_t iserror(int32_t ser);
00092 static funcptr_t to_fp_function(void (*val)(int32_t));
00093 
00094 /***********************************************************************************
00095  Inline Functions
00096 ***********************************************************************************/
00097 
00098 /**********************************************************************************
00099 Function Name:  unused_arg
00100 Description:    Used to prevent unused argument warnings from QA-C.
00101                 This function will be inlined by the SHC compiler and generate no code.
00102                 Use this function via the UNUSED_ARG macro.
00103 
00104 Parameters:     Pointer to unused argument
00105 
00106 Return value:   Passed in argument.
00107 ***********************************************************************************/
00108 #if   defined (__CC_ARM)
00109 #pragma inline unused_arg
00110 #elif defined (__ICCARM__)
00111 #pragma inline =forced
00112 #endif
00113 static const void* unused_arg(const void* const var)
00114 {
00115     return var;
00116 }
00117 
00118 /**********************************************************************************
00119 Function Name:  iserror
00120 Description:    Check if a value is an error code.  This is used instead of the HIOS
00121                 iserrno macro as that generates many warnings in QA-C.
00122                 This function will be inlined by the SHC compiler.
00123                 Use this function via the ISERROR macro.
00124 
00125 Parameters:     Value to check for error code
00126 
00127 Return value:   Non-zero if the value is an error code
00128 ***********************************************************************************/
00129 
00130 #if   defined (__CC_ARM)
00131 #pragma inline iserror
00132 #elif defined (__ICCARM__)
00133 #pragma inline =forced
00134 #endif
00135 static bool_t iserror(const int32_t ser)
00136 {
00137     uint32_t er = (uint32_t) ser;
00138     return er >= 0xffffff80u;
00139 }
00140 
00141 /**********************************************************************************
00142 Function Name:  error_to_ptr
00143 Description:    Convert an error code to a pointer so we can return an error from
00144                 IOIF driver functions such as open and initialise without getting
00145                 warnings from QA-C.
00146                 This function will be inlined by the SHC compiler.
00147 
00148 Parameters:     Error code
00149 
00150 Return value:   Error code converted to a pointer
00151 ***********************************************************************************/
00152 #if   defined (__CC_ARM)
00153 #pragma inline error_to_ptr
00154 #elif defined (__ICCARM__)
00155 #pragma inline =forced
00156 #endif
00157 static void *error_to_ptr(const int32_t er)
00158 {
00159     return (void*) er;
00160 }
00161 
00162 /**********************************************************************************
00163 Function Name:  to_fp_function
00164 Description:    Converts a void (*fn)(VP_INT) function pointer to a FP function pointer
00165                 without getting warnings from QA-C.
00166                 This function will be inlined by the SHC compiler.
00167 
00168 Parameters:     Function pointer as void (*fn)(VP_INT)
00169 
00170 Return value:   Functino pointer as a FP
00171 ***********************************************************************************/
00172 #if   defined (__CC_ARM)
00173 #pragma inline to_fp_function
00174 #elif defined (__ICCARM__)
00175 #pragma inline =forced
00176 #endif
00177 static funcptr_t to_fp_function(void (*val)(int32_t))
00178 {
00179     /* QA-C will generate an error for this line as we are casting
00180      * between different function pointer types.
00181      */
00182     return (funcptr_t)val;
00183 }
00184 
00185 #ifdef __cplusplus
00186 }
00187 #endif
00188 
00189 #endif /* _MISRATYPES_H_INCLUDED_ */