Commit code folders
This commit is contained in:
parent
10c58a7405
commit
e97ff023d2
|
@ -0,0 +1,17 @@
|
|||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<project>
|
||||
<configuration id="com.crt.advproject.config.exe.debug.1158252545" name="Debug">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="com.crt.advproject.GCCBuildCommandParser" keep-relative-paths="false" name="MCU GCC Build Output Parser" parameter="(arm-none-eabi-gcc)|(arm-none-eabi-[gc]\+\+)|(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
</extension>
|
||||
</configuration>
|
||||
<configuration id="com.crt.advproject.config.exe.release.2014374705" name="Release">
|
||||
<extension point="org.eclipse.cdt.core.LanguageSettingsProvider">
|
||||
<provider copy-of="extension" id="org.eclipse.cdt.ui.UserLanguageSettingsProvider"/>
|
||||
<provider class="org.eclipse.cdt.managedbuilder.language.settings.providers.GCCBuildCommandParser" id="com.crt.advproject.GCCBuildCommandParser" keep-relative-paths="false" name="MCU GCC Build Output Parser" parameter="(arm-none-eabi-gcc)|(arm-none-eabi-[gc]\+\+)|(gcc)|([gc]\+\+)|(clang)" prefer-non-shared="true"/>
|
||||
<provider-reference id="org.eclipse.cdt.managedbuilder.core.MBSLanguageSettingsProvider" ref="shared-provider"/>
|
||||
</extension>
|
||||
</configuration>
|
||||
</project>
|
|
@ -0,0 +1,11 @@
|
|||
eclipse.preferences.version=1
|
||||
environment/buildEnvironmentInclude/com.crt.advproject.config.exe.debug.1158252545/CPATH/delimiter=;
|
||||
environment/buildEnvironmentInclude/com.crt.advproject.config.exe.debug.1158252545/CPATH/operation=remove
|
||||
environment/buildEnvironmentInclude/com.crt.advproject.config.exe.debug.1158252545/C_INCLUDE_PATH/delimiter=;
|
||||
environment/buildEnvironmentInclude/com.crt.advproject.config.exe.debug.1158252545/C_INCLUDE_PATH/operation=remove
|
||||
environment/buildEnvironmentInclude/com.crt.advproject.config.exe.debug.1158252545/append=true
|
||||
environment/buildEnvironmentInclude/com.crt.advproject.config.exe.debug.1158252545/appendContributed=true
|
||||
environment/buildEnvironmentLibrary/com.crt.advproject.config.exe.debug.1158252545/LIBRARY_PATH/delimiter=;
|
||||
environment/buildEnvironmentLibrary/com.crt.advproject.config.exe.debug.1158252545/LIBRARY_PATH/operation=remove
|
||||
environment/buildEnvironmentLibrary/com.crt.advproject.config.exe.debug.1158252545/append=true
|
||||
environment/buildEnvironmentLibrary/com.crt.advproject.config.exe.debug.1158252545/appendContributed=true
|
|
@ -0,0 +1,121 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_common_tables.h
|
||||
* Description: Extern declaration for common tables
|
||||
*
|
||||
* $Date: 27. January 2017
|
||||
* $Revision: V.1.5.1
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_COMMON_TABLES_H
|
||||
#define _ARM_COMMON_TABLES_H
|
||||
|
||||
#include "arm_math.h"
|
||||
|
||||
extern const uint16_t armBitRevTable[1024];
|
||||
extern const q15_t armRecipTableQ15[64];
|
||||
extern const q31_t armRecipTableQ31[64];
|
||||
extern const float32_t twiddleCoef_16[32];
|
||||
extern const float32_t twiddleCoef_32[64];
|
||||
extern const float32_t twiddleCoef_64[128];
|
||||
extern const float32_t twiddleCoef_128[256];
|
||||
extern const float32_t twiddleCoef_256[512];
|
||||
extern const float32_t twiddleCoef_512[1024];
|
||||
extern const float32_t twiddleCoef_1024[2048];
|
||||
extern const float32_t twiddleCoef_2048[4096];
|
||||
extern const float32_t twiddleCoef_4096[8192];
|
||||
#define twiddleCoef twiddleCoef_4096
|
||||
extern const q31_t twiddleCoef_16_q31[24];
|
||||
extern const q31_t twiddleCoef_32_q31[48];
|
||||
extern const q31_t twiddleCoef_64_q31[96];
|
||||
extern const q31_t twiddleCoef_128_q31[192];
|
||||
extern const q31_t twiddleCoef_256_q31[384];
|
||||
extern const q31_t twiddleCoef_512_q31[768];
|
||||
extern const q31_t twiddleCoef_1024_q31[1536];
|
||||
extern const q31_t twiddleCoef_2048_q31[3072];
|
||||
extern const q31_t twiddleCoef_4096_q31[6144];
|
||||
extern const q15_t twiddleCoef_16_q15[24];
|
||||
extern const q15_t twiddleCoef_32_q15[48];
|
||||
extern const q15_t twiddleCoef_64_q15[96];
|
||||
extern const q15_t twiddleCoef_128_q15[192];
|
||||
extern const q15_t twiddleCoef_256_q15[384];
|
||||
extern const q15_t twiddleCoef_512_q15[768];
|
||||
extern const q15_t twiddleCoef_1024_q15[1536];
|
||||
extern const q15_t twiddleCoef_2048_q15[3072];
|
||||
extern const q15_t twiddleCoef_4096_q15[6144];
|
||||
extern const float32_t twiddleCoef_rfft_32[32];
|
||||
extern const float32_t twiddleCoef_rfft_64[64];
|
||||
extern const float32_t twiddleCoef_rfft_128[128];
|
||||
extern const float32_t twiddleCoef_rfft_256[256];
|
||||
extern const float32_t twiddleCoef_rfft_512[512];
|
||||
extern const float32_t twiddleCoef_rfft_1024[1024];
|
||||
extern const float32_t twiddleCoef_rfft_2048[2048];
|
||||
extern const float32_t twiddleCoef_rfft_4096[4096];
|
||||
|
||||
/* floating-point bit reversal tables */
|
||||
#define ARMBITREVINDEXTABLE_16_TABLE_LENGTH ((uint16_t)20)
|
||||
#define ARMBITREVINDEXTABLE_32_TABLE_LENGTH ((uint16_t)48)
|
||||
#define ARMBITREVINDEXTABLE_64_TABLE_LENGTH ((uint16_t)56)
|
||||
#define ARMBITREVINDEXTABLE_128_TABLE_LENGTH ((uint16_t)208)
|
||||
#define ARMBITREVINDEXTABLE_256_TABLE_LENGTH ((uint16_t)440)
|
||||
#define ARMBITREVINDEXTABLE_512_TABLE_LENGTH ((uint16_t)448)
|
||||
#define ARMBITREVINDEXTABLE_1024_TABLE_LENGTH ((uint16_t)1800)
|
||||
#define ARMBITREVINDEXTABLE_2048_TABLE_LENGTH ((uint16_t)3808)
|
||||
#define ARMBITREVINDEXTABLE_4096_TABLE_LENGTH ((uint16_t)4032)
|
||||
|
||||
extern const uint16_t armBitRevIndexTable16[ARMBITREVINDEXTABLE_16_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable32[ARMBITREVINDEXTABLE_32_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable64[ARMBITREVINDEXTABLE_64_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable128[ARMBITREVINDEXTABLE_128_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable256[ARMBITREVINDEXTABLE_256_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable512[ARMBITREVINDEXTABLE_512_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable1024[ARMBITREVINDEXTABLE_1024_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable2048[ARMBITREVINDEXTABLE_2048_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable4096[ARMBITREVINDEXTABLE_4096_TABLE_LENGTH];
|
||||
|
||||
/* fixed-point bit reversal tables */
|
||||
#define ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH ((uint16_t)12)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH ((uint16_t)24)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH ((uint16_t)56)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH ((uint16_t)112)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH ((uint16_t)240)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH ((uint16_t)480)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH ((uint16_t)992)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH ((uint16_t)1984)
|
||||
#define ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH ((uint16_t)4032)
|
||||
|
||||
extern const uint16_t armBitRevIndexTable_fixed_16[ARMBITREVINDEXTABLE_FIXED_16_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_32[ARMBITREVINDEXTABLE_FIXED_32_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_64[ARMBITREVINDEXTABLE_FIXED_64_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_128[ARMBITREVINDEXTABLE_FIXED_128_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_256[ARMBITREVINDEXTABLE_FIXED_256_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_512[ARMBITREVINDEXTABLE_FIXED_512_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_1024[ARMBITREVINDEXTABLE_FIXED_1024_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_2048[ARMBITREVINDEXTABLE_FIXED_2048_TABLE_LENGTH];
|
||||
extern const uint16_t armBitRevIndexTable_fixed_4096[ARMBITREVINDEXTABLE_FIXED_4096_TABLE_LENGTH];
|
||||
|
||||
/* Tables for Fast Math Sine and Cosine */
|
||||
extern const float32_t sinTable_f32[FAST_MATH_TABLE_SIZE + 1];
|
||||
extern const q31_t sinTable_q31[FAST_MATH_TABLE_SIZE + 1];
|
||||
extern const q15_t sinTable_q15[FAST_MATH_TABLE_SIZE + 1];
|
||||
|
||||
#endif /* ARM_COMMON_TABLES_H */
|
|
@ -0,0 +1,66 @@
|
|||
/* ----------------------------------------------------------------------
|
||||
* Project: CMSIS DSP Library
|
||||
* Title: arm_const_structs.h
|
||||
* Description: Constant structs that are initialized for user convenience.
|
||||
* For example, some can be given as arguments to the arm_cfft_f32() function.
|
||||
*
|
||||
* $Date: 27. January 2017
|
||||
* $Revision: V.1.5.1
|
||||
*
|
||||
* Target Processor: Cortex-M cores
|
||||
* -------------------------------------------------------------------- */
|
||||
/*
|
||||
* Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef _ARM_CONST_STRUCTS_H
|
||||
#define _ARM_CONST_STRUCTS_H
|
||||
|
||||
#include "arm_math.h"
|
||||
#include "arm_common_tables.h"
|
||||
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len16;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len32;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len64;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len128;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len256;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len512;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len1024;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len2048;
|
||||
extern const arm_cfft_instance_f32 arm_cfft_sR_f32_len4096;
|
||||
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len16;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len32;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len64;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len128;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len256;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len512;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len1024;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len2048;
|
||||
extern const arm_cfft_instance_q31 arm_cfft_sR_q31_len4096;
|
||||
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len16;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len32;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len64;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len128;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len256;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len512;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len1024;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len2048;
|
||||
extern const arm_cfft_instance_q15 arm_cfft_sR_q15_len4096;
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,870 @@
|
|||
/**************************************************************************//**
|
||||
* @file cmsis_armcc.h
|
||||
* @brief CMSIS compiler ARMCC (Arm Compiler 5) header file
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_ARMCC_H
|
||||
#define __CMSIS_ARMCC_H
|
||||
|
||||
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 400677)
|
||||
#error "Please use Arm Compiler Toolchain V4.0.677 or later!"
|
||||
#endif
|
||||
|
||||
/* CMSIS compiler control architecture macros */
|
||||
#if ((defined (__TARGET_ARCH_6_M ) && (__TARGET_ARCH_6_M == 1)) || \
|
||||
(defined (__TARGET_ARCH_6S_M ) && (__TARGET_ARCH_6S_M == 1)) )
|
||||
#define __ARM_ARCH_6M__ 1
|
||||
#endif
|
||||
|
||||
#if (defined (__TARGET_ARCH_7_M ) && (__TARGET_ARCH_7_M == 1))
|
||||
#define __ARM_ARCH_7M__ 1
|
||||
#endif
|
||||
|
||||
#if (defined (__TARGET_ARCH_7E_M) && (__TARGET_ARCH_7E_M == 1))
|
||||
#define __ARM_ARCH_7EM__ 1
|
||||
#endif
|
||||
|
||||
/* __ARM_ARCH_8M_BASE__ not applicable */
|
||||
/* __ARM_ARCH_8M_MAIN__ not applicable */
|
||||
|
||||
|
||||
/* CMSIS compiler specific defines */
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE __inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static __inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE static __forceinline
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __declspec(noreturn)
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT __packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION __packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
#define __UNALIGNED_UINT32(x) (*((__packed uint32_t *)(x)))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) ((*((__packed uint16_t *)(addr))) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
#define __UNALIGNED_UINT16_READ(addr) (*((const __packed uint16_t *)(addr)))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) ((*((__packed uint32_t *)(addr))) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
#define __UNALIGNED_UINT32_READ(addr) (*((const __packed uint32_t *)(addr)))
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#define __RESTRICT __restrict
|
||||
#endif
|
||||
|
||||
/* ########################### Core Function Access ########################### */
|
||||
/** \ingroup CMSIS_Core_FunctionInterface
|
||||
\defgroup CMSIS_Core_RegAccFunctions CMSIS Core Register Access Functions
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief Enable IRQ Interrupts
|
||||
\details Enables IRQ interrupts by clearing the I-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
/* intrinsic void __enable_irq(); */
|
||||
|
||||
|
||||
/**
|
||||
\brief Disable IRQ Interrupts
|
||||
\details Disables IRQ interrupts by setting the I-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
/* intrinsic void __disable_irq(); */
|
||||
|
||||
/**
|
||||
\brief Get Control Register
|
||||
\details Returns the content of the Control Register.
|
||||
\return Control Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_CONTROL(void)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
return(__regControl);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Control Register
|
||||
\details Writes the given value to the Control Register.
|
||||
\param [in] control Control Register value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_CONTROL(uint32_t control)
|
||||
{
|
||||
register uint32_t __regControl __ASM("control");
|
||||
__regControl = control;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get IPSR Register
|
||||
\details Returns the content of the IPSR Register.
|
||||
\return IPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_IPSR(void)
|
||||
{
|
||||
register uint32_t __regIPSR __ASM("ipsr");
|
||||
return(__regIPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get APSR Register
|
||||
\details Returns the content of the APSR Register.
|
||||
\return APSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||
{
|
||||
register uint32_t __regAPSR __ASM("apsr");
|
||||
return(__regAPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get xPSR Register
|
||||
\details Returns the content of the xPSR Register.
|
||||
\return xPSR Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_xPSR(void)
|
||||
{
|
||||
register uint32_t __regXPSR __ASM("xpsr");
|
||||
return(__regXPSR);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Process Stack Pointer
|
||||
\details Returns the current value of the Process Stack Pointer (PSP).
|
||||
\return PSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PSP(void)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
return(__regProcessStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Process Stack Pointer
|
||||
\details Assigns the given value to the Process Stack Pointer (PSP).
|
||||
\param [in] topOfProcStack Process Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_PSP(uint32_t topOfProcStack)
|
||||
{
|
||||
register uint32_t __regProcessStackPointer __ASM("psp");
|
||||
__regProcessStackPointer = topOfProcStack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Main Stack Pointer
|
||||
\details Returns the current value of the Main Stack Pointer (MSP).
|
||||
\return MSP Register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_MSP(void)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
return(__regMainStackPointer);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Main Stack Pointer
|
||||
\details Assigns the given value to the Main Stack Pointer (MSP).
|
||||
\param [in] topOfMainStack Main Stack Pointer value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_MSP(uint32_t topOfMainStack)
|
||||
{
|
||||
register uint32_t __regMainStackPointer __ASM("msp");
|
||||
__regMainStackPointer = topOfMainStack;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Priority Mask
|
||||
\details Returns the current state of the priority mask bit from the Priority Mask Register.
|
||||
\return Priority Mask value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_PRIMASK(void)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
return(__regPriMask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Priority Mask
|
||||
\details Assigns the given value to the Priority Mask Register.
|
||||
\param [in] priMask Priority Mask
|
||||
*/
|
||||
__STATIC_INLINE void __set_PRIMASK(uint32_t priMask)
|
||||
{
|
||||
register uint32_t __regPriMask __ASM("primask");
|
||||
__regPriMask = (priMask);
|
||||
}
|
||||
|
||||
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
/**
|
||||
\brief Enable FIQ
|
||||
\details Enables FIQ interrupts by clearing the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __enable_fault_irq __enable_fiq
|
||||
|
||||
|
||||
/**
|
||||
\brief Disable FIQ
|
||||
\details Disables FIQ interrupts by setting the F-bit in the CPSR.
|
||||
Can only be executed in Privileged modes.
|
||||
*/
|
||||
#define __disable_fault_irq __disable_fiq
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Base Priority
|
||||
\details Returns the current value of the Base Priority register.
|
||||
\return Base Priority register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_BASEPRI(void)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
return(__regBasePri);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Base Priority
|
||||
\details Assigns the given value to the Base Priority register.
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_BASEPRI(uint32_t basePri)
|
||||
{
|
||||
register uint32_t __regBasePri __ASM("basepri");
|
||||
__regBasePri = (basePri & 0xFFU);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Base Priority with condition
|
||||
\details Assigns the given value to the Base Priority register only if BASEPRI masking is disabled,
|
||||
or the new value increases the BASEPRI priority level.
|
||||
\param [in] basePri Base Priority value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_BASEPRI_MAX(uint32_t basePri)
|
||||
{
|
||||
register uint32_t __regBasePriMax __ASM("basepri_max");
|
||||
__regBasePriMax = (basePri & 0xFFU);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Get Fault Mask
|
||||
\details Returns the current value of the Fault Mask register.
|
||||
\return Fault Mask register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FAULTMASK(void)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
return(__regFaultMask);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set Fault Mask
|
||||
\details Assigns the given value to the Fault Mask register.
|
||||
\param [in] faultMask Fault Mask value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FAULTMASK(uint32_t faultMask)
|
||||
{
|
||||
register uint32_t __regFaultMask __ASM("faultmask");
|
||||
__regFaultMask = (faultMask & (uint32_t)1U);
|
||||
}
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
|
||||
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
/**
|
||||
\brief Get FPSCR
|
||||
\details Returns the current value of the Floating Point Status/Control register.
|
||||
\return Floating Point Status/Control register value
|
||||
*/
|
||||
__STATIC_INLINE uint32_t __get_FPSCR(void)
|
||||
{
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
return(__regfpscr);
|
||||
#else
|
||||
return(0U);
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
\brief Set FPSCR
|
||||
\details Assigns the given value to the Floating Point Status/Control register.
|
||||
\param [in] fpscr Floating Point Status/Control value to set
|
||||
*/
|
||||
__STATIC_INLINE void __set_FPSCR(uint32_t fpscr)
|
||||
{
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
register uint32_t __regfpscr __ASM("fpscr");
|
||||
__regfpscr = (fpscr);
|
||||
#else
|
||||
(void)fpscr;
|
||||
#endif
|
||||
}
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
|
||||
|
||||
/*@} end of CMSIS_Core_RegAccFunctions */
|
||||
|
||||
|
||||
/* ########################## Core Instruction Access ######################### */
|
||||
/** \defgroup CMSIS_Core_InstructionInterface CMSIS Core Instruction Interface
|
||||
Access to dedicated instructions
|
||||
@{
|
||||
*/
|
||||
|
||||
/**
|
||||
\brief No Operation
|
||||
\details No Operation does nothing. This instruction can be used for code alignment purposes.
|
||||
*/
|
||||
#define __NOP __nop
|
||||
|
||||
|
||||
/**
|
||||
\brief Wait For Interrupt
|
||||
\details Wait For Interrupt is a hint instruction that suspends execution until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFI __wfi
|
||||
|
||||
|
||||
/**
|
||||
\brief Wait For Event
|
||||
\details Wait For Event is a hint instruction that permits the processor to enter
|
||||
a low-power state until one of a number of events occurs.
|
||||
*/
|
||||
#define __WFE __wfe
|
||||
|
||||
|
||||
/**
|
||||
\brief Send Event
|
||||
\details Send Event is a hint instruction. It causes an event to be signaled to the CPU.
|
||||
*/
|
||||
#define __SEV __sev
|
||||
|
||||
|
||||
/**
|
||||
\brief Instruction Synchronization Barrier
|
||||
\details Instruction Synchronization Barrier flushes the pipeline in the processor,
|
||||
so that all instructions following the ISB are fetched from cache or memory,
|
||||
after the instruction has been completed.
|
||||
*/
|
||||
#define __ISB() do {\
|
||||
__schedule_barrier();\
|
||||
__isb(0xF);\
|
||||
__schedule_barrier();\
|
||||
} while (0U)
|
||||
|
||||
/**
|
||||
\brief Data Synchronization Barrier
|
||||
\details Acts as a special kind of Data Memory Barrier.
|
||||
It completes when all explicit memory accesses before this instruction complete.
|
||||
*/
|
||||
#define __DSB() do {\
|
||||
__schedule_barrier();\
|
||||
__dsb(0xF);\
|
||||
__schedule_barrier();\
|
||||
} while (0U)
|
||||
|
||||
/**
|
||||
\brief Data Memory Barrier
|
||||
\details Ensures the apparent order of the explicit memory operations before
|
||||
and after the instruction, without ensuring their completion.
|
||||
*/
|
||||
#define __DMB() do {\
|
||||
__schedule_barrier();\
|
||||
__dmb(0xF);\
|
||||
__schedule_barrier();\
|
||||
} while (0U)
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (32 bit)
|
||||
\details Reverses the byte order in unsigned integer value. For example, 0x12345678 becomes 0x78563412.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#define __REV __rev
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (16 bit)
|
||||
\details Reverses the byte order within each halfword of a word. For example, 0x12345678 becomes 0x34127856.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".rev16_text"))) __STATIC_INLINE __ASM uint32_t __REV16(uint32_t value)
|
||||
{
|
||||
rev16 r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse byte order (16 bit)
|
||||
\details Reverses the byte order in a 16-bit value and returns the signed 16-bit result. For example, 0x0080 becomes 0x8000.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".revsh_text"))) __STATIC_INLINE __ASM int16_t __REVSH(int16_t value)
|
||||
{
|
||||
revsh r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Rotate Right in unsigned value (32 bit)
|
||||
\details Rotate Right (immediate) provides the value of the contents of a register rotated by a variable number of bits.
|
||||
\param [in] op1 Value to rotate
|
||||
\param [in] op2 Number of Bits to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
#define __ROR __ror
|
||||
|
||||
|
||||
/**
|
||||
\brief Breakpoint
|
||||
\details Causes the processor to enter Debug state.
|
||||
Debug tools can use this to investigate system state when the instruction at a particular address is reached.
|
||||
\param [in] value is ignored by the processor.
|
||||
If required, a debugger can use it to store additional information about the breakpoint.
|
||||
*/
|
||||
#define __BKPT(value) __breakpoint(value)
|
||||
|
||||
|
||||
/**
|
||||
\brief Reverse bit order of value
|
||||
\details Reverses the bit order of the given value.
|
||||
\param [in] value Value to reverse
|
||||
\return Reversed value
|
||||
*/
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
#define __RBIT __rbit
|
||||
#else
|
||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __RBIT(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
uint32_t s = (4U /*sizeof(v)*/ * 8U) - 1U; /* extra shift needed at end */
|
||||
|
||||
result = value; /* r will be reversed bits of v; first get LSB of v */
|
||||
for (value >>= 1U; value != 0U; value >>= 1U)
|
||||
{
|
||||
result <<= 1U;
|
||||
result |= value & 1U;
|
||||
s--;
|
||||
}
|
||||
result <<= s; /* shift when v's highest bits are zero */
|
||||
return result;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Count leading zeros
|
||||
\details Counts the number of leading zeros of a data value.
|
||||
\param [in] value Value to count the leading zeros
|
||||
\return number of leading zeros in value
|
||||
*/
|
||||
#define __CLZ __clz
|
||||
|
||||
|
||||
#if ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (8 bit)
|
||||
\details Executes a exclusive LDR instruction for 8 bit value.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXB(ptr) ((uint8_t ) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXB(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint8_t ) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (16 bit)
|
||||
\details Executes a exclusive LDR instruction for 16 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXH(ptr) ((uint16_t) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXH(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint16_t) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDR Exclusive (32 bit)
|
||||
\details Executes a exclusive LDR instruction for 32 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __LDREXW(ptr) ((uint32_t ) __ldrex(ptr))
|
||||
#else
|
||||
#define __LDREXW(ptr) _Pragma("push") _Pragma("diag_suppress 3731") ((uint32_t ) __ldrex(ptr)) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (8 bit)
|
||||
\details Executes a exclusive STR instruction for 8 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXB(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXB(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (16 bit)
|
||||
\details Executes a exclusive STR instruction for 16 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXH(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXH(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief STR Exclusive (32 bit)
|
||||
\details Executes a exclusive STR instruction for 32 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
\return 0 Function succeeded
|
||||
\return 1 Function failed
|
||||
*/
|
||||
#if defined(__ARMCC_VERSION) && (__ARMCC_VERSION < 5060020)
|
||||
#define __STREXW(value, ptr) __strex(value, ptr)
|
||||
#else
|
||||
#define __STREXW(value, ptr) _Pragma("push") _Pragma("diag_suppress 3731") __strex(value, ptr) _Pragma("pop")
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief Remove the exclusive lock
|
||||
\details Removes the exclusive lock which is created by LDREX.
|
||||
*/
|
||||
#define __CLREX __clrex
|
||||
|
||||
|
||||
/**
|
||||
\brief Signed Saturate
|
||||
\details Saturates a signed value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __SSAT __ssat
|
||||
|
||||
|
||||
/**
|
||||
\brief Unsigned Saturate
|
||||
\details Saturates an unsigned value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
#define __USAT __usat
|
||||
|
||||
|
||||
/**
|
||||
\brief Rotate Right with Extend (32 bit)
|
||||
\details Moves each bit of a bitstring right by one bit.
|
||||
The carry input is shifted in at the left end of the bitstring.
|
||||
\param [in] value Value to rotate
|
||||
\return Rotated value
|
||||
*/
|
||||
#ifndef __NO_EMBEDDED_ASM
|
||||
__attribute__((section(".rrx_text"))) __STATIC_INLINE __ASM uint32_t __RRX(uint32_t value)
|
||||
{
|
||||
rrx r0, r0
|
||||
bx lr
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (8 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 8 bit value.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint8_t at (*ptr)
|
||||
*/
|
||||
#define __LDRBT(ptr) ((uint8_t ) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (16 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 16 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint16_t at (*ptr)
|
||||
*/
|
||||
#define __LDRHT(ptr) ((uint16_t) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief LDRT Unprivileged (32 bit)
|
||||
\details Executes a Unprivileged LDRT instruction for 32 bit values.
|
||||
\param [in] ptr Pointer to data
|
||||
\return value of type uint32_t at (*ptr)
|
||||
*/
|
||||
#define __LDRT(ptr) ((uint32_t ) __ldrt(ptr))
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (8 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 8 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRBT(value, ptr) __strt(value, ptr)
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (16 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 16 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRHT(value, ptr) __strt(value, ptr)
|
||||
|
||||
|
||||
/**
|
||||
\brief STRT Unprivileged (32 bit)
|
||||
\details Executes a Unprivileged STRT instruction for 32 bit values.
|
||||
\param [in] value Value to store
|
||||
\param [in] ptr Pointer to location
|
||||
*/
|
||||
#define __STRT(value, ptr) __strt(value, ptr)
|
||||
|
||||
#else /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
/**
|
||||
\brief Signed Saturate
|
||||
\details Saturates a signed value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (1..32)
|
||||
\return Saturated value
|
||||
*/
|
||||
__attribute__((always_inline)) __STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if ((sat >= 1U) && (sat <= 32U))
|
||||
{
|
||||
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
|
||||
const int32_t min = -1 - max ;
|
||||
if (val > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
/**
|
||||
\brief Unsigned Saturate
|
||||
\details Saturates an unsigned value.
|
||||
\param [in] value Value to be saturated
|
||||
\param [in] sat Bit position to saturate to (0..31)
|
||||
\return Saturated value
|
||||
*/
|
||||
__attribute__((always_inline)) __STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if (sat <= 31U)
|
||||
{
|
||||
const uint32_t max = ((1U << sat) - 1U);
|
||||
if (val > (int32_t)max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < 0)
|
||||
{
|
||||
return 0U;
|
||||
}
|
||||
}
|
||||
return (uint32_t)val;
|
||||
}
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7M__ ) && (__ARM_ARCH_7M__ == 1)) || \
|
||||
(defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
|
||||
/*@}*/ /* end of group CMSIS_Core_InstructionInterface */
|
||||
|
||||
|
||||
/* ################### Compiler specific Intrinsics ########################### */
|
||||
/** \defgroup CMSIS_SIMD_intrinsics CMSIS SIMD Intrinsics
|
||||
Access to dedicated SIMD instructions
|
||||
@{
|
||||
*/
|
||||
|
||||
#if ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) )
|
||||
|
||||
#define __SADD8 __sadd8
|
||||
#define __QADD8 __qadd8
|
||||
#define __SHADD8 __shadd8
|
||||
#define __UADD8 __uadd8
|
||||
#define __UQADD8 __uqadd8
|
||||
#define __UHADD8 __uhadd8
|
||||
#define __SSUB8 __ssub8
|
||||
#define __QSUB8 __qsub8
|
||||
#define __SHSUB8 __shsub8
|
||||
#define __USUB8 __usub8
|
||||
#define __UQSUB8 __uqsub8
|
||||
#define __UHSUB8 __uhsub8
|
||||
#define __SADD16 __sadd16
|
||||
#define __QADD16 __qadd16
|
||||
#define __SHADD16 __shadd16
|
||||
#define __UADD16 __uadd16
|
||||
#define __UQADD16 __uqadd16
|
||||
#define __UHADD16 __uhadd16
|
||||
#define __SSUB16 __ssub16
|
||||
#define __QSUB16 __qsub16
|
||||
#define __SHSUB16 __shsub16
|
||||
#define __USUB16 __usub16
|
||||
#define __UQSUB16 __uqsub16
|
||||
#define __UHSUB16 __uhsub16
|
||||
#define __SASX __sasx
|
||||
#define __QASX __qasx
|
||||
#define __SHASX __shasx
|
||||
#define __UASX __uasx
|
||||
#define __UQASX __uqasx
|
||||
#define __UHASX __uhasx
|
||||
#define __SSAX __ssax
|
||||
#define __QSAX __qsax
|
||||
#define __SHSAX __shsax
|
||||
#define __USAX __usax
|
||||
#define __UQSAX __uqsax
|
||||
#define __UHSAX __uhsax
|
||||
#define __USAD8 __usad8
|
||||
#define __USADA8 __usada8
|
||||
#define __SSAT16 __ssat16
|
||||
#define __USAT16 __usat16
|
||||
#define __UXTB16 __uxtb16
|
||||
#define __UXTAB16 __uxtab16
|
||||
#define __SXTB16 __sxtb16
|
||||
#define __SXTAB16 __sxtab16
|
||||
#define __SMUAD __smuad
|
||||
#define __SMUADX __smuadx
|
||||
#define __SMLAD __smlad
|
||||
#define __SMLADX __smladx
|
||||
#define __SMLALD __smlald
|
||||
#define __SMLALDX __smlaldx
|
||||
#define __SMUSD __smusd
|
||||
#define __SMUSDX __smusdx
|
||||
#define __SMLSD __smlsd
|
||||
#define __SMLSDX __smlsdx
|
||||
#define __SMLSLD __smlsld
|
||||
#define __SMLSLDX __smlsldx
|
||||
#define __SEL __sel
|
||||
#define __QADD __qadd
|
||||
#define __QSUB __qsub
|
||||
|
||||
#define __PKHBT(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0x0000FFFFUL) | \
|
||||
((((uint32_t)(ARG2)) << (ARG3)) & 0xFFFF0000UL) )
|
||||
|
||||
#define __PKHTB(ARG1,ARG2,ARG3) ( ((((uint32_t)(ARG1)) ) & 0xFFFF0000UL) | \
|
||||
((((uint32_t)(ARG2)) >> (ARG3)) & 0x0000FFFFUL) )
|
||||
|
||||
#define __SMMLA(ARG1,ARG2,ARG3) ( (int32_t)((((int64_t)(ARG1) * (ARG2)) + \
|
||||
((int64_t)(ARG3) << 32U) ) >> 32U))
|
||||
|
||||
#endif /* ((defined (__ARM_ARCH_7EM__) && (__ARM_ARCH_7EM__ == 1)) ) */
|
||||
/*@} end of group CMSIS_SIMD_intrinsics */
|
||||
|
||||
|
||||
#endif /* __CMSIS_ARMCC_H */
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,266 @@
|
|||
/**************************************************************************//**
|
||||
* @file cmsis_compiler.h
|
||||
* @brief CMSIS compiler generic header file
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __CMSIS_COMPILER_H
|
||||
#define __CMSIS_COMPILER_H
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/*
|
||||
* Arm Compiler 4/5
|
||||
*/
|
||||
#if defined ( __CC_ARM )
|
||||
#include "cmsis_armcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* Arm Compiler 6 (armclang)
|
||||
*/
|
||||
#elif defined (__ARMCC_VERSION) && (__ARMCC_VERSION >= 6010050)
|
||||
#include "cmsis_armclang.h"
|
||||
|
||||
|
||||
/*
|
||||
* GNU Compiler
|
||||
*/
|
||||
#elif defined ( __GNUC__ )
|
||||
#include "cmsis_gcc.h"
|
||||
|
||||
|
||||
/*
|
||||
* IAR Compiler
|
||||
*/
|
||||
#elif defined ( __ICCARM__ )
|
||||
#include <cmsis_iccarm.h>
|
||||
|
||||
|
||||
/*
|
||||
* TI Arm Compiler
|
||||
*/
|
||||
#elif defined ( __TI_ARM__ )
|
||||
#include <cmsis_ccs.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __attribute__((packed))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __attribute__((packed)) T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void*)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* TASKING Compiler
|
||||
*/
|
||||
#elif defined ( __TASKING__ )
|
||||
/*
|
||||
* The CMSIS functions have been implemented as intrinsics in the compiler.
|
||||
* Please use "carm -?i" to get an up to date list of all intrinsics,
|
||||
* Including the CMSIS ones.
|
||||
*/
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
#define __NO_RETURN __attribute__((noreturn))
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#define __USED __attribute__((used))
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __attribute__((weak))
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT struct __packed__
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION union __packed__
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
struct __packed__ T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#define __ALIGNED(x) __align(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
/*
|
||||
* COSMIC Compiler
|
||||
*/
|
||||
#elif defined ( __CSMC__ )
|
||||
#include <cmsis_csm.h>
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM _asm
|
||||
#endif
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
#ifndef __NO_RETURN
|
||||
// NO RETURN is automatically detected hence no warning here
|
||||
#define __NO_RETURN
|
||||
#endif
|
||||
#ifndef __USED
|
||||
#warning No compiler specific solution for __USED. __USED is ignored.
|
||||
#define __USED
|
||||
#endif
|
||||
#ifndef __WEAK
|
||||
#define __WEAK __weak
|
||||
#endif
|
||||
#ifndef __PACKED
|
||||
#define __PACKED @packed
|
||||
#endif
|
||||
#ifndef __PACKED_STRUCT
|
||||
#define __PACKED_STRUCT @packed struct
|
||||
#endif
|
||||
#ifndef __PACKED_UNION
|
||||
#define __PACKED_UNION @packed union
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
@packed struct T_UINT32 { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32(x) (((struct T_UINT32 *)(x))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
__PACKED_STRUCT T_UINT16_WRITE { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_WRITE(addr, val) (void)((((struct T_UINT16_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
__PACKED_STRUCT T_UINT16_READ { uint16_t v; };
|
||||
#define __UNALIGNED_UINT16_READ(addr) (((const struct T_UINT16_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
__PACKED_STRUCT T_UINT32_WRITE { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_WRITE(addr, val) (void)((((struct T_UINT32_WRITE *)(void *)(addr))->v) = (val))
|
||||
#endif
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
__PACKED_STRUCT T_UINT32_READ { uint32_t v; };
|
||||
#define __UNALIGNED_UINT32_READ(addr) (((const struct T_UINT32_READ *)(const void *)(addr))->v)
|
||||
#endif
|
||||
#ifndef __ALIGNED
|
||||
#warning No compiler specific solution for __ALIGNED. __ALIGNED is ignored.
|
||||
#define __ALIGNED(x)
|
||||
#endif
|
||||
#ifndef __RESTRICT
|
||||
#warning No compiler specific solution for __RESTRICT. __RESTRICT is ignored.
|
||||
#define __RESTRICT
|
||||
#endif
|
||||
|
||||
|
||||
#else
|
||||
#error Unknown compiler.
|
||||
#endif
|
||||
|
||||
|
||||
#endif /* __CMSIS_COMPILER_H */
|
||||
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,913 @@
|
|||
/**************************************************************************//**
|
||||
* @file cmsis_iccarm.h
|
||||
* @brief CMSIS compiler ICCARM (IAR Compiler for Arm) header file
|
||||
* @version V5.0.5
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
//
|
||||
// Copyright (c) 2017-2018 IAR Systems
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License")
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS,
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
//
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
#ifndef __CMSIS_ICCARM_H__
|
||||
#define __CMSIS_ICCARM_H__
|
||||
|
||||
#ifndef __ICCARM__
|
||||
#error This file should only be compiled by ICCARM
|
||||
#endif
|
||||
|
||||
#pragma system_include
|
||||
|
||||
#define __IAR_FT _Pragma("inline=forced") __intrinsic
|
||||
|
||||
#if (__VER__ >= 8000000)
|
||||
#define __ICCARM_V8 1
|
||||
#else
|
||||
#define __ICCARM_V8 0
|
||||
#endif
|
||||
|
||||
#ifndef __ALIGNED
|
||||
#if __ICCARM_V8
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#elif (__VER__ >= 7080000)
|
||||
/* Needs IAR language extensions */
|
||||
#define __ALIGNED(x) __attribute__((aligned(x)))
|
||||
#else
|
||||
#warning No compiler specific solution for __ALIGNED.__ALIGNED is ignored.
|
||||
#define __ALIGNED(x)
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
/* Define compiler macros for CPU architecture, used in CMSIS 5.
|
||||
*/
|
||||
#if __ARM_ARCH_6M__ || __ARM_ARCH_7M__ || __ARM_ARCH_7EM__ || __ARM_ARCH_8M_BASE__ || __ARM_ARCH_8M_MAIN__
|
||||
/* Macros already defined */
|
||||
#else
|
||||
#if defined(__ARM8M_MAINLINE__) || defined(__ARM8EM_MAINLINE__)
|
||||
#define __ARM_ARCH_8M_MAIN__ 1
|
||||
#elif defined(__ARM8M_BASELINE__)
|
||||
#define __ARM_ARCH_8M_BASE__ 1
|
||||
#elif defined(__ARM_ARCH_PROFILE) && __ARM_ARCH_PROFILE == 'M'
|
||||
#if __ARM_ARCH == 6
|
||||
#define __ARM_ARCH_6M__ 1
|
||||
#elif __ARM_ARCH == 7
|
||||
#if __ARM_FEATURE_DSP
|
||||
#define __ARM_ARCH_7EM__ 1
|
||||
#else
|
||||
#define __ARM_ARCH_7M__ 1
|
||||
#endif
|
||||
#endif /* __ARM_ARCH */
|
||||
#endif /* __ARM_ARCH_PROFILE == 'M' */
|
||||
#endif
|
||||
|
||||
/* Alternativ core deduction for older ICCARM's */
|
||||
#if !defined(__ARM_ARCH_6M__) && !defined(__ARM_ARCH_7M__) && !defined(__ARM_ARCH_7EM__) && \
|
||||
!defined(__ARM_ARCH_8M_BASE__) && !defined(__ARM_ARCH_8M_MAIN__)
|
||||
#if defined(__ARM6M__) && (__CORE__ == __ARM6M__)
|
||||
#define __ARM_ARCH_6M__ 1
|
||||
#elif defined(__ARM7M__) && (__CORE__ == __ARM7M__)
|
||||
#define __ARM_ARCH_7M__ 1
|
||||
#elif defined(__ARM7EM__) && (__CORE__ == __ARM7EM__)
|
||||
#define __ARM_ARCH_7EM__ 1
|
||||
#elif defined(__ARM8M_BASELINE__) && (__CORE == __ARM8M_BASELINE__)
|
||||
#define __ARM_ARCH_8M_BASE__ 1
|
||||
#elif defined(__ARM8M_MAINLINE__) && (__CORE == __ARM8M_MAINLINE__)
|
||||
#define __ARM_ARCH_8M_MAIN__ 1
|
||||
#elif defined(__ARM8EM_MAINLINE__) && (__CORE == __ARM8EM_MAINLINE__)
|
||||
#define __ARM_ARCH_8M_MAIN__ 1
|
||||
#else
|
||||
#error "Unknown target."
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#if defined(__ARM_ARCH_6M__) && __ARM_ARCH_6M__==1
|
||||
#define __IAR_M0_FAMILY 1
|
||||
#elif defined(__ARM_ARCH_8M_BASE__) && __ARM_ARCH_8M_BASE__==1
|
||||
#define __IAR_M0_FAMILY 1
|
||||
#else
|
||||
#define __IAR_M0_FAMILY 0
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __ASM
|
||||
#define __ASM __asm
|
||||
#endif
|
||||
|
||||
#ifndef __INLINE
|
||||
#define __INLINE inline
|
||||
#endif
|
||||
|
||||
#ifndef __NO_RETURN
|
||||
#if __ICCARM_V8
|
||||
#define __NO_RETURN __attribute__((__noreturn__))
|
||||
#else
|
||||
#define __NO_RETURN _Pragma("object_attribute=__noreturn")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED
|
||||
#if __ICCARM_V8
|
||||
#define __PACKED __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
#define __PACKED __packed
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED_STRUCT
|
||||
#if __ICCARM_V8
|
||||
#define __PACKED_STRUCT struct __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
#define __PACKED_STRUCT __packed struct
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __PACKED_UNION
|
||||
#if __ICCARM_V8
|
||||
#define __PACKED_UNION union __attribute__((packed, aligned(1)))
|
||||
#else
|
||||
/* Needs IAR language extensions */
|
||||
#define __PACKED_UNION __packed union
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __RESTRICT
|
||||
#define __RESTRICT restrict
|
||||
#endif
|
||||
|
||||
#ifndef __STATIC_INLINE
|
||||
#define __STATIC_INLINE static inline
|
||||
#endif
|
||||
|
||||
#ifndef __FORCEINLINE
|
||||
#define __FORCEINLINE _Pragma("inline=forced")
|
||||
#endif
|
||||
|
||||
#ifndef __STATIC_FORCEINLINE
|
||||
#define __STATIC_FORCEINLINE __FORCEINLINE __STATIC_INLINE
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT16_READ
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT uint16_t __iar_uint16_read(void const *ptr)
|
||||
{
|
||||
return *(__packed uint16_t*)(ptr);
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT16_READ(PTR) __iar_uint16_read(PTR)
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __UNALIGNED_UINT16_WRITE
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT void __iar_uint16_write(void const *ptr, uint16_t val)
|
||||
{
|
||||
*(__packed uint16_t*)(ptr) = val;;
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT16_WRITE(PTR,VAL) __iar_uint16_write(PTR,VAL)
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT32_READ
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT uint32_t __iar_uint32_read(void const *ptr)
|
||||
{
|
||||
return *(__packed uint32_t*)(ptr);
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT32_READ(PTR) __iar_uint32_read(PTR)
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT32_WRITE
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__IAR_FT void __iar_uint32_write(void const *ptr, uint32_t val)
|
||||
{
|
||||
*(__packed uint32_t*)(ptr) = val;;
|
||||
}
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT32_WRITE(PTR,VAL) __iar_uint32_write(PTR,VAL)
|
||||
#endif
|
||||
|
||||
#ifndef __UNALIGNED_UINT32 /* deprecated */
|
||||
#pragma language=save
|
||||
#pragma language=extended
|
||||
__packed struct __iar_u32 { uint32_t v; };
|
||||
#pragma language=restore
|
||||
#define __UNALIGNED_UINT32(PTR) (((struct __iar_u32 *)(PTR))->v)
|
||||
#endif
|
||||
|
||||
#ifndef __USED
|
||||
#if __ICCARM_V8
|
||||
#define __USED __attribute__((used))
|
||||
#else
|
||||
#define __USED _Pragma("__root")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef __WEAK
|
||||
#if __ICCARM_V8
|
||||
#define __WEAK __attribute__((weak))
|
||||
#else
|
||||
#define __WEAK _Pragma("__weak")
|
||||
#endif
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef __ICCARM_INTRINSICS_VERSION__
|
||||
#define __ICCARM_INTRINSICS_VERSION__ 0
|
||||
#endif
|
||||
|
||||
#if __ICCARM_INTRINSICS_VERSION__ == 2
|
||||
|
||||
#if defined(__CLZ)
|
||||
#undef __CLZ
|
||||
#endif
|
||||
#if defined(__REVSH)
|
||||
#undef __REVSH
|
||||
#endif
|
||||
#if defined(__RBIT)
|
||||
#undef __RBIT
|
||||
#endif
|
||||
#if defined(__SSAT)
|
||||
#undef __SSAT
|
||||
#endif
|
||||
#if defined(__USAT)
|
||||
#undef __USAT
|
||||
#endif
|
||||
|
||||
#include "iccarm_builtin.h"
|
||||
|
||||
#define __disable_fault_irq __iar_builtin_disable_fiq
|
||||
#define __disable_irq __iar_builtin_disable_interrupt
|
||||
#define __enable_fault_irq __iar_builtin_enable_fiq
|
||||
#define __enable_irq __iar_builtin_enable_interrupt
|
||||
#define __arm_rsr __iar_builtin_rsr
|
||||
#define __arm_wsr __iar_builtin_wsr
|
||||
|
||||
|
||||
#define __get_APSR() (__arm_rsr("APSR"))
|
||||
#define __get_BASEPRI() (__arm_rsr("BASEPRI"))
|
||||
#define __get_CONTROL() (__arm_rsr("CONTROL"))
|
||||
#define __get_FAULTMASK() (__arm_rsr("FAULTMASK"))
|
||||
|
||||
#if ((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) )
|
||||
#define __get_FPSCR() (__arm_rsr("FPSCR"))
|
||||
#define __set_FPSCR(VALUE) (__arm_wsr("FPSCR", (VALUE)))
|
||||
#else
|
||||
#define __get_FPSCR() ( 0 )
|
||||
#define __set_FPSCR(VALUE) ((void)VALUE)
|
||||
#endif
|
||||
|
||||
#define __get_IPSR() (__arm_rsr("IPSR"))
|
||||
#define __get_MSP() (__arm_rsr("MSP"))
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
#define __get_MSPLIM() (0U)
|
||||
#else
|
||||
#define __get_MSPLIM() (__arm_rsr("MSPLIM"))
|
||||
#endif
|
||||
#define __get_PRIMASK() (__arm_rsr("PRIMASK"))
|
||||
#define __get_PSP() (__arm_rsr("PSP"))
|
||||
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
#define __get_PSPLIM() (0U)
|
||||
#else
|
||||
#define __get_PSPLIM() (__arm_rsr("PSPLIM"))
|
||||
#endif
|
||||
|
||||
#define __get_xPSR() (__arm_rsr("xPSR"))
|
||||
|
||||
#define __set_BASEPRI(VALUE) (__arm_wsr("BASEPRI", (VALUE)))
|
||||
#define __set_BASEPRI_MAX(VALUE) (__arm_wsr("BASEPRI_MAX", (VALUE)))
|
||||
#define __set_CONTROL(VALUE) (__arm_wsr("CONTROL", (VALUE)))
|
||||
#define __set_FAULTMASK(VALUE) (__arm_wsr("FAULTMASK", (VALUE)))
|
||||
#define __set_MSP(VALUE) (__arm_wsr("MSP", (VALUE)))
|
||||
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
#define __set_MSPLIM(VALUE) ((void)(VALUE))
|
||||
#else
|
||||
#define __set_MSPLIM(VALUE) (__arm_wsr("MSPLIM", (VALUE)))
|
||||
#endif
|
||||
#define __set_PRIMASK(VALUE) (__arm_wsr("PRIMASK", (VALUE)))
|
||||
#define __set_PSP(VALUE) (__arm_wsr("PSP", (VALUE)))
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
#define __set_PSPLIM(VALUE) ((void)(VALUE))
|
||||
#else
|
||||
#define __set_PSPLIM(VALUE) (__arm_wsr("PSPLIM", (VALUE)))
|
||||
#endif
|
||||
|
||||
#define __TZ_get_CONTROL_NS() (__arm_rsr("CONTROL_NS"))
|
||||
#define __TZ_set_CONTROL_NS(VALUE) (__arm_wsr("CONTROL_NS", (VALUE)))
|
||||
#define __TZ_get_PSP_NS() (__arm_rsr("PSP_NS"))
|
||||
#define __TZ_set_PSP_NS(VALUE) (__arm_wsr("PSP_NS", (VALUE)))
|
||||
#define __TZ_get_MSP_NS() (__arm_rsr("MSP_NS"))
|
||||
#define __TZ_set_MSP_NS(VALUE) (__arm_wsr("MSP_NS", (VALUE)))
|
||||
#define __TZ_get_SP_NS() (__arm_rsr("SP_NS"))
|
||||
#define __TZ_set_SP_NS(VALUE) (__arm_wsr("SP_NS", (VALUE)))
|
||||
#define __TZ_get_PRIMASK_NS() (__arm_rsr("PRIMASK_NS"))
|
||||
#define __TZ_set_PRIMASK_NS(VALUE) (__arm_wsr("PRIMASK_NS", (VALUE)))
|
||||
#define __TZ_get_BASEPRI_NS() (__arm_rsr("BASEPRI_NS"))
|
||||
#define __TZ_set_BASEPRI_NS(VALUE) (__arm_wsr("BASEPRI_NS", (VALUE)))
|
||||
#define __TZ_get_FAULTMASK_NS() (__arm_rsr("FAULTMASK_NS"))
|
||||
#define __TZ_set_FAULTMASK_NS(VALUE)(__arm_wsr("FAULTMASK_NS", (VALUE)))
|
||||
#define __TZ_get_PSPLIM_NS() (__arm_rsr("PSPLIM_NS"))
|
||||
#define __TZ_set_PSPLIM_NS(VALUE) (__arm_wsr("PSPLIM_NS", (VALUE)))
|
||||
#define __TZ_get_MSPLIM_NS() (__arm_rsr("MSPLIM_NS"))
|
||||
#define __TZ_set_MSPLIM_NS(VALUE) (__arm_wsr("MSPLIM_NS", (VALUE)))
|
||||
|
||||
#define __NOP __iar_builtin_no_operation
|
||||
|
||||
#define __CLZ __iar_builtin_CLZ
|
||||
#define __CLREX __iar_builtin_CLREX
|
||||
|
||||
#define __DMB __iar_builtin_DMB
|
||||
#define __DSB __iar_builtin_DSB
|
||||
#define __ISB __iar_builtin_ISB
|
||||
|
||||
#define __LDREXB __iar_builtin_LDREXB
|
||||
#define __LDREXH __iar_builtin_LDREXH
|
||||
#define __LDREXW __iar_builtin_LDREX
|
||||
|
||||
#define __RBIT __iar_builtin_RBIT
|
||||
#define __REV __iar_builtin_REV
|
||||
#define __REV16 __iar_builtin_REV16
|
||||
|
||||
__IAR_FT int16_t __REVSH(int16_t val)
|
||||
{
|
||||
return (int16_t) __iar_builtin_REVSH(val);
|
||||
}
|
||||
|
||||
#define __ROR __iar_builtin_ROR
|
||||
#define __RRX __iar_builtin_RRX
|
||||
|
||||
#define __SEV __iar_builtin_SEV
|
||||
|
||||
#if !__IAR_M0_FAMILY
|
||||
#define __SSAT __iar_builtin_SSAT
|
||||
#endif
|
||||
|
||||
#define __STREXB __iar_builtin_STREXB
|
||||
#define __STREXH __iar_builtin_STREXH
|
||||
#define __STREXW __iar_builtin_STREX
|
||||
|
||||
#if !__IAR_M0_FAMILY
|
||||
#define __USAT __iar_builtin_USAT
|
||||
#endif
|
||||
|
||||
#define __WFE __iar_builtin_WFE
|
||||
#define __WFI __iar_builtin_WFI
|
||||
|
||||
#if __ARM_MEDIA__
|
||||
#define __SADD8 __iar_builtin_SADD8
|
||||
#define __QADD8 __iar_builtin_QADD8
|
||||
#define __SHADD8 __iar_builtin_SHADD8
|
||||
#define __UADD8 __iar_builtin_UADD8
|
||||
#define __UQADD8 __iar_builtin_UQADD8
|
||||
#define __UHADD8 __iar_builtin_UHADD8
|
||||
#define __SSUB8 __iar_builtin_SSUB8
|
||||
#define __QSUB8 __iar_builtin_QSUB8
|
||||
#define __SHSUB8 __iar_builtin_SHSUB8
|
||||
#define __USUB8 __iar_builtin_USUB8
|
||||
#define __UQSUB8 __iar_builtin_UQSUB8
|
||||
#define __UHSUB8 __iar_builtin_UHSUB8
|
||||
#define __SADD16 __iar_builtin_SADD16
|
||||
#define __QADD16 __iar_builtin_QADD16
|
||||
#define __SHADD16 __iar_builtin_SHADD16
|
||||
#define __UADD16 __iar_builtin_UADD16
|
||||
#define __UQADD16 __iar_builtin_UQADD16
|
||||
#define __UHADD16 __iar_builtin_UHADD16
|
||||
#define __SSUB16 __iar_builtin_SSUB16
|
||||
#define __QSUB16 __iar_builtin_QSUB16
|
||||
#define __SHSUB16 __iar_builtin_SHSUB16
|
||||
#define __USUB16 __iar_builtin_USUB16
|
||||
#define __UQSUB16 __iar_builtin_UQSUB16
|
||||
#define __UHSUB16 __iar_builtin_UHSUB16
|
||||
#define __SASX __iar_builtin_SASX
|
||||
#define __QASX __iar_builtin_QASX
|
||||
#define __SHASX __iar_builtin_SHASX
|
||||
#define __UASX __iar_builtin_UASX
|
||||
#define __UQASX __iar_builtin_UQASX
|
||||
#define __UHASX __iar_builtin_UHASX
|
||||
#define __SSAX __iar_builtin_SSAX
|
||||
#define __QSAX __iar_builtin_QSAX
|
||||
#define __SHSAX __iar_builtin_SHSAX
|
||||
#define __USAX __iar_builtin_USAX
|
||||
#define __UQSAX __iar_builtin_UQSAX
|
||||
#define __UHSAX __iar_builtin_UHSAX
|
||||
#define __USAD8 __iar_builtin_USAD8
|
||||
#define __USADA8 __iar_builtin_USADA8
|
||||
#define __SSAT16 __iar_builtin_SSAT16
|
||||
#define __USAT16 __iar_builtin_USAT16
|
||||
#define __UXTB16 __iar_builtin_UXTB16
|
||||
#define __UXTAB16 __iar_builtin_UXTAB16
|
||||
#define __SXTB16 __iar_builtin_SXTB16
|
||||
#define __SXTAB16 __iar_builtin_SXTAB16
|
||||
#define __SMUAD __iar_builtin_SMUAD
|
||||
#define __SMUADX __iar_builtin_SMUADX
|
||||
#define __SMMLA __iar_builtin_SMMLA
|
||||
#define __SMLAD __iar_builtin_SMLAD
|
||||
#define __SMLADX __iar_builtin_SMLADX
|
||||
#define __SMLALD __iar_builtin_SMLALD
|
||||
#define __SMLALDX __iar_builtin_SMLALDX
|
||||
#define __SMUSD __iar_builtin_SMUSD
|
||||
#define __SMUSDX __iar_builtin_SMUSDX
|
||||
#define __SMLSD __iar_builtin_SMLSD
|
||||
#define __SMLSDX __iar_builtin_SMLSDX
|
||||
#define __SMLSLD __iar_builtin_SMLSLD
|
||||
#define __SMLSLDX __iar_builtin_SMLSLDX
|
||||
#define __SEL __iar_builtin_SEL
|
||||
#define __QADD __iar_builtin_QADD
|
||||
#define __QSUB __iar_builtin_QSUB
|
||||
#define __PKHBT __iar_builtin_PKHBT
|
||||
#define __PKHTB __iar_builtin_PKHTB
|
||||
#endif
|
||||
|
||||
#else /* __ICCARM_INTRINSICS_VERSION__ == 2 */
|
||||
|
||||
#if __IAR_M0_FAMILY
|
||||
/* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
|
||||
#define __CLZ __cmsis_iar_clz_not_active
|
||||
#define __SSAT __cmsis_iar_ssat_not_active
|
||||
#define __USAT __cmsis_iar_usat_not_active
|
||||
#define __RBIT __cmsis_iar_rbit_not_active
|
||||
#define __get_APSR __cmsis_iar_get_APSR_not_active
|
||||
#endif
|
||||
|
||||
|
||||
#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
|
||||
#define __get_FPSCR __cmsis_iar_get_FPSR_not_active
|
||||
#define __set_FPSCR __cmsis_iar_set_FPSR_not_active
|
||||
#endif
|
||||
|
||||
#ifdef __INTRINSICS_INCLUDED
|
||||
#error intrinsics.h is already included previously!
|
||||
#endif
|
||||
|
||||
#include <intrinsics.h>
|
||||
|
||||
#if __IAR_M0_FAMILY
|
||||
/* Avoid clash between intrinsics.h and arm_math.h when compiling for Cortex-M0. */
|
||||
#undef __CLZ
|
||||
#undef __SSAT
|
||||
#undef __USAT
|
||||
#undef __RBIT
|
||||
#undef __get_APSR
|
||||
|
||||
__STATIC_INLINE uint8_t __CLZ(uint32_t data)
|
||||
{
|
||||
if (data == 0U) { return 32U; }
|
||||
|
||||
uint32_t count = 0U;
|
||||
uint32_t mask = 0x80000000U;
|
||||
|
||||
while ((data & mask) == 0U)
|
||||
{
|
||||
count += 1U;
|
||||
mask = mask >> 1U;
|
||||
}
|
||||
return count;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __RBIT(uint32_t v)
|
||||
{
|
||||
uint8_t sc = 31U;
|
||||
uint32_t r = v;
|
||||
for (v >>= 1U; v; v >>= 1U)
|
||||
{
|
||||
r <<= 1U;
|
||||
r |= v & 1U;
|
||||
sc--;
|
||||
}
|
||||
return (r << sc);
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __get_APSR(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm("MRS %0,APSR" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if (!((defined (__FPU_PRESENT) && (__FPU_PRESENT == 1U)) && \
|
||||
(defined (__FPU_USED ) && (__FPU_USED == 1U)) ))
|
||||
#undef __get_FPSCR
|
||||
#undef __set_FPSCR
|
||||
#define __get_FPSCR() (0)
|
||||
#define __set_FPSCR(VALUE) ((void)VALUE)
|
||||
#endif
|
||||
|
||||
#pragma diag_suppress=Pe940
|
||||
#pragma diag_suppress=Pe177
|
||||
|
||||
#define __enable_irq __enable_interrupt
|
||||
#define __disable_irq __disable_interrupt
|
||||
#define __NOP __no_operation
|
||||
|
||||
#define __get_xPSR __get_PSR
|
||||
|
||||
#if (!defined(__ARM_ARCH_6M__) || __ARM_ARCH_6M__==0)
|
||||
|
||||
__IAR_FT uint32_t __LDREXW(uint32_t volatile *ptr)
|
||||
{
|
||||
return __LDREX((unsigned long *)ptr);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STREXW(uint32_t value, uint32_t volatile *ptr)
|
||||
{
|
||||
return __STREX(value, (unsigned long *)ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
/* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
|
||||
#if (__CORTEX_M >= 0x03)
|
||||
|
||||
__IAR_FT uint32_t __RRX(uint32_t value)
|
||||
{
|
||||
uint32_t result;
|
||||
__ASM("RRX %0, %1" : "=r"(result) : "r" (value) : "cc");
|
||||
return(result);
|
||||
}
|
||||
|
||||
__IAR_FT void __set_BASEPRI_MAX(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR BASEPRI_MAX,%0"::"r" (value));
|
||||
}
|
||||
|
||||
|
||||
#define __enable_fault_irq __enable_fiq
|
||||
#define __disable_fault_irq __disable_fiq
|
||||
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
__IAR_FT uint32_t __ROR(uint32_t op1, uint32_t op2)
|
||||
{
|
||||
return (op1 >> op2) | (op1 << ((sizeof(op1)*8)-op2));
|
||||
}
|
||||
|
||||
#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
|
||||
(defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
|
||||
|
||||
__IAR_FT uint32_t __get_MSPLIM(void)
|
||||
{
|
||||
uint32_t res;
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
res = 0U;
|
||||
#else
|
||||
__asm volatile("MRS %0,MSPLIM" : "=r" (res));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __set_MSPLIM(uint32_t value)
|
||||
{
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure MSPLIM is RAZ/WI
|
||||
(void)value;
|
||||
#else
|
||||
__asm volatile("MSR MSPLIM,%0" :: "r" (value));
|
||||
#endif
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __get_PSPLIM(void)
|
||||
{
|
||||
uint32_t res;
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
res = 0U;
|
||||
#else
|
||||
__asm volatile("MRS %0,PSPLIM" : "=r" (res));
|
||||
#endif
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __set_PSPLIM(uint32_t value)
|
||||
{
|
||||
#if (!(defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) && \
|
||||
(!defined (__ARM_FEATURE_CMSE ) || (__ARM_FEATURE_CMSE < 3)))
|
||||
// without main extensions, the non-secure PSPLIM is RAZ/WI
|
||||
(void)value;
|
||||
#else
|
||||
__asm volatile("MSR PSPLIM,%0" :: "r" (value));
|
||||
#endif
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_CONTROL_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,CONTROL_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_CONTROL_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR CONTROL_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_PSP_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,PSP_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_PSP_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR PSP_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_MSP_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,MSP_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_MSP_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR MSP_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_SP_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,SP_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
__IAR_FT void __TZ_set_SP_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR SP_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_PRIMASK_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,PRIMASK_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_PRIMASK_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR PRIMASK_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_BASEPRI_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,BASEPRI_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_BASEPRI_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR BASEPRI_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_FAULTMASK_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,FAULTMASK_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_FAULTMASK_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR FAULTMASK_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_PSPLIM_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,PSPLIM_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
__IAR_FT void __TZ_set_PSPLIM_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR PSPLIM_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __TZ_get_MSPLIM_NS(void)
|
||||
{
|
||||
uint32_t res;
|
||||
__asm volatile("MRS %0,MSPLIM_NS" : "=r" (res));
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __TZ_set_MSPLIM_NS(uint32_t value)
|
||||
{
|
||||
__asm volatile("MSR MSPLIM_NS,%0" :: "r" (value));
|
||||
}
|
||||
|
||||
#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
|
||||
|
||||
#endif /* __ICCARM_INTRINSICS_VERSION__ == 2 */
|
||||
|
||||
#define __BKPT(value) __asm volatile ("BKPT %0" : : "i"(value))
|
||||
|
||||
#if __IAR_M0_FAMILY
|
||||
__STATIC_INLINE int32_t __SSAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if ((sat >= 1U) && (sat <= 32U))
|
||||
{
|
||||
const int32_t max = (int32_t)((1U << (sat - 1U)) - 1U);
|
||||
const int32_t min = -1 - max ;
|
||||
if (val > max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < min)
|
||||
{
|
||||
return min;
|
||||
}
|
||||
}
|
||||
return val;
|
||||
}
|
||||
|
||||
__STATIC_INLINE uint32_t __USAT(int32_t val, uint32_t sat)
|
||||
{
|
||||
if (sat <= 31U)
|
||||
{
|
||||
const uint32_t max = ((1U << sat) - 1U);
|
||||
if (val > (int32_t)max)
|
||||
{
|
||||
return max;
|
||||
}
|
||||
else if (val < 0)
|
||||
{
|
||||
return 0U;
|
||||
}
|
||||
}
|
||||
return (uint32_t)val;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if (__CORTEX_M >= 0x03) /* __CORTEX_M is defined in core_cm0.h, core_cm3.h and core_cm4.h. */
|
||||
|
||||
__IAR_FT uint8_t __LDRBT(volatile uint8_t *addr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM("LDRBT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
|
||||
return ((uint8_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint16_t __LDRHT(volatile uint16_t *addr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM("LDRHT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
|
||||
return ((uint16_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __LDRT(volatile uint32_t *addr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM("LDRT %0, [%1]" : "=r" (res) : "r" (addr) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __STRBT(uint8_t value, volatile uint8_t *addr)
|
||||
{
|
||||
__ASM("STRBT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STRHT(uint16_t value, volatile uint16_t *addr)
|
||||
{
|
||||
__ASM("STRHT %1, [%0]" : : "r" (addr), "r" ((uint32_t)value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STRT(uint32_t value, volatile uint32_t *addr)
|
||||
{
|
||||
__ASM("STRT %1, [%0]" : : "r" (addr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
#endif /* (__CORTEX_M >= 0x03) */
|
||||
|
||||
#if ((defined (__ARM_ARCH_8M_MAIN__ ) && (__ARM_ARCH_8M_MAIN__ == 1)) || \
|
||||
(defined (__ARM_ARCH_8M_BASE__ ) && (__ARM_ARCH_8M_BASE__ == 1)) )
|
||||
|
||||
|
||||
__IAR_FT uint8_t __LDAB(volatile uint8_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAB %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
|
||||
return ((uint8_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint16_t __LDAH(volatile uint16_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAH %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
|
||||
return ((uint16_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __LDA(volatile uint32_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDA %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT void __STLB(uint8_t value, volatile uint8_t *ptr)
|
||||
{
|
||||
__ASM volatile ("STLB %1, [%0]" :: "r" (*ptr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STLH(uint16_t value, volatile uint16_t *ptr)
|
||||
{
|
||||
__ASM volatile ("STLH %1, [%0]" :: "r" (*ptr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT void __STL(uint32_t value, volatile uint32_t *ptr)
|
||||
{
|
||||
__ASM volatile ("STL %1, [%0]" :: "r" (*ptr), "r" (value) : "memory");
|
||||
}
|
||||
|
||||
__IAR_FT uint8_t __LDAEXB(volatile uint8_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAEXB %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
|
||||
return ((uint8_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint16_t __LDAEXH(volatile uint16_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAEXH %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
|
||||
return ((uint16_t)res);
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __LDAEX(volatile uint32_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("LDAEX %0, [%1]" : "=r" (res) : "r" (*ptr) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STLEXB(uint8_t value, volatile uint8_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("STLEXB %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STLEXH(uint16_t value, volatile uint16_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("STLEXH %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
__IAR_FT uint32_t __STLEX(uint32_t value, volatile uint32_t *ptr)
|
||||
{
|
||||
uint32_t res;
|
||||
__ASM volatile ("STLEX %0, %2, [%1]" : "=r" (res) : "r" (*ptr), "r" (value) : "memory");
|
||||
return res;
|
||||
}
|
||||
|
||||
#endif /* __ARM_ARCH_8M_MAIN__ or __ARM_ARCH_8M_BASE__ */
|
||||
|
||||
#undef __IAR_FT
|
||||
#undef __IAR_M0_FAMILY
|
||||
#undef __ICCARM_V8
|
||||
|
||||
#pragma diag_default=Pe940
|
||||
#pragma diag_default=Pe177
|
||||
|
||||
#endif /* __CMSIS_ICCARM_H__ */
|
|
@ -0,0 +1,39 @@
|
|||
/**************************************************************************//**
|
||||
* @file cmsis_version.h
|
||||
* @brief CMSIS Core(M) Version definitions
|
||||
* @version V5.0.2
|
||||
* @date 19. April 2017
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2009-2017 ARM Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef __CMSIS_VERSION_H
|
||||
#define __CMSIS_VERSION_H
|
||||
|
||||
/* CMSIS Version definitions */
|
||||
#define __CM_CMSIS_VERSION_MAIN ( 5U) /*!< [31:16] CMSIS Core(M) main version */
|
||||
#define __CM_CMSIS_VERSION_SUB ( 1U) /*!< [15:0] CMSIS Core(M) sub version */
|
||||
#define __CM_CMSIS_VERSION ((__CM_CMSIS_VERSION_MAIN << 16U) | \
|
||||
__CM_CMSIS_VERSION_SUB ) /*!< CMSIS Core(M) version number */
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,197 @@
|
|||
/******************************************************************************
|
||||
* @file mpu_armv7.h
|
||||
* @brief CMSIS MPU API for Armv7-M MPU
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2017-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef ARM_MPU_ARMV7_H
|
||||
#define ARM_MPU_ARMV7_H
|
||||
|
||||
#define ARM_MPU_REGION_SIZE_32B ((uint8_t)0x04U)
|
||||
#define ARM_MPU_REGION_SIZE_64B ((uint8_t)0x05U)
|
||||
#define ARM_MPU_REGION_SIZE_128B ((uint8_t)0x06U)
|
||||
#define ARM_MPU_REGION_SIZE_256B ((uint8_t)0x07U)
|
||||
#define ARM_MPU_REGION_SIZE_512B ((uint8_t)0x08U)
|
||||
#define ARM_MPU_REGION_SIZE_1KB ((uint8_t)0x09U)
|
||||
#define ARM_MPU_REGION_SIZE_2KB ((uint8_t)0x0AU)
|
||||
#define ARM_MPU_REGION_SIZE_4KB ((uint8_t)0x0BU)
|
||||
#define ARM_MPU_REGION_SIZE_8KB ((uint8_t)0x0CU)
|
||||
#define ARM_MPU_REGION_SIZE_16KB ((uint8_t)0x0DU)
|
||||
#define ARM_MPU_REGION_SIZE_32KB ((uint8_t)0x0EU)
|
||||
#define ARM_MPU_REGION_SIZE_64KB ((uint8_t)0x0FU)
|
||||
#define ARM_MPU_REGION_SIZE_128KB ((uint8_t)0x10U)
|
||||
#define ARM_MPU_REGION_SIZE_256KB ((uint8_t)0x11U)
|
||||
#define ARM_MPU_REGION_SIZE_512KB ((uint8_t)0x12U)
|
||||
#define ARM_MPU_REGION_SIZE_1MB ((uint8_t)0x13U)
|
||||
#define ARM_MPU_REGION_SIZE_2MB ((uint8_t)0x14U)
|
||||
#define ARM_MPU_REGION_SIZE_4MB ((uint8_t)0x15U)
|
||||
#define ARM_MPU_REGION_SIZE_8MB ((uint8_t)0x16U)
|
||||
#define ARM_MPU_REGION_SIZE_16MB ((uint8_t)0x17U)
|
||||
#define ARM_MPU_REGION_SIZE_32MB ((uint8_t)0x18U)
|
||||
#define ARM_MPU_REGION_SIZE_64MB ((uint8_t)0x19U)
|
||||
#define ARM_MPU_REGION_SIZE_128MB ((uint8_t)0x1AU)
|
||||
#define ARM_MPU_REGION_SIZE_256MB ((uint8_t)0x1BU)
|
||||
#define ARM_MPU_REGION_SIZE_512MB ((uint8_t)0x1CU)
|
||||
#define ARM_MPU_REGION_SIZE_1GB ((uint8_t)0x1DU)
|
||||
#define ARM_MPU_REGION_SIZE_2GB ((uint8_t)0x1EU)
|
||||
#define ARM_MPU_REGION_SIZE_4GB ((uint8_t)0x1FU)
|
||||
|
||||
#define ARM_MPU_AP_NONE 0U
|
||||
#define ARM_MPU_AP_PRIV 1U
|
||||
#define ARM_MPU_AP_URO 2U
|
||||
#define ARM_MPU_AP_FULL 3U
|
||||
#define ARM_MPU_AP_PRO 5U
|
||||
#define ARM_MPU_AP_RO 6U
|
||||
|
||||
/** MPU Region Base Address Register Value
|
||||
*
|
||||
* \param Region The region to be configured, number 0 to 15.
|
||||
* \param BaseAddress The base address for the region.
|
||||
*/
|
||||
#define ARM_MPU_RBAR(Region, BaseAddress) \
|
||||
(((BaseAddress) & MPU_RBAR_ADDR_Msk) | \
|
||||
((Region) & MPU_RBAR_REGION_Msk) | \
|
||||
(MPU_RBAR_VALID_Msk))
|
||||
|
||||
/**
|
||||
* MPU Region Attribute and Size Register Value
|
||||
*
|
||||
* \param DisableExec Instruction access disable bit, 1= disable instruction fetches.
|
||||
* \param AccessPermission Data access permissions, allows you to configure read/write access for User and Privileged mode.
|
||||
* \param TypeExtField Type extension field, allows you to configure memory access type, for example strongly ordered, peripheral.
|
||||
* \param IsShareable Region is shareable between multiple bus masters.
|
||||
* \param IsCacheable Region is cacheable, i.e. its value may be kept in cache.
|
||||
* \param IsBufferable Region is bufferable, i.e. using write-back caching. Cacheable but non-bufferable regions use write-through policy.
|
||||
* \param SubRegionDisable Sub-region disable field.
|
||||
* \param Size Region size of the region to be configured, for example 4K, 8K.
|
||||
*/
|
||||
#define ARM_MPU_RASR(DisableExec, AccessPermission, TypeExtField, IsShareable, IsCacheable, IsBufferable, SubRegionDisable, Size) \
|
||||
((((DisableExec ) << MPU_RASR_XN_Pos) & MPU_RASR_XN_Msk) | \
|
||||
(((AccessPermission) << MPU_RASR_AP_Pos) & MPU_RASR_AP_Msk) | \
|
||||
(((TypeExtField ) << MPU_RASR_TEX_Pos) & MPU_RASR_TEX_Msk) | \
|
||||
(((IsShareable ) << MPU_RASR_S_Pos) & MPU_RASR_S_Msk) | \
|
||||
(((IsCacheable ) << MPU_RASR_C_Pos) & MPU_RASR_C_Msk) | \
|
||||
(((IsBufferable ) << MPU_RASR_B_Pos) & MPU_RASR_B_Msk) | \
|
||||
(((SubRegionDisable) << MPU_RASR_SRD_Pos) & MPU_RASR_SRD_Msk) | \
|
||||
(((Size ) << MPU_RASR_SIZE_Pos) & MPU_RASR_SIZE_Msk) | \
|
||||
(MPU_RASR_ENABLE_Msk))
|
||||
|
||||
|
||||
/**
|
||||
* Struct for a single MPU Region
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t RBAR; //!< The region base address register value (RBAR)
|
||||
uint32_t RASR; //!< The region attribute and size register value (RASR) \ref MPU_RASR
|
||||
} ARM_MPU_Region_t;
|
||||
|
||||
/** Enable the MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Disable the MPU.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Disable(void)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
/** Clear and disable the given MPU region.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
|
||||
{
|
||||
MPU->RNR = rnr;
|
||||
MPU->RASR = 0U;
|
||||
}
|
||||
|
||||
/** Configure an MPU region.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rsar Value for RSAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RBAR = rbar;
|
||||
MPU->RASR = rasr;
|
||||
}
|
||||
|
||||
/** Configure the given MPU region.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rsar Value for RSAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegionEx(uint32_t rnr, uint32_t rbar, uint32_t rasr)
|
||||
{
|
||||
MPU->RNR = rnr;
|
||||
MPU->RBAR = rbar;
|
||||
MPU->RASR = rasr;
|
||||
}
|
||||
|
||||
/** Memcopy with strictly ordered memory access, e.g. for register targets.
|
||||
* \param dst Destination data is copied to.
|
||||
* \param src Source data is copied from.
|
||||
* \param len Amount of data words to be copied.
|
||||
*/
|
||||
__STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0U; i < len; ++i)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** Load the given number of MPU regions from a table.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load(ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
||||
while (cnt > MPU_TYPE_RALIASES) {
|
||||
orderedCpy(&(MPU->RBAR), &(table->RBAR), MPU_TYPE_RALIASES*rowWordSize);
|
||||
table += MPU_TYPE_RALIASES;
|
||||
cnt -= MPU_TYPE_RALIASES;
|
||||
}
|
||||
orderedCpy(&(MPU->RBAR), &(table->RBAR), cnt*rowWordSize);
|
||||
}
|
||||
|
||||
#endif
|
|
@ -0,0 +1,333 @@
|
|||
/******************************************************************************
|
||||
* @file mpu_armv8.h
|
||||
* @brief CMSIS MPU API for Armv8-M MPU
|
||||
* @version V5.0.4
|
||||
* @date 10. January 2018
|
||||
******************************************************************************/
|
||||
/*
|
||||
* Copyright (c) 2017-2018 Arm Limited. All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: Apache-2.0
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the License); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an AS IS BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#if defined ( __ICCARM__ )
|
||||
#pragma system_include /* treat file as system include file for MISRA check */
|
||||
#elif defined (__clang__)
|
||||
#pragma clang system_header /* treat file as system include file */
|
||||
#endif
|
||||
|
||||
#ifndef ARM_MPU_ARMV8_H
|
||||
#define ARM_MPU_ARMV8_H
|
||||
|
||||
/** \brief Attribute for device memory (outer only) */
|
||||
#define ARM_MPU_ATTR_DEVICE ( 0U )
|
||||
|
||||
/** \brief Attribute for non-cacheable, normal memory */
|
||||
#define ARM_MPU_ATTR_NON_CACHEABLE ( 4U )
|
||||
|
||||
/** \brief Attribute for normal memory (outer and inner)
|
||||
* \param NT Non-Transient: Set to 1 for non-transient data.
|
||||
* \param WB Write-Back: Set to 1 to use write-back update policy.
|
||||
* \param RA Read Allocation: Set to 1 to use cache allocation on read miss.
|
||||
* \param WA Write Allocation: Set to 1 to use cache allocation on write miss.
|
||||
*/
|
||||
#define ARM_MPU_ATTR_MEMORY_(NT, WB, RA, WA) \
|
||||
(((NT & 1U) << 3U) | ((WB & 1U) << 2U) | ((RA & 1U) << 1U) | (WA & 1U))
|
||||
|
||||
/** \brief Device memory type non Gathering, non Re-ordering, non Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_nGnRnE (0U)
|
||||
|
||||
/** \brief Device memory type non Gathering, non Re-ordering, Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_nGnRE (1U)
|
||||
|
||||
/** \brief Device memory type non Gathering, Re-ordering, Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_nGRE (2U)
|
||||
|
||||
/** \brief Device memory type Gathering, Re-ordering, Early Write Acknowledgement */
|
||||
#define ARM_MPU_ATTR_DEVICE_GRE (3U)
|
||||
|
||||
/** \brief Memory Attribute
|
||||
* \param O Outer memory attributes
|
||||
* \param I O == ARM_MPU_ATTR_DEVICE: Device memory attributes, else: Inner memory attributes
|
||||
*/
|
||||
#define ARM_MPU_ATTR(O, I) (((O & 0xFU) << 4U) | (((O & 0xFU) != 0U) ? (I & 0xFU) : ((I & 0x3U) << 2U)))
|
||||
|
||||
/** \brief Normal memory non-shareable */
|
||||
#define ARM_MPU_SH_NON (0U)
|
||||
|
||||
/** \brief Normal memory outer shareable */
|
||||
#define ARM_MPU_SH_OUTER (2U)
|
||||
|
||||
/** \brief Normal memory inner shareable */
|
||||
#define ARM_MPU_SH_INNER (3U)
|
||||
|
||||
/** \brief Memory access permissions
|
||||
* \param RO Read-Only: Set to 1 for read-only memory.
|
||||
* \param NP Non-Privileged: Set to 1 for non-privileged memory.
|
||||
*/
|
||||
#define ARM_MPU_AP_(RO, NP) (((RO & 1U) << 1U) | (NP & 1U))
|
||||
|
||||
/** \brief Region Base Address Register value
|
||||
* \param BASE The base address bits [31:5] of a memory region. The value is zero extended. Effective address gets 32 byte aligned.
|
||||
* \param SH Defines the Shareability domain for this memory region.
|
||||
* \param RO Read-Only: Set to 1 for a read-only memory region.
|
||||
* \param NP Non-Privileged: Set to 1 for a non-privileged memory region.
|
||||
* \oaram XN eXecute Never: Set to 1 for a non-executable memory region.
|
||||
*/
|
||||
#define ARM_MPU_RBAR(BASE, SH, RO, NP, XN) \
|
||||
((BASE & MPU_RBAR_BASE_Pos) | \
|
||||
((SH << MPU_RBAR_SH_Pos) & MPU_RBAR_SH_Msk) | \
|
||||
((ARM_MPU_AP_(RO, NP) << MPU_RBAR_AP_Pos) & MPU_RBAR_AP_Msk) | \
|
||||
((XN << MPU_RBAR_XN_Pos) & MPU_RBAR_XN_Msk))
|
||||
|
||||
/** \brief Region Limit Address Register value
|
||||
* \param LIMIT The limit address bits [31:5] for this memory region. The value is one extended.
|
||||
* \param IDX The attribute index to be associated with this memory region.
|
||||
*/
|
||||
#define ARM_MPU_RLAR(LIMIT, IDX) \
|
||||
((LIMIT & MPU_RLAR_LIMIT_Msk) | \
|
||||
((IDX << MPU_RLAR_AttrIndx_Pos) & MPU_RLAR_AttrIndx_Msk) | \
|
||||
(MPU_RLAR_EN_Msk))
|
||||
|
||||
/**
|
||||
* Struct for a single MPU Region
|
||||
*/
|
||||
typedef struct {
|
||||
uint32_t RBAR; /*!< Region Base Address Register value */
|
||||
uint32_t RLAR; /*!< Region Limit Address Register value */
|
||||
} ARM_MPU_Region_t;
|
||||
|
||||
/** Enable the MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Enable(uint32_t MPU_Control)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
MPU->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Disable the MPU.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Disable(void)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
MPU->CTRL &= ~MPU_CTRL_ENABLE_Msk;
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Enable the Non-secure MPU.
|
||||
* \param MPU_Control Default access permissions for unconfigured regions.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Enable_NS(uint32_t MPU_Control)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
MPU_NS->CTRL = MPU_Control | MPU_CTRL_ENABLE_Msk;
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB_NS->SHCSR |= SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
}
|
||||
|
||||
/** Disable the Non-secure MPU.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Disable_NS(void)
|
||||
{
|
||||
__DSB();
|
||||
__ISB();
|
||||
#ifdef SCB_SHCSR_MEMFAULTENA_Msk
|
||||
SCB_NS->SHCSR &= ~SCB_SHCSR_MEMFAULTENA_Msk;
|
||||
#endif
|
||||
MPU_NS->CTRL &= ~MPU_CTRL_ENABLE_Msk;
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Set the memory attribute encoding to the given MPU.
|
||||
* \param mpu Pointer to the MPU to be configured.
|
||||
* \param idx The attribute index to be set [0-7]
|
||||
* \param attr The attribute value to be set.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetMemAttrEx(MPU_Type* mpu, uint8_t idx, uint8_t attr)
|
||||
{
|
||||
const uint8_t reg = idx / 4U;
|
||||
const uint32_t pos = ((idx % 4U) * 8U);
|
||||
const uint32_t mask = 0xFFU << pos;
|
||||
|
||||
if (reg >= (sizeof(mpu->MAIR) / sizeof(mpu->MAIR[0]))) {
|
||||
return; // invalid index
|
||||
}
|
||||
|
||||
mpu->MAIR[reg] = ((mpu->MAIR[reg] & ~mask) | ((attr << pos) & mask));
|
||||
}
|
||||
|
||||
/** Set the memory attribute encoding.
|
||||
* \param idx The attribute index to be set [0-7]
|
||||
* \param attr The attribute value to be set.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetMemAttr(uint8_t idx, uint8_t attr)
|
||||
{
|
||||
ARM_MPU_SetMemAttrEx(MPU, idx, attr);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Set the memory attribute encoding to the Non-secure MPU.
|
||||
* \param idx The attribute index to be set [0-7]
|
||||
* \param attr The attribute value to be set.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetMemAttr_NS(uint8_t idx, uint8_t attr)
|
||||
{
|
||||
ARM_MPU_SetMemAttrEx(MPU_NS, idx, attr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Clear and disable the given MPU region of the given MPU.
|
||||
* \param mpu Pointer to MPU to be used.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegionEx(MPU_Type* mpu, uint32_t rnr)
|
||||
{
|
||||
mpu->RNR = rnr;
|
||||
mpu->RLAR = 0U;
|
||||
}
|
||||
|
||||
/** Clear and disable the given MPU region.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegion(uint32_t rnr)
|
||||
{
|
||||
ARM_MPU_ClrRegionEx(MPU, rnr);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Clear and disable the given Non-secure MPU region.
|
||||
* \param rnr Region number to be cleared.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_ClrRegion_NS(uint32_t rnr)
|
||||
{
|
||||
ARM_MPU_ClrRegionEx(MPU_NS, rnr);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Configure the given MPU region of the given MPU.
|
||||
* \param mpu Pointer to MPU to be used.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rlar Value for RLAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegionEx(MPU_Type* mpu, uint32_t rnr, uint32_t rbar, uint32_t rlar)
|
||||
{
|
||||
mpu->RNR = rnr;
|
||||
mpu->RBAR = rbar;
|
||||
mpu->RLAR = rlar;
|
||||
}
|
||||
|
||||
/** Configure the given MPU region.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rlar Value for RLAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion(uint32_t rnr, uint32_t rbar, uint32_t rlar)
|
||||
{
|
||||
ARM_MPU_SetRegionEx(MPU, rnr, rbar, rlar);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Configure the given Non-secure MPU region.
|
||||
* \param rnr Region number to be configured.
|
||||
* \param rbar Value for RBAR register.
|
||||
* \param rlar Value for RLAR register.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_SetRegion_NS(uint32_t rnr, uint32_t rbar, uint32_t rlar)
|
||||
{
|
||||
ARM_MPU_SetRegionEx(MPU_NS, rnr, rbar, rlar);
|
||||
}
|
||||
#endif
|
||||
|
||||
/** Memcopy with strictly ordered memory access, e.g. for register targets.
|
||||
* \param dst Destination data is copied to.
|
||||
* \param src Source data is copied from.
|
||||
* \param len Amount of data words to be copied.
|
||||
*/
|
||||
__STATIC_INLINE void orderedCpy(volatile uint32_t* dst, const uint32_t* __RESTRICT src, uint32_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
for (i = 0U; i < len; ++i)
|
||||
{
|
||||
dst[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
||||
/** Load the given number of MPU regions from a table to the given MPU.
|
||||
* \param mpu Pointer to the MPU registers to be used.
|
||||
* \param rnr First region number to be configured.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_LoadEx(MPU_Type* mpu, uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
const uint32_t rowWordSize = sizeof(ARM_MPU_Region_t)/4U;
|
||||
if (cnt == 1U) {
|
||||
mpu->RNR = rnr;
|
||||
orderedCpy(&(mpu->RBAR), &(table->RBAR), rowWordSize);
|
||||
} else {
|
||||
uint32_t rnrBase = rnr & ~(MPU_TYPE_RALIASES-1U);
|
||||
uint32_t rnrOffset = rnr % MPU_TYPE_RALIASES;
|
||||
|
||||
mpu->RNR = rnrBase;
|
||||
while ((rnrOffset + cnt) > MPU_TYPE_RALIASES) {
|
||||
uint32_t c = MPU_TYPE_RALIASES - rnrOffset;
|
||||
orderedCpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), c*rowWordSize);
|
||||
table += c;
|
||||
cnt -= c;
|
||||
rnrOffset = 0U;
|
||||
rnrBase += MPU_TYPE_RALIASES;
|
||||
mpu->RNR = rnrBase;
|
||||
}
|
||||
|
||||
orderedCpy(&(mpu->RBAR)+(rnrOffset*2U), &(table->RBAR), cnt*rowWordSize);
|
||||
}
|
||||
}
|
||||
|
||||
/** Load the given number of MPU regions from a table.
|
||||
* \param rnr First region number to be configured.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
ARM_MPU_LoadEx(MPU, rnr, table, cnt);
|
||||
}
|
||||
|
||||
#ifdef MPU_NS
|
||||
/** Load the given number of MPU regions from a table to the Non-secure MPU.
|
||||
* \param rnr First region number to be configured.
|
||||
* \param table Pointer to the MPU configuration table.
|
||||
* \param cnt Amount of regions to be configured.
|
||||
*/
|
||||
__STATIC_INLINE void ARM_MPU_Load_NS(uint32_t rnr, ARM_MPU_Region_t const* table, uint32_t cnt)
|
||||
{
|
||||
ARM_MPU_LoadEx(MPU_NS, rnr, table, cnt);
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
/*
|
||||
* Copyright 2016-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file board.c
|
||||
* @brief Board initialization file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "board.h"
|
||||
|
||||
/**
|
||||
* @brief Set up and initialize all required blocks and functions related to the board hardware.
|
||||
*/
|
||||
void BOARD_InitDebugConsole(void) {
|
||||
/* The user initialization should be placed here */
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
/*
|
||||
* Copyright 2016-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file board.h
|
||||
* @brief Board initialization header file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#ifndef _BOARD_H_
|
||||
#define _BOARD_H_
|
||||
|
||||
/**
|
||||
* @brief The board name
|
||||
*/
|
||||
#define BOARD_NAME "board"
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @brief Initialize board specific settings.
|
||||
*/
|
||||
void BOARD_InitDebugConsole(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _BOARD_H_ */
|
||||
|
||||
|
|
@ -0,0 +1,54 @@
|
|||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Clocks v4.0
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
|
||||
/**
|
||||
* @file clock_config.c
|
||||
* @brief Board clocks initialization file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#include "MK64F12.h"
|
||||
#include "clock_config.h"
|
||||
|
||||
/**
|
||||
* @brief Set up and initialize all required blocks and functions related to the board hardware.
|
||||
*/
|
||||
void BOARD_InitBootClocks(void) {
|
||||
/* The user initialization should be placed here */
|
||||
|
||||
/* Read core clock setting. */
|
||||
SystemCoreClockUpdate();
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file clock_config.h
|
||||
* @brief Board clocks header file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#ifndef _CLOCK_CONFIG_H_
|
||||
#define _CLOCK_CONFIG_H_
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @brief Initialize board clocks.
|
||||
*/
|
||||
void BOARD_InitBootClocks(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _CLOCK_CONFIG_H_ */
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Peripherals v1.0
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS **********/
|
||||
|
||||
/**
|
||||
* @file peripherals.c
|
||||
* @brief Peripherals initialization file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#include "peripherals.h"
|
||||
|
||||
/**
|
||||
* @brief Set up and initialize all required blocks and functions related to the peripherals hardware.
|
||||
*/
|
||||
void BOARD_InitBootPeripherals(void) {
|
||||
/* The user initialization should be placed here */
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file peripherals.h
|
||||
* @brief Peripherals initialization header file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#ifndef _PERIPHERALS_H_
|
||||
#define _PERIPHERALS_H_
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @brief Initialize peripherals specific settings.
|
||||
*/
|
||||
void BOARD_InitBootPeripherals(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _PERIPHERALS_H_ */
|
||||
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/* TEXT BELOW IS USED AS SETTING FOR TOOLS *************************************
|
||||
!!GlobalInfo
|
||||
product: Pins v4.0
|
||||
* BE CAREFUL MODIFYING THIS COMMENT - IT IS YAML SETTINGS FOR TOOLS ***********/
|
||||
|
||||
/**
|
||||
* @file pin_mux.c
|
||||
* @brief Board pins file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#include "pin_mux.h"
|
||||
|
||||
/**
|
||||
* @brief Set up and initialize all required blocks and functions related to the board hardware.
|
||||
*/
|
||||
void BOARD_InitBootPins(void) {
|
||||
/* The user initialization should be placed here */
|
||||
}
|
|
@ -0,0 +1,56 @@
|
|||
/*
|
||||
* Copyright 2017-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without modification,
|
||||
* are permitted provided that the following conditions are met:
|
||||
*
|
||||
* o Redistributions of source code must retain the above copyright notice, this list
|
||||
* of conditions and the following disclaimer.
|
||||
*
|
||||
* o Redistributions in binary form must reproduce the above copyright notice, this
|
||||
* list of conditions and the following disclaimer in the documentation and/or
|
||||
* other materials provided with the distribution.
|
||||
*
|
||||
* o Neither the name of NXP Semiconductor, Inc. nor the names of its
|
||||
* contributors may be used to endorse or promote products derived from this
|
||||
* software without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
||||
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
|
||||
* ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
|
||||
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
||||
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
||||
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @file pin_mux.h
|
||||
* @brief Board pins header file.
|
||||
*/
|
||||
|
||||
/* This is a template for board specific configuration created by MCUXpresso IDE Project Wizard.*/
|
||||
|
||||
#ifndef _PIN_MUX_H_
|
||||
#define _PIN_MUX_H_
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/**
|
||||
* @brief Initialize board pins.
|
||||
*/
|
||||
void BOARD_InitBootPins(void);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* _PIN_MUX_H_ */
|
||||
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,36 @@
|
|||
/*
|
||||
* Copyright 2014-2016 Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef __FSL_DEVICE_REGISTERS_H__
|
||||
#define __FSL_DEVICE_REGISTERS_H__
|
||||
|
||||
/*
|
||||
* Include the cpu specific register header files.
|
||||
*
|
||||
* The CPU macro should be declared in the project or makefile.
|
||||
*/
|
||||
#if (defined(CPU_MK64FN1M0CAJ12) || defined(CPU_MK64FN1M0VDC12) || defined(CPU_MK64FN1M0VLL12) || \
|
||||
defined(CPU_MK64FN1M0VLQ12) || defined(CPU_MK64FN1M0VMD12) || defined(CPU_MK64FX512VDC12) || \
|
||||
defined(CPU_MK64FX512VLL12) || defined(CPU_MK64FX512VLQ12) || defined(CPU_MK64FX512VMD12))
|
||||
|
||||
#define K64F12_SERIES
|
||||
|
||||
/* CMSIS-style register definitions */
|
||||
#include "MK64F12.h"
|
||||
/* CPU specific feature definitions */
|
||||
#include "MK64F12_features.h"
|
||||
|
||||
#else
|
||||
#error "No valid CPU defined!"
|
||||
#endif
|
||||
|
||||
#endif /* __FSL_DEVICE_REGISTERS_H__ */
|
||||
|
||||
/*******************************************************************************
|
||||
* EOF
|
||||
******************************************************************************/
|
|
@ -0,0 +1,302 @@
|
|||
/*
|
||||
** ###################################################################
|
||||
** Processors: MK64FN1M0CAJ12
|
||||
** MK64FN1M0VDC12
|
||||
** MK64FN1M0VLL12
|
||||
** MK64FN1M0VLQ12
|
||||
** MK64FN1M0VMD12
|
||||
** MK64FX512VDC12
|
||||
** MK64FX512VLL12
|
||||
** MK64FX512VLQ12
|
||||
** MK64FX512VMD12
|
||||
**
|
||||
** Compilers: Keil ARM C/C++ Compiler
|
||||
** Freescale C/C++ for Embedded ARM
|
||||
** GNU C Compiler
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
** MCUXpresso Compiler
|
||||
**
|
||||
** Reference manual: K64P144M120SF5RM, Rev.2, January 2014
|
||||
** Version: rev. 2.9, 2016-03-21
|
||||
** Build: b180801
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2018 NXP
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2013-08-12)
|
||||
** Initial version.
|
||||
** - rev. 2.0 (2013-10-29)
|
||||
** Register accessor macros added to the memory map.
|
||||
** Symbols for Processor Expert memory map compatibility added to the memory map.
|
||||
** Startup file for gcc has been updated according to CMSIS 3.2.
|
||||
** System initialization updated.
|
||||
** MCG - registers updated.
|
||||
** PORTA, PORTB, PORTC, PORTE - registers for digital filter removed.
|
||||
** - rev. 2.1 (2013-10-30)
|
||||
** Definition of BITBAND macros updated to support peripherals with 32-bit acces disabled.
|
||||
** - rev. 2.2 (2013-12-09)
|
||||
** DMA - EARS register removed.
|
||||
** AIPS0, AIPS1 - MPRA register updated.
|
||||
** - rev. 2.3 (2014-01-24)
|
||||
** Update according to reference manual rev. 2
|
||||
** ENET, MCG, MCM, SIM, USB - registers updated
|
||||
** - rev. 2.4 (2014-02-10)
|
||||
** The declaration of clock configurations has been moved to separate header file system_MK64F12.h
|
||||
** Update of SystemInit() and SystemCoreClockUpdate() functions.
|
||||
** - rev. 2.5 (2014-02-10)
|
||||
** The declaration of clock configurations has been moved to separate header file system_MK64F12.h
|
||||
** Update of SystemInit() and SystemCoreClockUpdate() functions.
|
||||
** Module access macro module_BASES replaced by module_BASE_PTRS.
|
||||
** - rev. 2.6 (2014-08-28)
|
||||
** Update of system files - default clock configuration changed.
|
||||
** Update of startup files - possibility to override DefaultISR added.
|
||||
** - rev. 2.7 (2014-10-14)
|
||||
** Interrupt INT_LPTimer renamed to INT_LPTMR0, interrupt INT_Watchdog renamed to INT_WDOG_EWM.
|
||||
** - rev. 2.8 (2015-02-19)
|
||||
** Renamed interrupt vector LLW to LLWU.
|
||||
** - rev. 2.9 (2016-03-21)
|
||||
** Added MK64FN1M0CAJ12 part.
|
||||
** GPIO - renamed port instances: PTx -> GPIOx.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file MK64F12
|
||||
* @version 2.9
|
||||
* @date 2016-03-21
|
||||
* @brief Device specific configuration file for MK64F12 (implementation file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#include <stdint.h>
|
||||
#include "fsl_device_registers.h"
|
||||
#include "MK64F12.h"
|
||||
|
||||
|
||||
/*----------------------------------------------------------------------------
|
||||
Define clock source values
|
||||
*----------------------------------------------------------------------------*/
|
||||
#define CLOCK_SETUP 1
|
||||
|
||||
#if (CLOCK_SETUP == 1)
|
||||
#define CPU_XTAL0_CLK_HZ SYS_FREQ_OSC
|
||||
#define CPU_XTAL32k_CLK_HZ 32768u /* Value of the external 32k crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_INT_SLOW_CLK_HZ 32768u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_FAST_CLK_HZ 4000000u /* Value of the fast internal oscillator clock frequency in Hz */
|
||||
|
||||
#undef DEFAULT_SYSTEM_CLOCK
|
||||
#define DEFAULT_SYSTEM_CLOCK 120000000u /* Default System clock value */
|
||||
#endif //CLOCK_SETUP == 1
|
||||
|
||||
uint32_t SystemCoreClock = DEFAULT_SYSTEM_CLOCK;
|
||||
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInit()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemInit (void) {
|
||||
#if ((__FPU_PRESENT == 1) && (__FPU_USED == 1))
|
||||
SCB->CPACR |= ((3UL << 10*2) | (3UL << 11*2)); /* set CP10, CP11 Full Access */
|
||||
#endif /* ((__FPU_PRESENT == 1) && (__FPU_USED == 1)) */
|
||||
#if (DISABLE_WDOG)
|
||||
/* WDOG->UNLOCK: WDOGUNLOCK=0xC520 */
|
||||
WDOG->UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xC520); /* Key 1 */
|
||||
/* WDOG->UNLOCK: WDOGUNLOCK=0xD928 */
|
||||
WDOG->UNLOCK = WDOG_UNLOCK_WDOGUNLOCK(0xD928); /* Key 2 */
|
||||
/* WDOG->STCTRLH: ?=0,DISTESTWDOG=0,BYTESEL=0,TESTSEL=0,TESTWDOG=0,?=0,?=1,WAITEN=1,STOPEN=1,DBGEN=0,ALLOWUPDATE=1,WINEN=0,IRQRSTEN=0,CLKSRC=1,WDOGEN=0 */
|
||||
WDOG->STCTRLH = WDOG_STCTRLH_BYTESEL(0x00) |
|
||||
WDOG_STCTRLH_WAITEN_MASK |
|
||||
WDOG_STCTRLH_STOPEN_MASK |
|
||||
WDOG_STCTRLH_ALLOWUPDATE_MASK |
|
||||
WDOG_STCTRLH_CLKSRC_MASK |
|
||||
0x0100U;
|
||||
#endif /* (DISABLE_WDOG) */
|
||||
|
||||
SystemInitHook();
|
||||
|
||||
/* System clock initialization */
|
||||
#if (CLOCK_SETUP == 1)
|
||||
/* SIM_SCGC5: PORTA=1 */
|
||||
SIM->SCGC5 |= (uint32_t)0x0200UL; /* Enable clock gate for ports to enable pin routing */
|
||||
/* SIM_CLKDIV1: OUTDIV1=0,OUTDIV2=1,OUTDIV3=3,OUTDIV4=5,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0,??=0 */
|
||||
SIM->CLKDIV1 = (uint32_t)0x01350000UL; /* Update system prescalers */
|
||||
/* SIM_SOPT2: PLLFLLSEL=1 */
|
||||
SIM->SOPT2 = (uint32_t)((SIM->SOPT2 & (uint32_t)~0x00020000UL) | (uint32_t)0x00010000UL); /* Select PLL 0 as a clock source for various peripherals */
|
||||
/* SIM_SOPT1: OSC32KSEL=0 */
|
||||
SIM->SOPT1 &= (uint32_t)~0x00080000UL; /* System oscillator drives 32 kHz clock for various peripherals */
|
||||
/* SIM_SCGC1: OSC1=1 */
|
||||
SIM->SCGC1 |= (uint32_t)0x20UL;
|
||||
/* PORTA_PCR18: ISF=0,MUX=0 */
|
||||
PORTA->PCR[18] &= (uint32_t)~0x01000700UL;
|
||||
/* Switch to FBE Mode */
|
||||
/* OSC0_CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
OSC->CR = (uint8_t)0x80U;
|
||||
/* OSC1_CR: ERCLKEN=1,??=0,EREFSTEN=0,??=0,SC2P=0,SC4P=0,SC8P=0,SC16P=0 */
|
||||
//OSC1->CR = (uint8_t)0x80U;
|
||||
/* MCG_C7: OSCSEL=0 */
|
||||
MCG->C7 &= (uint8_t)~(uint8_t)0x01U;
|
||||
/* MCG_C2: LOCRE0=0,??=0,RANGE0=1,HGO0=0,EREFS0=1,LP=0,IRCS=0 */
|
||||
MCG->C2 = (uint8_t)0x14U;
|
||||
/* MCG_C1: CLKS=2,FRDIV=4,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG->C1 = (uint8_t)0xA2U;
|
||||
/* MCG_C4: DMX32=0,DRST_DRS=0 */
|
||||
MCG->C4 &= (uint8_t)~(uint8_t)0xE0U;
|
||||
/* MCG_C5: PLLREFSEL0=0,PLLCLKEN0=0,PLLSTEN0=0,??=0,??=0,PRDIV0=3 */
|
||||
MCG->C5 = (uint8_t)0x03U;
|
||||
/* MCG_C6: LOLIE0=0,PLLS=0,CME0=0,VDIV0=6 */
|
||||
MCG->C6 = (uint8_t)0x06U;
|
||||
/* MCG_C11: PLLREFSEL1=0,PLLCLKEN1=0,PLLSTEN1=0,PLLCS=0,??=0,PRDIV1=0 */
|
||||
//MCG->C11 = (uint8_t)0x00U;
|
||||
/* MCG_C12: LOLIE1=0,??=0,CME2=0,VDIV1=0 */
|
||||
//MCG->C12 = (uint8_t)0x00U;
|
||||
while((MCG->S & MCG_S_IREFST_MASK) != 0x00U) { /* Check that the source of the FLL reference clock is the external reference clock. */
|
||||
}
|
||||
while((MCG->S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
|
||||
}
|
||||
/* Switch to PBE Mode */
|
||||
/* MCG_C6: LOLIE0=0,PLLS=1,CME0=0,VDIV0=6 */
|
||||
MCG->C6 = (uint8_t)0x46U;
|
||||
while((MCG->S & 0x0CU) != 0x08U) { /* Wait until external reference clock is selected as MCG output */
|
||||
}
|
||||
while((MCG->S & MCG_S_LOCK0_MASK) == 0x00U) { /* Wait until PLL locked */
|
||||
}
|
||||
/* Switch to PEE Mode */
|
||||
/* MCG->C1: CLKS=0,FRDIV=5,IREFS=0,IRCLKEN=1,IREFSTEN=0 */
|
||||
MCG->C1 = (uint8_t)0x2AU;
|
||||
while((MCG->S & 0x0CU) != 0x0CU) {} /* Wait until output of the PLL is selected */
|
||||
#endif
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemCoreClockUpdate()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
void SystemCoreClockUpdate (void) {
|
||||
uint32_t MCGOUTClock; /* Variable to store output clock frequency of the MCG module */
|
||||
uint16_t Divider;
|
||||
|
||||
if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x00U) {
|
||||
/* Output of FLL or PLL is selected */
|
||||
if ((MCG->C6 & MCG_C6_PLLS_MASK) == 0x00U) {
|
||||
/* FLL is selected */
|
||||
if ((MCG->C1 & MCG_C1_IREFS_MASK) == 0x00U) {
|
||||
/* External reference clock is selected */
|
||||
switch (MCG->C7 & MCG_C7_OSCSEL_MASK) {
|
||||
case 0x00U:
|
||||
MCGOUTClock = CPU_XTAL_CLK_HZ; /* System oscillator drives MCG clock */
|
||||
break;
|
||||
case 0x01U:
|
||||
MCGOUTClock = CPU_XTAL32k_CLK_HZ; /* RTC 32 kHz oscillator drives MCG clock */
|
||||
break;
|
||||
case 0x02U:
|
||||
default:
|
||||
MCGOUTClock = CPU_INT_IRC_CLK_HZ; /* IRC 48MHz oscillator drives MCG clock */
|
||||
break;
|
||||
}
|
||||
if (((MCG->C2 & MCG_C2_RANGE_MASK) != 0x00U) && ((MCG->C7 & MCG_C7_OSCSEL_MASK) != 0x01U)) {
|
||||
switch (MCG->C1 & MCG_C1_FRDIV_MASK) {
|
||||
case 0x38U:
|
||||
Divider = 1536U;
|
||||
break;
|
||||
case 0x30U:
|
||||
Divider = 1280U;
|
||||
break;
|
||||
default:
|
||||
Divider = (uint16_t)(32LU << ((MCG->C1 & MCG_C1_FRDIV_MASK) >> MCG_C1_FRDIV_SHIFT));
|
||||
break;
|
||||
}
|
||||
} else {/* ((MCG->C2 & MCG_C2_RANGE_MASK) != 0x00U) */
|
||||
Divider = (uint16_t)(1LU << ((MCG->C1 & MCG_C1_FRDIV_MASK) >> MCG_C1_FRDIV_SHIFT));
|
||||
}
|
||||
MCGOUTClock = (MCGOUTClock / Divider); /* Calculate the divided FLL reference clock */
|
||||
} else { /* (!((MCG->C1 & MCG_C1_IREFS_MASK) == 0x00U)) */
|
||||
MCGOUTClock = CPU_INT_SLOW_CLK_HZ; /* The slow internal reference clock is selected */
|
||||
} /* (!((MCG->C1 & MCG_C1_IREFS_MASK) == 0x00U)) */
|
||||
/* Select correct multiplier to calculate the MCG output clock */
|
||||
switch (MCG->C4 & (MCG_C4_DMX32_MASK | MCG_C4_DRST_DRS_MASK)) {
|
||||
case 0x00U:
|
||||
MCGOUTClock *= 640U;
|
||||
break;
|
||||
case 0x20U:
|
||||
MCGOUTClock *= 1280U;
|
||||
break;
|
||||
case 0x40U:
|
||||
MCGOUTClock *= 1920U;
|
||||
break;
|
||||
case 0x60U:
|
||||
MCGOUTClock *= 2560U;
|
||||
break;
|
||||
case 0x80U:
|
||||
MCGOUTClock *= 732U;
|
||||
break;
|
||||
case 0xA0U:
|
||||
MCGOUTClock *= 1464U;
|
||||
break;
|
||||
case 0xC0U:
|
||||
MCGOUTClock *= 2197U;
|
||||
break;
|
||||
case 0xE0U:
|
||||
MCGOUTClock *= 2929U;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
} else { /* (!((MCG->C6 & MCG_C6_PLLS_MASK) == 0x00U)) */
|
||||
/* PLL is selected */
|
||||
Divider = (((uint16_t)MCG->C5 & MCG_C5_PRDIV0_MASK) + 0x01U);
|
||||
MCGOUTClock = (uint32_t)(CPU_XTAL_CLK_HZ / Divider); /* Calculate the PLL reference clock */
|
||||
Divider = (((uint16_t)MCG->C6 & MCG_C6_VDIV0_MASK) + 24U);
|
||||
MCGOUTClock *= Divider; /* Calculate the MCG output clock */
|
||||
} /* (!((MCG->C6 & MCG_C6_PLLS_MASK) == 0x00U)) */
|
||||
} else if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x40U) {
|
||||
/* Internal reference clock is selected */
|
||||
if ((MCG->C2 & MCG_C2_IRCS_MASK) == 0x00U) {
|
||||
MCGOUTClock = CPU_INT_SLOW_CLK_HZ; /* Slow internal reference clock selected */
|
||||
} else { /* (!((MCG->C2 & MCG_C2_IRCS_MASK) == 0x00U)) */
|
||||
Divider = (uint16_t)(0x01LU << ((MCG->SC & MCG_SC_FCRDIV_MASK) >> MCG_SC_FCRDIV_SHIFT));
|
||||
MCGOUTClock = (uint32_t) (CPU_INT_FAST_CLK_HZ / Divider); /* Fast internal reference clock selected */
|
||||
} /* (!((MCG->C2 & MCG_C2_IRCS_MASK) == 0x00U)) */
|
||||
} else if ((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80U) {
|
||||
/* External reference clock is selected */
|
||||
switch (MCG->C7 & MCG_C7_OSCSEL_MASK) {
|
||||
case 0x00U:
|
||||
MCGOUTClock = CPU_XTAL_CLK_HZ; /* System oscillator drives MCG clock */
|
||||
break;
|
||||
case 0x01U:
|
||||
MCGOUTClock = CPU_XTAL32k_CLK_HZ; /* RTC 32 kHz oscillator drives MCG clock */
|
||||
break;
|
||||
case 0x02U:
|
||||
default:
|
||||
MCGOUTClock = CPU_INT_IRC_CLK_HZ; /* IRC 48MHz oscillator drives MCG clock */
|
||||
break;
|
||||
}
|
||||
} else { /* (!((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80U)) */
|
||||
/* Reserved value */
|
||||
return;
|
||||
} /* (!((MCG->C1 & MCG_C1_CLKS_MASK) == 0x80U)) */
|
||||
SystemCoreClock = (MCGOUTClock / (0x01U + ((SIM->CLKDIV1 & SIM_CLKDIV1_OUTDIV1_MASK) >> SIM_CLKDIV1_OUTDIV1_SHIFT)));
|
||||
}
|
||||
|
||||
/* ----------------------------------------------------------------------------
|
||||
-- SystemInitHook()
|
||||
---------------------------------------------------------------------------- */
|
||||
|
||||
__attribute__ ((weak)) void SystemInitHook (void) {
|
||||
/* Void implementation of the weak function. */
|
||||
}
|
|
@ -0,0 +1,164 @@
|
|||
/*
|
||||
** ###################################################################
|
||||
** Processors: MK64FN1M0CAJ12
|
||||
** MK64FN1M0VDC12
|
||||
** MK64FN1M0VLL12
|
||||
** MK64FN1M0VLQ12
|
||||
** MK64FN1M0VMD12
|
||||
** MK64FX512VDC12
|
||||
** MK64FX512VLL12
|
||||
** MK64FX512VLQ12
|
||||
** MK64FX512VMD12
|
||||
**
|
||||
** Compilers: Keil ARM C/C++ Compiler
|
||||
** Freescale C/C++ for Embedded ARM
|
||||
** GNU C Compiler
|
||||
** IAR ANSI C/C++ Compiler for ARM
|
||||
** MCUXpresso Compiler
|
||||
**
|
||||
** Reference manual: K64P144M120SF5RM, Rev.2, January 2014
|
||||
** Version: rev. 2.9, 2016-03-21
|
||||
** Build: b180801
|
||||
**
|
||||
** Abstract:
|
||||
** Provides a system configuration function and a global variable that
|
||||
** contains the system frequency. It configures the device and initializes
|
||||
** the oscillator (PLL) that is part of the microcontroller device.
|
||||
**
|
||||
** Copyright 2016 Freescale Semiconductor, Inc.
|
||||
** Copyright 2016-2018 NXP
|
||||
**
|
||||
** SPDX-License-Identifier: BSD-3-Clause
|
||||
**
|
||||
** http: www.nxp.com
|
||||
** mail: support@nxp.com
|
||||
**
|
||||
** Revisions:
|
||||
** - rev. 1.0 (2013-08-12)
|
||||
** Initial version.
|
||||
** - rev. 2.0 (2013-10-29)
|
||||
** Register accessor macros added to the memory map.
|
||||
** Symbols for Processor Expert memory map compatibility added to the memory map.
|
||||
** Startup file for gcc has been updated according to CMSIS 3.2.
|
||||
** System initialization updated.
|
||||
** MCG - registers updated.
|
||||
** PORTA, PORTB, PORTC, PORTE - registers for digital filter removed.
|
||||
** - rev. 2.1 (2013-10-30)
|
||||
** Definition of BITBAND macros updated to support peripherals with 32-bit acces disabled.
|
||||
** - rev. 2.2 (2013-12-09)
|
||||
** DMA - EARS register removed.
|
||||
** AIPS0, AIPS1 - MPRA register updated.
|
||||
** - rev. 2.3 (2014-01-24)
|
||||
** Update according to reference manual rev. 2
|
||||
** ENET, MCG, MCM, SIM, USB - registers updated
|
||||
** - rev. 2.4 (2014-02-10)
|
||||
** The declaration of clock configurations has been moved to separate header file system_MK64F12.h
|
||||
** Update of SystemInit() and SystemCoreClockUpdate() functions.
|
||||
** - rev. 2.5 (2014-02-10)
|
||||
** The declaration of clock configurations has been moved to separate header file system_MK64F12.h
|
||||
** Update of SystemInit() and SystemCoreClockUpdate() functions.
|
||||
** Module access macro module_BASES replaced by module_BASE_PTRS.
|
||||
** - rev. 2.6 (2014-08-28)
|
||||
** Update of system files - default clock configuration changed.
|
||||
** Update of startup files - possibility to override DefaultISR added.
|
||||
** - rev. 2.7 (2014-10-14)
|
||||
** Interrupt INT_LPTimer renamed to INT_LPTMR0, interrupt INT_Watchdog renamed to INT_WDOG_EWM.
|
||||
** - rev. 2.8 (2015-02-19)
|
||||
** Renamed interrupt vector LLW to LLWU.
|
||||
** - rev. 2.9 (2016-03-21)
|
||||
** Added MK64FN1M0CAJ12 part.
|
||||
** GPIO - renamed port instances: PTx -> GPIOx.
|
||||
**
|
||||
** ###################################################################
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @file MK64F12
|
||||
* @version 2.9
|
||||
* @date 2016-03-21
|
||||
* @brief Device specific configuration file for MK64F12 (header file)
|
||||
*
|
||||
* Provides a system configuration function and a global variable that contains
|
||||
* the system frequency. It configures the device and initializes the oscillator
|
||||
* (PLL) that is part of the microcontroller device.
|
||||
*/
|
||||
|
||||
#ifndef _SYSTEM_MK64F12_H_
|
||||
#define _SYSTEM_MK64F12_H_ /**< Symbol preventing repeated inclusion */
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
|
||||
#ifndef DISABLE_WDOG
|
||||
#define DISABLE_WDOG 1
|
||||
#endif
|
||||
|
||||
/* Define clock source values */
|
||||
|
||||
#define CPU_XTAL_CLK_HZ 16000000u /* Value of the external crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_XTAL32k_CLK_HZ 32768u /* Value of the external 32k crystal or oscillator clock frequency in Hz */
|
||||
#define CPU_INT_SLOW_CLK_HZ 32768u /* Value of the slow internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_FAST_CLK_HZ 4000000u /* Value of the fast internal oscillator clock frequency in Hz */
|
||||
#define CPU_INT_IRC_CLK_HZ 48000000u /* Value of the 48M internal oscillator clock frequency in Hz */
|
||||
|
||||
/* RTC oscillator setting */
|
||||
/* RTC_CR: SC2P=0,SC4P=0,SC8P=0,SC16P=0,CLKO=1,OSCE=1,WPS=0,UM=0,SUP=0,WPE=0,SWR=0 */
|
||||
#define SYSTEM_RTC_CR_VALUE 0x0300U /* RTC_CR */
|
||||
|
||||
/* Low power mode enable */
|
||||
/* SMC_PMPROT: AVLP=1,ALLS=1,AVLLS=1 */
|
||||
#define SYSTEM_SMC_PMPROT_VALUE 0x2AU /* SMC_PMPROT */
|
||||
|
||||
#define DEFAULT_SYSTEM_CLOCK 20971520u /* Default System clock value */
|
||||
|
||||
|
||||
/**
|
||||
* @brief System clock frequency (core clock)
|
||||
*
|
||||
* The system clock frequency supplied to the SysTick timer and the processor
|
||||
* core clock. This variable can be used by the user application to setup the
|
||||
* SysTick timer or configure other parameters. It may also be used by debugger to
|
||||
* query the frequency of the debug timer or configure the trace clock speed
|
||||
* SystemCoreClock is initialized with a correct predefined value.
|
||||
*/
|
||||
extern uint32_t SystemCoreClock;
|
||||
|
||||
/**
|
||||
* @brief Setup the microcontroller system.
|
||||
*
|
||||
* Typically this function configures the oscillator (PLL) that is part of the
|
||||
* microcontroller device. For systems with variable clock speed it also updates
|
||||
* the variable SystemCoreClock. SystemInit is called from startup_device file.
|
||||
*/
|
||||
void SystemInit (void);
|
||||
|
||||
/**
|
||||
* @brief Updates the SystemCoreClock variable.
|
||||
*
|
||||
* It must be called whenever the core clock is changed during program
|
||||
* execution. SystemCoreClockUpdate() evaluates the clock register settings and calculates
|
||||
* the current core clock.
|
||||
*/
|
||||
void SystemCoreClockUpdate (void);
|
||||
|
||||
/**
|
||||
* @brief SystemInit function hook.
|
||||
*
|
||||
* This weak function allows to call specific initialization code during the
|
||||
* SystemInit() execution.This can be used when an application specific code needs
|
||||
* to be called as close to the reset entry as possible (for example the Multicore
|
||||
* Manager MCMGR_EarlyInit() function call).
|
||||
* NOTE: No global r/w variables can be used in this hook function because the
|
||||
* initialization of these variables happens after this function.
|
||||
*/
|
||||
void SystemInitHook (void);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* _SYSTEM_MK64F12_H_ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,147 @@
|
|||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "fsl_common.h"
|
||||
#define SDK_MEM_MAGIC_NUMBER 12345U
|
||||
|
||||
typedef struct _mem_align_control_block
|
||||
{
|
||||
uint16_t identifier; /*!< Identifier for the memory control block. */
|
||||
uint16_t offset; /*!< offset from aligned address to real address */
|
||||
} mem_align_cb_t;
|
||||
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "platform.drivers.common"
|
||||
#endif
|
||||
|
||||
#ifndef __GIC_PRIO_BITS
|
||||
#if defined(ENABLE_RAM_VECTOR_TABLE)
|
||||
uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler)
|
||||
{
|
||||
/* Addresses for VECTOR_TABLE and VECTOR_RAM come from the linker file */
|
||||
#if defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
extern uint32_t Image$$VECTOR_ROM$$Base[];
|
||||
extern uint32_t Image$$VECTOR_RAM$$Base[];
|
||||
extern uint32_t Image$$RW_m_data$$Base[];
|
||||
|
||||
#define __VECTOR_TABLE Image$$VECTOR_ROM$$Base
|
||||
#define __VECTOR_RAM Image$$VECTOR_RAM$$Base
|
||||
#define __RAM_VECTOR_TABLE_SIZE (((uint32_t)Image$$RW_m_data$$Base - (uint32_t)Image$$VECTOR_RAM$$Base))
|
||||
#elif defined(__ICCARM__)
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE[];
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
#elif defined(__GNUC__)
|
||||
extern uint32_t __VECTOR_TABLE[];
|
||||
extern uint32_t __VECTOR_RAM[];
|
||||
extern uint32_t __RAM_VECTOR_TABLE_SIZE_BYTES[];
|
||||
uint32_t __RAM_VECTOR_TABLE_SIZE = (uint32_t)(__RAM_VECTOR_TABLE_SIZE_BYTES);
|
||||
#endif /* defined(__CC_ARM) || defined(__ARMCC_VERSION) */
|
||||
uint32_t n;
|
||||
uint32_t ret;
|
||||
uint32_t irqMaskValue;
|
||||
|
||||
irqMaskValue = DisableGlobalIRQ();
|
||||
if (SCB->VTOR != (uint32_t)__VECTOR_RAM)
|
||||
{
|
||||
/* Copy the vector table from ROM to RAM */
|
||||
for (n = 0; n < ((uint32_t)__RAM_VECTOR_TABLE_SIZE) / sizeof(uint32_t); n++)
|
||||
{
|
||||
__VECTOR_RAM[n] = __VECTOR_TABLE[n];
|
||||
}
|
||||
/* Point the VTOR to the position of vector table */
|
||||
SCB->VTOR = (uint32_t)__VECTOR_RAM;
|
||||
}
|
||||
|
||||
ret = __VECTOR_RAM[irq + 16];
|
||||
/* make sure the __VECTOR_RAM is noncachable */
|
||||
__VECTOR_RAM[irq + 16] = irqHandler;
|
||||
|
||||
EnableGlobalIRQ(irqMaskValue);
|
||||
|
||||
/* Add for ARM errata 838869, affects Cortex-M4, Cortex-M4F Store immediate overlapping
|
||||
exception return operation might vector to incorrect interrupt */
|
||||
#if defined __CORTEX_M && (__CORTEX_M == 4U)
|
||||
__DSB();
|
||||
#endif
|
||||
|
||||
return ret;
|
||||
}
|
||||
#endif /* ENABLE_RAM_VECTOR_TABLE. */
|
||||
#endif /* __GIC_PRIO_BITS. */
|
||||
|
||||
#if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
|
||||
#if !(defined(FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS) && FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS)
|
||||
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
|
||||
uint32_t index = 0;
|
||||
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
SYSCON->STARTERSET[index] = 1u << intNumber;
|
||||
EnableIRQ(interrupt); /* also enable interrupt at NVIC */
|
||||
}
|
||||
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
uint32_t intNumber = (uint32_t)interrupt;
|
||||
|
||||
DisableIRQ(interrupt); /* also disable interrupt at NVIC */
|
||||
uint32_t index = 0;
|
||||
|
||||
while (intNumber >= 32u)
|
||||
{
|
||||
index++;
|
||||
intNumber -= 32u;
|
||||
}
|
||||
|
||||
SYSCON->STARTERCLR[index] = 1u << intNumber;
|
||||
}
|
||||
#endif /* FSL_FEATURE_SYSCON_STARTER_DISCONTINUOUS */
|
||||
#endif /* FSL_FEATURE_SOC_SYSCON_COUNT */
|
||||
|
||||
void *SDK_Malloc(size_t size, size_t alignbytes)
|
||||
{
|
||||
mem_align_cb_t *p_cb = NULL;
|
||||
uint32_t alignedsize = SDK_SIZEALIGN(size, alignbytes) + alignbytes + sizeof(mem_align_cb_t);
|
||||
void *p_align_addr, *p_addr = malloc(alignedsize);
|
||||
|
||||
if (!p_addr)
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
|
||||
p_align_addr = (void *)SDK_SIZEALIGN((uint32_t)p_addr + sizeof(mem_align_cb_t), alignbytes);
|
||||
|
||||
p_cb = (mem_align_cb_t *)((uint32_t)p_align_addr - 4);
|
||||
p_cb->identifier = SDK_MEM_MAGIC_NUMBER;
|
||||
p_cb->offset = (uint32_t)p_align_addr - (uint32_t)p_addr;
|
||||
|
||||
return (void *)p_align_addr;
|
||||
}
|
||||
|
||||
void SDK_Free(void *ptr)
|
||||
{
|
||||
mem_align_cb_t *p_cb = (mem_align_cb_t *)((uint32_t)ptr - 4);
|
||||
|
||||
if (p_cb->identifier != SDK_MEM_MAGIC_NUMBER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
free((void *)((uint32_t)ptr - p_cb->offset));
|
||||
}
|
|
@ -0,0 +1,585 @@
|
|||
/*
|
||||
* Copyright (c) 2015-2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2018 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef _FSL_COMMON_H_
|
||||
#define _FSL_COMMON_H_
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#if defined(__ICCARM__)
|
||||
#include <stddef.h>
|
||||
#endif
|
||||
|
||||
#include "fsl_device_registers.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup ksdk_common
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Construct a status code value from a group and code number. */
|
||||
#define MAKE_STATUS(group, code) ((((group)*100) + (code)))
|
||||
|
||||
/*! @brief Construct the version number for drivers. */
|
||||
#define MAKE_VERSION(major, minor, bugfix) (((major) << 16) | ((minor) << 8) | (bugfix))
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief common driver version 2.0.1. */
|
||||
#define FSL_COMMON_DRIVER_VERSION (MAKE_VERSION(2, 0, 1))
|
||||
/*@}*/
|
||||
|
||||
/* Debug console type definition. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_NONE 0U /*!< No debug console. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_UART 1U /*!< Debug console based on UART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPUART 2U /*!< Debug console based on LPUART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_LPSCI 3U /*!< Debug console based on LPSCI. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_USBCDC 4U /*!< Debug console based on USBCDC. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_FLEXCOMM 5U /*!< Debug console based on FLEXCOMM. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_IUART 6U /*!< Debug console based on i.MX UART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_VUSART 7U /*!< Debug console based on LPC_VUSART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_MINI_USART 8U /*!< Debug console based on LPC_USART. */
|
||||
#define DEBUG_CONSOLE_DEVICE_TYPE_SWO 9U /*!< Debug console based on SWO. */
|
||||
|
||||
/*! @brief Status group numbers. */
|
||||
enum _status_groups
|
||||
{
|
||||
kStatusGroup_Generic = 0, /*!< Group number for generic status codes. */
|
||||
kStatusGroup_FLASH = 1, /*!< Group number for FLASH status codes. */
|
||||
kStatusGroup_LPSPI = 4, /*!< Group number for LPSPI status codes. */
|
||||
kStatusGroup_FLEXIO_SPI = 5, /*!< Group number for FLEXIO SPI status codes. */
|
||||
kStatusGroup_DSPI = 6, /*!< Group number for DSPI status codes. */
|
||||
kStatusGroup_FLEXIO_UART = 7, /*!< Group number for FLEXIO UART status codes. */
|
||||
kStatusGroup_FLEXIO_I2C = 8, /*!< Group number for FLEXIO I2C status codes. */
|
||||
kStatusGroup_LPI2C = 9, /*!< Group number for LPI2C status codes. */
|
||||
kStatusGroup_UART = 10, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_I2C = 11, /*!< Group number for UART status codes. */
|
||||
kStatusGroup_LPSCI = 12, /*!< Group number for LPSCI status codes. */
|
||||
kStatusGroup_LPUART = 13, /*!< Group number for LPUART status codes. */
|
||||
kStatusGroup_SPI = 14, /*!< Group number for SPI status code.*/
|
||||
kStatusGroup_XRDC = 15, /*!< Group number for XRDC status code.*/
|
||||
kStatusGroup_SEMA42 = 16, /*!< Group number for SEMA42 status code.*/
|
||||
kStatusGroup_SDHC = 17, /*!< Group number for SDHC status code */
|
||||
kStatusGroup_SDMMC = 18, /*!< Group number for SDMMC status code */
|
||||
kStatusGroup_SAI = 19, /*!< Group number for SAI status code */
|
||||
kStatusGroup_MCG = 20, /*!< Group number for MCG status codes. */
|
||||
kStatusGroup_SCG = 21, /*!< Group number for SCG status codes. */
|
||||
kStatusGroup_SDSPI = 22, /*!< Group number for SDSPI status codes. */
|
||||
kStatusGroup_FLEXIO_I2S = 23, /*!< Group number for FLEXIO I2S status codes */
|
||||
kStatusGroup_FLEXIO_MCULCD = 24, /*!< Group number for FLEXIO LCD status codes */
|
||||
kStatusGroup_FLASHIAP = 25, /*!< Group number for FLASHIAP status codes */
|
||||
kStatusGroup_FLEXCOMM_I2C = 26, /*!< Group number for FLEXCOMM I2C status codes */
|
||||
kStatusGroup_I2S = 27, /*!< Group number for I2S status codes */
|
||||
kStatusGroup_IUART = 28, /*!< Group number for IUART status codes */
|
||||
kStatusGroup_CSI = 29, /*!< Group number for CSI status codes */
|
||||
kStatusGroup_MIPI_DSI = 30, /*!< Group number for MIPI DSI status codes */
|
||||
kStatusGroup_SDRAMC = 35, /*!< Group number for SDRAMC status codes. */
|
||||
kStatusGroup_POWER = 39, /*!< Group number for POWER status codes. */
|
||||
kStatusGroup_ENET = 40, /*!< Group number for ENET status codes. */
|
||||
kStatusGroup_PHY = 41, /*!< Group number for PHY status codes. */
|
||||
kStatusGroup_TRGMUX = 42, /*!< Group number for TRGMUX status codes. */
|
||||
kStatusGroup_SMARTCARD = 43, /*!< Group number for SMARTCARD status codes. */
|
||||
kStatusGroup_LMEM = 44, /*!< Group number for LMEM status codes. */
|
||||
kStatusGroup_QSPI = 45, /*!< Group number for QSPI status codes. */
|
||||
kStatusGroup_DMA = 50, /*!< Group number for DMA status codes. */
|
||||
kStatusGroup_EDMA = 51, /*!< Group number for EDMA status codes. */
|
||||
kStatusGroup_DMAMGR = 52, /*!< Group number for DMAMGR status codes. */
|
||||
kStatusGroup_FLEXCAN = 53, /*!< Group number for FlexCAN status codes. */
|
||||
kStatusGroup_LTC = 54, /*!< Group number for LTC status codes. */
|
||||
kStatusGroup_FLEXIO_CAMERA = 55, /*!< Group number for FLEXIO CAMERA status codes. */
|
||||
kStatusGroup_LPC_SPI = 56, /*!< Group number for LPC_SPI status codes. */
|
||||
kStatusGroup_LPC_USART = 57, /*!< Group number for LPC_USART status codes. */
|
||||
kStatusGroup_DMIC = 58, /*!< Group number for DMIC status codes. */
|
||||
kStatusGroup_SDIF = 59, /*!< Group number for SDIF status codes.*/
|
||||
kStatusGroup_SPIFI = 60, /*!< Group number for SPIFI status codes. */
|
||||
kStatusGroup_OTP = 61, /*!< Group number for OTP status codes. */
|
||||
kStatusGroup_MCAN = 62, /*!< Group number for MCAN status codes. */
|
||||
kStatusGroup_CAAM = 63, /*!< Group number for CAAM status codes. */
|
||||
kStatusGroup_ECSPI = 64, /*!< Group number for ECSPI status codes. */
|
||||
kStatusGroup_USDHC = 65, /*!< Group number for USDHC status codes.*/
|
||||
kStatusGroup_LPC_I2C = 66, /*!< Group number for LPC_I2C status codes.*/
|
||||
kStatusGroup_DCP = 67, /*!< Group number for DCP status codes.*/
|
||||
kStatusGroup_MSCAN = 68, /*!< Group number for MSCAN status codes.*/
|
||||
kStatusGroup_ESAI = 69, /*!< Group number for ESAI status codes. */
|
||||
kStatusGroup_FLEXSPI = 70, /*!< Group number for FLEXSPI status codes. */
|
||||
kStatusGroup_MMDC = 71, /*!< Group number for MMDC status codes. */
|
||||
kStatusGroup_PDM = 72, /*!< Group number for MIC status codes. */
|
||||
kStatusGroup_SDMA = 73, /*!< Group number for SDMA status codes. */
|
||||
kStatusGroup_ICS = 74, /*!< Group number for ICS status codes. */
|
||||
kStatusGroup_SPDIF = 75, /*!< Group number for SPDIF status codes. */
|
||||
kStatusGroup_LPC_MINISPI = 76, /*!< Group number for LPC_MINISPI status codes. */
|
||||
kStatusGroup_HASHCRYPT = 77, /*!< Group number for Hashcrypt status codes */
|
||||
kStatusGroup_LPC_SPI_SSP = 78, /*!< Group number for LPC_SPI_SSP status codes. */
|
||||
kStatusGroup_LPC_I2C_1 = 97, /*!< Group number for LPC_I2C_1 status codes. */
|
||||
kStatusGroup_NOTIFIER = 98, /*!< Group number for NOTIFIER status codes. */
|
||||
kStatusGroup_DebugConsole = 99, /*!< Group number for debug console status codes. */
|
||||
kStatusGroup_SEMC = 100, /*!< Group number for SEMC status codes. */
|
||||
kStatusGroup_ApplicationRangeStart = 101, /*!< Starting number for application groups. */
|
||||
kStatusGroup_IAP = 102, /*!< Group number for IAP status codes */
|
||||
|
||||
kStatusGroup_HAL_GPIO = 121, /*!< Group number for HAL GPIO status codes. */
|
||||
kStatusGroup_HAL_UART = 122, /*!< Group number for HAL UART status codes. */
|
||||
kStatusGroup_HAL_TIMER = 123, /*!< Group number for HAL TIMER status codes. */
|
||||
kStatusGroup_HAL_SPI = 124, /*!< Group number for HAL SPI status codes. */
|
||||
kStatusGroup_HAL_I2C = 125, /*!< Group number for HAL I2C status codes. */
|
||||
kStatusGroup_HAL_FLASH = 126, /*!< Group number for HAL FLASH status codes. */
|
||||
kStatusGroup_HAL_PWM = 127, /*!< Group number for HAL PWM status codes. */
|
||||
kStatusGroup_HAL_RNG = 128, /*!< Group number for HAL RNG status codes. */
|
||||
kStatusGroup_TIMERMANAGER = 135, /*!< Group number for TiMER MANAGER status codes. */
|
||||
kStatusGroup_SERIALMANAGER = 136, /*!< Group number for SERIAL MANAGER status codes. */
|
||||
kStatusGroup_LED = 137, /*!< Group number for LED status codes. */
|
||||
kStatusGroup_BUTTON = 138, /*!< Group number for BUTTON status codes. */
|
||||
kStatusGroup_EXTERN_EEPROM = 139, /*!< Group number for EXTERN EEPROM status codes. */
|
||||
kStatusGroup_SHELL = 140, /*!< Group number for SHELL status codes. */
|
||||
kStatusGroup_MEM_MANAGER = 141, /*!< Group number for MEM MANAGER status codes. */
|
||||
kStatusGroup_LIST = 142, /*!< Group number for List status codes. */
|
||||
kStatusGroup_OSA = 143, /*!< Group number for OSA status codes. */
|
||||
kStatusGroup_COMMON_TASK = 144, /*!< Group number for Common task status codes. */
|
||||
kStatusGroup_MSG = 145, /*!< Group number for messaging status codes. */
|
||||
};
|
||||
|
||||
/*! @brief Generic status return codes. */
|
||||
enum _generic_status
|
||||
{
|
||||
kStatus_Success = MAKE_STATUS(kStatusGroup_Generic, 0),
|
||||
kStatus_Fail = MAKE_STATUS(kStatusGroup_Generic, 1),
|
||||
kStatus_ReadOnly = MAKE_STATUS(kStatusGroup_Generic, 2),
|
||||
kStatus_OutOfRange = MAKE_STATUS(kStatusGroup_Generic, 3),
|
||||
kStatus_InvalidArgument = MAKE_STATUS(kStatusGroup_Generic, 4),
|
||||
kStatus_Timeout = MAKE_STATUS(kStatusGroup_Generic, 5),
|
||||
kStatus_NoTransferInProgress = MAKE_STATUS(kStatusGroup_Generic, 6),
|
||||
};
|
||||
|
||||
/*! @brief Type used for all status and error return values. */
|
||||
typedef int32_t status_t;
|
||||
|
||||
/*
|
||||
* The fsl_clock.h is included here because it needs MAKE_VERSION/MAKE_STATUS/status_t
|
||||
* defined in previous of this file.
|
||||
*/
|
||||
#include "fsl_clock.h"
|
||||
|
||||
/*
|
||||
* Chip level peripheral reset API, for MCUs that implement peripheral reset control external to a peripheral
|
||||
*/
|
||||
#if ((defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0)) || \
|
||||
(defined(FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT) && (FSL_FEATURE_SOC_ASYNC_SYSCON_COUNT > 0)))
|
||||
#include "fsl_reset.h"
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Macro guard for whether to use default weak IRQ implementation in drivers
|
||||
*/
|
||||
#ifndef FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ
|
||||
#define FSL_DRIVER_TRANSFER_DOUBLE_WEAK_IRQ 1
|
||||
#endif
|
||||
|
||||
/*! @name Min/max macros */
|
||||
/* @{ */
|
||||
#if !defined(MIN)
|
||||
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||
#endif
|
||||
|
||||
#if !defined(MAX)
|
||||
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @brief Computes the number of elements in an array. */
|
||||
#if !defined(ARRAY_SIZE)
|
||||
#define ARRAY_SIZE(x) (sizeof(x) / sizeof((x)[0]))
|
||||
#endif
|
||||
|
||||
/*! @name UINT16_MAX/UINT32_MAX value */
|
||||
/* @{ */
|
||||
#if !defined(UINT16_MAX)
|
||||
#define UINT16_MAX ((uint16_t)-1)
|
||||
#endif
|
||||
|
||||
#if !defined(UINT32_MAX)
|
||||
#define UINT32_MAX ((uint32_t)-1)
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @name Timer utilities */
|
||||
/* @{ */
|
||||
/*! Macro to convert a microsecond period to raw count value */
|
||||
#define USEC_TO_COUNT(us, clockFreqInHz) (uint64_t)((uint64_t)us * clockFreqInHz / 1000000U)
|
||||
/*! Macro to convert a raw count value to microsecond */
|
||||
#define COUNT_TO_USEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000000U / clockFreqInHz)
|
||||
|
||||
/*! Macro to convert a millisecond period to raw count value */
|
||||
#define MSEC_TO_COUNT(ms, clockFreqInHz) (uint64_t)((uint64_t)ms * clockFreqInHz / 1000U)
|
||||
/*! Macro to convert a raw count value to millisecond */
|
||||
#define COUNT_TO_MSEC(count, clockFreqInHz) (uint64_t)((uint64_t)count * 1000U / clockFreqInHz)
|
||||
/* @} */
|
||||
|
||||
/*! @name Alignment variable definition macros */
|
||||
/* @{ */
|
||||
#if (defined(__ICCARM__))
|
||||
/**
|
||||
* Workaround to disable MISRA C message suppress warnings for IAR compiler.
|
||||
* http://supp.iar.com/Support/?note=24725
|
||||
*/
|
||||
_Pragma("diag_suppress=Pm120")
|
||||
#define SDK_PRAGMA(x) _Pragma(#x)
|
||||
_Pragma("diag_error=Pm120")
|
||||
/*! Macro to define a variable with alignbytes alignment */
|
||||
#define SDK_ALIGN(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var
|
||||
/*! Macro to define a variable with L1 d-cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) SDK_PRAGMA(data_alignment = FSL_FEATURE_L1DCACHE_LINESIZE_BYTE) var
|
||||
#endif
|
||||
/*! Macro to define a variable with L2 cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) SDK_PRAGMA(data_alignment = FSL_FEATURE_L2CACHE_LINESIZE_BYTE) var
|
||||
#endif
|
||||
#elif defined(__CC_ARM) || defined(__ARMCC_VERSION)
|
||||
/*! Macro to define a variable with alignbytes alignment */
|
||||
#define SDK_ALIGN(var, alignbytes) __attribute__((aligned(alignbytes))) var
|
||||
/*! Macro to define a variable with L1 d-cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) __attribute__((aligned(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE))) var
|
||||
#endif
|
||||
/*! Macro to define a variable with L2 cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) __attribute__((aligned(FSL_FEATURE_L2CACHE_LINESIZE_BYTE))) var
|
||||
#endif
|
||||
#elif defined(__GNUC__)
|
||||
/*! Macro to define a variable with alignbytes alignment */
|
||||
#define SDK_ALIGN(var, alignbytes) var __attribute__((aligned(alignbytes)))
|
||||
/*! Macro to define a variable with L1 d-cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) var __attribute__((aligned(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)))
|
||||
#endif
|
||||
/*! Macro to define a variable with L2 cache line size alignment */
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) var __attribute__((aligned(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)))
|
||||
#endif
|
||||
#else
|
||||
#error Toolchain not supported
|
||||
#define SDK_ALIGN(var, alignbytes) var
|
||||
#if defined(FSL_FEATURE_L1DCACHE_LINESIZE_BYTE)
|
||||
#define SDK_L1DCACHE_ALIGN(var) var
|
||||
#endif
|
||||
#if defined(FSL_FEATURE_L2CACHE_LINESIZE_BYTE)
|
||||
#define SDK_L2CACHE_ALIGN(var) var
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*! Macro to change a value to a given size aligned value */
|
||||
#define SDK_SIZEALIGN(var, alignbytes) \
|
||||
((unsigned int)((var) + ((alignbytes)-1)) & (unsigned int)(~(unsigned int)((alignbytes)-1)))
|
||||
/* @} */
|
||||
|
||||
/*! @name Non-cacheable region definition macros */
|
||||
/* For initialized non-zero non-cacheable variables, please using "AT_NONCACHEABLE_SECTION_INIT(var) ={xx};" or
|
||||
* "AT_NONCACHEABLE_SECTION_ALIGN_INIT(var) ={xx};" in your projects to define them, for zero-inited non-cacheable variables,
|
||||
* please using "AT_NONCACHEABLE_SECTION(var);" or "AT_NONCACHEABLE_SECTION_ALIGN(var);" to define them, these zero-inited variables
|
||||
* will be initialized to zero in system startup.
|
||||
*/
|
||||
/* @{ */
|
||||
#if (defined(__ICCARM__))
|
||||
#if ((!(defined(FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION) && FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION)) && defined(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE))
|
||||
#define AT_NONCACHEABLE_SECTION(var) var @"NonCacheable"
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var @"NonCacheable"
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var @"NonCacheable.init"
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var @"NonCacheable.init"
|
||||
#else
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) SDK_PRAGMA(data_alignment = alignbytes) var
|
||||
#endif
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#if ((!(defined(FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION) && FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION)) && defined(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE))
|
||||
#define AT_NONCACHEABLE_SECTION(var) __attribute__((section("NonCacheable"), zero_init)) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable"), zero_init)) __attribute__((aligned(alignbytes))) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) __attribute__((section("NonCacheable.init"))) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable.init"))) __attribute__((aligned(alignbytes))) var
|
||||
#else
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) __attribute__((aligned(alignbytes))) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) __attribute__((aligned(alignbytes))) var
|
||||
#endif
|
||||
#elif(defined(__GNUC__))
|
||||
/* For GCC, when the non-cacheable section is required, please define "__STARTUP_INITIALIZE_NONCACHEDATA"
|
||||
* in your projects to make sure the non-cacheable section variables will be initialized in system startup.
|
||||
*/
|
||||
#if ((!(defined(FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION) && FSL_FEATURE_HAS_NO_NONCACHEABLE_SECTION)) && defined(FSL_FEATURE_L1ICACHE_LINESIZE_BYTE))
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) __attribute__((section("NonCacheable.init"))) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable.init"))) var __attribute__((aligned(alignbytes)))
|
||||
#define AT_NONCACHEABLE_SECTION(var) __attribute__((section("NonCacheable,\"aw\",%nobits @"))) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) \
|
||||
__attribute__((section("NonCacheable,\"aw\",%nobits @"))) var __attribute__((aligned(alignbytes)))
|
||||
#else
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) var __attribute__((aligned(alignbytes)))
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) var __attribute__((aligned(alignbytes)))
|
||||
#endif
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#define AT_NONCACHEABLE_SECTION(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN(var, alignbytes) var
|
||||
#define AT_NONCACHEABLE_SECTION_INIT(var) var
|
||||
#define AT_NONCACHEABLE_SECTION_ALIGN_INIT(var, alignbytes) var
|
||||
#endif
|
||||
/* @} */
|
||||
|
||||
/*! @name Time sensitive region */
|
||||
/* @{ */
|
||||
#if defined(FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE) && FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE
|
||||
#if (defined(__ICCARM__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func @"CodeQuickAccess"
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func @"DataQuickAccess"
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("CodeQuickAccess"))) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) __attribute__((section("DataQuickAccess"))) func
|
||||
#elif(defined(__GNUC__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) __attribute__((section("CodeQuickAccess"))) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) __attribute__((section("DataQuickAccess"))) func
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#endif /* defined(__ICCARM__) */
|
||||
#else
|
||||
#if (defined(__ICCARM__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func
|
||||
#elif(defined(__GNUC__))
|
||||
#define AT_QUICKACCESS_SECTION_CODE(func) func
|
||||
#define AT_QUICKACCESS_SECTION_DATA(func) func
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#endif
|
||||
#endif /* __FSL_SDK_DRIVER_QUICK_ACCESS_ENABLE */
|
||||
/* @} */
|
||||
|
||||
/*! @name Ram Function */
|
||||
#if (defined(__ICCARM__))
|
||||
#define RAMFUNCTION_SECTION_CODE(func) func @"RamFunction"
|
||||
#elif(defined(__CC_ARM) || defined(__ARMCC_VERSION))
|
||||
#define RAMFUNCTION_SECTION_CODE(func) __attribute__((section("RamFunction"))) func
|
||||
#elif(defined(__GNUC__))
|
||||
#define RAMFUNCTION_SECTION_CODE(func) __attribute__((section("RamFunction"))) func
|
||||
#else
|
||||
#error Toolchain not supported.
|
||||
#endif /* defined(__ICCARM__) */
|
||||
/* @} */
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C"
|
||||
{
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @brief Enable specific interrupt.
|
||||
*
|
||||
* Enable LEVEL1 interrupt. For some devices, there might be multiple interrupt
|
||||
* levels. For example, there are NVIC and intmux. Here the interrupts connected
|
||||
* to NVIC are the LEVEL1 interrupts, because they are routed to the core directly.
|
||||
* The interrupts connected to intmux are the LEVEL2 interrupts, they are routed
|
||||
* to NVIC first then routed to core.
|
||||
*
|
||||
* This function only enables the LEVEL1 interrupts. The number of LEVEL1 interrupts
|
||||
* is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
* @retval kStatus_Success Interrupt enabled successfully
|
||||
* @retval kStatus_Fail Failed to enable the interrupt
|
||||
*/
|
||||
static inline status_t EnableIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
if (NotAvail_IRQn == interrupt)
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS) && (FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS > 0)
|
||||
if (interrupt >= FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS)
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GIC_PRIO_BITS)
|
||||
GIC_EnableIRQ(interrupt);
|
||||
#else
|
||||
NVIC_EnableIRQ(interrupt);
|
||||
#endif
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable specific interrupt.
|
||||
*
|
||||
* Disable LEVEL1 interrupt. For some devices, there might be multiple interrupt
|
||||
* levels. For example, there are NVIC and intmux. Here the interrupts connected
|
||||
* to NVIC are the LEVEL1 interrupts, because they are routed to the core directly.
|
||||
* The interrupts connected to intmux are the LEVEL2 interrupts, they are routed
|
||||
* to NVIC first then routed to core.
|
||||
*
|
||||
* This function only disables the LEVEL1 interrupts. The number of LEVEL1 interrupts
|
||||
* is indicated by the feature macro FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS.
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
* @retval kStatus_Success Interrupt disabled successfully
|
||||
* @retval kStatus_Fail Failed to disable the interrupt
|
||||
*/
|
||||
static inline status_t DisableIRQ(IRQn_Type interrupt)
|
||||
{
|
||||
if (NotAvail_IRQn == interrupt)
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
|
||||
#if defined(FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS) && (FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS > 0)
|
||||
if (interrupt >= FSL_FEATURE_NUMBER_OF_LEVEL1_INT_VECTORS)
|
||||
{
|
||||
return kStatus_Fail;
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(__GIC_PRIO_BITS)
|
||||
GIC_DisableIRQ(interrupt);
|
||||
#else
|
||||
NVIC_DisableIRQ(interrupt);
|
||||
#endif
|
||||
return kStatus_Success;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disable the global IRQ
|
||||
*
|
||||
* Disable the global interrupt and return the current primask register. User is required to provided the primask
|
||||
* register for the EnableGlobalIRQ().
|
||||
*
|
||||
* @return Current primask value.
|
||||
*/
|
||||
static inline uint32_t DisableGlobalIRQ(void)
|
||||
{
|
||||
#if defined(CPSR_I_Msk)
|
||||
uint32_t cpsr = __get_CPSR() & CPSR_I_Msk;
|
||||
|
||||
__disable_irq();
|
||||
|
||||
return cpsr;
|
||||
#else
|
||||
uint32_t regPrimask = __get_PRIMASK();
|
||||
|
||||
__disable_irq();
|
||||
|
||||
return regPrimask;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enable the global IRQ
|
||||
*
|
||||
* Set the primask register with the provided primask value but not just enable the primask. The idea is for the
|
||||
* convenience of integration of RTOS. some RTOS get its own management mechanism of primask. User is required to
|
||||
* use the EnableGlobalIRQ() and DisableGlobalIRQ() in pair.
|
||||
*
|
||||
* @param primask value of primask register to be restored. The primask value is supposed to be provided by the
|
||||
* DisableGlobalIRQ().
|
||||
*/
|
||||
static inline void EnableGlobalIRQ(uint32_t primask)
|
||||
{
|
||||
#if defined(CPSR_I_Msk)
|
||||
__set_CPSR((__get_CPSR() & ~CPSR_I_Msk) | primask);
|
||||
#else
|
||||
__set_PRIMASK(primask);
|
||||
#endif
|
||||
}
|
||||
|
||||
#if defined(ENABLE_RAM_VECTOR_TABLE)
|
||||
/*!
|
||||
* @brief install IRQ handler
|
||||
*
|
||||
* @param irq IRQ number
|
||||
* @param irqHandler IRQ handler address
|
||||
* @return The old IRQ handler address
|
||||
*/
|
||||
uint32_t InstallIRQHandler(IRQn_Type irq, uint32_t irqHandler);
|
||||
#endif /* ENABLE_RAM_VECTOR_TABLE. */
|
||||
|
||||
#if (defined(FSL_FEATURE_SOC_SYSCON_COUNT) && (FSL_FEATURE_SOC_SYSCON_COUNT > 0))
|
||||
/*!
|
||||
* @brief Enable specific interrupt for wake-up from deep-sleep mode.
|
||||
*
|
||||
* Enable the interrupt for wake-up from deep sleep mode.
|
||||
* Some interrupts are typically used in sleep mode only and will not occur during
|
||||
* deep-sleep mode because relevant clocks are stopped. However, it is possible to enable
|
||||
* those clocks (significantly increasing power consumption in the reduced power mode),
|
||||
* making these wake-ups possible.
|
||||
*
|
||||
* @note This function also enables the interrupt in the NVIC (EnableIRQ() is called internaly).
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
void EnableDeepSleepIRQ(IRQn_Type interrupt);
|
||||
|
||||
/*!
|
||||
* @brief Disable specific interrupt for wake-up from deep-sleep mode.
|
||||
*
|
||||
* Disable the interrupt for wake-up from deep sleep mode.
|
||||
* Some interrupts are typically used in sleep mode only and will not occur during
|
||||
* deep-sleep mode because relevant clocks are stopped. However, it is possible to enable
|
||||
* those clocks (significantly increasing power consumption in the reduced power mode),
|
||||
* making these wake-ups possible.
|
||||
*
|
||||
* @note This function also disables the interrupt in the NVIC (DisableIRQ() is called internaly).
|
||||
*
|
||||
* @param interrupt The IRQ number.
|
||||
*/
|
||||
void DisableDeepSleepIRQ(IRQn_Type interrupt);
|
||||
#endif /* FSL_FEATURE_SOC_SYSCON_COUNT */
|
||||
|
||||
/*!
|
||||
* @brief Allocate memory with given alignment and aligned size.
|
||||
*
|
||||
* This is provided to support the dynamically allocated memory
|
||||
* used in cache-able region.
|
||||
* @param size The length required to malloc.
|
||||
* @param alignbytes The alignment size.
|
||||
* @retval The allocated memory.
|
||||
*/
|
||||
void *SDK_Malloc(size_t size, size_t alignbytes);
|
||||
|
||||
/*!
|
||||
* @brief Free memory.
|
||||
*
|
||||
* @param ptr The memory to be release.
|
||||
*/
|
||||
void SDK_Free(void *ptr);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! @} */
|
||||
|
||||
#endif /* _FSL_COMMON_H_ */
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,240 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#include "fsl_wdog.h"
|
||||
|
||||
/* Component ID definition, used by tools. */
|
||||
#ifndef FSL_COMPONENT_ID
|
||||
#define FSL_COMPONENT_ID "platform.drivers.wdog"
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
/*!
|
||||
* brief Initializes the WDOG configuration sturcture.
|
||||
*
|
||||
* This function initializes the WDOG configuration structure to default values. The default
|
||||
* values are as follows.
|
||||
* code
|
||||
* wdogConfig->enableWdog = true;
|
||||
* wdogConfig->clockSource = kWDOG_LpoClockSource;
|
||||
* wdogConfig->prescaler = kWDOG_ClockPrescalerDivide1;
|
||||
* wdogConfig->workMode.enableWait = true;
|
||||
* wdogConfig->workMode.enableStop = false;
|
||||
* wdogConfig->workMode.enableDebug = false;
|
||||
* wdogConfig->enableUpdate = true;
|
||||
* wdogConfig->enableInterrupt = false;
|
||||
* wdogConfig->enableWindowMode = false;
|
||||
* wdogConfig->windowValue = 0;
|
||||
* wdogConfig->timeoutValue = 0xFFFFU;
|
||||
* endcode
|
||||
*
|
||||
* param config Pointer to the WDOG configuration structure.
|
||||
* see wdog_config_t
|
||||
*/
|
||||
void WDOG_GetDefaultConfig(wdog_config_t *config)
|
||||
{
|
||||
assert(config);
|
||||
|
||||
/* Initializes the configure structure to zero. */
|
||||
memset(config, 0, sizeof(*config));
|
||||
|
||||
config->enableWdog = true;
|
||||
config->clockSource = kWDOG_LpoClockSource;
|
||||
config->prescaler = kWDOG_ClockPrescalerDivide1;
|
||||
#if defined(FSL_FEATURE_WDOG_HAS_WAITEN) && FSL_FEATURE_WDOG_HAS_WAITEN
|
||||
config->workMode.enableWait = true;
|
||||
#endif /* FSL_FEATURE_WDOG_HAS_WAITEN */
|
||||
config->workMode.enableStop = false;
|
||||
config->workMode.enableDebug = false;
|
||||
config->enableUpdate = true;
|
||||
config->enableInterrupt = false;
|
||||
config->enableWindowMode = false;
|
||||
config->windowValue = 0U;
|
||||
config->timeoutValue = 0xFFFFU;
|
||||
}
|
||||
|
||||
/*!
|
||||
* brief Initializes the WDOG.
|
||||
*
|
||||
* This function initializes the WDOG. When called, the WDOG runs according to the configuration.
|
||||
* To reconfigure WDOG without forcing a reset first, enableUpdate must be set to true
|
||||
* in the configuration.
|
||||
*
|
||||
* This is an example.
|
||||
* code
|
||||
* wdog_config_t config;
|
||||
* WDOG_GetDefaultConfig(&config);
|
||||
* config.timeoutValue = 0x7ffU;
|
||||
* config.enableUpdate = true;
|
||||
* WDOG_Init(wdog_base,&config);
|
||||
* endcode
|
||||
*
|
||||
* param base WDOG peripheral base address
|
||||
* param config The configuration of WDOG
|
||||
*/
|
||||
void WDOG_Init(WDOG_Type *base, const wdog_config_t *config)
|
||||
{
|
||||
assert(config);
|
||||
|
||||
uint32_t value = 0U;
|
||||
uint32_t primaskValue = 0U;
|
||||
|
||||
value = WDOG_STCTRLH_WDOGEN(config->enableWdog) | WDOG_STCTRLH_CLKSRC(config->clockSource) |
|
||||
WDOG_STCTRLH_IRQRSTEN(config->enableInterrupt) | WDOG_STCTRLH_WINEN(config->enableWindowMode) |
|
||||
WDOG_STCTRLH_ALLOWUPDATE(config->enableUpdate) | WDOG_STCTRLH_DBGEN(config->workMode.enableDebug) |
|
||||
WDOG_STCTRLH_STOPEN(config->workMode.enableStop) |
|
||||
#if defined(FSL_FEATURE_WDOG_HAS_WAITEN) && FSL_FEATURE_WDOG_HAS_WAITEN
|
||||
WDOG_STCTRLH_WAITEN(config->workMode.enableWait) |
|
||||
#endif /* FSL_FEATURE_WDOG_HAS_WAITEN */
|
||||
WDOG_STCTRLH_DISTESTWDOG(1U);
|
||||
|
||||
/* Disable the global interrupts. Otherwise, an interrupt could effectively invalidate the unlock sequence
|
||||
* and the WCT may expire. After the configuration finishes, re-enable the global interrupts. */
|
||||
primaskValue = DisableGlobalIRQ();
|
||||
WDOG_Unlock(base);
|
||||
/* Wait one bus clock cycle */
|
||||
base->RSTCNT = 0U;
|
||||
/* Set configruation */
|
||||
base->PRESC = WDOG_PRESC_PRESCVAL(config->prescaler);
|
||||
base->WINH = (uint16_t)((config->windowValue >> 16U) & 0xFFFFU);
|
||||
base->WINL = (uint16_t)((config->windowValue) & 0xFFFFU);
|
||||
base->TOVALH = (uint16_t)((config->timeoutValue >> 16U) & 0xFFFFU);
|
||||
base->TOVALL = (uint16_t)((config->timeoutValue) & 0xFFFFU);
|
||||
base->STCTRLH = value;
|
||||
EnableGlobalIRQ(primaskValue);
|
||||
}
|
||||
|
||||
/*!
|
||||
* brief Shuts down the WDOG.
|
||||
*
|
||||
* This function shuts down the WDOG.
|
||||
* Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which indicates that the register update is enabled.
|
||||
*/
|
||||
void WDOG_Deinit(WDOG_Type *base)
|
||||
{
|
||||
uint32_t primaskValue = 0U;
|
||||
|
||||
/* Disable the global interrupts */
|
||||
primaskValue = DisableGlobalIRQ();
|
||||
WDOG_Unlock(base);
|
||||
/* Wait one bus clock cycle */
|
||||
base->RSTCNT = 0U;
|
||||
WDOG_Disable(base);
|
||||
EnableGlobalIRQ(primaskValue);
|
||||
WDOG_ClearResetCount(base);
|
||||
}
|
||||
|
||||
/*!
|
||||
* brief Configures the WDOG functional test.
|
||||
*
|
||||
* This function is used to configure the WDOG functional test. When called, the WDOG goes into test mode
|
||||
* and runs according to the configuration.
|
||||
* Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which means that the register update is enabled.
|
||||
*
|
||||
* This is an example.
|
||||
* code
|
||||
* wdog_test_config_t test_config;
|
||||
* test_config.testMode = kWDOG_QuickTest;
|
||||
* test_config.timeoutValue = 0xfffffu;
|
||||
* WDOG_SetTestModeConfig(wdog_base, &test_config);
|
||||
* endcode
|
||||
* param base WDOG peripheral base address
|
||||
* param config The functional test configuration of WDOG
|
||||
*/
|
||||
void WDOG_SetTestModeConfig(WDOG_Type *base, wdog_test_config_t *config)
|
||||
{
|
||||
assert(config);
|
||||
|
||||
uint32_t value = 0U;
|
||||
uint32_t primaskValue = 0U;
|
||||
|
||||
value = WDOG_STCTRLH_DISTESTWDOG(0U) | WDOG_STCTRLH_TESTWDOG(1U) | WDOG_STCTRLH_TESTSEL(config->testMode) |
|
||||
WDOG_STCTRLH_BYTESEL(config->testedByte) | WDOG_STCTRLH_IRQRSTEN(0U) | WDOG_STCTRLH_WDOGEN(1U) |
|
||||
WDOG_STCTRLH_ALLOWUPDATE(1U);
|
||||
|
||||
/* Disable the global interrupts. Otherwise, an interrupt could effectively invalidate the unlock sequence
|
||||
* and the WCT may expire. After the configuration finishes, re-enable the global interrupts. */
|
||||
primaskValue = DisableGlobalIRQ();
|
||||
WDOG_Unlock(base);
|
||||
/* Wait one bus clock cycle */
|
||||
base->RSTCNT = 0U;
|
||||
/* Set configruation */
|
||||
base->TOVALH = (uint16_t)((config->timeoutValue >> 16U) & 0xFFFFU);
|
||||
base->TOVALL = (uint16_t)((config->timeoutValue) & 0xFFFFU);
|
||||
base->STCTRLH = value;
|
||||
EnableGlobalIRQ(primaskValue);
|
||||
}
|
||||
|
||||
/*!
|
||||
* brief Gets the WDOG all status flags.
|
||||
*
|
||||
* This function gets all status flags.
|
||||
*
|
||||
* This is an example for getting the Running Flag.
|
||||
* code
|
||||
* uint32_t status;
|
||||
* status = WDOG_GetStatusFlags (wdog_base) & kWDOG_RunningFlag;
|
||||
* endcode
|
||||
* param base WDOG peripheral base address
|
||||
* return State of the status flag: asserted (true) or not-asserted (false).see _wdog_status_flags_t
|
||||
* - true: a related status flag has been set.
|
||||
* - false: a related status flag is not set.
|
||||
*/
|
||||
uint32_t WDOG_GetStatusFlags(WDOG_Type *base)
|
||||
{
|
||||
uint32_t status_flag = 0U;
|
||||
|
||||
status_flag |= (base->STCTRLH & WDOG_STCTRLH_WDOGEN_MASK);
|
||||
status_flag |= (base->STCTRLL & WDOG_STCTRLL_INTFLG_MASK);
|
||||
|
||||
return status_flag;
|
||||
}
|
||||
|
||||
/*!
|
||||
* brief Clears the WDOG flag.
|
||||
*
|
||||
* This function clears the WDOG status flag.
|
||||
*
|
||||
* This is an example for clearing the timeout (interrupt) flag.
|
||||
* code
|
||||
* WDOG_ClearStatusFlags(wdog_base,kWDOG_TimeoutFlag);
|
||||
* endcode
|
||||
* param base WDOG peripheral base address
|
||||
* param mask The status flags to clear.
|
||||
* The parameter could be any combination of the following values.
|
||||
* kWDOG_TimeoutFlag
|
||||
*/
|
||||
void WDOG_ClearStatusFlags(WDOG_Type *base, uint32_t mask)
|
||||
{
|
||||
if (mask & kWDOG_TimeoutFlag)
|
||||
{
|
||||
base->STCTRLL |= WDOG_STCTRLL_INTFLG_MASK;
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
* brief Refreshes the WDOG timer.
|
||||
*
|
||||
* This function feeds the WDOG.
|
||||
* This function should be called before the WDOG timer is in timeout. Otherwise, a reset is asserted.
|
||||
*
|
||||
* param base WDOG peripheral base address
|
||||
*/
|
||||
void WDOG_Refresh(WDOG_Type *base)
|
||||
{
|
||||
uint32_t primaskValue = 0U;
|
||||
|
||||
/* Disable the global interrupt to protect refresh sequence */
|
||||
primaskValue = DisableGlobalIRQ();
|
||||
base->REFRESH = WDOG_FIRST_WORD_OF_REFRESH;
|
||||
base->REFRESH = WDOG_SECOND_WORD_OF_REFRESH;
|
||||
EnableGlobalIRQ(primaskValue);
|
||||
}
|
|
@ -0,0 +1,411 @@
|
|||
/*
|
||||
* Copyright (c) 2015, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016-2017 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#ifndef _FSL_WDOG_H_
|
||||
#define _FSL_WDOG_H_
|
||||
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*!
|
||||
* @addtogroup wdog
|
||||
* @{
|
||||
*/
|
||||
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
*******************************************************************************/
|
||||
|
||||
/*! @name Driver version */
|
||||
/*@{*/
|
||||
/*! @brief Defines WDOG driver version 2.0.0. */
|
||||
#define FSL_WDOG_DRIVER_VERSION (MAKE_VERSION(2, 0, 0))
|
||||
/*@}*/
|
||||
|
||||
/*! @name Unlock sequence */
|
||||
/*@{*/
|
||||
#define WDOG_FIRST_WORD_OF_UNLOCK (0xC520U) /*!< First word of unlock sequence */
|
||||
#define WDOG_SECOND_WORD_OF_UNLOCK (0xD928U) /*!< Second word of unlock sequence */
|
||||
/*@}*/
|
||||
|
||||
/*! @name Refresh sequence */
|
||||
/*@{*/
|
||||
#define WDOG_FIRST_WORD_OF_REFRESH (0xA602U) /*!< First word of refresh sequence */
|
||||
#define WDOG_SECOND_WORD_OF_REFRESH (0xB480U) /*!< Second word of refresh sequence */
|
||||
/*@}*/
|
||||
|
||||
/*! @brief Describes WDOG clock source. */
|
||||
typedef enum _wdog_clock_source
|
||||
{
|
||||
kWDOG_LpoClockSource = 0U, /*!< WDOG clock sourced from LPO*/
|
||||
kWDOG_AlternateClockSource = 1U, /*!< WDOG clock sourced from alternate clock source*/
|
||||
} wdog_clock_source_t;
|
||||
|
||||
/*! @brief Defines WDOG work mode. */
|
||||
typedef struct _wdog_work_mode
|
||||
{
|
||||
#if defined(FSL_FEATURE_WDOG_HAS_WAITEN) && FSL_FEATURE_WDOG_HAS_WAITEN
|
||||
bool enableWait; /*!< Enables or disables WDOG in wait mode */
|
||||
#endif /* FSL_FEATURE_WDOG_HAS_WAITEN */
|
||||
bool enableStop; /*!< Enables or disables WDOG in stop mode */
|
||||
bool enableDebug; /*!< Enables or disables WDOG in debug mode */
|
||||
} wdog_work_mode_t;
|
||||
|
||||
/*! @brief Describes the selection of the clock prescaler. */
|
||||
typedef enum _wdog_clock_prescaler
|
||||
{
|
||||
kWDOG_ClockPrescalerDivide1 = 0x0U, /*!< Divided by 1 */
|
||||
kWDOG_ClockPrescalerDivide2 = 0x1U, /*!< Divided by 2 */
|
||||
kWDOG_ClockPrescalerDivide3 = 0x2U, /*!< Divided by 3 */
|
||||
kWDOG_ClockPrescalerDivide4 = 0x3U, /*!< Divided by 4 */
|
||||
kWDOG_ClockPrescalerDivide5 = 0x4U, /*!< Divided by 5 */
|
||||
kWDOG_ClockPrescalerDivide6 = 0x5U, /*!< Divided by 6 */
|
||||
kWDOG_ClockPrescalerDivide7 = 0x6U, /*!< Divided by 7 */
|
||||
kWDOG_ClockPrescalerDivide8 = 0x7U, /*!< Divided by 8 */
|
||||
} wdog_clock_prescaler_t;
|
||||
|
||||
/*! @brief Describes WDOG configuration structure. */
|
||||
typedef struct _wdog_config
|
||||
{
|
||||
bool enableWdog; /*!< Enables or disables WDOG */
|
||||
wdog_clock_source_t clockSource; /*!< Clock source select */
|
||||
wdog_clock_prescaler_t prescaler; /*!< Clock prescaler value */
|
||||
wdog_work_mode_t workMode; /*!< Configures WDOG work mode in debug stop and wait mode */
|
||||
bool enableUpdate; /*!< Update write-once register enable */
|
||||
bool enableInterrupt; /*!< Enables or disables WDOG interrupt */
|
||||
bool enableWindowMode; /*!< Enables or disables WDOG window mode */
|
||||
uint32_t windowValue; /*!< Window value */
|
||||
uint32_t timeoutValue; /*!< Timeout value */
|
||||
} wdog_config_t;
|
||||
|
||||
/*! @brief Describes WDOG test mode. */
|
||||
typedef enum _wdog_test_mode
|
||||
{
|
||||
kWDOG_QuickTest = 0U, /*!< Selects quick test */
|
||||
kWDOG_ByteTest = 1U, /*!< Selects byte test */
|
||||
} wdog_test_mode_t;
|
||||
|
||||
/*! @brief Describes WDOG tested byte selection in byte test mode. */
|
||||
typedef enum _wdog_tested_byte
|
||||
{
|
||||
kWDOG_TestByte0 = 0U, /*!< Byte 0 selected in byte test mode */
|
||||
kWDOG_TestByte1 = 1U, /*!< Byte 1 selected in byte test mode */
|
||||
kWDOG_TestByte2 = 2U, /*!< Byte 2 selected in byte test mode */
|
||||
kWDOG_TestByte3 = 3U, /*!< Byte 3 selected in byte test mode */
|
||||
} wdog_tested_byte_t;
|
||||
|
||||
/*! @brief Describes WDOG test mode configuration structure. */
|
||||
typedef struct _wdog_test_config
|
||||
{
|
||||
wdog_test_mode_t testMode; /*!< Selects test mode */
|
||||
wdog_tested_byte_t testedByte; /*!< Selects tested byte in byte test mode */
|
||||
uint32_t timeoutValue; /*!< Timeout value */
|
||||
} wdog_test_config_t;
|
||||
|
||||
/*!
|
||||
* @brief WDOG interrupt configuration structure, default settings all disabled.
|
||||
*
|
||||
* This structure contains the settings for all of the WDOG interrupt configurations.
|
||||
*/
|
||||
enum _wdog_interrupt_enable_t
|
||||
{
|
||||
kWDOG_InterruptEnable = WDOG_STCTRLH_IRQRSTEN_MASK, /*!< WDOG timeout generates an interrupt before reset*/
|
||||
};
|
||||
|
||||
/*!
|
||||
* @brief WDOG status flags.
|
||||
*
|
||||
* This structure contains the WDOG status flags for use in the WDOG functions.
|
||||
*/
|
||||
enum _wdog_status_flags_t
|
||||
{
|
||||
kWDOG_RunningFlag = WDOG_STCTRLH_WDOGEN_MASK, /*!< Running flag, set when WDOG is enabled*/
|
||||
kWDOG_TimeoutFlag = WDOG_STCTRLL_INTFLG_MASK, /*!< Interrupt flag, set when an exception occurs*/
|
||||
};
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
*******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*!
|
||||
* @name WDOG Initialization and De-initialization
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Initializes the WDOG configuration sturcture.
|
||||
*
|
||||
* This function initializes the WDOG configuration structure to default values. The default
|
||||
* values are as follows.
|
||||
* @code
|
||||
* wdogConfig->enableWdog = true;
|
||||
* wdogConfig->clockSource = kWDOG_LpoClockSource;
|
||||
* wdogConfig->prescaler = kWDOG_ClockPrescalerDivide1;
|
||||
* wdogConfig->workMode.enableWait = true;
|
||||
* wdogConfig->workMode.enableStop = false;
|
||||
* wdogConfig->workMode.enableDebug = false;
|
||||
* wdogConfig->enableUpdate = true;
|
||||
* wdogConfig->enableInterrupt = false;
|
||||
* wdogConfig->enableWindowMode = false;
|
||||
* wdogConfig->windowValue = 0;
|
||||
* wdogConfig->timeoutValue = 0xFFFFU;
|
||||
* @endcode
|
||||
*
|
||||
* @param config Pointer to the WDOG configuration structure.
|
||||
* @see wdog_config_t
|
||||
*/
|
||||
void WDOG_GetDefaultConfig(wdog_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Initializes the WDOG.
|
||||
*
|
||||
* This function initializes the WDOG. When called, the WDOG runs according to the configuration.
|
||||
* To reconfigure WDOG without forcing a reset first, enableUpdate must be set to true
|
||||
* in the configuration.
|
||||
*
|
||||
* This is an example.
|
||||
* @code
|
||||
* wdog_config_t config;
|
||||
* WDOG_GetDefaultConfig(&config);
|
||||
* config.timeoutValue = 0x7ffU;
|
||||
* config.enableUpdate = true;
|
||||
* WDOG_Init(wdog_base,&config);
|
||||
* @endcode
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
* @param config The configuration of WDOG
|
||||
*/
|
||||
void WDOG_Init(WDOG_Type *base, const wdog_config_t *config);
|
||||
|
||||
/*!
|
||||
* @brief Shuts down the WDOG.
|
||||
*
|
||||
* This function shuts down the WDOG.
|
||||
* Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which indicates that the register update is enabled.
|
||||
*/
|
||||
void WDOG_Deinit(WDOG_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Configures the WDOG functional test.
|
||||
*
|
||||
* This function is used to configure the WDOG functional test. When called, the WDOG goes into test mode
|
||||
* and runs according to the configuration.
|
||||
* Ensure that the WDOG_STCTRLH.ALLOWUPDATE is 1 which means that the register update is enabled.
|
||||
*
|
||||
* This is an example.
|
||||
* @code
|
||||
* wdog_test_config_t test_config;
|
||||
* test_config.testMode = kWDOG_QuickTest;
|
||||
* test_config.timeoutValue = 0xfffffu;
|
||||
* WDOG_SetTestModeConfig(wdog_base, &test_config);
|
||||
* @endcode
|
||||
* @param base WDOG peripheral base address
|
||||
* @param config The functional test configuration of WDOG
|
||||
*/
|
||||
void WDOG_SetTestModeConfig(WDOG_Type *base, wdog_test_config_t *config);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name WDOG Functional Operation
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Enables the WDOG module.
|
||||
*
|
||||
* This function write value into WDOG_STCTRLH register to enable the WDOG, it is a write-once register,
|
||||
* make sure that the WCT window is still open and this register has not been written in this WCT
|
||||
* while this function is called.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
*/
|
||||
static inline void WDOG_Enable(WDOG_Type *base)
|
||||
{
|
||||
base->STCTRLH |= WDOG_STCTRLH_WDOGEN_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the WDOG module.
|
||||
*
|
||||
* This function writes a value into the WDOG_STCTRLH register to disable the WDOG. It is a write-once register.
|
||||
* Ensure that the WCT window is still open and that register has not been written to in this WCT
|
||||
* while the function is called.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
*/
|
||||
static inline void WDOG_Disable(WDOG_Type *base)
|
||||
{
|
||||
base->STCTRLH &= ~WDOG_STCTRLH_WDOGEN_MASK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Enables the WDOG interrupt.
|
||||
*
|
||||
* This function writes a value into the WDOG_STCTRLH register to enable the WDOG interrupt. It is a write-once register.
|
||||
* Ensure that the WCT window is still open and the register has not been written to in this WCT
|
||||
* while the function is called.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
* @param mask The interrupts to enable
|
||||
* The parameter can be combination of the following source if defined.
|
||||
* @arg kWDOG_InterruptEnable
|
||||
*/
|
||||
static inline void WDOG_EnableInterrupts(WDOG_Type *base, uint32_t mask)
|
||||
{
|
||||
base->STCTRLH |= mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Disables the WDOG interrupt.
|
||||
*
|
||||
* This function writes a value into the WDOG_STCTRLH register to disable the WDOG interrupt. It is a write-once register.
|
||||
* Ensure that the WCT window is still open and the register has not been written to in this WCT
|
||||
* while the function is called.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
* @param mask The interrupts to disable
|
||||
* The parameter can be combination of the following source if defined.
|
||||
* @arg kWDOG_InterruptEnable
|
||||
*/
|
||||
static inline void WDOG_DisableInterrupts(WDOG_Type *base, uint32_t mask)
|
||||
{
|
||||
base->STCTRLH &= ~mask;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Gets the WDOG all status flags.
|
||||
*
|
||||
* This function gets all status flags.
|
||||
*
|
||||
* This is an example for getting the Running Flag.
|
||||
* @code
|
||||
* uint32_t status;
|
||||
* status = WDOG_GetStatusFlags (wdog_base) & kWDOG_RunningFlag;
|
||||
* @endcode
|
||||
* @param base WDOG peripheral base address
|
||||
* @return State of the status flag: asserted (true) or not-asserted (false).@see _wdog_status_flags_t
|
||||
* - true: a related status flag has been set.
|
||||
* - false: a related status flag is not set.
|
||||
*/
|
||||
uint32_t WDOG_GetStatusFlags(WDOG_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Clears the WDOG flag.
|
||||
*
|
||||
* This function clears the WDOG status flag.
|
||||
*
|
||||
* This is an example for clearing the timeout (interrupt) flag.
|
||||
* @code
|
||||
* WDOG_ClearStatusFlags(wdog_base,kWDOG_TimeoutFlag);
|
||||
* @endcode
|
||||
* @param base WDOG peripheral base address
|
||||
* @param mask The status flags to clear.
|
||||
* The parameter could be any combination of the following values.
|
||||
* kWDOG_TimeoutFlag
|
||||
*/
|
||||
void WDOG_ClearStatusFlags(WDOG_Type *base, uint32_t mask);
|
||||
|
||||
/*!
|
||||
* @brief Sets the WDOG timeout value.
|
||||
*
|
||||
* This function sets the timeout value.
|
||||
* It should be ensured that the time-out value for the WDOG is always greater than
|
||||
* 2xWCT time + 20 bus clock cycles.
|
||||
* This function writes a value into WDOG_TOVALH and WDOG_TOVALL registers which are wirte-once.
|
||||
* Ensure the WCT window is still open and the two registers have not been written to in this WCT
|
||||
* while the function is called.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
* @param timeoutCount WDOG timeout value; count of WDOG clock tick.
|
||||
*/
|
||||
static inline void WDOG_SetTimeoutValue(WDOG_Type *base, uint32_t timeoutCount)
|
||||
{
|
||||
base->TOVALH = (uint16_t)((timeoutCount >> 16U) & 0xFFFFU);
|
||||
base->TOVALL = (uint16_t)((timeoutCount)&0xFFFFU);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Sets the WDOG window value.
|
||||
*
|
||||
* This function sets the WDOG window value.
|
||||
* This function writes a value into WDOG_WINH and WDOG_WINL registers which are wirte-once.
|
||||
* Ensure the WCT window is still open and the two registers have not been written to in this WCT
|
||||
* while the function is called.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
* @param windowValue WDOG window value.
|
||||
*/
|
||||
static inline void WDOG_SetWindowValue(WDOG_Type *base, uint32_t windowValue)
|
||||
{
|
||||
base->WINH = (uint16_t)((windowValue >> 16U) & 0xFFFFU);
|
||||
base->WINL = (uint16_t)((windowValue)&0xFFFFU);
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Unlocks the WDOG register written.
|
||||
*
|
||||
* This function unlocks the WDOG register written.
|
||||
* Before starting the unlock sequence and following congfiguration, disable the global interrupts.
|
||||
* Otherwise, an interrupt may invalidate the unlocking sequence and the WCT may expire.
|
||||
* After the configuration finishes, re-enable the global interrupts.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
*/
|
||||
static inline void WDOG_Unlock(WDOG_Type *base)
|
||||
{
|
||||
base->UNLOCK = WDOG_FIRST_WORD_OF_UNLOCK;
|
||||
base->UNLOCK = WDOG_SECOND_WORD_OF_UNLOCK;
|
||||
}
|
||||
|
||||
/*!
|
||||
* @brief Refreshes the WDOG timer.
|
||||
*
|
||||
* This function feeds the WDOG.
|
||||
* This function should be called before the WDOG timer is in timeout. Otherwise, a reset is asserted.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
*/
|
||||
void WDOG_Refresh(WDOG_Type *base);
|
||||
|
||||
/*!
|
||||
* @brief Gets the WDOG reset count.
|
||||
*
|
||||
* This function gets the WDOG reset count value.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
* @return WDOG reset count value.
|
||||
*/
|
||||
static inline uint16_t WDOG_GetResetCount(WDOG_Type *base)
|
||||
{
|
||||
return base->RSTCNT;
|
||||
}
|
||||
/*!
|
||||
* @brief Clears the WDOG reset count.
|
||||
*
|
||||
* This function clears the WDOG reset count value.
|
||||
*
|
||||
* @param base WDOG peripheral base address
|
||||
*/
|
||||
static inline void WDOG_ClearResetCount(WDOG_Type *base)
|
||||
{
|
||||
base->RSTCNT |= UINT16_MAX;
|
||||
}
|
||||
|
||||
/*@}*/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
/*! @}*/
|
||||
|
||||
#endif /* _FSL_WDOG_H_ */
|
|
@ -0,0 +1,576 @@
|
|||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __USB_OSA_H__
|
||||
#define __USB_OSA_H__
|
||||
|
||||
/*!
|
||||
* @addtogroup usb_os_abstraction
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
/*! @brief Define big endian */
|
||||
#define USB_BIG_ENDIAN (0U)
|
||||
/*! @brief Define little endian */
|
||||
#define USB_LITTLE_ENDIAN (1U)
|
||||
|
||||
/*! @brief Define current endian */
|
||||
#define ENDIANNESS USB_LITTLE_ENDIAN
|
||||
|
||||
/*! @brief Define USB OSA event handle */
|
||||
typedef void *usb_osa_event_handle;
|
||||
|
||||
/*! @brief Define USB OSA semaphore handle */
|
||||
typedef void *usb_osa_sem_handle;
|
||||
|
||||
/*! @brief Define USB OSA mutex handle */
|
||||
typedef void *usb_osa_mutex_handle;
|
||||
|
||||
/*! @brief Define USB OSA message queue handle */
|
||||
typedef void *usb_osa_msgq_handle;
|
||||
|
||||
/*! @brief USB OSA error code */
|
||||
typedef enum _usb_osa_status
|
||||
{
|
||||
kStatus_USB_OSA_Success = 0x00U, /*!< Success */
|
||||
kStatus_USB_OSA_Error, /*!< Failed */
|
||||
kStatus_USB_OSA_TimeOut, /*!< Timeout occurs while waiting */
|
||||
} usb_osa_status_t;
|
||||
|
||||
/*! @brief The event flags are cleared automatically or manually.*/
|
||||
typedef enum _usb_osa_event_mode
|
||||
{
|
||||
kUSB_OsaEventManualClear = 0U, /*!< The flags of the event is cleared manually. */
|
||||
kUSB_OsaEventAutoClear = 1U, /*!< The flags of the event is cleared automatically. */
|
||||
} usb_osa_event_mode_t;
|
||||
|
||||
/* Include required header file based on RTOS selection */
|
||||
#if defined(USB_STACK_BM)
|
||||
|
||||
#include "usb_osa_bm.h"
|
||||
|
||||
#elif defined(USB_STACK_FREERTOS)
|
||||
|
||||
#include "usb_osa_freertos.h"
|
||||
|
||||
#elif defined(USB_STACK_UCOSII)
|
||||
|
||||
#include "usb_osa_ucosii.h"
|
||||
|
||||
#elif defined(USB_STACK_UCOSIII)
|
||||
|
||||
#include "usb_osa_ucosiii.h"
|
||||
|
||||
#else
|
||||
#if defined(SDK_OS_BAREMETAL)
|
||||
|
||||
#define USB_STACK_BM
|
||||
#include "usb_osa_bm.h"
|
||||
|
||||
#elif defined(SDK_OS_FREE_RTOS)
|
||||
|
||||
#define USB_STACK_FREERTOS
|
||||
#include "usb_osa_freertos.h"
|
||||
|
||||
#elif defined(SDK_OS_UCOSII)
|
||||
|
||||
#define USB_STACK_UCOSII
|
||||
#include "usb_osa_ucosii.h"
|
||||
|
||||
#elif defined(SDK_OS_UCOSIII)
|
||||
|
||||
#define USB_STACK_UCOSIII
|
||||
#include "usb_osa_ucosiii.h"
|
||||
|
||||
#else
|
||||
|
||||
#error Not define RTOS in file "usb_osa.h".
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
/*!
|
||||
* @name USB OSA Memory Management
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Reserves the requested amount of memory in bytes.
|
||||
*
|
||||
* The function is used to reserve the requested amount of memory in bytes and initializes it to 0.
|
||||
*
|
||||
* @param length Amount of bytes to reserve.
|
||||
*
|
||||
* @return Pointer to the reserved memory. NULL if memory can't be allocated.
|
||||
*/
|
||||
void *USB_OsaMemoryAllocate(uint32_t length);
|
||||
|
||||
/*!
|
||||
* @brief Frees the memory previously reserved.
|
||||
*
|
||||
* The function is used to free the memory block previously reserved.
|
||||
*
|
||||
* @param p Pointer to the start of the memory block previously reserved.
|
||||
*
|
||||
*/
|
||||
extern void USB_OsaMemoryFree(void *p);
|
||||
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name USB OSA Event
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Creates an event object with all flags cleared.
|
||||
*
|
||||
* This function creates an event object and sets its clear mode. If the clear mode
|
||||
* is kUSB_OsaEventAutoClear, when a task gets the event flags, these flags are
|
||||
* cleared automatically. If the clear mode is kUSB_OsaEventManualClear, the flags must
|
||||
* be cleared manually.
|
||||
*
|
||||
* @param handle It is an out parameter, which is used to return the pointer of the event object.
|
||||
* @param flag The event is auto-clear or manual-clear. See the enumeration #usb_osa_event_mode_t.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_event_handle eventHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
usbOsaStatus = USB_OsaEventCreate(&eventHandle, kUSB_OsaEventManualClear);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaEventCreate(usb_osa_event_handle *handle, uint32_t flag);
|
||||
|
||||
/*!
|
||||
* @brief Destroys a created event object.
|
||||
*
|
||||
* @param handle Pointer to the event object.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaEventDestroy(eventHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaEventDestroy(usb_osa_event_handle handle);
|
||||
|
||||
/*!
|
||||
* @brief Sets an event flag.
|
||||
*
|
||||
* Sets specified flags for an event object.
|
||||
*
|
||||
* @param handle Pointer to the event object.
|
||||
* @param bitMask Event flags to be set.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaEventSet(eventHandle, 0x01U);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaEventSet(usb_osa_event_handle handle, uint32_t bitMask);
|
||||
|
||||
/*!
|
||||
* @brief Waits for an event flag.
|
||||
*
|
||||
* This function waits for a combination of flags to be set in an event object.
|
||||
* An applications can wait for any/all bits to be set. This function can
|
||||
* get the flags that wake up the waiting task.
|
||||
*
|
||||
* @param handle Pointer to the event object.
|
||||
* @param bitMask Event flags to wait.
|
||||
* @param flag Wait all flags or any flag to be set. 0U - wait any flag, others, wait all flags.
|
||||
* @param timeout The maximum number of milliseconds to wait for the event.
|
||||
* If the wait condition is not met, passing 0U
|
||||
* waits indefinitely when the environment is an RTOS and returns the kStatus_OSA_Timeout
|
||||
* immediately. Pass any value for the bare metal.
|
||||
* @param bitSet Flags that wake up the waiting task are obtained by this parameter.
|
||||
*
|
||||
* @return An USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
uint32_t bitSet;
|
||||
...
|
||||
usbOsaStatus = USB_OsaEventWait(eventHandle, 0x01U, 0U, 0U, &bitSet);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaEventWait(
|
||||
usb_osa_event_handle handle, uint32_t bitMask, uint32_t flag, uint32_t timeout, uint32_t *bitSet);
|
||||
|
||||
/*!
|
||||
* @brief Checks an event flag.
|
||||
*
|
||||
* This function checks for a combination of flags to be set in an event object.
|
||||
*
|
||||
* @param handle Pointer to the event object.
|
||||
* @param bitMask Event flags to check.
|
||||
* @param bitSet Flags have been set.
|
||||
*
|
||||
* @return An USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
uint32_t bitSet;
|
||||
...
|
||||
usbOsaStatus = USB_OsaEventCheck(eventHandle, 0x01U, &bitSet);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaEventCheck(usb_osa_event_handle handle, uint32_t bitMask, uint32_t *bitSet);
|
||||
|
||||
/*!
|
||||
* @brief Clears an event flag.
|
||||
*
|
||||
* This function clears flags of an event object.
|
||||
*
|
||||
* @param handle Pointer to the event object
|
||||
* @param bitMask Event flags to be cleared.
|
||||
*
|
||||
* @return An USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaEventClear(eventHandle, 0x01U);
|
||||
@endcode
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaEventClear(usb_osa_event_handle handle, uint32_t bitMask);
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name USB OSA Semaphore
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Creates a semaphore with a given value.
|
||||
*
|
||||
* This function creates a semaphore and sets the default count.
|
||||
*
|
||||
* @param handle It is an out parameter, which is used to return pointer of the semaphore object.
|
||||
* @param count Initializes a value of the semaphore.
|
||||
*
|
||||
* @return An USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_sem_handle semHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
usbOsaStatus = USB_OsaSemCreate(&semHandle, 1U);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaSemCreate(usb_osa_sem_handle *handle, uint32_t count);
|
||||
|
||||
/*!
|
||||
* @brief Destroys a semaphore object.
|
||||
*
|
||||
* This function destroys a semaphore object.
|
||||
*
|
||||
* @param handle Pointer to the semaphore.
|
||||
*
|
||||
* @return An USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_sem_handle semHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaSemDestroy(semHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaSemDestroy(usb_osa_sem_handle handle);
|
||||
|
||||
/*!
|
||||
* @brief Posts a semaphore.
|
||||
*
|
||||
* This function wakes up a task waiting on the semaphore. If a task is not pending, increases the semaphore's
|
||||
value.
|
||||
*
|
||||
* @param handle Pointer to the semaphore.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_sem_handle semHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaSemPost(semHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaSemPost(usb_osa_sem_handle handle);
|
||||
|
||||
/*!
|
||||
* @brief Waits on a semaphore.
|
||||
*
|
||||
* This function checks the semaphore's value. If it is positive, it decreases the semaphore's value and return
|
||||
kStatus_OSA_Success.
|
||||
*
|
||||
* @param handle Pointer to the semaphore.
|
||||
* @param timeout The maximum number of milliseconds to wait for the semaphore.
|
||||
* If the wait condition is not met, passing 0U
|
||||
* waits indefinitely when environment is RTOS. And return kStatus_OSA_Timeout
|
||||
* immediately for bare metal no matter what value has been passed.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_sem_handle semHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaSemWait(semHandle, 0U);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaSemWait(usb_osa_sem_handle handle, uint32_t timeout);
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name USB OSA Mutex
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Creates a mutex.
|
||||
*
|
||||
* This function creates a mutex and sets it to an unlocked status.
|
||||
*
|
||||
* @param handle It is out parameter, which is used to return the pointer of the mutex object.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_mutex_handle mutexHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
usbOsaStatus = USB_OsaMutexCreate(&mutexHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMutexCreate(usb_osa_mutex_handle *handle);
|
||||
|
||||
/*!
|
||||
* @brief Destroys a mutex.
|
||||
*
|
||||
* This function destroys a mutex and sets it to an unlocked status.
|
||||
*
|
||||
* @param handle Pointer to the mutex.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_mutex_handle mutexHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaMutexDestroy(mutexHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMutexDestroy(usb_osa_mutex_handle handle);
|
||||
|
||||
/*!
|
||||
* @brief Waits for a mutex and locks it.
|
||||
*
|
||||
* This function checks the mutex status. If it is unlocked, it locks it and returns the
|
||||
* kStatus_OSA_Success. Otherwise, it waits forever to lock in RTOS and returns the
|
||||
* kStatus_OSA_Success immediately for bare metal.
|
||||
*
|
||||
* @param handle Pointer to the mutex.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_mutex_handle mutexHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaMutexLock(mutexHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMutexLock(usb_osa_mutex_handle handle);
|
||||
|
||||
/*!
|
||||
* @brief Unlocks a mutex.
|
||||
*
|
||||
* This function unlocks a mutex.
|
||||
*
|
||||
* @param handle Pointer to the mutex.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_mutex_handle mutexHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaMutexUnlock(mutexHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMutexUnlock(usb_osa_mutex_handle handle);
|
||||
/* @} */
|
||||
|
||||
/*!
|
||||
* @name USB OSA Message Queue
|
||||
* @{
|
||||
*/
|
||||
|
||||
/*!
|
||||
* @brief Creates a message queue.
|
||||
*
|
||||
* This function creates a message queue.
|
||||
*
|
||||
* @param handle It is an out parameter, which is used to return a pointer of the message queue object.
|
||||
* @param count The count of elements in the queue.
|
||||
* @param size Size of every elements in words.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_msgq_handle msgqHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
usbOsaStatus = USB_OsaMsgqCreate(msgqHandle, 8U, 4U);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMsgqCreate(usb_osa_msgq_handle *handle, uint32_t count, uint32_t size);
|
||||
|
||||
/*!
|
||||
* @brief Destroys a message queue.
|
||||
*
|
||||
* This function destroys a message queue.
|
||||
*
|
||||
* @param handle Pointer to a message queue.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_msgq_handle msgqHandle;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaMsgqDestroy(msgqHandle);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMsgqDestroy(usb_osa_msgq_handle handle);
|
||||
|
||||
/*!
|
||||
* @brief Sends a message.
|
||||
*
|
||||
* This function sends a message to the tail of the message queue.
|
||||
*
|
||||
* @param handle Pointer to a message queue.
|
||||
* @param msg The pointer to a message to be put into the queue.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_msgq_handle msgqHandle;
|
||||
message_struct_t message;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaMsgqSend(msgqHandle, &message);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMsgqSend(usb_osa_msgq_handle handle, void *msg);
|
||||
|
||||
/*!
|
||||
* @brief Receives a message.
|
||||
*
|
||||
* This function receives a message from the head of the message queue.
|
||||
*
|
||||
* @param handle Pointer to a message queue.
|
||||
* @param msg The pointer to save a received message.
|
||||
* @param timeout The maximum number of milliseconds to wait for a message.
|
||||
* If the wait condition is not met, passing 0U
|
||||
* waits indefinitely when an environment is RTOS and returns the kStatus_OSA_Timeout
|
||||
* immediately for bare metal.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_msgq_handle msgqHandle;
|
||||
message_struct_t message;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaMsgqRecv(msgqHandle, &message, 0U);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMsgqRecv(usb_osa_msgq_handle handle, void *msg, uint32_t timeout);
|
||||
|
||||
/*!
|
||||
* @brief Checks a message queue and receives a message if the queue is not empty.
|
||||
*
|
||||
* This function checks a message queue and receives a message if the queue is not empty.
|
||||
*
|
||||
* @param handle Pointer to a message queue.
|
||||
* @param msg The pointer to save a received message.
|
||||
*
|
||||
* @return A USB OSA error code or kStatus_OSA_Success.
|
||||
*
|
||||
* Example:
|
||||
@code
|
||||
usb_osa_msgq_handle msgqHandle;
|
||||
message_struct_t message;
|
||||
usb_osa_status_t usbOsaStatus;
|
||||
...
|
||||
usbOsaStatus = USB_OsaMsgqCheck(msgqHandle, &message);
|
||||
@endcode
|
||||
*
|
||||
*/
|
||||
extern usb_osa_status_t USB_OsaMsgqCheck(usb_osa_msgq_handle handle, void *msg);
|
||||
|
||||
/* @} */
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* @} */
|
||||
|
||||
#endif /* __USB_OSA_H__ */
|
|
@ -0,0 +1,522 @@
|
|||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
#include "stdint.h"
|
||||
#include "usb.h"
|
||||
#include "usb_osa.h"
|
||||
#include "stdlib.h"
|
||||
#include "fsl_device_registers.h"
|
||||
#include "fsl_common.h"
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
#define USB_OSA_BM_EVENT_COUNT (4U)
|
||||
#define USB_OSA_BM_SEM_COUNT (1U)
|
||||
#define USB_OSA_BM_MSGQ_COUNT (1U)
|
||||
#define USB_OSA_BM_MSG_COUNT (8U)
|
||||
#define USB_OSA_BM_MSG_SIZE (4U)
|
||||
|
||||
/* BM Event status structure */
|
||||
typedef struct _usb_osa_event_struct
|
||||
{
|
||||
uint32_t value; /* Event mask */
|
||||
uint32_t flag; /* Event flags, includes auto clear flag */
|
||||
uint8_t isUsed; /* Is used */
|
||||
} usb_osa_event_struct_t;
|
||||
|
||||
/* BM semaphore status structure */
|
||||
typedef struct _usb_osa_sem_struct
|
||||
{
|
||||
uint32_t value; /* Semaphore count */
|
||||
uint8_t isUsed; /* Is used */
|
||||
} usb_osa_sem_struct_t;
|
||||
|
||||
/* BM msg status structure */
|
||||
typedef struct _usb_osa_msg_struct
|
||||
{
|
||||
uint32_t msg[USB_OSA_BM_MSG_SIZE]; /* Message entity pointer */
|
||||
} usb_osa_msg_struct_t;
|
||||
|
||||
/* BM msgq status structure */
|
||||
typedef struct _usb_osa_msgq_struct
|
||||
{
|
||||
usb_osa_msg_struct_t msgs[USB_OSA_BM_MSG_COUNT]; /* Message entity list */
|
||||
uint32_t count; /* Max message entity count */
|
||||
uint32_t msgSize; /* Size of each message */
|
||||
uint32_t msgCount; /* Valid messages */
|
||||
uint32_t index; /* The first empty message entity index */
|
||||
uint32_t current; /* The vaild message index */
|
||||
uint8_t isUsed; /* Is used */
|
||||
} usb_osa_msgq_struct_t;
|
||||
|
||||
/*******************************************************************************
|
||||
* Prototypes
|
||||
******************************************************************************/
|
||||
|
||||
/*******************************************************************************
|
||||
* Variables
|
||||
******************************************************************************/
|
||||
|
||||
USB_GLOBAL USB_RAM_ADDRESS_ALIGNMENT(USB_DATA_ALIGN_SIZE) static usb_osa_sem_struct_t
|
||||
s_UsbBmSemStruct[USB_OSA_BM_SEM_COUNT];
|
||||
USB_GLOBAL USB_RAM_ADDRESS_ALIGNMENT(USB_DATA_ALIGN_SIZE) static usb_osa_event_struct_t
|
||||
s_UsbBmEventStruct[USB_OSA_BM_EVENT_COUNT];
|
||||
USB_GLOBAL USB_RAM_ADDRESS_ALIGNMENT(USB_DATA_ALIGN_SIZE) static usb_osa_msgq_struct_t
|
||||
s_UsbBmMsgqStruct[USB_OSA_BM_MSGQ_COUNT];
|
||||
|
||||
/*******************************************************************************
|
||||
* Code
|
||||
******************************************************************************/
|
||||
|
||||
void *USB_OsaMemoryAllocate(uint32_t length)
|
||||
{
|
||||
void *p = (void *)malloc(length);
|
||||
uint8_t *temp = (uint8_t *)p;
|
||||
if (p)
|
||||
{
|
||||
for (uint32_t count = 0U; count < length; count++)
|
||||
{
|
||||
temp[count] = 0U;
|
||||
}
|
||||
}
|
||||
return p;
|
||||
}
|
||||
|
||||
void USB_OsaMemoryFree(void *p)
|
||||
{
|
||||
free(p);
|
||||
}
|
||||
|
||||
void USB_OsaEnterCritical(uint32_t *sr)
|
||||
{
|
||||
*sr = DisableGlobalIRQ();
|
||||
|
||||
|
||||
__ASM("CPSID i");
|
||||
}
|
||||
|
||||
void USB_OsaExitCritical(uint32_t sr)
|
||||
{
|
||||
EnableGlobalIRQ(sr);
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaEventCreate(usb_osa_event_handle *handle, uint32_t flag)
|
||||
{
|
||||
usb_osa_event_struct_t *event = NULL;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
for (uint32_t i = 0; i < USB_OSA_BM_EVENT_COUNT; i++)
|
||||
{
|
||||
if (0 == s_UsbBmEventStruct[i].isUsed)
|
||||
{
|
||||
event = &s_UsbBmEventStruct[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (NULL == event)
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
event->value = 0U;
|
||||
event->flag = flag;
|
||||
event->isUsed = 1;
|
||||
*handle = event;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaEventDestroy(usb_osa_event_handle handle)
|
||||
{
|
||||
usb_osa_event_struct_t *event = (usb_osa_event_struct_t *)handle;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (handle)
|
||||
{
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
event->isUsed = 0;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaEventSet(usb_osa_event_handle handle, uint32_t bitMask)
|
||||
{
|
||||
usb_osa_event_struct_t *event = (usb_osa_event_struct_t *)handle;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (handle)
|
||||
{
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
event->value |= bitMask;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaEventWait(
|
||||
usb_osa_event_handle handle, uint32_t bitMask, uint32_t flag, uint32_t timeout, uint32_t *bitSet)
|
||||
{
|
||||
usb_osa_event_struct_t *event = (usb_osa_event_struct_t *)handle;
|
||||
uint32_t bits;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (handle)
|
||||
{
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
bits = event->value & bitMask;
|
||||
if (flag)
|
||||
{
|
||||
if (bits != bitMask)
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_TimeOut;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!bits)
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_TimeOut;
|
||||
}
|
||||
}
|
||||
if (bitSet)
|
||||
{
|
||||
*bitSet = bits;
|
||||
}
|
||||
if (event->flag)
|
||||
{
|
||||
event->value &= ~bits;
|
||||
}
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaEventCheck(usb_osa_event_handle handle, uint32_t bitMask, uint32_t *bitSet)
|
||||
{
|
||||
usb_osa_event_struct_t *event = (usb_osa_event_struct_t *)handle;
|
||||
uint32_t bits;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (handle)
|
||||
{
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
bits = event->value & bitMask;
|
||||
|
||||
if (!bits)
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
if (bitSet)
|
||||
{
|
||||
*bitSet = bits;
|
||||
}
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaEventClear(usb_osa_event_handle handle, uint32_t bitMask)
|
||||
{
|
||||
usb_osa_event_struct_t *event = (usb_osa_event_struct_t *)handle;
|
||||
uint32_t bits;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (handle)
|
||||
{
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
bits = event->value & bitMask;
|
||||
event->value &= ~bits;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaSemCreate(usb_osa_sem_handle *handle, uint32_t count)
|
||||
{
|
||||
usb_osa_sem_struct_t *sem = NULL;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
for (uint32_t i = 0; i < USB_OSA_BM_SEM_COUNT; i++)
|
||||
{
|
||||
if (0 == s_UsbBmSemStruct[i].isUsed)
|
||||
{
|
||||
sem = &s_UsbBmSemStruct[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (NULL == sem)
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
sem->value = count;
|
||||
sem->isUsed = 1;
|
||||
*handle = sem;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaSemDestroy(usb_osa_sem_handle handle)
|
||||
{
|
||||
usb_osa_sem_struct_t *sem = (usb_osa_sem_struct_t *)handle;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (handle)
|
||||
{
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
sem->isUsed = 0;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaSemPost(usb_osa_sem_handle handle)
|
||||
{
|
||||
usb_osa_sem_struct_t *sem = (usb_osa_sem_struct_t *)handle;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
sem->value++;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaSemWait(usb_osa_sem_handle handle, uint32_t timeout)
|
||||
{
|
||||
usb_osa_sem_struct_t *sem = (usb_osa_sem_struct_t *)handle;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
if (sem->value)
|
||||
{
|
||||
sem->value--;
|
||||
}
|
||||
else
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_TimeOut;
|
||||
}
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaMutexCreate(usb_osa_mutex_handle *handle)
|
||||
{
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
*handle = (usb_osa_mutex_handle)0xFFFF0000U;
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaMutexDestroy(usb_osa_mutex_handle handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
usb_osa_status_t USB_OsaMutexLock(usb_osa_mutex_handle handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
usb_osa_status_t USB_OsaMutexUnlock(usb_osa_mutex_handle handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaMsgqCreate(usb_osa_msgq_handle *handle, uint32_t count, uint32_t size)
|
||||
{
|
||||
usb_osa_msgq_struct_t *msgq = NULL;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
|
||||
for (uint32_t i = 0; i < USB_OSA_BM_MSGQ_COUNT; i++)
|
||||
{
|
||||
if (0 == s_UsbBmMsgqStruct[i].isUsed)
|
||||
{
|
||||
msgq = &s_UsbBmMsgqStruct[i];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ((NULL == msgq) || (count > USB_OSA_BM_MSG_COUNT) || (size > USB_OSA_BM_MSG_SIZE))
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
msgq->count = count;
|
||||
msgq->msgSize = size;
|
||||
msgq->msgCount = 0U;
|
||||
msgq->index = 0U;
|
||||
msgq->current = 0U;
|
||||
msgq->isUsed = 1;
|
||||
*handle = msgq;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaMsgqDestroy(usb_osa_msgq_handle handle)
|
||||
{
|
||||
usb_osa_msgq_struct_t *msgq = (usb_osa_msgq_struct_t *)handle;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
msgq->isUsed = 0;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaMsgqSend(usb_osa_msgq_handle handle, void *msg)
|
||||
{
|
||||
usb_osa_msgq_struct_t *msgq = (usb_osa_msgq_struct_t *)handle;
|
||||
usb_osa_msg_struct_t *msgEntity;
|
||||
uint32_t *p;
|
||||
uint32_t *q;
|
||||
uint32_t count;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
if (msgq->msgCount >= msgq->count)
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
msgEntity = &msgq->msgs[msgq->index];
|
||||
p = (uint32_t *)&msgEntity->msg[0];
|
||||
q = (uint32_t *)msg;
|
||||
|
||||
for (count = 0U; count < msgq->msgSize; count++)
|
||||
{
|
||||
p[count] = q[count];
|
||||
}
|
||||
|
||||
if (0U == msgq->msgCount)
|
||||
{
|
||||
msgq->current = msgq->index;
|
||||
}
|
||||
|
||||
msgq->msgCount++;
|
||||
msgq->index++;
|
||||
msgq->index = msgq->index % msgq->count;
|
||||
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaMsgqRecv(usb_osa_msgq_handle handle, void *msg, uint32_t timeout)
|
||||
{
|
||||
usb_osa_msgq_struct_t *msgq = (usb_osa_msgq_struct_t *)handle;
|
||||
usb_osa_msg_struct_t *msgEntity;
|
||||
uint32_t *p;
|
||||
uint32_t *q;
|
||||
uint32_t count;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
if (msgq->msgCount < 1U)
|
||||
{
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
return kStatus_USB_OSA_TimeOut;
|
||||
}
|
||||
|
||||
msgEntity = &msgq->msgs[msgq->current];
|
||||
q = (uint32_t *)&msgEntity->msg[0];
|
||||
p = (uint32_t *)msg;
|
||||
|
||||
for (count = 0U; count < msgq->msgSize; count++)
|
||||
{
|
||||
p[count] = q[count];
|
||||
}
|
||||
|
||||
msgq->msgCount--;
|
||||
msgq->current++;
|
||||
msgq->current = msgq->current % msgq->count;
|
||||
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
|
||||
usb_osa_status_t USB_OsaMsgqCheck(usb_osa_msgq_handle handle, void *msg)
|
||||
{
|
||||
usb_osa_msgq_struct_t *msgq = (usb_osa_msgq_struct_t *)handle;
|
||||
uint32_t msgCount;
|
||||
USB_OSA_SR_ALLOC();
|
||||
|
||||
if (!handle)
|
||||
{
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
||||
|
||||
USB_OSA_ENTER_CRITICAL();
|
||||
msgCount = msgq->msgCount;
|
||||
USB_OSA_EXIT_CRITICAL();
|
||||
|
||||
if (msgCount)
|
||||
{
|
||||
if (kStatus_USB_OSA_Success == USB_OsaMsgqRecv(msgq, msg, 0U))
|
||||
{
|
||||
return kStatus_USB_OSA_Success;
|
||||
}
|
||||
}
|
||||
|
||||
return kStatus_USB_OSA_Error;
|
||||
}
|
|
@ -0,0 +1,35 @@
|
|||
/*
|
||||
* Copyright (c) 2015 - 2016, Freescale Semiconductor, Inc.
|
||||
* Copyright 2016 NXP
|
||||
* All rights reserved.
|
||||
*
|
||||
* SPDX-License-Identifier: BSD-3-Clause
|
||||
*/
|
||||
|
||||
#ifndef __USB_OSA_BM_H__
|
||||
#define __USB_OSA_BM_H__
|
||||
|
||||
/*******************************************************************************
|
||||
* Definitions
|
||||
******************************************************************************/
|
||||
|
||||
#define USB_OSA_SR_ALLOC() uint32_t usbOsaCurrentSr;
|
||||
#define USB_OSA_ENTER_CRITICAL() USB_OsaEnterCritical(&usbOsaCurrentSr)
|
||||
#define USB_OSA_EXIT_CRITICAL() USB_OsaExitCritical(usbOsaCurrentSr)
|
||||
|
||||
/*******************************************************************************
|
||||
* API
|
||||
******************************************************************************/
|
||||
|
||||
#if defined(__cplusplus)
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
extern void USB_OsaEnterCritical(uint32_t *sr);
|
||||
extern void USB_OsaExitCritical(uint32_t sr);
|
||||
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __USB_OSA_BM_H__ */
|
|
@ -0,0 +1,43 @@
|
|||
/* Copyright (C) Code Red Technologies Ltd. */
|
||||
|
||||
/*
|
||||
* <assert.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*
|
||||
*/
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
void __assertion_failed(char *_Expr) __attribute__ ((noreturn));
|
||||
|
||||
/*
|
||||
* It is legal to reset NDEBUG and re-include <assert.h> hence the
|
||||
* fact that this bit gets done every time it is included. This
|
||||
* implementation follows the Rationale to the C99 standard.
|
||||
*/
|
||||
|
||||
#ifdef NDEBUG
|
||||
# define assert(ignore) ((void)0)
|
||||
#else
|
||||
#define _ASSERT_STR(x) _ASSERT_VAL(x)
|
||||
#define _ASSERT_VAL(x) #x
|
||||
#define assert(expr) \
|
||||
((expr) ? (void)0 : \
|
||||
__assertion_failed(__FILE__ ":" _ASSERT_STR(__LINE__) " : " #expr))
|
||||
#endif
|
||||
/* end of assert.h */
|
|
@ -0,0 +1,123 @@
|
|||
/* (C) Code Red Technologies Ltd. 2007.
|
||||
* Modified the macros.
|
||||
*
|
||||
*
|
||||
*
|
||||
* <ctype.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*/
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef __CTYPE_H_INCLUDED
|
||||
#define __CTYPE_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
|
||||
/* N.B. - keep in step with <ctype.c> */
|
||||
|
||||
#define __S 1 /* whitespace */
|
||||
#define __P 2 /* punctuation */
|
||||
#define __B 4 /* blank */
|
||||
#define __L 8 /* lower case letter */
|
||||
#define __U 16 /* upper case letter */
|
||||
#define __N 32 /* (decimal) digit */
|
||||
#define __C 64 /* control chars */
|
||||
#define __X 128 /* A-F and a-f */
|
||||
|
||||
extern const unsigned char __ctype[];
|
||||
|
||||
#define isalnum(c) (__ctype[(c)+128] & (__U+__L+__N))
|
||||
#ifndef _Codemist
|
||||
extern int (isalnum)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is alphabetic or numeric */
|
||||
|
||||
#define isalpha(c) (__ctype[(c)+128] & (__U+__L))
|
||||
#ifndef _Codemist
|
||||
extern int (isalpha)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is alphabetic */
|
||||
|
||||
#define iscntrl(c) (__ctype[(c)+128] & __C)
|
||||
#ifndef _Codemist
|
||||
extern int (iscntrl)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is a control character - in the ASCII locale */
|
||||
/* this means (c < ' ') || (c > '~') */
|
||||
|
||||
#define isdigit(c) (__ctype[(c)+128] & __N)
|
||||
#ifndef _Codemist
|
||||
extern int (isdigit)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is a decimal digit */
|
||||
|
||||
#define isgraph(c) (__ctype[(c)+128] & (__L+__U+__N+__P))
|
||||
#ifndef _Codemist
|
||||
extern int (isgraph)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is any printing character other than ' ' */
|
||||
|
||||
#define islower(c) (__ctype[(c)+128] & __L)
|
||||
#ifndef _Codemist
|
||||
extern int (islower)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is a lower-case letter */
|
||||
|
||||
#define isprint(c) (__ctype[(c)+128] & (__L+__U+__N+__P+__B))
|
||||
#ifndef _Codemist
|
||||
extern int (isprint)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is a printing character - in the ASCII locale */
|
||||
/* this means 0x20 (space) -> 0x7E (tilde) */
|
||||
|
||||
#define ispunct(c) (__ctype[(c)+128] & __P)
|
||||
#ifndef _Codemist
|
||||
extern int (ispunct)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is a non-space, non-alpha-numeric, printing character */
|
||||
|
||||
#define isspace(c) (__ctype[(c)+128] & __S)
|
||||
#ifndef _Codemist
|
||||
extern int (isspace)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is a white-space char: ' ', '\f', '\n', '\r', '\t', '\v'. */
|
||||
|
||||
#define isupper(c) (__ctype[(c)+128] & __U)
|
||||
#ifndef _Codemist
|
||||
extern int (isupper)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is an upper-case letter */
|
||||
|
||||
#define isxdigit(c) (__ctype[(c)+128] & (__N+__X))
|
||||
#ifndef _Codemist
|
||||
extern int (isxdigit)(int __c);
|
||||
#endif
|
||||
/* non-0 iff c is a digit, in 'a'..'f', or in 'A'..'F' */
|
||||
|
||||
extern int tolower(int __c);
|
||||
/* if c is an upper-case letter then return the corresponding */
|
||||
/* lower-case letter, otherwise return c. */
|
||||
|
||||
extern int toupper(int __c);
|
||||
/* if c is an lower-case letter then return the corresponding */
|
||||
/* upper-case letter, otherwise return c. */
|
||||
|
||||
extern int isblank(int __c);
|
||||
|
||||
#endif /* __CTYPE_H_INCLUDED */
|
||||
|
||||
/* end of <ctype.h> */
|
|
@ -0,0 +1,144 @@
|
|||
/* Copyright (C) Code Red Technologies Ltd. */
|
||||
|
||||
/*
|
||||
* <errno.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*/
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef __ERRNO_H_INCLUDED
|
||||
#define __ERRNO_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#define EPERM 1 /* Not owner */
|
||||
#define ENOENT 2 /* No such file or directory */
|
||||
#define ESRCH 3 /* No such process */
|
||||
#define EINTR 4 /* Interrupted system call */
|
||||
#define EIO 5 /* I/O error */
|
||||
#define ENXIO 6 /* No such device or address */
|
||||
#define E2BIG 7 /* Arg list too long */
|
||||
#define ENOEXEC 8 /* Exec format error */
|
||||
#define EBADF 9 /* Bad file number */
|
||||
#define ECHILD 10 /* No children */
|
||||
#define EAGAIN 11 /* No more processes */
|
||||
#define ENOMEM 12 /* Not enough core */
|
||||
#define EACCES 13 /* Permission denied */
|
||||
#define EFAULT 14 /* Bad address */
|
||||
#define ENOTBLK 15 /* Block device required */
|
||||
#define EBUSY 16 /* Mount device busy */
|
||||
#define EEXIST 17 /* File exists */
|
||||
#define EXDEV 18 /* Cross-device link */
|
||||
#define ENODEV 19 /* No such device */
|
||||
#define ENOTDIR 20 /* Not a directory*/
|
||||
#define EISDIR 21 /* Is a directory */
|
||||
#define EINVAL 22 /* Invalid argument */
|
||||
#define ENFILE 23 /* File table overflow */
|
||||
#define EMFILE 24 /* Too many open files */
|
||||
#define ENOTTY 25 /* Not a typewriter */
|
||||
#define ETXTBSY 26 /* Text file busy */
|
||||
#define EFBIG 27 /* File too large */
|
||||
#define ENOSPC 28 /* No space left on device */
|
||||
#define ESPIPE 29 /* Illegal seek */
|
||||
#define EROFS 30 /* Read-only file system */
|
||||
#define EMLINK 31 /* Too many links */
|
||||
#define EPIPE 32 /* Broken pipe */
|
||||
|
||||
/* math software */
|
||||
#define EDOM 33 /* Argument too large */
|
||||
/*
|
||||
* if a domain error occurs (an input argument is outside the domain over
|
||||
* which the mathematical function is defined) the integer expression errno
|
||||
* acquires the value of the macro EDOM and HUGE_VAL is returned. EDOM may
|
||||
* be used by non-mathematical functions.
|
||||
*/
|
||||
#define ERANGE 34 /* Result too large */
|
||||
/*
|
||||
* a range error occurs if the result of a function can not be represented
|
||||
* as a double value. If the result overflows (the magnitude of the result
|
||||
* is so large that it cannot be represented in an object of the specified
|
||||
* type), the function returns the value of the macro HUGE_VAL, with the
|
||||
* same sign as the correct value of the function; the integer expression
|
||||
* errno acquires the value of the macro ERANGE. If the result underflows
|
||||
* (the magnitude of the result is so small that it cannot be represented
|
||||
* in an object of the specified type), the function returns zero; the
|
||||
* integer expression errno acquires the value of the macro ERANGE. ERANGE
|
||||
* may be used by non-mathematical functions.
|
||||
*/
|
||||
|
||||
/* non-blocking and interrupt i/o */
|
||||
#define EWOULDBLOCK 35 /* Operation would block */
|
||||
#define EINPROGRESS 36 /* Operation now in progress */
|
||||
#define EALREADY 37 /* Operation already in progress */
|
||||
/* ipc/network software */
|
||||
|
||||
/* argument errors */
|
||||
#define ENOTSOCK 38 /* Socket operation on non-socket */
|
||||
#define EDESTADDRREQ 39 /* Destination address required */
|
||||
#define EMSGSIZE 40 /* Message too long */
|
||||
#define EPROTOTYPE 41 /* Protocol wrong type for socket */
|
||||
#define ENOPROTOOPT 42 /* Protocol not available */
|
||||
#define EPROTONOSUPPORT 43 /* Protocol not supported */
|
||||
#define ESOCKTNOSUPPORT 44 /* Socket type not supported */
|
||||
#define EOPNOTSUPP 45 /* Operation not supported on socket */
|
||||
#define EPFNOSUPPORT 46 /* Protocol family not supported */
|
||||
#define EAFNOSUPPORT 47 /* Address family not supported by protocol family */
|
||||
#define EADDRINUSE 48 /* Address already in use */
|
||||
#define EADDRNOTAVAIL 49 /* Can't assign requested address */
|
||||
|
||||
/* operational errors */
|
||||
#define ENETDOWN 50 /* Network is down */
|
||||
#define ENETUNREACH 51 /* Network is unreachable */
|
||||
#define ENETRESET 52 /* Network dropped connection on reset */
|
||||
#define ECONNABORTED 53 /* Software caused connection abort */
|
||||
#define ECONNRESET 54 /* Connection reset by peer */
|
||||
#define ENOBUFS 55 /* No buffer space available */
|
||||
#define EISCONN 56 /* Socket is already connected */
|
||||
#define ENOTCONN 57 /* Socket is not connected */
|
||||
#define ESHUTDOWN 58 /* Can't send after socket shutdown */
|
||||
#define ETOOMANYREFS 59 /* Too many references: can't splice */
|
||||
#define ETIMEDOUT 60 /* Connection timed out */
|
||||
#define ECONNREFUSED 61 /* Connection refused */
|
||||
|
||||
/* */
|
||||
#define ELOOP 62 /* Too many levels of symbolic links */
|
||||
#define ENAMETOOLONG 63 /* File name too long */
|
||||
|
||||
/* should be rearranged */
|
||||
#define EHOSTDOWN 64 /* Host is down */
|
||||
#define EHOSTUNREACH 65 /* No route to host */
|
||||
#define ENOTEMPTY 66 /* Directory not empty */
|
||||
|
||||
/* quotas & mush */
|
||||
#define EPROCLIM 67 /* Too many processes */
|
||||
#define EUSERS 68 /* Too many users */
|
||||
#define EDQUOT 69 /* Disc quota exceeded */
|
||||
|
||||
/* Network File System */
|
||||
#define ESTALE 70 /* Stale NFS file handle */
|
||||
#define EREMOTE 71 /* Too many levels of remote in path */
|
||||
|
||||
#define ESIGNUM 99
|
||||
|
||||
#define EILSEQ 100
|
||||
|
||||
extern volatile int errno;
|
||||
|
||||
|
||||
#endif /* __ERRNO_H_INCLUDED */
|
||||
|
||||
/* end of <errno.h> */
|
||||
|
|
@ -0,0 +1,169 @@
|
|||
/*
|
||||
* <float.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*/
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef __FLOAT_H_INCLUDED
|
||||
#define __FLOAT_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
|
||||
#define FLT_RADIX 2
|
||||
/* radix of exponent representation */
|
||||
#define FLT_ROUNDS 1
|
||||
/*
|
||||
* The rounding mode for floating-point addition is characterised by the
|
||||
* value of FLT_ROUNDS:
|
||||
* -1 : indeterminable.
|
||||
* 0 : towards zero.
|
||||
* 1 : to nearest.
|
||||
* 2 : towards positive infinity.
|
||||
* 3 : towards negative infinity.
|
||||
* ? : any other is implementation-defined.
|
||||
*/
|
||||
|
||||
#define FLT_MANT_DIG 24
|
||||
/* number of base-FLT_RADIX digits in the floating point mantissa */
|
||||
|
||||
/* The values that follow are not achieved under Acorn's FPE version 17 */
|
||||
/* but they should be correct in due course! */
|
||||
|
||||
#define FLT_DIG 6
|
||||
/* number of decimal digits of precision */
|
||||
|
||||
#define FLT_MIN_EXP (-125)
|
||||
/* minimum negative integer such that FLT_RADIX raised to that power */
|
||||
/* minus 1 is a normalised floating-point number. */
|
||||
|
||||
#define FLT_MIN_10_EXP (-37)
|
||||
/* minimum negative integer such that 10 raised to that power is in the */
|
||||
/* range of normalised floating-point numbers. */
|
||||
|
||||
#define FLT_MAX_EXP 128
|
||||
/* maximum integer such that FLT_RADIX raised to that power minus 1 is a */
|
||||
|
||||
#define FLT_MAX_10_EXP 38
|
||||
/* maximum integer such that 10 raised to that power is in the range of */
|
||||
/* representable finite floating-point numbers. */
|
||||
|
||||
#define FLT_MAX 3.40282347e+38F
|
||||
/* maximum representable finite floating-point number. */
|
||||
|
||||
#define FLT_EPSILON 1.19209290e-7F
|
||||
/* minimum positive floating point number x such that 1.0 + x != 1.0 */
|
||||
|
||||
#define FLT_MIN 1.17549435e-38F
|
||||
/* minimum normalised positive floating-point number. */
|
||||
|
||||
|
||||
|
||||
#define FLT_MANT_DIG 24
|
||||
#define DBL_MANT_DIG 53
|
||||
#define LDBL_MANT_DIG 53
|
||||
/* number of base-FLT_RADIX digits in the floating point mantissa */
|
||||
|
||||
/* The values that follow are not achieved under Acorn's FPE version 17 */
|
||||
/* but they should be correct in due course! */
|
||||
|
||||
#define FLT_DIG 6
|
||||
#define DBL_DIG 15
|
||||
#define LDBL_DIG 15
|
||||
/* number of decimal digits of precision */
|
||||
|
||||
#define FLT_MIN_EXP (-125)
|
||||
#define DBL_MIN_EXP (-1021)
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
/* minimum negative integer such that FLT_RADIX raised to that power */
|
||||
/* minus 1 is a normalised floating-point number. */
|
||||
|
||||
#define FLT_MIN_10_EXP (-37)
|
||||
#define DBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
/* minimum negative integer such that 10 raised to that power is in the */
|
||||
/* range of normalised floating-point numbers. */
|
||||
|
||||
#define FLT_MAX_EXP 128
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define LDBL_MAX_EXP 1024
|
||||
/* maximum integer such that FLT_RADIX raised to that power minus 1 is a */
|
||||
#define FLT_MAX_10_EXP 38
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
/* maximum integer such that 10 raised to that power is in the range of */
|
||||
/* representable finite floating-point numbers. */
|
||||
|
||||
#define FLT_MAX 3.40282347e+38F
|
||||
#define DBL_MAX 1.79769313486231571e+308
|
||||
#define LDBL_MAX 1.79769313486231571e+308L
|
||||
/* maximum representable finite floating-point number. */
|
||||
|
||||
#define FLT_EPSILON 1.19209290e-7F
|
||||
#define DBL_EPSILON 2.2204460492503131e-16
|
||||
#define LDBL_EPSILON 2.2204460492503131e-16L
|
||||
/* minimum positive floating point number x such that 1.0 + x != 1.0 */
|
||||
|
||||
#define FLT_MIN 1.17549435e-38F
|
||||
#define DBL_MIN 2.22507385850720138e-308
|
||||
#define LDBL_MIN 2.22507385850720138e-308L
|
||||
/* minimum normalised positive floating-point number. */
|
||||
|
||||
|
||||
|
||||
#define DBL_MANT_DIG 53
|
||||
#define LDBL_MANT_DIG 53
|
||||
/* number of base-FLT_RADIX digits in the floating point mantissa */
|
||||
|
||||
#define DBL_DIG 15
|
||||
#define LDBL_DIG 15
|
||||
/* number of decimal digits of precision */
|
||||
|
||||
#define DBL_MIN_EXP (-1021)
|
||||
#define LDBL_MIN_EXP (-1021)
|
||||
/* minimum negative integer such that FLT_RADIX raised to that power */
|
||||
/* minus 1 is a normalised floating-point number. */
|
||||
|
||||
#define DBL_MIN_10_EXP (-307)
|
||||
#define LDBL_MIN_10_EXP (-307)
|
||||
/* minimum negative integer such that 10 raised to that power is in the */
|
||||
/* range of normalised floating-point numbers. */
|
||||
|
||||
#define DBL_MAX_EXP 1024
|
||||
#define LDBL_MAX_EXP 1024
|
||||
/* maximum integer such that FLT_RADIX raised to that power minus 1 is a */
|
||||
|
||||
#define DBL_MAX_10_EXP 308
|
||||
#define LDBL_MAX_10_EXP 308
|
||||
/* maximum integer such that 10 raised to that power is in the range of */
|
||||
/* representable finite floating-point numbers. */
|
||||
|
||||
#define DBL_MAX 1.79769313486231571e+308
|
||||
#define LDBL_MAX 1.79769313486231571e+308L
|
||||
/* maximum representable finite floating-point number. */
|
||||
|
||||
#define DBL_EPSILON 2.2204460492503131e-16
|
||||
#define LDBL_EPSILON 2.2204460492503131e-16L
|
||||
/* minimum positive floating point number x such that 1.0 + x != 1.0 */
|
||||
|
||||
#define DBL_MIN 2.22507385850720138e-308
|
||||
#define LDBL_MIN 2.22507385850720138e-308L
|
||||
/* minimum normalised positive floating-point number. */
|
||||
|
||||
|
||||
#endif /* __FLOAT_H_INCLUDED */
|
||||
|
||||
/* end of <float.h> */
|
|
@ -0,0 +1,81 @@
|
|||
/* Copyright (C) Code Red Technologies Ltd. */
|
||||
|
||||
/*
|
||||
* <limits.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*/
|
||||
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
// Portions Copyright(C) NXP Semiconductors, 2014
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __LIMITS_H_INCLUDED
|
||||
#define __LIMITS_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
|
||||
#define CHAR_BIT 8
|
||||
/* max number of bits for smallest object that is not a bit-field (byte) */
|
||||
#define SCHAR_MIN (-128)
|
||||
/* mimimum value for an object of type signed char */
|
||||
#define SCHAR_MAX 127
|
||||
/* maximum value for an object of type signed char */
|
||||
#define UCHAR_MAX 255
|
||||
|
||||
#ifdef __CHAR_UNSIGNED__
|
||||
#define CHAR_MIN 0
|
||||
/* minimum value for an object of type char */
|
||||
#define CHAR_MAX 255
|
||||
/* maximum value for an object of type char */
|
||||
#else
|
||||
#define CHAR_MIN (-128)
|
||||
/* minimum value for an object of type char */
|
||||
#define CHAR_MAX 127
|
||||
/* maximum value for an object of type char */
|
||||
#endif
|
||||
|
||||
/* maximum value for an object of type char */
|
||||
#define MB_LEN_MAX 1
|
||||
/* maximum number of bytes in a multibyte character, */
|
||||
/* for any supported locale */
|
||||
|
||||
#define SHRT_MIN (-0x8000)
|
||||
/* minimum value for an object of type short int */
|
||||
#define SHRT_MAX 0x7fff
|
||||
/* maximum value for an object of type short int */
|
||||
#define USHRT_MAX 65535U
|
||||
/* maximum value for an object of type unsigned short int */
|
||||
#define INT_MIN (~0x7fffffff) /* -2147483648 and 0x80000000 are unsigned */
|
||||
/* minimum value for an object of type int */
|
||||
#define INT_MAX 0x7fffffff
|
||||
/* maximum value for an object of type int */
|
||||
#define UINT_MAX 0xffffffff
|
||||
/* maximum value for an object of type unsigned int */
|
||||
#define LONG_MIN (~0x7fffffff)
|
||||
/* minimum value for an object of type long int */
|
||||
#define LONG_MAX 0x7fffffff
|
||||
/* maximum value for an object of type long int */
|
||||
#define ULONG_MAX 0xffffffffU
|
||||
/* maximum value for an object of type unsigned long int */
|
||||
#define LLONG_MIN (~0x7fffffffffffffffLL)
|
||||
#define LLONG_MAX 0x7fffffffffffffffLL
|
||||
#define ULLONG_MAX 0xffffffffffffffffULL
|
||||
|
||||
#endif /* __LIMITS_H_INCLUDED */
|
||||
|
||||
/* end of <limits.h> */
|
|
@ -0,0 +1,180 @@
|
|||
/* Copyright (C) Code Red Technologies Ltd. */
|
||||
/*
|
||||
* <locale.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*/
|
||||
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef __LOCALE_H_INCLUDED
|
||||
#define __LOCALE_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
|
||||
/* Handles national characteristics eg. USA month day year UK day month year */
|
||||
|
||||
#define LC_COLLATE 1
|
||||
/* affects the behaviour of the strcoll function */
|
||||
#define LC_CTYPE 2
|
||||
/* affects the behaviour of the character handling functions */
|
||||
/* (isdigit, isspace and isxdigit are not affected) */
|
||||
#define LC_MONETARY 4
|
||||
/* affects the monetary formatting information returned by the */
|
||||
/* localeconv function. */
|
||||
#define LC_NUMERIC 8
|
||||
/* affects the decimal-point character for the formatted input/output */
|
||||
/* functions and the string conversion functions */
|
||||
#define LC_TIME 16
|
||||
/* affects the behaviour of the strftime function */
|
||||
#define LC_ALL 31
|
||||
/* program's entire locale */
|
||||
|
||||
extern char *setlocale(int /*category*/, const char * /*locale*/);
|
||||
/*
|
||||
* Selects the appropriate piece of the program's locale as specified by the
|
||||
* category and locale arguments. The setlocale function may be used to
|
||||
* change or query the program's entire current locale or portions thereof.
|
||||
* The effect of the category argument for each value is described above.
|
||||
* A value of "C" for locale specifies the minimal environment for C
|
||||
* translation; a value of "" for locale specifies the implementation-defined
|
||||
* native environment. At program startup the equivalent of
|
||||
* setlocale(LC_ALL, "C") is executed.
|
||||
*
|
||||
* Return value:
|
||||
* If a pointer to string is given for locale and the selection can be
|
||||
* honoured, the string associated with the specified category for the new
|
||||
* locale is returned. If the selction can not be honoured, a null pointer
|
||||
* is returned and the program's locale is not changed.
|
||||
* A null pointer for locale causes the string associated with the category
|
||||
* for the program's current locale to be returned and the program's locale
|
||||
* is not changed. This enquiry can fail by returning a null pointer only if
|
||||
* the category is LC_ALL and the most recent successful locale-setting call
|
||||
* used a category other than LC_ALL.
|
||||
* The string returned is such that a subsequent call with that string and
|
||||
* its associated category will restore that part of the program's locale.
|
||||
* The string returned shall not be modified by the program, but may be
|
||||
* overwritten by a subsequent call to setlocale.
|
||||
*/
|
||||
|
||||
struct lconv {
|
||||
char *decimal_point;
|
||||
/* The decimal point character used to format non-monetary quantities */
|
||||
char *thousands_sep;
|
||||
/* The character used to separate groups of digits to the left of the */
|
||||
/* decimal point character in formatted non-monetary quantities. */
|
||||
char *grouping;
|
||||
/* A string whose elements indicate the size of each group of digits */
|
||||
/* in formatted non-monetary quantities. See below for more details. */
|
||||
char *int_curr_symbol;
|
||||
/* The international currency symbol applicable to the current locale.*/
|
||||
/* The first three characters contain the alphabetic international */
|
||||
/* currency symbol in accordance with those specified in ISO 4217 */
|
||||
/* Codes for the representation of Currency and Funds. The fourth */
|
||||
/* character (immediately preceding the null character) is the */
|
||||
/* character used to separate the international currency symbol from */
|
||||
/* the monetary quantity. */
|
||||
char *currency_symbol;
|
||||
/* The local currency symbol applicable to the current locale. */
|
||||
char *mon_decimal_point;
|
||||
/* The decimal-point used to format monetary quantities. */
|
||||
char *mon_thousands_sep;
|
||||
/* The separator for groups of digits to the left of the decimal-point*/
|
||||
/* in formatted monetary quantities. */
|
||||
char *mon_grouping;
|
||||
/* A string whose elements indicate the size of each group of digits */
|
||||
/* in formatted monetary quantities. See below for more details. */
|
||||
char *positive_sign;
|
||||
/* The string used to indicate a nonnegative-valued formatted */
|
||||
/* monetary quantity. */
|
||||
char *negative_sign;
|
||||
/* The string used to indicate a negative-valued formatted monetary */
|
||||
/* quantity. */
|
||||
char int_frac_digits;
|
||||
/* The number of fractional digits (those to the right of the */
|
||||
/* decimal-point) to be displayed in an internationally formatted */
|
||||
/* monetary quantities. */
|
||||
char frac_digits;
|
||||
/* The number of fractional digits (those to the right of the */
|
||||
/* decimal-point) to be displayed in a formatted monetary quantity. */
|
||||
char p_cs_precedes;
|
||||
/* Set to 1 or 0 if the currency_symbol respectively precedes or */
|
||||
/* succeeds the value for a nonnegative formatted monetary quantity. */
|
||||
char p_sep_by_space;
|
||||
/* Set to 1 or 0 if the currency_symbol respectively is or is not */
|
||||
/* separated by a space from the value for a nonnegative formatted */
|
||||
/* monetary quantity. */
|
||||
char n_cs_precedes;
|
||||
/* Set to 1 or 0 if the currency_symbol respectively precedes or */
|
||||
/* succeeds the value for a negative formatted monetary quantity. */
|
||||
char n_sep_by_space;
|
||||
/* Set to 1 or 0 if the currency_symbol respectively is or is not */
|
||||
/* separated by a space from the value for a negative formatted */
|
||||
/* monetary quantity. */
|
||||
char p_sign_posn;
|
||||
/* Set to a value indicating the position of the positive_sign for a */
|
||||
/* nonnegative formatted monetary quantity. See below for more details*/
|
||||
char n_sign_posn;
|
||||
/* Set to a value indicating the position of the negative_sign for a */
|
||||
/* negative formatted monetary quantity. See below for more details. */
|
||||
|
||||
/*
|
||||
* The elements of grouping amd mon_grouping are interpreted according to
|
||||
* the following:
|
||||
* CHAR_MAX No further grouping is to be performed.
|
||||
* 0 The previous element is to be repeatedly used for the
|
||||
* remainder of the digits.
|
||||
* other The value is the number of digits that compromise the current
|
||||
* group. The next element is examined to determine the size of
|
||||
* the next group of digits to the left of the current group.
|
||||
*
|
||||
* The value of p_sign_posn and n_sign_posn is interpreted according to
|
||||
* the following:
|
||||
* 0 Parentheses surround the quantity and currency_symbol.
|
||||
* 1 The sign string preceeds the quantity and currency_symbol.
|
||||
* 2 The sign string succeeds the quantity and currency_symbol.
|
||||
* 3 The sign string immediately preceeds the currency_symbol.
|
||||
* 4 The sign string immediately succeeds the currency_symbol.
|
||||
*/
|
||||
};
|
||||
|
||||
extern struct lconv *localeconv(void);
|
||||
/*
|
||||
* Sets the components of an object with type struct lconv with values
|
||||
* appropriate for the formatting of numeric quantities (monetary and
|
||||
* otherwise) according to the rules of the current locale.
|
||||
* The members of the structure with type char * are strings, any of which
|
||||
* (except decimal_point) can point to "", to indicate that the value is not
|
||||
* available in the current locale or is of zero length. The members with
|
||||
* type char are nonnegative numbers, any of which can be CHAR_MAX to
|
||||
* indicate that the value is not available in the current locale.
|
||||
* The members included are described above.
|
||||
*
|
||||
* Return value:
|
||||
* A pointer to the filled in object. The structure pointed to by the return
|
||||
* value shall not be modified by the program, but may be overwritten by a
|
||||
* subsequent call to the localeconv function. In addition, calls to the
|
||||
* setlocale function with categories LC_ALL, LC_MONETARY, or LC_NUMERIC may
|
||||
* overwrite the contents of the structure.
|
||||
*/
|
||||
|
||||
#ifndef NULL
|
||||
# define NULL 0
|
||||
#endif
|
||||
|
||||
#endif /* __LOCALE_H_INCLUDED */
|
||||
|
||||
/* end of locale.h */
|
|
@ -0,0 +1,220 @@
|
|||
//*******************************************************************
|
||||
// <math.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// Portions Copyright (C) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright (C) NXP Semiconductors, 2013-14
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef __MATH_H_INCLUDED
|
||||
#define __MATH_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
typedef double float_t;
|
||||
typedef double double_t;
|
||||
|
||||
#ifndef HUGE_VAL
|
||||
# define HUGE_VAL __huge_val
|
||||
extern const double HUGE_VAL;
|
||||
#endif
|
||||
|
||||
#ifndef HUGE_VALF
|
||||
# define HUGE_VALF __huge_valf
|
||||
extern const double HUGE_VALF;
|
||||
#endif
|
||||
|
||||
#ifndef HUGE_VALL
|
||||
# define HUGE_VALL __huge_vall
|
||||
extern const double HUGE_VALL;
|
||||
#endif
|
||||
|
||||
#ifndef INFINITY
|
||||
# define INFINITY __huge_val
|
||||
extern const double INFINITY;
|
||||
#endif
|
||||
|
||||
#ifndef NAN
|
||||
# define NAN __huge_val
|
||||
extern const double NAN;
|
||||
#endif
|
||||
|
||||
|
||||
#undef FP_FAST_FMA
|
||||
#undef FP_FAST_FMAF
|
||||
#undef FP_FAST_FMAL
|
||||
|
||||
#define FP_ILOGB0 INT_MIN
|
||||
#define FP_ILOGBNAN INT_MIN
|
||||
|
||||
#define MATH_ERRNO 1
|
||||
#define MATH_ERREXCEPT 2
|
||||
#define math_errhandling MATH_ERRNO
|
||||
|
||||
/* #pragma STDC FP_CONTRACT on-off-switch */
|
||||
|
||||
|
||||
#define FP_INFINITE 4
|
||||
#define FP_NAN 3
|
||||
#define FP_NORMAL 2
|
||||
#define FP_SUBNORMAL 1
|
||||
#define FP_ZERO 0
|
||||
|
||||
extern int __fpclassifyf(float), __fpclassify(double), __fpclassifyl(long double);
|
||||
extern int __isfinitef(float), __isfinite(double), __isfinitel(long double);
|
||||
extern int __isinff(float), __isinf(double), __isinfl(long double);
|
||||
extern int __isnanf(float), __isnan(double), __isnanl(long double);
|
||||
extern int __isnormalf(float), __isnormal(double), __isnormall(long double);
|
||||
extern int __signbitf(float), __signbit(double), __signbitl(long double);
|
||||
|
||||
#define fpclassify(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __fpclassifyf(x) : \
|
||||
(sizeof (x) == sizeof (double)) ? __fpclassifyd(x) : \
|
||||
__fpclassifyl(x))
|
||||
#define isfinite(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isfinitef(x) : \
|
||||
(sizeof (x) == sizeof (double)) ? __isfinited(x) : \
|
||||
__isfinitel(x))
|
||||
#define isinf(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isinff(x) : \
|
||||
(sizeof (x) == sizeof (double)) ? __isinfd(x) : \
|
||||
__isinfl(x))
|
||||
#define isnan(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isnanf(x) : \
|
||||
(sizeof (x) == sizeof (double)) ? __isnand(x) : \
|
||||
__isnanl(x))
|
||||
#define isnormal(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __isnormalf(x) : \
|
||||
(sizeof (x) == sizeof (double)) ? __isnormald(x) : \
|
||||
__isnormall(x))
|
||||
#define signbit(x) \
|
||||
((sizeof (x) == sizeof (float)) ? __signbitf(x) : \
|
||||
(sizeof (x) == sizeof (double)) ? __signbitd(x) : \
|
||||
__signbitl(x))
|
||||
|
||||
// ==================================================================
|
||||
|
||||
// Trigonometric functions
|
||||
// =======================
|
||||
|
||||
// cos - Compute cosine
|
||||
extern double cos(double __x);
|
||||
extern float cosf(float __x);
|
||||
|
||||
// sin - Compute sine
|
||||
extern double sin(double __x);
|
||||
extern float sinf(float __x);
|
||||
|
||||
// tan - Compute tangent
|
||||
extern double tan(double __x);
|
||||
extern float tanf(float __x);
|
||||
|
||||
// acos - Compute arc cosine
|
||||
extern double acos(double __x);
|
||||
extern float acosf(float __x);
|
||||
|
||||
// asin - Compute arc sine
|
||||
extern double asin(double __x);
|
||||
extern float asinf(float __x);
|
||||
|
||||
// atan - Compute arc tangent
|
||||
extern double atan(double __x);
|
||||
extern float atanf(float __x);
|
||||
|
||||
// atan2 - Compute arc tangent with two parameters
|
||||
extern double atan2(double __y, double __x);
|
||||
extern float atan2f(float __y, float __x);
|
||||
|
||||
// Hyperbolic functions
|
||||
// ====================
|
||||
|
||||
// cosh - Compute hyperbolic cosine
|
||||
extern double cosh(double __x);
|
||||
extern float coshf(float __x);
|
||||
|
||||
// sinh - Compute hyperbolic sine
|
||||
extern double sinh(double __x);
|
||||
extern float sinhf(float __x);
|
||||
|
||||
// tanh - Compute hyperbolic tangent
|
||||
extern double tanh(double __x);
|
||||
extern float tanhf(float __x);
|
||||
|
||||
// Exponential and logarithmic functions
|
||||
// =====================================
|
||||
|
||||
// exp - Compute exponential function
|
||||
extern double exp(double __x);
|
||||
extern float expf(float __x);
|
||||
|
||||
// frexp - Get significand and exponent
|
||||
extern double frexp(double __value, int *__exp);
|
||||
extern float frexpf(float __value, int *__exp);
|
||||
|
||||
// ldexp - Generate number from significand and exponent
|
||||
extern double ldexp(double __x, int __exp);
|
||||
extern float ldexpf(float __x, int __exp);
|
||||
|
||||
// log - Compute natural logarithm
|
||||
extern double log(double __x);
|
||||
extern float logf(float __x);
|
||||
|
||||
// log10 - Compute common logarithm
|
||||
extern double log10(double __x);
|
||||
extern float log10f(float __x);
|
||||
|
||||
// modf - Break into fractional and integral parts
|
||||
extern double modf(double __value, double *iptr);
|
||||
extern float modff(float __value, float *iptr);
|
||||
|
||||
// Power functions
|
||||
// ===============
|
||||
|
||||
// pow - Raise to power
|
||||
extern double pow(double __x, double __y);
|
||||
extern float powf(float __x, float __y);
|
||||
|
||||
// sqrt - Compute square root
|
||||
extern double sqrt(double __x);
|
||||
extern float sqrtf(float __x);
|
||||
|
||||
// Rounding, absolute value and remainder functions
|
||||
// ================================================
|
||||
|
||||
// ceil - Round up value
|
||||
extern double ceil(double __x);
|
||||
extern float ceilf(float __x);
|
||||
|
||||
// fabs - Compute absolute value
|
||||
extern double fabs(double __x);
|
||||
extern float fabsf(float __x);
|
||||
|
||||
// floor - Round down value
|
||||
extern double floor(double __x);
|
||||
extern float floorf(float __x);
|
||||
|
||||
// fmod - Compute remainder of division
|
||||
extern double fmod(double __x, double __y);
|
||||
extern float fmodf(float __x, float __y);
|
||||
|
||||
/*
|
||||
* These are probably only sensibly dealt with my expanding them into
|
||||
* intrinsics. The versions here are NOT GOOD. The requirement is that
|
||||
* these apply to float, double or long double and do comparisons in a
|
||||
* way that can never raise an exception even in the face of NaNs. The
|
||||
* built-in operators (x > __y) etc may raise exceptions when faced with
|
||||
* values that can not be compared.
|
||||
*/
|
||||
#define isgreater(x, y) ((x) > (y))
|
||||
#define isgreaterequal(x, y) ((x) >= (y))
|
||||
#define isless(x, y) ((x) < (y))
|
||||
#define islessequal(x, y) ((x) <= (y))
|
||||
#define islessgreater(x, y) ((x) != (y))
|
||||
#define isunordered(x, y) (0)
|
||||
|
||||
#endif /* __MATH_H_INCLUDED */
|
||||
|
||||
/* end of <math.h> */
|
|
@ -0,0 +1,68 @@
|
|||
/* Copyright (C) Code Red Technologies Ltd. */
|
||||
|
||||
/*
|
||||
* <setjmp.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*/
|
||||
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __SETJMP_H_INCLUDED
|
||||
#define __SETJMP_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#include <sys/libconfig.h>
|
||||
|
||||
typedef int jmp_buf[__JMP_BUF_SIZE];
|
||||
/* an array type suitable for holding the data
|
||||
* needed to restore a calling environment.
|
||||
*/
|
||||
|
||||
extern int setjmp(jmp_buf /*env*/);
|
||||
/* Saves its calling environment in its jmp_buf argument, for later use
|
||||
* by the longjmp function.
|
||||
* Returns: If the return is from a direct invocation, the setjmp function
|
||||
* returns the value zero. If the return from a call to the
|
||||
* longjmp function, the setjmp function returns a non zero value.
|
||||
*/
|
||||
|
||||
extern void longjmp(jmp_buf /*env*/, int /*val*/);
|
||||
/* Restores the environment saved by the most recent call to setjmp in the
|
||||
* same invocation of the program, with the corresponding jmp_buf argument.
|
||||
* If there has been no such call, or if the function containing the call
|
||||
* to setjmp has terminated execution (eg. with a return statement) in the
|
||||
* interim, the behaviour is undefined.
|
||||
* All accessible objects have values as of the time longjmp was called,
|
||||
* except that the values of objects of automatic storage duration that do
|
||||
* not have volatile type and have been changed between the setjmp and
|
||||
* longjmp calls are indeterminate.
|
||||
* As it bypasses the usual function call and return mechanism, the longjmp
|
||||
* function shall execute correctly in contexts of interrupts, signals and
|
||||
* any of their associated functions. However, if the longjmp function is
|
||||
* invoked from a nested signal handler (that is, from a function invoked
|
||||
* as a result of a signal raised during the handling of another signal),
|
||||
* the behaviour is undefined.
|
||||
* Returns: After longjmp is completed, program execution continues as if
|
||||
* the corresponding call to setjmp had just returned the value
|
||||
* specified by val. The longjmp function cannot cause setjmp to
|
||||
* return the value 0; if val is 0, setjmp returns the value 1.
|
||||
*/
|
||||
|
||||
#endif /* __SETJMP_H_INCLUDED */
|
||||
|
||||
/* end of <setjmp.h> */
|
|
@ -0,0 +1,94 @@
|
|||
/* Copyright (C) Code Red Technologies Ltd. */
|
||||
|
||||
/*
|
||||
* <signal.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*/
|
||||
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef __SIGNAL_H_INCLUDED
|
||||
#define __SIGNAL_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
typedef unsigned char sig_atomic_t;
|
||||
|
||||
/*
|
||||
* Each of the following macros expand to distinct constant expressions that
|
||||
* have the same type as the second argument to and the return value of the
|
||||
* signal function, and whose value matches no declarable function.
|
||||
*/
|
||||
#define SIG_DFL (void (*)(int))0
|
||||
#define SIG_ERR (void (*)(int))(-1)
|
||||
#define SIG_IGN (void (*)(int))1
|
||||
|
||||
/*
|
||||
* Each of the following macros expand to a positive integral constant
|
||||
* expression that is the signal number corresponding the the specified
|
||||
* condition.
|
||||
*/
|
||||
#define NSIG 32
|
||||
|
||||
/*
|
||||
* The signal numbers listed here need reviewing against the particular
|
||||
* system that the library is running on top of...
|
||||
*/
|
||||
|
||||
#define SIGHUP 1 /* hangup */
|
||||
#define SIGINT 2 /* interrupt */
|
||||
#define SIGQUIT 3 /* quit */
|
||||
#define SIGILL 4 /* illegal instruction (not reset when caught) */
|
||||
#define SIGTRAP 5 /* trace trap (not reset when caught) */
|
||||
#define SIGABRT 6
|
||||
#define SIGIOT 6 /* IOT instruction */
|
||||
#define SIGEMT 7 /* EMT instruction */
|
||||
#define SIGFPE 8 /* floating point exception */
|
||||
#define FPE_INTDIV_TRAP (0x208>>3) /* Integer division by zero */
|
||||
#define FPE_FLTOVF_TRAP (0x1a0>>3) /* Floating overflow trap */
|
||||
#define FPE_FLTUND_TRAP (0x188>>3) /* Floating underflow trap */
|
||||
#define FPE_FLTDIV_TRAP (0x190>>3) /* Floating division by zero */
|
||||
#define FPE_FLTIOP_TRAP (0x1c0>>3) /* Floating invalid operand */
|
||||
#define FPE_FLTINX_TRAP (0x180>>3) /* Floating inexact result */
|
||||
#define SIGKILL 9 /* kill (cannot be caught or ignored) */
|
||||
#define SIGBUS 10 /* bus error */
|
||||
#define SIGSEGV 11 /* segmentation violation */
|
||||
#define SIGSYS 12 /* bad argument to system call */
|
||||
#define SIGPIPE 13 /* write on a pipe with no one to read it */
|
||||
#define SIGALRM 14 /* alarm clock */
|
||||
#define SIGTERM 15 /* software termination signal from kill */
|
||||
#define SIGURG 16 /* urgent condition on IO channel */
|
||||
#define SIGSTOP 17 /* sendable stop signal not from tty */
|
||||
#define SIGTSTP 18 /* stop signal from tty */
|
||||
#define SIGCONT 19 /* continue a stopped process */
|
||||
#define SIGCHLD 20 /* to parent on child stop or exit */
|
||||
#define SIGTTIN 21 /* to readers pgrp upon background tty read */
|
||||
#define SIGTTOU 22 /* like TTIN for output if (tp->t_local<OSTOP) */
|
||||
#define SIGIO 23 /* input/output possible signal */
|
||||
#define SIGXCPU 24 /* exceeded CPU time limit */
|
||||
#define SIGXFSZ 25 /* exceeded file size limit */
|
||||
#define SIGVTALRM 26 /* virtual time alarm */
|
||||
#define SIGPROF 27 /* profiling time alarm */
|
||||
#define SIGWINCH 28 /* window changed */
|
||||
|
||||
|
||||
extern void (*signal(int sig, void (*func)(int)))(int);
|
||||
extern int raise(int sig);
|
||||
|
||||
#endif /* __SIGNAL_H_INCLUDED */
|
||||
|
||||
/* end of <signal.h> */
|
|
@ -0,0 +1,30 @@
|
|||
/* (C) Code Red Technologies Ltd. 2008
|
||||
*
|
||||
* Use the standard GCC variable argument builtins.
|
||||
*
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#ifndef _STDARG_H
|
||||
#define _STDARG_H
|
||||
#endif
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
typedef __builtin_va_list va_list;
|
||||
|
||||
#define va_start(v,l) __builtin_va_start((v),l)
|
||||
#define va_end(v) __builtin_va_end(v)
|
||||
#define va_arg(v,l)__builtin_va_arg((v),l)
|
|
@ -0,0 +1,26 @@
|
|||
//*******************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Copyright (c) 2011 Code Red Technologies Ltd.
|
||||
//
|
||||
// stdbool.h
|
||||
//
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef STDBOOL_H_
|
||||
#define STDBOOL_H_
|
||||
|
||||
#ifndef __cplusplus
|
||||
//#define bool _bool
|
||||
typedef unsigned char bool;
|
||||
#define false 0
|
||||
#define true 1
|
||||
#endif /* ifndef __cplusplus */
|
||||
|
||||
#define __bool_true_false_are_defined 1
|
||||
|
||||
#endif /* STDBOOL_H_ */
|
|
@ -0,0 +1,35 @@
|
|||
//*******************************************************************
|
||||
// <stddef.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// Portions Copyright (c) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright(C) NXP Semiconductors, 2013-14
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef __STDDEF_H_INCLUDED
|
||||
#define __STDDEF_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#include <sys/libconfig.h>
|
||||
|
||||
typedef int ptrdiff_t;
|
||||
|
||||
#ifndef WCHAR_T_DEFINED
|
||||
#define WCHAR_T_DEFINED
|
||||
typedef __WCHAR_TYPE__ wchar_t;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#define offsetof(type, member_designator) \
|
||||
((size_t)((char *)&(((type *)0)->member_designator) - (char *)0))
|
||||
|
||||
#endif /* __STDDEF_H_INCLUDED */
|
||||
|
||||
/* end of <stddef.h> */
|
|
@ -0,0 +1,320 @@
|
|||
//*******************************************************************
|
||||
// <stdint.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// A C Norman
|
||||
//
|
||||
// Portions Copyright (c) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright(C) NXP Semiconductors, 2013-17
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef __STDINT_H_INCLUDED
|
||||
#define __STDINT_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#include <sys/libconfig.h>
|
||||
|
||||
|
||||
/*
|
||||
* I will permit __SIZEOF_LONG_LONG not to exist if the"long long"
|
||||
* type is not available on this system.
|
||||
*/
|
||||
|
||||
|
||||
typedef signed char int8_t;
|
||||
typedef unsigned char uint8_t;
|
||||
#define INT8_C(value) ((signed char)(value))
|
||||
#define UINT8_C(value) ((unsigned char)(value))
|
||||
typedef signed char int_least8_t;
|
||||
typedef unsigned char uint_least8_t;
|
||||
#define INT8_MIN (-0x80)
|
||||
#define INT8_MAX 0x7f
|
||||
#define UINT8_MAX 0xffU
|
||||
#define INT_LEAST8_MIN (-0x80)
|
||||
#define INT_LEAST8_MAX 0x7f
|
||||
#define UINT_LEAST8_MAX 0xffU
|
||||
|
||||
typedef int int_fast8_t;
|
||||
typedef unsigned int uint_fast8_t;
|
||||
|
||||
|
||||
#define INT_FAST8_MIN (-0x80000000)
|
||||
#define INT_FAST8_MAX 0x7fffffff
|
||||
#define UINT_FAST8_MAX 0xffffffffU
|
||||
|
||||
|
||||
|
||||
#define __PRIdFAST8 "d"
|
||||
#define __PRIiFAST8 "i"
|
||||
#define __PRIoFAST8 "o"
|
||||
#define __PRIuFAST8 "u"
|
||||
#define __PRIxFAST8 "x"
|
||||
#define __PRIXFAST8 "X"
|
||||
#define __SCNdFAST8 "d"
|
||||
#define __SCNiFAST8 "i"
|
||||
#define __SCNoFAST8 "o"
|
||||
#define __SCNuFAST8 "u"
|
||||
#define __SCNxFAST8 "x"
|
||||
|
||||
|
||||
|
||||
#define __PRId8 "hhd"
|
||||
#define __PRIdLEAST8 "hhd"
|
||||
#define __PRIi8 "hhi"
|
||||
#define __PRIiLEAST8 "hhi"
|
||||
#define __PRIo8 "hho"
|
||||
#define __PRIoLEAST8 "hho"
|
||||
#define __PRIu8 "hhu"
|
||||
#define __PRIuLEAST8 "hhu"
|
||||
#define __PRIx8 "hhx"
|
||||
#define __PRIxLEAST8 "hhx"
|
||||
#define __PRIX8 "hhX"
|
||||
#define __PRIXLEAST8 "hhX"
|
||||
#define __SCNd8 "hhd"
|
||||
#define __SCNdLEAST8 "hhd"
|
||||
#define __SCNi8 "hhi"
|
||||
#define __SCNiLEAST8 "hhi"
|
||||
#define __SCNo8 "hho"
|
||||
#define __SCNoLEAST8 "hho"
|
||||
#define __SCNu8 "hhu"
|
||||
#define __SCNuLEAST8 "hhu"
|
||||
#define __SCNx8 "hhx"
|
||||
#define __SCNxLEAST8 "hhx"
|
||||
|
||||
|
||||
typedef short int16_t;
|
||||
typedef unsigned short uint16_t;
|
||||
#define INT16_C(value) ((short)(value))
|
||||
#define UINT16_C(value) ((unsigned short)(value))
|
||||
typedef short int_least16_t;
|
||||
typedef unsigned short uint_least16_t;
|
||||
#define INT16_MIN (-0x8000)
|
||||
#define INT16_MAX 0x7fff
|
||||
#define UINT16_MAX 0xffffU
|
||||
#define INT_LEAST16_MIN (-0x8000)
|
||||
#define INT_LEAST16_MAX 0x7fff
|
||||
#define UINT_LEAST16_MAX 0xffffU
|
||||
|
||||
typedef int int_fast16_t;
|
||||
typedef unsigned int uint_fast16_t;
|
||||
|
||||
#define INT_FAST16_MIN (-0x80000000)
|
||||
#define INT_FAST16_MAX 0x7fffffff
|
||||
#define UINT_FAST16_MAX 0xffffffffU
|
||||
|
||||
#define __PRIdFAST16 "d"
|
||||
#define __PRIiFAST16 "i"
|
||||
#define __PRIoFAST16 "o"
|
||||
#define __PRIuFAST16 "o"
|
||||
#define __PRIxFAST16 "x"
|
||||
#define __PRIXFAST16 "X"
|
||||
#define __SCNdFAST16 "d"
|
||||
#define __SCNiFAST16 "i"
|
||||
#define __SCNoFAST16 "o"
|
||||
#define __SCNuFAST16 "u"
|
||||
#define __SCNxFAST16 "x"
|
||||
|
||||
|
||||
#define __PRId16 "hd"
|
||||
#define __PRIdLEAST16 "hd"
|
||||
#define __PRIi16 "hi"
|
||||
#define __PRIiLEAST16 "hi"
|
||||
#define __PRIo16 "ho"
|
||||
#define __PRIoLEAST16 "ho"
|
||||
#define __PRIu16 "hu"
|
||||
#define __PRIuLEAST16 "hu"
|
||||
#define __PRIx16 "hx"
|
||||
#define __PRIxLEAST16 "hx"
|
||||
#define __PRIX16 "hX"
|
||||
#define __PRIXLEAST16 "hX"
|
||||
#define __SCNd16 "hd"
|
||||
#define __SCNdLEAST16 "hd"
|
||||
#define __SCNi16 "hi"
|
||||
#define __SCNiLEAST16 "hi"
|
||||
#define __SCNo16 "ho"
|
||||
#define __SCNoLEAST16 "ho"
|
||||
#define __SCNu16 "hu"
|
||||
#define __SCNuLEAST16 "hu"
|
||||
#define __SCNx16 "hx"
|
||||
#define __SCNxLEAST16 "hx"
|
||||
|
||||
typedef int int32_t;
|
||||
typedef unsigned int uint32_t;
|
||||
#define INT32_C(value) ((int)(value))
|
||||
#define UINT32_C(value) ((unsigned int)(value))
|
||||
typedef int int_least32_t;
|
||||
typedef unsigned int uint_least32_t;
|
||||
typedef int int_fast32_t;
|
||||
typedef unsigned int uint_fast32_t;
|
||||
#define INT32_MIN (-0x80000000)
|
||||
#define INT32_MAX 0x7fffffff
|
||||
#define UINT32_MAX 0xffffffffU
|
||||
#define INT_LEAST32_MIN (-0x80000000)
|
||||
#define INT_LEAST32_MAX 0x7fffffff
|
||||
#define UINT_LEAST32_MAX 0xffffffffU
|
||||
#define INT_FAST32_MIN (-0x80000000)
|
||||
#define INT_FAST32_MAX 0x7fffffff
|
||||
#define UINT_FAST32_MAX 0xffffffffU
|
||||
#define __PRId32 "d"
|
||||
#define __PRIdLEAST32 "d"
|
||||
#define __PRIdFAST32 "d"
|
||||
#define __PRIi32 "i"
|
||||
#define __PRIiLEAST32 "i"
|
||||
#define __PRIiFAST32 "i"
|
||||
#define __PRIo32 "o"
|
||||
#define __PRIoLEAST32 "o"
|
||||
#define __PRIoFAST32 "o"
|
||||
#define __PRIu32 "u"
|
||||
#define __PRIuLEAST32 "u"
|
||||
#define __PRIuFAST32 "u"
|
||||
#define __PRIx32 "x"
|
||||
#define __PRIxLEAST32 "x"
|
||||
#define __PRIxFAST32 "x"
|
||||
#define __PRIX32 "X"
|
||||
#define __PRIXLEAST32 "X"
|
||||
#define __PRIXFAST32 "X"
|
||||
#define __SCNd32 "d"
|
||||
#define __SCNdLEAST32 "d"
|
||||
#define __SCNdFAST32 "d"
|
||||
#define __SCNi32 "i"
|
||||
#define __SCNiLEAST32 "i"
|
||||
#define __SCNiFAST32 "i"
|
||||
#define __SCNo32 "o"
|
||||
#define __SCNoLEAST32 "o"
|
||||
#define __SCNoFAST32 "o"
|
||||
#define __SCNu32 "u"
|
||||
#define __SCNuLEAST32 "u"
|
||||
#define __SCNuFAST32 "u"
|
||||
#define __SCNx32 "x"
|
||||
#define __SCNxLEAST32 "x"
|
||||
#define __SCNxFAST32 "x"
|
||||
|
||||
|
||||
typedef long long int64_t;
|
||||
typedef unsigned long long uint64_t;
|
||||
#define INT64_C(value) ((long long)(value))
|
||||
#define UINT64_C(value) ((unsigned long long)(value))
|
||||
typedef long long int_least64_t;
|
||||
typedef unsigned long long uint_least64_t;
|
||||
typedef long long int_fast64_t;
|
||||
typedef unsigned long long uint_fast64_t;
|
||||
#define INT64_MIN (-0x8000000000000000LL)
|
||||
#define INT64_MAX 0x7fffffffffffffffLL
|
||||
#define UINT64_MAX 0xffffffffffffffffULL
|
||||
#define INT_LEAST64_MIN (-0x8000000000000000LL)
|
||||
#define INT_LEAST64_MAX 0x7fffffffffffffffLL
|
||||
#define UINT_LEAST64_MAX 0xffffffffffffffffULL
|
||||
#define INT_FAST64_MIN (-0x8000000000000000LL)
|
||||
#define INT_FAST64_MAX 0x7fffffffffffffffLL
|
||||
#define UINT_FAST64_MAX 0xffffffffffffffffULL
|
||||
#define __PRId64 "lld"
|
||||
#define __PRIdLEAST64 "lld"
|
||||
#define __PRIdFAST64 "lld"
|
||||
#define __PRIi64 "lli"
|
||||
#define __PRIiLEAST64 "lli"
|
||||
#define __PRIiFAST64 "lli"
|
||||
#define __PRIo64 "llo"
|
||||
#define __PRIoLEAST64 "llo"
|
||||
#define __PRIoFAST64 "llo"
|
||||
#define __PRIu64 "llu"
|
||||
#define __PRIuLEAST64 "llu"
|
||||
#define __PRIuFAST64 "llu"
|
||||
#define __PRIx64 "llx"
|
||||
#define __PRIxLEAST64 "llx"
|
||||
#define __PRIxFAST64 "llx"
|
||||
#define __PRIX64 "llX"
|
||||
#define __PRIXLEAST64 "llX"
|
||||
#define __PRIXFAST64 "llX"
|
||||
#define __SCNd64 "lld"
|
||||
#define __SCNdLEAST64 "lld"
|
||||
#define __SCNdFAST64 "lld"
|
||||
#define __SCNi64 "lli"
|
||||
#define __SCNiLEAST64 "lli"
|
||||
#define __SCNiFAST64 "lli"
|
||||
#define __SCNo64 "llo"
|
||||
#define __SCNoLEAST64 "llo"
|
||||
#define __SCNoFAST64 "llo"
|
||||
#define __SCNu64 "llu"
|
||||
#define __SCNuLEAST64 "llu"
|
||||
#define __SCNuFAST64 "llu"
|
||||
#define __SCNx64 "llx"
|
||||
#define __SCNxLEAST64 "llx"
|
||||
#define __SCNxFAST64 "llx"
|
||||
|
||||
/*
|
||||
* I see which of "int", "long" or "long long" is the same width as
|
||||
* a pointer and use the first that I find.
|
||||
*/
|
||||
|
||||
typedef int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
|
||||
#define INTPTR_MIN (-0x80000000)
|
||||
#define INTPTR_MAX 0x7fffffff
|
||||
#define UINTPTR_MAX 0xffffffffU
|
||||
|
||||
#define __PRIdPTR "d"
|
||||
#define __PRIiPTR "i"
|
||||
#define __PRIoPTR "o"
|
||||
#define __PRIuPTR "u"
|
||||
#define __PRIxPTR "x"
|
||||
#define __PRIXPTR "X"
|
||||
#define __SCNdPTR "d"
|
||||
#define __SCNiPTR "i"
|
||||
#define __SCNoPTR "o"
|
||||
#define __SCNuPTR "u"
|
||||
#define __SCNxPTR "x"
|
||||
|
||||
/*
|
||||
* I only use "long long" for intmax_t if it is strictly wider than
|
||||
* "long". I only use "long" if it is strictly wider than "int".
|
||||
*/
|
||||
|
||||
typedef long long intmax_t;
|
||||
typedef unsigned long long uintmax_t;
|
||||
#define __SIZEOF_INTMAX __SIZEOF_LONG_LONG
|
||||
|
||||
#define INTMAX_MIN (-0x8000000000000000LL)
|
||||
#define INTMAX_MAX 0x7fffffffffffffffLL
|
||||
#define UINTMAX_MAX 0xffffffffffffffffULL
|
||||
|
||||
#define INTMAX_C(value) ((long long)(value))
|
||||
#define UINTMAX_C(value) ((unsigned long long)(value))
|
||||
#define __PRIdMAX "lld"
|
||||
#define __PRIiMAX "lli"
|
||||
#define __PRIoMAX "llo"
|
||||
#define __PRIuMAX "llu"
|
||||
#define __PRIxMAX "llx"
|
||||
#define __PRIXMAX "llX"
|
||||
#define __SCNdMAX "lld"
|
||||
#define __SCNiMAX "lli"
|
||||
#define __SCNoMAX "llo"
|
||||
#define __SCNuMAX "llu"
|
||||
#define __SCNxMAX "llx"
|
||||
|
||||
#define __SIZEOF_PTRDIFF 4
|
||||
#define PTRDIFF_MIN (-0x80000000)
|
||||
#define PTRDIFF_MAX 0x7fffffff
|
||||
|
||||
#define __SIZEOF_SIZE 4
|
||||
#define SIZE_MAX 0xffffffffU
|
||||
|
||||
|
||||
#define WCHAR_MIN __WCHAR_MIN__
|
||||
#define WCHAR_MAX __WCHAR_MAX__
|
||||
|
||||
#define WINT_MIN INT32_MIN
|
||||
#define WINT_MAX INT32_MAX
|
||||
|
||||
#define SIG_ATOMIC_MIN 0
|
||||
#define SIG_ATOMIC_MAX 0xff
|
||||
|
||||
#endif /* __STDINT_H_INCLUDED */
|
||||
|
||||
/* end of <stdint.h> */
|
||||
|
||||
|
|
@ -0,0 +1,235 @@
|
|||
//*******************************************************************
|
||||
// <stdio.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// Portions Copyright (C) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright (C) NXP Semiconductors, 2013-18
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef __STDIO_H_INCLUDED
|
||||
#define __STDIO_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#include <sys/libconfig.h>
|
||||
|
||||
|
||||
/* ANSI forbids va_list to be defined here */
|
||||
//typedef char *__va_list; /* keep in step with <stdarg.h> */
|
||||
#ifdef __GNUC__
|
||||
typedef __builtin_va_list ___gnuc_va_list;
|
||||
typedef ___gnuc_va_list __va_list;
|
||||
#else
|
||||
typedef struct __va_list __va_list;
|
||||
#endif
|
||||
|
||||
/* I have put the FILE structure in libconfig.h */
|
||||
|
||||
typedef struct __FILE_struct FILE;
|
||||
|
||||
typedef struct __ftpos_t_struct
|
||||
{
|
||||
unsigned long __lo;
|
||||
/*
|
||||
* Anybody needing to support files larger than 4G would need to adjust
|
||||
* this, eg inserting an extra "__hi" field or using a "long long"
|
||||
* offset.
|
||||
*/
|
||||
} fpos_t;
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
#define __IOEOF 0x40 /* end-of-file reached */
|
||||
#define __IOERR 0x80 /* error occurred on stream */
|
||||
|
||||
#define _IOFBF 0x100 /* fully buffered IO */
|
||||
#define _IOLBF 0x200 /* line buffered IO */
|
||||
#define _IONBF 0x400 /* unbuffered IO */
|
||||
|
||||
#define BUFSIZ (256) /* system buffer size (as used by setbuf) */
|
||||
#define EOF (-1)
|
||||
/*
|
||||
* negative integral constant, indicates end-of-file, that is, no more
|
||||
* input from a stream.
|
||||
*/
|
||||
/* It is not clear to me what value FOPEN_MAX should have, so I will
|
||||
err in the cautious direction - ANSI requires it to be at least 8 */
|
||||
#define FOPEN_MAX 8 /* check re arthur/unix/mvs */
|
||||
/*
|
||||
* an integral constant expression that is the minimum number of files that
|
||||
* this implementation guarantees can be open simultaneously.
|
||||
*/
|
||||
|
||||
#define FILENAME_MAX 256
|
||||
/*
|
||||
* an integral constant expression that is the size of an array of char
|
||||
* large enough to hold the longest filename string. On modern systems
|
||||
* the value 256 may not be large enough, but I feel that anybody using a
|
||||
* file-name longer than that may be pushing their luck.
|
||||
*/
|
||||
#define L_tmpnam 32
|
||||
/*
|
||||
* an integral constant expression that is the size of an array of char
|
||||
* large enough to hold a temporary file name string generated by the
|
||||
* tmpnam function.
|
||||
*/
|
||||
|
||||
#define SEEK_SET 0 /* start of stream (see fseek) */
|
||||
#define SEEK_CUR 1 /* current position in stream (see fseek) */
|
||||
#define SEEK_END 2 /* end of stream (see fseek) */
|
||||
|
||||
#define TMP_MAX 1000000000
|
||||
/*
|
||||
* an integral constant expression that is the minimum number of unique
|
||||
* file names that shall be generated by the tmpnam function.
|
||||
*/
|
||||
|
||||
|
||||
#define _SYS_OPEN 8
|
||||
/*
|
||||
* Limit on number of files that can be opened at once
|
||||
*/
|
||||
|
||||
/*
|
||||
* What happens here is that each thread gets their own "stdin", "stdout"
|
||||
* and "stderr". And no thread should ever attempt to use a file opened by
|
||||
* a different thread.
|
||||
*/
|
||||
extern __THREAD FILE __Ciob[];
|
||||
/* an array of file objects for use by the system. */
|
||||
|
||||
#define stdin (&__Ciob[0])
|
||||
/* pointer to a FILE object associated with standard input stream */
|
||||
#define stdout (&__Ciob[1])
|
||||
/* pointer to a FILE object associated with standard output stream */
|
||||
#define stderr (&__Ciob[2])
|
||||
/* pointer to a FILE object associated with standard error stream */
|
||||
|
||||
extern int remove(const char *filename);
|
||||
extern int rename(const char *old, const char *new);
|
||||
extern FILE *tmpfile(void);
|
||||
extern char *tmpnam(char *s);
|
||||
extern int fclose(FILE *stream);
|
||||
extern int fflush(FILE *stream);
|
||||
extern FILE *fopen(const char * restrict filename,
|
||||
const char * restrict mode);
|
||||
extern FILE *freopen(const char * restrict filename,
|
||||
const char * restrict mode,
|
||||
FILE * restrict stream);
|
||||
extern void setbuf(FILE * restrict stream,
|
||||
char * restrict buf);
|
||||
extern int setvbuf(FILE * restrict stream,
|
||||
char * restrict buf,
|
||||
int mode, size_t size);
|
||||
extern int fprintf(FILE * restrict stream,
|
||||
const char * restrict format, ...);
|
||||
extern int fscanf(FILE * restrict stream,
|
||||
const char * restrict format, ...);
|
||||
extern int printf(const char * restrict format, ...);
|
||||
extern int scanf(const char * restrict format, ...);
|
||||
extern int snprintf(char * restrict s, size_t n,
|
||||
const char * restrict format, ...);
|
||||
extern int sprintf(char * restrict s,
|
||||
const char * restrict format, ...);
|
||||
extern int sscanf(const char * restrict s,
|
||||
const char * restrict format, ...);
|
||||
extern int vfprintf(FILE * restrict stream,
|
||||
const char * restrict format, __va_list arg);
|
||||
extern int vfscanf(FILE * restrict stream,
|
||||
const char * restrict format, __va_list arg);
|
||||
extern int vprintf(const char * restrict format, __va_list arg);
|
||||
|
||||
extern int vsnprintf(char * restrict s, size_t n,
|
||||
const char * restrict format, __va_list arg);
|
||||
extern int vsprintf(char * restrict s,
|
||||
const char * restrict format, __va_list arg);
|
||||
extern int fgetc(FILE *stream);
|
||||
extern char *fgets(char * restrict s, int n,
|
||||
FILE * restrict stream);
|
||||
extern int fputc(int c, FILE *stream);
|
||||
extern int fputs(const char * restrict s,
|
||||
FILE * restrict stream);
|
||||
extern int __filbuf(FILE *);
|
||||
extern int getc(FILE *stream);
|
||||
#define getc(p) \
|
||||
(--((p)->__icnt) >= 0 ? *((p)->__ptr)++ : __filbuf(p))
|
||||
extern int getchar(void);
|
||||
#define getchar() getc(stdin)
|
||||
extern char *gets(char *s);
|
||||
extern int putc(int c, FILE *stream);
|
||||
extern int __flsbuf(int /*c*/, FILE * /*stream*/);
|
||||
/*
|
||||
* SYSTEM USE ONLY, called by putc to flush buffer and or sort out flags.
|
||||
* Returns: character put into buffer or EOF on error.
|
||||
*/
|
||||
#define putc(ch, p) \
|
||||
(--((p)->__ocnt) >= 0 ? (*((p)->__ptr)++ = (ch)) : __flsbuf(ch,p))
|
||||
extern int putchar(int c);
|
||||
#define putchar(ch) putc(ch, stdout)
|
||||
extern int puts(const char *s);
|
||||
extern int ungetc(int c, FILE *stream);
|
||||
extern size_t fread(void * restrict ptr,
|
||||
size_t size, size_t nmemb,
|
||||
FILE * restrict stream);
|
||||
extern size_t fwrite(const void * restrict ptr,
|
||||
size_t size, size_t nmemb,
|
||||
FILE * restrict stream);
|
||||
extern int fgetpos(FILE * restrict stream,
|
||||
fpos_t * restrict pos);
|
||||
extern int fseek(FILE *stream, long int offset, int whence);
|
||||
extern int fsetpos(FILE *stream, const fpos_t *pos);
|
||||
extern long int ftell(FILE *stream);
|
||||
extern void rewind(FILE *stream);
|
||||
extern void clearerr(FILE *stream);
|
||||
extern int feof(FILE *stream);
|
||||
#define feof(stream) ((stream)->__flag & __IOEOF)
|
||||
extern int ferror(FILE *stream);
|
||||
#define ferror(stream) ((stream)->__flag & __IOERR)
|
||||
extern void perror(const char *s);
|
||||
|
||||
/* CR: Here are the integer printf entry points */
|
||||
extern int _fprintf(FILE *fp, const char *fmt, ...);
|
||||
extern int _printf(const char *fmt, ...);
|
||||
extern int _sprintf(char *buff, const char *fmt, ...);
|
||||
extern int _vprintf(const char * restrict format, __va_list arg);
|
||||
extern int _vfprintf(FILE *p, const char *fmt, __va_list args);
|
||||
extern int _vsprintf(char *buff, const char *fmt, __va_list args);
|
||||
extern int _snprintf(char *buff, size_t limit, const char *fmt, ...);
|
||||
extern int _vsnprintf(char *buff, size_t limit, const char *fmt, __va_list args);
|
||||
|
||||
/* CR: Here are the character-by-character printf entry points */
|
||||
extern int _printf_char(const char *fmt, ...);
|
||||
extern int printf_char(const char *fmt, ...);
|
||||
|
||||
extern int puts_char(const char *s);
|
||||
|
||||
#if defined (CR_INTEGER_PRINTF)
|
||||
#define fprintf _fprintf
|
||||
#define sprintf _sprintf
|
||||
#define vfprintf _vfprintf
|
||||
#define vsprintf _vsprintf
|
||||
#define vprintf _vprintf
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#if defined (CR_PRINTF_CHAR)
|
||||
#define printf _printf_char
|
||||
#define puts puts_char
|
||||
#else
|
||||
#define printf _printf
|
||||
#endif
|
||||
#elif defined (CR_PRINTF_CHAR)
|
||||
#define printf printf_char
|
||||
#define puts puts_char
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* __STDIO_H_INCLUDED */
|
||||
|
||||
/* end of <stdio.h> */
|
|
@ -0,0 +1,106 @@
|
|||
//*******************************************************************
|
||||
// <stdlib.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// Portions Copyright (c) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright(C) NXP Semiconductors, 2013-14
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef __STDLIB_H_INCLUDED
|
||||
#define __STDLIB_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#include <sys/libconfig.h>
|
||||
|
||||
|
||||
#ifndef WCHAR_T_DEFINED
|
||||
#define WCHAR_T_DEFINED
|
||||
typedef __WCHAR_TYPE__ wchar_t;
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
typedef struct div_t { int quot, rem; } div_t;
|
||||
/* type of the value returned by the div function. */
|
||||
typedef struct ldiv_t { long int quot, rem; } ldiv_t;
|
||||
/* type of the value returned by the ldiv function. */
|
||||
typedef struct lldiv_t { long long int quot, rem; } lldiv_t;
|
||||
/* type of the value returned by the lldiv function. */
|
||||
|
||||
#define EXIT_FAILURE __EXIT_FAILURE
|
||||
#define EXIT_SUCCESS __EXIT_SUCCESS
|
||||
|
||||
#define RAND_MAX 0x7fffffff
|
||||
/*
|
||||
* an integral constant expression, the value of which is the maximum value
|
||||
* returned by the rand function.
|
||||
*/
|
||||
#define MB_CUR_MAX 1
|
||||
/*
|
||||
* a positive integer expression whose value is the maximum number of bytes
|
||||
* in a multibyte character for the extended character set specified by the
|
||||
* current locale (category LC_CTYPE), and whose value is never greater
|
||||
* than MB_LEN_MAX.
|
||||
*/
|
||||
extern double atof(const char *nptr);
|
||||
extern int atoi(const char *nptr);
|
||||
extern long int atol(const char *nptr);
|
||||
|
||||
extern double strtod(const char * restrict nptr,
|
||||
char ** restrict endptr);
|
||||
extern float strtof(const char * restrict nptr,
|
||||
char ** restrict endptr);
|
||||
|
||||
extern long int strtol(const char * restrict nptr,
|
||||
char ** restrict endptr, int base);
|
||||
|
||||
extern unsigned long int strtoul(const char * restrict nptr,
|
||||
char ** restrict endptr, int base);
|
||||
|
||||
extern int rand(void);
|
||||
extern void srand(unsigned int seed);
|
||||
extern void *calloc(size_t nmemb, size_t size);
|
||||
extern void free(void *ptr);
|
||||
extern void *malloc(size_t size);
|
||||
extern void *realloc(void *ptr, size_t size);
|
||||
extern void abort(void);
|
||||
extern int atexit(void (*func)(void));
|
||||
extern void exit(int status);
|
||||
|
||||
extern char *getenv(const char *name);
|
||||
extern int system(const char *string);
|
||||
extern void *bsearch(const void *key, const void *base,
|
||||
size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *));
|
||||
extern void qsort(void *base, size_t nmemb, size_t size,
|
||||
int (*compar)(const void *, const void *));
|
||||
extern int abs(int j);
|
||||
extern long int labs(long int j);
|
||||
|
||||
extern div_t div(int numer, int denom);
|
||||
extern ldiv_t ldiv(long int numer, long int denom);
|
||||
|
||||
extern int mblen(const char *s, size_t n);
|
||||
extern int mbtowc(wchar_t * restrict pwc,
|
||||
const char * restrict s, size_t n);
|
||||
extern int wctomb(char *s, wchar_t wchar);
|
||||
extern size_t mbstowcs(wchar_t * restrict pwcs,
|
||||
const char * restrict s, size_t n);
|
||||
extern size_t wcstombs(char * restrict s,
|
||||
const wchar_t * restrict pwcs, size_t n);
|
||||
|
||||
// Implementation of the non-standard 'itoa' and 'uitoa' functions,
|
||||
// which support bases between 2 and 16 (2=binary, 10=decimal,
|
||||
// 16=hexadecimal).
|
||||
extern char * uitoa(unsigned int value, char *vstring, unsigned int base);
|
||||
extern char * itoa(int value, char *vstring, unsigned int base);
|
||||
|
||||
#endif /* __STDLIB_H_INCLUDED */
|
||||
|
||||
/* end of <stdlib.h> */
|
|
@ -0,0 +1,71 @@
|
|||
//*******************************************************************
|
||||
// <string.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// A C Norman
|
||||
//
|
||||
// Portions Copyright (c) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright (c) NXP Semiconductors, 2013-14
|
||||
//*******************************************************************
|
||||
#ifndef __STRING_H_INCLUDED
|
||||
#define __STRING_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#include <sys/libconfig.h>
|
||||
|
||||
#ifndef __SIZE_T_DEFINED
|
||||
#define __SIZE_T_DEFINED
|
||||
#if __SIZEOF_INT < __SIZEOF_VOID_P
|
||||
typedef unsigned long size_t;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
extern void *memcpy(void * restrict __s1,
|
||||
const void * restrict __s2, size_t __n);
|
||||
extern void *memmove(void *__s1, const void *__s2, size_t __n);
|
||||
extern char *strcpy(char * restrict __s1,
|
||||
const char * restrict __s2);
|
||||
extern char *strncpy(char * restrict __s1,
|
||||
const char * restrict __s2, size_t __n);
|
||||
extern char *strcat(char * restrict __s1,
|
||||
const char * restrict __s2);
|
||||
extern char *strncat(char * restrict __s1,
|
||||
const char * restrict __s2, size_t __n);
|
||||
extern int memcmp(const void *__s1, const void *__s2, size_t __n);
|
||||
extern int strcmp(const char *__s1, const char *__s2);
|
||||
extern int strcoll(const char *__s1, const char *__s2);
|
||||
extern int strncmp(const char *__s1, const char *__s2, size_t __n);
|
||||
size_t strxfrm(char * restrict __s1,
|
||||
const char * restrict __s2, size_t ____n);
|
||||
extern void *memchr(const void *__s, int __c, size_t ____n);
|
||||
extern char *strchr(const char *__s, int __c);
|
||||
extern size_t strcspn(const char *__s1, const char *__s2);
|
||||
extern char *strpbrk(const char *__s1, const char *__s2);
|
||||
extern char *strrchr(const char *s, int c);
|
||||
extern size_t strspn(const char *__s1, const char *__s2);
|
||||
extern char *strstr(const char *__s1, const char *__s2);
|
||||
extern char *strtok(char * restrict __s1,
|
||||
const char * restrict __s2);
|
||||
extern void *memset(void *__s, int __c, size_t __n);
|
||||
extern char *strerror(int __errnum);
|
||||
extern size_t strlen(const char *__s);
|
||||
|
||||
// ******************************************************
|
||||
// Non-standard case-insensitive string compare functions
|
||||
// ******************************************************
|
||||
extern int strncasecmp(char const *s1, char const *s2, size_t n) ;
|
||||
extern int strcasecmp(const char * s1, const char * s2);
|
||||
|
||||
#endif /* __STRING_H_INCLUDED */
|
||||
|
||||
/* end of <string.h> */
|
|
@ -0,0 +1,349 @@
|
|||
//*******************************************************************
|
||||
// <sys/libconfig-arm.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// A C Norman
|
||||
//
|
||||
// This file is modelled on "config.h" as used with the GNU autoconf
|
||||
// tools, but is expected to be configured manually here.
|
||||
// If one of the types shown is not present then just leave the
|
||||
// corresponding symbol undefined.
|
||||
//
|
||||
// This varient is set up for x86 data sizes.
|
||||
//
|
||||
// Portions Copyright (c) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright (c) NXP Semiconductors, 2013-17
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef __SYS_LIBCONFIG_H_INCLUDED
|
||||
#define __SYS_LIBCONFIG_H_INCLUDED
|
||||
|
||||
/* code_red
|
||||
*
|
||||
* Allow use with non C99 builds.
|
||||
*/
|
||||
|
||||
#define restrict __restrict__
|
||||
/*
|
||||
* This is some basic infrastructure for a study in making the
|
||||
* library thread-safe. Decorating a data defintion with __THREAD is
|
||||
* intended to cause the storage to be allocated on a per-thread basis.
|
||||
*
|
||||
* gcc supports a decoration "__thread" but does not implement it on all
|
||||
* platforms, and in particular it is not available on Cygwin which is
|
||||
* where my initial tetsing of this code has been done, so for now I
|
||||
* will #define __TREAD to empty...
|
||||
*/
|
||||
#ifdef THREAD_LOCAL_STORE_AVAILABLE
|
||||
#define __THREAD __thread
|
||||
#else
|
||||
#define __THREAD
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Critical regions are delimited by these two, which at present are defined
|
||||
* as noops. The "do {} while (0)" construct does nothing but is such that
|
||||
* a semicolon after it is called for...
|
||||
*/
|
||||
#define __START_CRITICAL_REGION() do {} while (0)
|
||||
#define __END_CRITICAL_REGION() do {} while (0)
|
||||
|
||||
/* The size of `char', as computed by sizeof. */
|
||||
#define __SIZEOF_CHAR 1
|
||||
|
||||
/* The size of `short int', as computed by sizeof. */
|
||||
#define __SIZEOF_SHORT 2
|
||||
|
||||
/* The size of `int', as computed by sizeof. */
|
||||
#define __SIZEOF_INT 4
|
||||
|
||||
/* The size of `long', as computed by sizeof. */
|
||||
#define __SIZEOF_LONG 4
|
||||
|
||||
/* The size of `long long', as computed by sizeof. */
|
||||
#define __SIZEOF_LONG_LONG 8
|
||||
|
||||
/* The size of `float', as computed by sizeof. */
|
||||
#define __SIZEOF_FLOAT 4
|
||||
|
||||
/* The size of `double', as computed by sizeof. */
|
||||
#define __SIZEOF_DOUBLE 8
|
||||
|
||||
/* The size of `long double', as computed by sizeof. */
|
||||
#define __SIZEOF_LONG_DOUBLE 12
|
||||
|
||||
/* The size of `float _Complex', as computed by sizeof. */
|
||||
#define __SIZEOF_FLOAT__COMPLEX 8
|
||||
|
||||
/* The size of `_Complex', as computed by sizeof. */
|
||||
#define __SIZEOF__COMPLEX 16
|
||||
|
||||
/* The size of `double _Complex', as computed by sizeof. */
|
||||
#define __SIZEOF_DOUBLE__COMPLEX 16
|
||||
|
||||
/* The size of `long double _Complex', as computed by sizeof. */
|
||||
#define __SIZEOF_LONG_DOUBLE__COMPLEX 24
|
||||
|
||||
/* The size of `void *', as computed by sizeof. */
|
||||
#define __SIZEOF_PTR 4
|
||||
|
||||
/* Define to 1 if your processor stores words with the most significant byte
|
||||
first (like Motorola and SPARC, unlike Intel and VAX). */
|
||||
/* #undef __WORDS_BIGENDIAN */
|
||||
|
||||
/* The number of int-sized words needed to save status in a jmp_buf
|
||||
The value "22" put in here right now is utterly arbitrary but dates back
|
||||
to the amount of space used on an ARM once upon a time long ago. */
|
||||
|
||||
#define __JMP_BUF_SIZE 22
|
||||
|
||||
/* Failure and Success codes to return when a program completes */
|
||||
#define __EXIT_FAILURE 1
|
||||
#define __EXIT_SUCCESS 0
|
||||
|
||||
/* clock ticks per second */
|
||||
/* Code Red Technologies 2007
|
||||
* Officially the semihosting SWI returns a clock value
|
||||
* in CentiSeconds
|
||||
*/
|
||||
#define __CLK_TCK 100
|
||||
|
||||
/* Defining these indicates that an 8-bit or 16-bit data type is liable
|
||||
to lead to faster or more compact code than use of a 32-bit int. */
|
||||
/* #undef __EIGHT_BIT_MACHINE */
|
||||
/* #undef __SIXTEEN_BIT_MACHINE */
|
||||
|
||||
|
||||
/*
|
||||
* @@@ from here down pollutes name-space etc...
|
||||
*/
|
||||
|
||||
|
||||
/* Specify byte-order. EVEN is for Intel etc, ODD is Motorola etc */
|
||||
#define BYTESEX_EVEN 1
|
||||
#undef BYTESEX_ODD
|
||||
|
||||
/* Layout in memory for floating point values must be indicated here */
|
||||
// code_red
|
||||
#define DOUBLE_EXP_LAST 1
|
||||
#undef OTHER_WORD_ORDER_FOR_FP_NUMBERS
|
||||
|
||||
|
||||
#define MAXSTORE 0x03ffffff /* used only by alloc.c */
|
||||
#define HOST_LACKS_ALLOC 1
|
||||
|
||||
struct __FILE_struct
|
||||
{
|
||||
unsigned char *__ptr;
|
||||
int __icnt; /* two separate _cnt fields so we can police ... */
|
||||
int __ocnt; /* ... restrictions that read/write are fseek separated */
|
||||
int __flag;
|
||||
/*
|
||||
* The fields below here are for system use only.
|
||||
*/
|
||||
unsigned char *__base; /* buffer base */
|
||||
#ifndef FILEHANDLE
|
||||
#define FILEHANDLE int
|
||||
#endif
|
||||
FILEHANDLE __file; /* file handle as used by lower level code */
|
||||
long __pos; /* position in file */
|
||||
int __bufsiz; /* maximum buffer size */
|
||||
int __signature; /* used with temporary files */
|
||||
unsigned char __lilbuf[2]; /* single byte buffer for them that want it */
|
||||
/* plus an unget char is put in __lilbuf[1] */
|
||||
long _lspos; /* what __pos should be (set after lazy seek) */
|
||||
unsigned char *__extent; /* extent of writes into the current buffer */
|
||||
int __buflim; /* used size of buffer */
|
||||
int __savedicnt; /* after unget contains old icnt */
|
||||
int __savedocnt; /* after unget contains old ocnt */
|
||||
};
|
||||
/*
|
||||
* FILE is an object capable of recording all information needed to control
|
||||
* a stream, such as its file position indicator, a pointer to its
|
||||
* associated buffer, an error indicator that records whether a read/write
|
||||
* error has occurred and an end-of-file indicator that records whether the
|
||||
* end-of-file has been reached.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
extern int _interrupts_off;
|
||||
extern void _raise_stacked_interrupts(void);
|
||||
extern void _postmortem(void);
|
||||
extern void _mapstore(void);
|
||||
extern void _Cwrite_profile(char *filename);
|
||||
|
||||
extern void _init_alloc(void), _initio(void),
|
||||
_terminateio(void), _lib_shutdown(void), _signal_init(void),
|
||||
_exit_init(void);
|
||||
|
||||
extern int _signal_real_handler(int sig);
|
||||
|
||||
#ifndef __SIZE_T_DEFINED
|
||||
#define __SIZE_T_DEFINED
|
||||
#if __SIZEOF_INT < __SIZEOF_VOID_P
|
||||
typedef unsigned long size_t;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
extern void *_Csys_alloc(size_t n);
|
||||
extern void _init_user_alloc(void);
|
||||
extern void _terminate_user_alloc(void);
|
||||
extern void _Csys_msg(const char *);
|
||||
extern void _deferredlazyseek(struct __FILE_struct *stream);
|
||||
extern int _fflush(struct __FILE_struct *stream);
|
||||
extern int _Cwritebuf(unsigned char *buf, int len, struct __FILE_struct *stream);
|
||||
extern struct __FILE_struct *_fdopen(FILEHANDLE fh, const char *mode, struct __FILE_struct *iob);
|
||||
extern int _Cread(char *ptr, int nbytes, struct __FILE_struct *stream);
|
||||
extern int _Cwrite(const char *ptr, int nbytes, struct __FILE_struct *stream);
|
||||
extern int _fillb2(struct __FILE_struct *stream);
|
||||
|
||||
#define _exit(n) __sys_appexit()
|
||||
|
||||
#ifndef FILEHANDLE
|
||||
/* This is a bit of a hack for the Codemist simulator (see stdio.h). */
|
||||
typedef int FILEHANDLE;
|
||||
#endif
|
||||
|
||||
/*
|
||||
* Note that on some machines where there is no "divide" instruction in the
|
||||
* hardware these may best turn into procedure calls to kernel code...
|
||||
*/
|
||||
#define _kernel_sdiv10(x) ((x)/10)
|
||||
#define _kernel_sdiv(x,y) ((y)/(x))
|
||||
#define _kernel_udiv10(v) ((unsigned)((v))/10)
|
||||
|
||||
/* I/O stuff... */
|
||||
|
||||
//extern FILEHANDLE _Csys_open(const char *name, int openmode);
|
||||
|
||||
#define NONHANDLE ((FILEHANDLE)(-1))
|
||||
|
||||
#ifndef __TIME_T_DEFINED
|
||||
#define __TIME_T_DEFINED
|
||||
typedef unsigned int time_t; /* date/time in unix secs past 1-Jan-70 */
|
||||
#endif
|
||||
|
||||
#ifndef __CLOCK_T_DEFINED
|
||||
#define __CLOCK_T_DEFINED
|
||||
typedef unsigned int clock_t; /* cpu time type */
|
||||
#endif
|
||||
|
||||
void __sys_appexit (void);
|
||||
clock_t __sys_clock(void);
|
||||
int __sys_close(int iFileHandle);
|
||||
int __sys_flen(int handle);
|
||||
int __sys_istty(int handle);
|
||||
int __sys_open(const char *pcFileName, int iFileMode, int len);
|
||||
int __sys_read(int iFileHandle, char *pcBuffer, int iLen);
|
||||
int __sys_readc(void);
|
||||
int __sys_remove(const char *pcFileName, int len);
|
||||
int __sys_rename(const char *oldFileName, int oldlen, const char *newFileName, int newlen);
|
||||
int __sys_seek(int handle, int pos);
|
||||
time_t __sys_time(void);
|
||||
int __sys_tmpnam(char *pcBuf, int iTargetId, int iBufLen);
|
||||
int __sys_write(int iFileHandle, char *pcBuffer, int iLength);
|
||||
void __sys_write0(char *pcBuffer);
|
||||
|
||||
#define _Csys_istty_(fh) __sys_istty((int)fh)
|
||||
#define _Csys_seek_(fh, pos) __sys_seek((int)fh,(int)pos)
|
||||
#define _Csys_flen_(fh) __sys_flen((int)fh)
|
||||
#define _ttywrite(buf, len, wh) __sys_write(0,(int)(buf),len)
|
||||
#define _Csys_write_(fh,buf,len,mode) __sys_write(fh,buf,len)
|
||||
extern int _Csys_read_(FILEHANDLE fh, unsigned char *buf, int len, int mode);
|
||||
#define _Csys_close_(fh) __sys_close((int)(fh))
|
||||
|
||||
#define _Csys_open(name,mode,len) __sys_open(name,mode,len)
|
||||
//extern void _Csys_tmpnam_(char *name, int sig);
|
||||
|
||||
|
||||
|
||||
#if __SIZEOF_DOUBLE==4
|
||||
#define FLOAT64 long double
|
||||
#else
|
||||
#define FLOAT64 double
|
||||
#endif
|
||||
|
||||
#ifndef DOUBLE_EXP_LAST /* i.e. __sparc __nec etc */
|
||||
# ifdef BYTESEX_EVEN
|
||||
typedef union
|
||||
{
|
||||
//JR
|
||||
struct
|
||||
{
|
||||
//JR
|
||||
unsigned int mhi:20, x:11, s:1;
|
||||
unsigned mlo;
|
||||
} i;
|
||||
FLOAT64 d;
|
||||
} fp_number;
|
||||
# else
|
||||
typedef union {struct {unsigned int s:1, x:11, mhi:20; unsigned mlo; } i;
|
||||
FLOAT64 d; } fp_number;
|
||||
# endif
|
||||
#else
|
||||
# ifdef BYTESEX_EVEN
|
||||
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned mlo;
|
||||
unsigned int mhi:20, x:11, s:1;
|
||||
} i;
|
||||
FLOAT64 d;
|
||||
} fp_number;
|
||||
|
||||
# else
|
||||
typedef union
|
||||
{
|
||||
struct
|
||||
{
|
||||
unsigned mlo;
|
||||
unsigned int s:1, x:11, mhi:20;
|
||||
} i;
|
||||
FLOAT64 d;
|
||||
} fp_number;
|
||||
# endif
|
||||
#endif
|
||||
|
||||
/* the object of the following macro is to adjust the floating point */
|
||||
/* variables concerned so that the more significant one can be squared */
|
||||
/* with NO LOSS OF PRECISION. It is only used when there is no danger */
|
||||
/* of over- or under-flow. */
|
||||
|
||||
/* This code is NOT PORTABLE but can be modified for use elsewhere */
|
||||
/* It should, however, serve for IEEE and IBM FP formats. */
|
||||
|
||||
#define _fp_normalize(high, low) \
|
||||
{ fp_number temp; /* access to representation */ \
|
||||
double temp1; \
|
||||
temp.d = high; /* take original number */ \
|
||||
temp.i.mlo = 0; /* make low part of mantissa 0 */ \
|
||||
temp1 = high - temp.d; /* the bit that was thrown away */ \
|
||||
low += temp1; /* add into low-order result */ \
|
||||
high = temp.d; \
|
||||
}
|
||||
|
||||
extern struct __FILE_struct *_fopen_string_file(const char *data, int length);
|
||||
|
||||
extern int _number_of_exit_functions;
|
||||
extern void (*_exitvector[])(void);
|
||||
|
||||
/*
|
||||
* The definitions here are a bit dodgy wrt all the possible mixtures of
|
||||
* floating point widths.
|
||||
*/
|
||||
extern FLOAT64 _frexpl(FLOAT64, int *);
|
||||
extern FLOAT64 _ldexpl(FLOAT64, int);
|
||||
|
||||
extern double _sincos(double x, double y, int sign, int coscase);
|
||||
extern double _tancot(double, int);
|
||||
extern double _asinacos(double, int);
|
||||
|
||||
|
||||
#endif /* __SYS_LIBCONFIG_H_INCLUDED */
|
||||
|
||||
/* end of <sys/libconfig.h> */
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
/* Copyright (C) Code Red Technologies Ltd. */
|
||||
/*
|
||||
* <sys/libconfig.h> Copyright (C) Codemist 2007
|
||||
*
|
||||
* A C Norman
|
||||
*
|
||||
* This file specified library configuation options, such as
|
||||
* prseence or absence of floating point, datatype sizes and other
|
||||
* stuff. It is implemented by chaining to a visibly system-specific
|
||||
* version. I could, I imagine, use #ifdefs based on predefined macros
|
||||
* to select between different sub-types.
|
||||
*
|
||||
*/
|
||||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Portions copyright (c) 2010-11 Code Red Technologies Ltd.
|
||||
//
|
||||
//*****************************************************************************
|
||||
|
||||
#include <sys/libconfig-arm.h>
|
||||
|
||||
|
||||
/* end of <sys/libconfig.h> */
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
//*****************************************************************************
|
||||
// +--+
|
||||
// | ++----+
|
||||
// +-++ |
|
||||
// | |
|
||||
// +-+--+ |
|
||||
// | +--+--+
|
||||
// +----+ Copyright (c) 2010 Code Red Technologies Ltd.
|
||||
//
|
||||
// NXP Semiconductors, 2013-17
|
||||
//
|
||||
// redlib_version.h - provides Redlib versioning information
|
||||
//
|
||||
//*****************************************************************************
|
||||
#ifndef REDLIB_VERSION_H_
|
||||
#define REDLIB_VERSION_H_
|
||||
|
||||
// * Version of Redlib interface (semihosting) in use
|
||||
#define __REDLIB_INTERFACE_VERSION__ 30000
|
||||
|
||||
#endif /* REDLIB_VERSION_H_ */
|
|
@ -0,0 +1,87 @@
|
|||
//*******************************************************************
|
||||
// <time.h> Copyright (C) Codemist 2007
|
||||
//
|
||||
// Portions Copyright (c) Code Red Technologies Ltd., 2008-13
|
||||
// Portions Copyright (c) NXP Semiconductors, 2013-14
|
||||
//*******************************************************************
|
||||
|
||||
#ifndef __TIME_H_INCLUDED
|
||||
#define __TIME_H_INCLUDED
|
||||
|
||||
#include <sys/redlib_version.h>
|
||||
|
||||
#ifndef __CODEMIST
|
||||
#define __CODEMIST
|
||||
#endif
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL ((void *)0)
|
||||
#endif
|
||||
|
||||
#include <sys/libconfig.h>
|
||||
|
||||
#define CLOCKS_PER_SEC __CLK_TCK
|
||||
|
||||
#ifndef __SIZE_T_DEFINED
|
||||
#define __SIZE_T_DEFINED
|
||||
#if __SIZEOF_INT < __SIZEOF_VOID_P
|
||||
typedef unsigned long size_t;
|
||||
#else
|
||||
typedef unsigned int size_t;
|
||||
#endif
|
||||
#endif
|
||||
|
||||
/*
|
||||
* The types here are probably pretty dubious and would lead to
|
||||
* significant risk of overflow.
|
||||
*/
|
||||
|
||||
#ifndef __CLOCK_T_DEFINED
|
||||
#define __CLOCK_T_DEFINED
|
||||
typedef unsigned int clock_t; /* cpu time type */
|
||||
#endif
|
||||
|
||||
#ifndef __TIME_T_DEFINED
|
||||
#define __TIME_T_DEFINED
|
||||
typedef unsigned int time_t; /* date/time in unix secs past 1-Jan-70 */
|
||||
#endif
|
||||
|
||||
#ifndef __STRUCT_TM_DEFINED
|
||||
#define __STRUCT_TM_DEFINED
|
||||
|
||||
struct tm
|
||||
{
|
||||
int tm_sec; /* seconds after the minute, 0 to 60
|
||||
(0 - 60 allows for the occasional leap second) */
|
||||
int tm_min; /* minutes after the hour, 0 to 59 */
|
||||
int tm_hour; /* hours since midnight, 0 to 23 */
|
||||
int tm_mday; /* day of the month, 1 to 31 */
|
||||
int tm_mon; /* months since January, 0 to 11 */
|
||||
int tm_year; /* years since 1900 */
|
||||
int tm_wday; /* days since Sunday, 0 to 6 */
|
||||
int tm_yday; /* days since January 1, 0 to 365 */
|
||||
int tm_isdst; /* Daylight Savings Time flag */
|
||||
};
|
||||
/* struct tm holds the components of a calendar time, called the broken-down
|
||||
* time. The value of tm_isdst is positive if Daylight Savings Time is in
|
||||
* effect, zero if Daylight Savings Time is not in effect, and negative if
|
||||
* the information is not available.
|
||||
*/
|
||||
#endif
|
||||
|
||||
extern clock_t clock(void);
|
||||
extern double difftime(time_t time1, time_t time0);
|
||||
extern time_t mktime(struct tm *timeptr);
|
||||
extern time_t time(time_t *timer);
|
||||
extern char *asctime(const struct tm *timeptr);
|
||||
extern char *ctime(const time_t *timer);
|
||||
extern struct tm *gmtime(const time_t *timer);
|
||||
extern struct tm *localtime(const time_t *timer);
|
||||
extern size_t strftime(char * restrict s,
|
||||
size_t maxsize,
|
||||
const char * restrict format,
|
||||
const struct tm * restrict timeptr);
|
||||
|
||||
#endif /* __TIME_H_INCLUDED */
|
||||
|
||||
/* end of <time.h> */
|
|
@ -0,0 +1,75 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: ADCAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed AD conversion */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: ADCAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef ADCAPI_H
|
||||
#define ADCAPI_H
|
||||
|
||||
#include "types.h"
|
||||
#include "IOAPI.h"
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef void (*ADCAPI_tpfResultCB)(IOAPI_tenEHIOResource, uint32);/*CR1_83*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ADCAPI_en1Sample,
|
||||
ADCAPI_en4Samples,
|
||||
ADCAPI_en8Samples,
|
||||
ADCAPI_en16Samples,
|
||||
ADCAPI_en32Samples
|
||||
} ADCAPI_tenSamplesAv;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ADCAPI_enDiffGain1,
|
||||
ADCAPI_enDiffGain2,
|
||||
ADCAPI_enDiffGain4,
|
||||
ADCAPI_enDiffGain8,
|
||||
ADCAPI_enDiffGain16,
|
||||
ADCAPI_enDiffGain32,
|
||||
ADCAPI_enDiffGain64
|
||||
} ADCAPI_tenDiffGain;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
ADCAPI_en1000Hz = 0,
|
||||
ADCAPI_en500Hz = 1,
|
||||
ADCAPI_en250Hz = 2,
|
||||
ADCAPI_en125Hz = 3,
|
||||
ADCAPI_en64Hz = 4,
|
||||
ADCAPI_en32Hz = 5,
|
||||
ADCAPI_en16Hz = 6,
|
||||
ADCAPI_en8Hz = 7,
|
||||
ADCAPI_en4Hz = 8,
|
||||
ADCAPI_en2Hz = 9,
|
||||
ADCAPI_en1Hz = 10,
|
||||
ADCAPI_enTrigger1 = 11,
|
||||
ADCAPI_enTrigger2 = 12,
|
||||
ADCAPI_enTrigger3 = 13,
|
||||
ADCAPI_enTrigger4 = 14,
|
||||
ADCAPI_enTriggerCount
|
||||
} ADCAPI_tenTrigger;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
ADCAPI_tenSamplesAv enSamplesAv;
|
||||
ADCAPI_tenDiffGain enDiffGain;
|
||||
ADCAPI_tpfResultCB pfResultCB;
|
||||
ADCAPI_tenTrigger enTrigger;
|
||||
} ADCAPI_tstADCCB;
|
||||
|
||||
|
||||
#endif //ADCAPI_H
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: CEMAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel Cyclic Event Manager */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: CEMAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef CEMAPI_H
|
||||
#define CEMAPI_H
|
||||
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef uint16 CEMAPI_ttEventTime;
|
||||
typedef void (*CEMAPI_tpfEventCB)(IOAPI_tenEHIOResource, CEMAPI_ttEventTime);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CEMAPI_enHardwareRising,
|
||||
CEMAPI_enHardwareFalling,
|
||||
CEMAPI_enHardwareAny
|
||||
} CEMAPI_tenEventTrigger;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32TriggerType;
|
||||
IOAPI_tenEdgePolarity enEdgePolarity;
|
||||
bool boFirstEdgeRising;
|
||||
} CEM_tstPatternSetupCB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32CycleDuration;
|
||||
puint32 pu32EventProgram;
|
||||
puint32 pu32CallbackProgram;
|
||||
IOAPI_tenEHIOResource enIOHardwareTrigger;
|
||||
} IOAPI_tenCEMCycleCB;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#endif //CEMAPI_H
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: CtrlAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed controllers */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: CtrlAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef CTRLAPI_H
|
||||
#define CTRLAPI_H
|
||||
|
||||
#include "types.h"
|
||||
#include "build.h"
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef void (*CTRLAPI_pfPIDResultCB)(uint32);
|
||||
typedef sint16 CTRLAPI_ttPIDIDX;/*CR1_95*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CTRLAPI_enPID,
|
||||
CTRLAPI_enFIC
|
||||
} CTRLAPI_tenCTRLType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
CTRLAPI_enPID1ms = 0,
|
||||
CTRLAPI_enPID2ms = 1,
|
||||
CTRLAPI_enPID4ms = 2,
|
||||
CTRLAPI_enPID8ms = 3,
|
||||
CTRLAPI_enPID16ms = 4,
|
||||
CTRLAPI_enPID32ms = 5,
|
||||
CTRLAPI_enPID64ms = 6,
|
||||
CTRLAPI_enPID128ms = 7,
|
||||
CTRLAPI_enPID256ms = 8,
|
||||
CTRLAPI_enPID512ms = 9,
|
||||
CTRLAPI_enPID1024ms = 10,
|
||||
CTRLAPI_enPIDCall = 11,
|
||||
} CTRLAPI_tenPIDRate;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
sint32* pi32Target;
|
||||
sint32* pi32Feedback;
|
||||
sint32 i32Error;
|
||||
sint32 i32OldError;
|
||||
sint32 i32Integral;
|
||||
sint32 i32IntegralInput;
|
||||
uint8 u8PTerm;
|
||||
uint8 u8ITerm;
|
||||
uint8 u8DTerm;
|
||||
sint32* pi32Output;
|
||||
sint32 i32OutputMin;
|
||||
sint32 i32OutputMax;
|
||||
bool boNoWindUp;
|
||||
bool boResetIntegrator;
|
||||
bool boRun;
|
||||
bool boReset;
|
||||
CTRLAPI_tenPIDRate enPIDRate;
|
||||
CTRLAPI_pfPIDResultCB pfResultCB;
|
||||
} BUILD_PACKING CTRLAPI_tstPIDCB;
|
||||
|
||||
|
||||
#endif //CTRLAPI_H
|
||||
|
|
@ -0,0 +1,80 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: DACAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed DA conversion */
|
||||
/* initialisation, functions and DA conversion */
|
||||
/* */
|
||||
/* FILE NAME: DACAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef DACAPI_H
|
||||
#define DACAPI_H
|
||||
|
||||
#include "types.h"
|
||||
#include "IOAPI.h"
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef uint16 DACAPI_ttOutputVoltage;/*CR1_96*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DACAPI_enWaterMarkReached,
|
||||
DACAPI_enPointerTop,
|
||||
DACAPI_enPointerBottom
|
||||
} DACAPI_tenEventType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DACAPI_enHardwareTrigger = 0,
|
||||
DACAPI_enSoftwareTrigger = 1
|
||||
} DACAPI_tenTriggerType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DACAPI_enQueueDepth1 = 0,
|
||||
DACAPI_enQueueDepth2 = 1,
|
||||
DACAPI_enQueueDepth3 = 2,
|
||||
DACAPI_enQueueDepth4 = 3,
|
||||
DACAPI_enQueueDepth5 = 4,
|
||||
DACAPI_enQueueDepth6 = 5,
|
||||
DACAPI_enQueueDepth7 = 6,
|
||||
DACAPI_enQueueDepth8 = 7,
|
||||
DACAPI_enQueueDepth9 = 8,
|
||||
DACAPI_enQueueDepth10 = 9,
|
||||
DACAPI_enQueueDepth11 = 10,
|
||||
DACAPI_enQueueDepth12 = 11,
|
||||
DACAPI_enQueueDepth13 = 12,
|
||||
DACAPI_enQueueDepth14 = 13,
|
||||
DACAPI_enQueueDepth15 = 14,
|
||||
DACAPI_enQueueDepth16 = 15
|
||||
} DACAPI_tenQueueDepth;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DACAPI_enWatermark1Word = 0,
|
||||
DACAPI_enWatermark2Words = 1,
|
||||
DACAPI_enWatermark3Words = 2,
|
||||
DACAPI_enWatermark4Words = 3
|
||||
} DACAPI_tenWatermarkWords;
|
||||
|
||||
typedef void (*DACAPI_tpfEventCB)(IOAPI_tenEHIOResource, DACAPI_tenEventType);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
DACAPI_tenQueueDepth enQueueDepth;
|
||||
DACAPI_tenWatermarkWords enWatermarkWords;
|
||||
bool boWaterMarkEventEnable;
|
||||
bool boPointerTopEventEnable;
|
||||
bool boPointerBottomEventEnable;
|
||||
DACAPI_tenTriggerType enTriggerType;
|
||||
DACAPI_tpfEventCB pfEventCB;
|
||||
} DACAPI_tstDACCB;
|
||||
|
||||
|
||||
#endif //DACAPI_H
|
||||
|
|
@ -0,0 +1,72 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: DiagAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed diagnostics */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: DiagAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef DIAGAPI_H
|
||||
#define DIAGAPI_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef enum
|
||||
{
|
||||
DIAGAPI_enNoSession,
|
||||
DIAGAPI_enExtendedSession,
|
||||
DIAGAPI_enProgramming
|
||||
} DIAGAPI_tenSession;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIAGAPI_enSecLevelInactive,
|
||||
DIAGAPI_enSecLevelOEM,
|
||||
DIAGAPI_enSecLevelMDAC
|
||||
} DIAGAPI_tenDiagSecurityLevel;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIAGAPI_enStartRoutine,
|
||||
DIAGAPI_enStopRoutine,
|
||||
DIAGAPI_enResultsRoutine
|
||||
} DIAGAPI_tenRoutineAction;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
bool boTransferComplete;
|
||||
uint16 u16CID;
|
||||
puint8 pu8Data;
|
||||
uint8 u8DataCount;
|
||||
} DIAGAPI_tstDataTransferCB;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIAGAPI_enDataWriteCB,
|
||||
DIAGAPI_enDataReadCB,
|
||||
DIAGAPI_enRoutineCB
|
||||
} DIAGAPI_tenCallBackType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
DIAGAPI_enCBOK,
|
||||
DIAGAPI_enRWSecurityError,
|
||||
DIAGAPI_enRWParamNotFound,
|
||||
DIAGAPI_enRWGenFail
|
||||
} DIAGAPI_tenCBResult;
|
||||
|
||||
|
||||
typedef DIAGAPI_tenCBResult (*DIAGAPI_tDataWriteCB)(uint16, puint8, uint8);
|
||||
typedef DIAGAPI_tenCBResult (*DIAGAPI_tReadWriteCB)(uint16, puint8, uint8);
|
||||
typedef DIAGAPI_tenCBResult (*DIAGAPI_tRoutineCB)(DIAGAPI_tenRoutineAction, puint8, uint8);
|
||||
|
||||
#endif //DIAGAPI_H
|
||||
|
|
@ -0,0 +1,28 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: IICAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed IIC resources */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: IICAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef IICAPI_H
|
||||
#define IICAPI_H
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32BaudRateHz;
|
||||
uint8 u8SlaveAddress;
|
||||
} IICAPI_tstIICConfig;
|
||||
|
||||
|
||||
#endif //IICAPI_H
|
||||
|
|
@ -0,0 +1,404 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: IOAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed I/O */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: IOAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef IOAPI_H
|
||||
#define IOAPI_H
|
||||
|
||||
#include "build.h"
|
||||
#include <SYS.h>
|
||||
#include "PROTAPI.h"
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef enum
|
||||
{
|
||||
IOAPI_IO_RX = 0,
|
||||
IOAPI_IO_TX = 1,
|
||||
IOAPI_IO_MEM_READ = 2,
|
||||
IOAPI_IO_MEM_WRITE = 3
|
||||
} IOAPI_enTransferType;
|
||||
/*CR1_103*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IOAPI_enPortComms,
|
||||
IOAPI_enPortSerialTransfer,
|
||||
IOAPI_enPortNone
|
||||
} IOAPI_tenPortMode;
|
||||
|
||||
#if defined(BUILD_MK60) && defined(BUILD_ECUHOST_1_4)
|
||||
typedef enum
|
||||
{
|
||||
EH_IO_ADSE1 = 0,
|
||||
EH_IO_ADSE2 = 1,
|
||||
EH_IO_ADSE3 = 2,
|
||||
EH_IO_ADSE4 = 3,
|
||||
EH_IO_ADSE5 = 4,
|
||||
EH_IO_ADSE6 = 5,
|
||||
EH_IO_ADSE7 = 6,
|
||||
EH_IO_ADSE8 = 7,
|
||||
EH_IO_ADSE9 = 8,
|
||||
EH_IO_ADSE10 = 9,
|
||||
EH_IO_ADSE11 = 10,
|
||||
EH_IO_ADSE12 = 11,
|
||||
EH_IO_GPSE1 = 12,
|
||||
EH_IO_GPSE2 = 13,
|
||||
EH_IO_GPSE5 = 14,
|
||||
EH_IO_GPSE6 = 15,
|
||||
EH_IO_GPSE7 = 16,
|
||||
EH_IO_GPSE8 = 17,
|
||||
EH_IO_GPSE9 = 18,
|
||||
EH_IO_GPSE10 = 19,
|
||||
EH_I_ADD1 = 20,
|
||||
EH_I_ADD2 = 21,
|
||||
EH_I_ADD3 = 22,
|
||||
EH_I_ADD4 = 23,
|
||||
EH_I_ADD5 = 24,
|
||||
EH_I_ADD6 = 25,
|
||||
EH_I_ADD7 = 26,
|
||||
EH_I_ADD8 = 27,
|
||||
EH_IO_CAN2T = 28,
|
||||
EH_IO_CAN2R = 29,
|
||||
EH_I_CMP1 = 30,
|
||||
EH_I_CMP2 = 31,
|
||||
EH_I_CMP3 = 32,
|
||||
IO_AD_Count = 33,
|
||||
EH_IO_UART1_TX = 34,
|
||||
EH_IO_UART1_RX = 35,
|
||||
EH_IO_UART1_CTS = 36,
|
||||
EH_IO_UART1_RTS = 37,
|
||||
EH_IO_UART2_TX = 38,
|
||||
EH_IO_UART2_RX = 39,
|
||||
EH_IO_UART2_CTS = 40,
|
||||
EH_IO_UART2_RTS = 41,
|
||||
EH_IO_CAN1T = 42,
|
||||
EH_IO_CAN1R = 43,
|
||||
EH_IO_TMR1 = 44,
|
||||
EH_IO_TMR2 = 45,
|
||||
EH_IO_TMR3 = 46,
|
||||
EH_IO_TMR4 = 47,
|
||||
EH_IO_TMR5 = 48,
|
||||
EH_IO_TMR6 = 49,
|
||||
EH_IO_TMR7 = 50,
|
||||
EH_IO_TMR8 = 51,
|
||||
EH_IO_TMR9 = 52,
|
||||
EH_IO_TMR10 = 53,
|
||||
EH_IO_TMR11 = 54,
|
||||
EH_IO_TMR12 = 55,
|
||||
EH_IO_TMR13 = 56,
|
||||
EH_IO_TMR14 = 57,
|
||||
EH_IO_TMR15 = 58,
|
||||
EH_IO_TMR16 = 59,
|
||||
EH_IO_IIC1_SCL = 60,
|
||||
EH_IO_IIC1_SDA = 61,
|
||||
EH_I_CMP4 = 62,
|
||||
EH_I_CMP5 = 63,
|
||||
EH_O_DAC1 = 64,
|
||||
EH_O_DAC2 = 65,
|
||||
EH_IO_GP3 = 66,
|
||||
EH_IO_GP4 = 67,
|
||||
EH_IO_K33A = 68,
|
||||
EH_IO_USB5V = 69,
|
||||
IO_Total_Discrete_Count = 70,
|
||||
EH_VIO_IIC1 = 100,
|
||||
EH_VIO_IIC2 = 101,
|
||||
EH_VIO_SPI1 = 102,
|
||||
EH_VIO_SPI2 = 103,
|
||||
EH_VIO_UART1 = 104,
|
||||
EH_VIO_UART2 = 105,
|
||||
EH_VIO_UART3 = 106,
|
||||
EH_VIO_UART4 = 107,
|
||||
EH_VIO_UART5 = 108,
|
||||
EH_VIO_UART6 = 109,
|
||||
EH_VIO_CAN1 = 110,
|
||||
EH_VIO_CAN2 = 111,
|
||||
EH_VIO_ENET_CH1 = 112,
|
||||
EH_VIO_ENET_CH2 = 113,
|
||||
EH_VIO_ENET_CH3 = 114,
|
||||
EH_VIO_ENET_CH4 = 115,
|
||||
EH_VIO_FTM0 = 116,
|
||||
EH_VIO_FTM1 = 117,
|
||||
EH_VIO_FTM2 = 118,
|
||||
EH_VIO_FTM3 = 119,
|
||||
IO_Total_Count,
|
||||
EH_IO_Invalid
|
||||
} IOAPI_tenEHIOResource;
|
||||
|
||||
#define EH_FIRST_TMR EH_IO_TMR1
|
||||
#define EH_LAST_TMR EH_IO_TMR16
|
||||
#endif //BUILD_MK60
|
||||
|
||||
#ifdef BUILD_MK64
|
||||
typedef enum
|
||||
{
|
||||
EH_IO_GPSE1 = 0,
|
||||
EH_IO_GPSE2 = 1,
|
||||
EH_IO_GPSE3 = 2,
|
||||
EH_IO_GPSE4 = 3,
|
||||
EH_IO_GPSE5 = 4,
|
||||
EH_IO_GPSE6 = 5,
|
||||
EH_IO_GPSE7 = 6,
|
||||
EH_IO_GPSE8 = 7,
|
||||
EH_I_ADD1 = 8,
|
||||
EH_I_ADD2 = 9,
|
||||
EH_I_CMP1 = 10,
|
||||
EH_I_CMP2 = 11,
|
||||
IO_AD_Count = 12,
|
||||
EH_IO_CAN1T = 13,
|
||||
EH_IO_CAN1R = 14,
|
||||
EH_IO_UART1_TX = 15,
|
||||
EH_IO_UART1_RX = 16,
|
||||
EH_IO_UART1_CTS = 17,
|
||||
EH_IO_UART1_RTS = 18,
|
||||
EH_IO_UART2_TX = 19,
|
||||
EH_IO_UART2_RX = 20,
|
||||
EH_IO_SPI1_MISO = 21,
|
||||
EH_IO_SPI1_MOSI = 22,
|
||||
EH_IO_SPI1_CLK = 23,
|
||||
EH_IO_SPI1_CS = 24,
|
||||
EH_IO_TMR1 = 25,
|
||||
EH_IO_TMR2 = 26,
|
||||
EH_IO_TMR3 = 27,
|
||||
EH_IO_TMR4 = 28,
|
||||
EH_IO_TMR5 = 29,
|
||||
EH_IO_TMR6 = 30,
|
||||
EH_IO_TMR7 = 31,
|
||||
EH_IO_TMR8 = 32,
|
||||
EH_IO_TMR9 = 33,
|
||||
EH_IO_TMR10 = 34,
|
||||
EH_IO_TMR11 = 35,
|
||||
EH_IO_TMR12 = 36,
|
||||
EH_IO_TMR13 = 37,
|
||||
EH_IO_TMR14 = 38,
|
||||
EH_IO_TMR15 = 39,
|
||||
EH_IO_TMR16 = 40,
|
||||
EH_IO_TMR17 = 41,
|
||||
EH_IO_TMR18 = 42,
|
||||
EH_IO_IIC1_SCL = 43,
|
||||
EH_IO_IIC1_SDA = 44,
|
||||
EH_O_DAC1 = 45,
|
||||
EH_O_DAC2 = 46,
|
||||
EH_IO_GP1 = 47,
|
||||
EH_IO_GP2 = 48,
|
||||
EH_IO_GP3 = 49,
|
||||
EH_IO_GP4 = 50,
|
||||
EH_IO_GP5 = 51,
|
||||
EH_IO_GP6 = 52,
|
||||
EH_IO_GP7 = 53,
|
||||
EH_IO_GP8 = 54,
|
||||
EH_IO_GP9 = 55,
|
||||
EH_IO_GP10 = 56,
|
||||
EH_IO_GP11 = 57,
|
||||
EH_IO_GP12 = 58,
|
||||
EH_IO_GP13 = 59,
|
||||
EH_IO_GP14 = 60,
|
||||
EH_IO_K33A = 61,
|
||||
EH_IO_USB5V = 62,
|
||||
IO_Total_Discrete_Count,
|
||||
EH_VIO_IIC1 = 100,
|
||||
EH_VIO_IIC2 = 101,
|
||||
EH_VIO_SPI1 = 102,
|
||||
EH_VIO_SPI2 = 103,
|
||||
EH_VIO_UART1 = 104,
|
||||
EH_VIO_UART2 = 105,
|
||||
EH_VIO_UART3 = 106,
|
||||
EH_VIO_UART4 = 107,
|
||||
EH_VIO_UART5 = 108,
|
||||
EH_VIO_UART6 = 109,
|
||||
EH_VIO_CAN1 = 110,
|
||||
EH_VIO_USB = 111,
|
||||
EH_VIO_ENET_CH1 = 112,
|
||||
EH_VIO_ENET_CH2 = 113,
|
||||
EH_VIO_ENET_CH3 = 114,
|
||||
EH_VIO_ENET_CH4 = 115,
|
||||
EH_VIO_FTM0 = 116,
|
||||
EH_VIO_FTM1 = 117,
|
||||
EH_VIO_FTM2 = 118,
|
||||
EH_VIO_FTM3 = 119,
|
||||
EH_VIO_ADC0 = 120,
|
||||
EH_VIO_ADC1 = 121,
|
||||
EH_VIO_ADC2 = 122,
|
||||
EH_VIO_ADC3 = 123,
|
||||
IO_Total_Count,
|
||||
EH_IO_Invalid
|
||||
} IOAPI_tenEHIOResource;
|
||||
|
||||
#define EH_FIRST_TMR EH_IO_TMR1
|
||||
#define EH_LAST_TMR EH_IO_TMR18
|
||||
#define EH_FIRST_UART EH_VIO_UART1
|
||||
#define EH_LAST_UART EH_VIO_UART2
|
||||
#define EH_FIRST_IIC EH_VIO_IIC1
|
||||
#define EH_LAST_IIC EH_VIO_IIC2
|
||||
#define EH_FIRST_SPI EH_VIO_SPI1
|
||||
#define EH_LAST_SPI EH_VIO_SPI2
|
||||
#define EH_FIRST_CAN EH_VIO_CAN1
|
||||
#define EH_LAST_CAN EH_VIO_CAN1
|
||||
#define EH_FIRST_USB EH_VIO_USB
|
||||
#define EH_LAST_USB EH_VIO_USB
|
||||
#define EH_FIRST_VIO_COMMS EH_VIO_IIC1
|
||||
#define EH_LAST_VIO_COMMS EH_VIO_ENET_CH2
|
||||
|
||||
#endif //BUILD_MK64
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IOAPI_enDIOOutput,
|
||||
IOAPI_enDIOInput,
|
||||
IOAPI_enADSE,
|
||||
IOAPI_enADD,
|
||||
IOAPI_enDAC,
|
||||
IOAPI_enCaptureCompare,
|
||||
IOAPI_enPWM,
|
||||
IOAPI_enIICBus,
|
||||
IOAPI_enIISBus,
|
||||
IOAPI_enSPIBus,
|
||||
IOAPI_enUARTBus,
|
||||
IOAPI_enCANBus,
|
||||
IOAPI_enENETChannel,
|
||||
IOAPI_enUSBChannel,
|
||||
IOAPI_enTEPM
|
||||
} IOAPI_tenEHIOType;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IOAPI_enEdgeRising,
|
||||
IOAPI_enEdgeFalling,
|
||||
IOAPI_enEdgeBoth
|
||||
} IOAPI_tenEdgePolarity;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IOAPI_enLow,
|
||||
IOAPI_enHigh,
|
||||
IOAPI_enToggle,
|
||||
IOAPI_enHiZ,
|
||||
IOAPI_enError
|
||||
} IOAPI_tenTriState;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
IOAPI_enWeak,
|
||||
IOAPI_enStrong
|
||||
} IOAPI_tenDriveStrength;
|
||||
|
||||
typedef void (*IOAPI_tpfTransferCB)(IOAPI_tenEHIOResource, puint8, uint32, IOAPI_enTransferType);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32MasterAddress;
|
||||
uint32 u32SlaveAddress;
|
||||
} tstIICNetInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32Dummy1;
|
||||
uint32 u32Dummy2;
|
||||
} tstUARTNetInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32GlobalCANDiagAddress;
|
||||
uint32 u32CANDiagAddress;
|
||||
uint32 u32CANPriorityAddress[4];
|
||||
uint32 u32CANPriorityMask[4];
|
||||
} tstCANNetInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 u16RPCREQSourcePort;
|
||||
uint16 u16RPCREQDestPort;
|
||||
} tstLANNetInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
tstIICNetInfo stIICNetInfo;
|
||||
tstCANNetInfo stCANNetInfo;
|
||||
tstLANNetInfo stLANNetInfo;
|
||||
tstUARTNetInfo stUARTNetInfo;
|
||||
} uNetInfo;
|
||||
} IOAPI_tstNetConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tenEHIOResource enRXPin;
|
||||
IOAPI_tenEHIOResource enTXPin;
|
||||
IOAPI_tenEHIOResource enRTSPin;
|
||||
IOAPI_tenEHIOResource enCTSPin;
|
||||
} IOAPI_tstUARTPinInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tenEHIOResource enRXPin;
|
||||
IOAPI_tenEHIOResource enTXPin;
|
||||
} IOAPI_tstCANPinInfo;
|
||||
/*CR1_104*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tenEHIOResource enSDAPin;
|
||||
IOAPI_tenEHIOResource enSCLPin;
|
||||
} IOAPI_tstIICPinInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tenEHIOResource enMOSIPin;
|
||||
IOAPI_tenEHIOResource enMISOPin;
|
||||
IOAPI_tenEHIOResource enSCKPin;
|
||||
bool boCaptureRising;
|
||||
bool boShiftRising;
|
||||
bool boIdleHigh;
|
||||
bool boDataIdleHigh;
|
||||
} IOAPI_tstSPIPinInfo;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
IOAPI_tstUARTPinInfo stUARTPinInfo;
|
||||
IOAPI_tstIICPinInfo stIICPinInfo;
|
||||
IOAPI_tstSPIPinInfo stSPIPinInfo;
|
||||
IOAPI_tstCANPinInfo stCANPinInfo;
|
||||
} uPinInfo;
|
||||
} IOAPI_tstPinConfig;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tstNetConfig stNetConfig;
|
||||
IOAPI_tstPinConfig stPinConfig;
|
||||
IOAPI_tenPortMode enPortMode;
|
||||
uint32 u32BaudRateHz;
|
||||
uint32 u32TXPacketRateMs;
|
||||
IOAPI_tenEHIOResource enVIOResource;
|
||||
PROTAPI_tenLLProtocol enLLProtocol;
|
||||
PROTAPI_tenNLProtocol enNLProtocol;
|
||||
PROTAPI_tenTLProtocol enTLProtocol;
|
||||
IOAPI_tpfTransferCB pfRXTransferCB;
|
||||
IOAPI_tpfTransferCB pfTXTransferCB;
|
||||
} IOAPI_tstPortConfigCB;
|
||||
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_enTransferType enTransferType;
|
||||
IOAPI_tpfTransferCB pfCB;
|
||||
void* pvData;
|
||||
uint32 u32ByteCount;
|
||||
bool boBlockingMode;
|
||||
} IOAPI_tstTransferCB;
|
||||
|
||||
#endif //IOAPI_H
|
||||
|
|
@ -0,0 +1,45 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: MapsAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed maps */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: MapsAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef MAPSAPI_H
|
||||
#define MAPSAPI_H
|
||||
|
||||
#include <BUILD.h>
|
||||
#include <TYPES.h>
|
||||
#include "SPREADSAPI.h"
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef sint16 MAPSAPI_ttMapIDX;/*CR1_118*/
|
||||
typedef void (*MAPSAPI_pfPIDResultCB)(sint32);
|
||||
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Wattributes"
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void* pvMapData;
|
||||
void* pvOutputData;
|
||||
TYPE_tenDataType enDataType;
|
||||
sint16 i16MapSizeX;
|
||||
sint16 i16MapSizeY;
|
||||
SPREADAPI_ttSpreadIDX tSpreadIDXX;
|
||||
SPREADAPI_ttSpreadIDX tSpreadIDXY;
|
||||
MAPSAPI_pfPIDResultCB pfResultCB;
|
||||
} BUILD_PACKING MAPSAPI_tstMapCB;
|
||||
|
||||
#pragma GCC diagnostic pop
|
||||
|
||||
#endif //MAPSAPI_H
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: PIMAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed port integration */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: PIMAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef PIMAPI_H
|
||||
#define PIMAPI_H
|
||||
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define PIMAPI_PORT_BIT_0 0x00000001
|
||||
#define PIMAPI_PORT_BIT_1 0x00000002
|
||||
#define PIMAPI_PORT_BIT_2 0x00000004
|
||||
#define PIMAPI_PORT_BIT_3 0x00000008
|
||||
#define PIMAPI_PORT_BIT_4 0x00000010
|
||||
#define PIMAPI_PORT_BIT_5 0x00000020
|
||||
#define PIMAPI_PORT_BIT_6 0x00000040
|
||||
#define PIMAPI_PORT_BIT_7 0x00000080
|
||||
#define PIMAPI_PORT_BIT_8 0x00000100
|
||||
#define PIMAPI_PORT_BIT_9 0x00000200
|
||||
#define PIMAPI_PORT_BIT_10 0x00000400
|
||||
#define PIMAPI_PORT_BIT_11 0x00000800
|
||||
#define PIMAPI_PORT_BIT_12 0x00001000
|
||||
#define PIMAPI_PORT_BIT_13 0x00002000
|
||||
#define PIMAPI_PORT_BIT_14 0x00004000
|
||||
#define PIMAPI_PORT_BIT_15 0x00008000
|
||||
#define PIMAPI_PORT_BIT_16 0x00010000
|
||||
#define PIMAPI_PORT_BIT_17 0x00020000
|
||||
#define PIMAPI_PORT_BIT_18 0x00040000
|
||||
#define PIMAPI_PORT_BIT_19 0x00080000
|
||||
#define PIMAPI_PORT_BIT_20 0x00100000
|
||||
#define PIMAPI_PORT_BIT_21 0x00200000
|
||||
#define PIMAPI_PORT_BIT_22 0x00400000
|
||||
#define PIMAPI_PORT_BIT_23 0x00800000
|
||||
#define PIMAPI_PORT_BIT_24 0x01000000
|
||||
#define PIMAPI_PORT_BIT_25 0x02000000
|
||||
#define PIMAPI_PORT_BIT_26 0x04000000
|
||||
#define PIMAPI_PORT_BIT_27 0x08000000
|
||||
#define PIMAPI_PORT_BIT_28 0x10000000
|
||||
#define PIMAPI_PORT_BIT_29 0x20000000
|
||||
#define PIMAPI_PORT_BIT_30 0x40000000
|
||||
#define PIMAPI_PORT_BIT_31 0x80000000
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PIMAPI_enPHYS_PORT_A = 0,
|
||||
PIMAPI_enPHYS_PORT_B = 1,
|
||||
PIMAPI_enPHYS_PORT_C = 2,
|
||||
PIMAPI_enPHYS_PORT_D = 3,
|
||||
PIMAPI_enPHYS_PORT_E = 4,
|
||||
PIMAPI_enVIRT_PORT_F,
|
||||
PIMAPI_enPORT_Count,
|
||||
PIMAPI_enPortInvalid
|
||||
} PIMAPI_tenPort;
|
||||
|
||||
|
||||
#endif //PIMAPI_H
|
||||
|
|
@ -0,0 +1,62 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: ProtAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed protocol */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: ProtAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef PROTAPI_H
|
||||
#define PROTAPI_H
|
||||
|
||||
#include "sys.h"
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef enum
|
||||
{
|
||||
PROTAPI_enTLKWP,
|
||||
PROTAPI_enTLUDS,
|
||||
PROTAPI_enTLUDS_UDP,
|
||||
PROTAPI_enTLJ1939,
|
||||
PROTAPI_enTLUDP,
|
||||
PROTAPI_enTLNone
|
||||
} PROTAPI_tenTLProtocol;
|
||||
/*CR1_109*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PROTAPI_enISO15765,
|
||||
PROTAPI_enISO15765_IP,
|
||||
PROTAPI_enNLNone
|
||||
} PROTAPI_tenNLProtocol;
|
||||
/*CR1_109*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
PROTAPI_enLLUARTPacked,
|
||||
PROTAPI_enLLUARTSZDelim,
|
||||
PROTAPI_enLLCAN11,
|
||||
PROTAPI_enLLCAN29,
|
||||
PROTAPI_enLL802_3,
|
||||
PROTAPI_enUSB,
|
||||
PROTAPI_enLLNone
|
||||
} PROTAPI_tenLLProtocol;
|
||||
/*CR1_109*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint8 u8DLC;
|
||||
uint32 u32ID;
|
||||
uint32 u32DWH;
|
||||
uint32 u32DWL;
|
||||
} PROTAPI_tstCANMsg;
|
||||
|
||||
#endif //PROTAPI_H
|
||||
|
|
@ -0,0 +1,33 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: ResourceAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for off micro */
|
||||
/* resources */
|
||||
/* */
|
||||
/* */
|
||||
/* FILE NAME: SpreadsAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#include <SYS.h>
|
||||
#ifdef KERNEL
|
||||
|
||||
#ifndef RESAPI_H
|
||||
#define RESAPI_H
|
||||
|
||||
#include <TYPES.h>
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SDHC_MEM,
|
||||
SPI_MEM,
|
||||
RES_Count
|
||||
} RES_tenResource;
|
||||
|
||||
#endif // RESM_H
|
||||
|
||||
#endif // KERNEL
|
||||
|
|
@ -0,0 +1,69 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: SpreadsAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed spreads */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: SpreadsAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef SPREADSAPI_H
|
||||
#define SPREADSAPI_H
|
||||
|
||||
#include <BUILD.h>
|
||||
#include <TYPES.h>
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef sint16 SPREADAPI_ttSpreadIDX;/*CR1_111*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint16 u16SpreadIndex;
|
||||
uint16 u16SpreadOffset;
|
||||
} BUILD_PACKING tstSpreadResult;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
union
|
||||
{
|
||||
tstSpreadResult stSpreadResult;
|
||||
uint32 u32Data;
|
||||
} uSpreadData;
|
||||
} BUILD_PACKING SPREADAPI_tstSpreadResult;
|
||||
|
||||
typedef void (*SPREADAPI_pfPIDResultCB)(SPREADAPI_tstSpreadResult);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SPREADAPI_enSpread1ms = 0,
|
||||
SPREADAPI_enSpread2ms = 1,
|
||||
SPREADAPI_enSpread4ms = 2,
|
||||
SPREADAPI_enSpread8ms = 3,
|
||||
SPREADAPI_enSpread16ms = 4,
|
||||
SPREADAPI_enSpread32ms = 5,
|
||||
SPREADAPI_enSpread64ms = 6,
|
||||
SPREADAPI_enSpread128ms = 7,
|
||||
SPREADAPI_enSpread256ms = 8,
|
||||
SPREADAPI_enSpread512ms = 9,
|
||||
SPREADAPI_enSpread1024ms = 10,
|
||||
SPREADAPI_enSpreadCall = 11,
|
||||
} SPREADAPI_tenSpreadRate;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
void* pvSourceData;
|
||||
void* pvSpreadData;
|
||||
TYPE_tenDataType enDataType;
|
||||
sint16 s16SpreadSize;
|
||||
SPREADAPI_tenSpreadRate enSpreadRate;
|
||||
SPREADAPI_pfPIDResultCB pfResultCB;
|
||||
} BUILD_PACKING SPREADAPI_tstSpreadCB;
|
||||
|
||||
#endif //SPREADSAPI_H
|
||||
|
|
@ -0,0 +1,221 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. */
|
||||
/* All rights reserved. */
|
||||
/******************************************************************************/
|
||||
/* */
|
||||
/* API TITLE: SYSAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required for System calls */
|
||||
/* */
|
||||
/* FILE NAME: SYSAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef SYSAPI_H
|
||||
#define SYSAPI_H
|
||||
|
||||
#include <TYPES.h>
|
||||
#include "TASKAPI.h"
|
||||
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define SYSAPI_CALL_MASK_FAIL_RES_INIT 1u
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef enum
|
||||
{
|
||||
SYSAPI_enSetSVCDataPointer = 0x1000,
|
||||
/* USER_vSVC(SYSAPI_enSetSVCDataPointer, SYSAPI_stSVCDataStruct*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enSetClientStartTask = 0x1010,
|
||||
/* USER_vSVC(SYSAPI_enSetClientStartTask, SYSAPI_tpfUserTaskFunction, TASKAPI_tenPriority*, TASKAPI_tenRateMs*) */
|
||||
|
||||
SYSAPI_enSetClientCyclicTask = 0x1011,
|
||||
/* USER_vSVC(SYSAPI_enSetClientStartTask, SYSAPI_tpfUserTaskFunction, TASKAPI_tenPriority*, TASKAPI_tenRateMs*) */
|
||||
|
||||
SYSAPI_enSetClientTerminateTask = 0x1012,
|
||||
/* USER_vSVC(SYSAPI_enSetClientStartTask, SYSAPI_tpfUserTaskFunction, TASKAPI_tenPriority*, TASKAPI_tenRateMs*) */
|
||||
|
||||
SYSAPI_enPopulateADArray = 0x1020,
|
||||
/* USER_vSVC(SYSAPI_enPopulateADArray, NULL, NULL, NULL) TBC*/
|
||||
|
||||
SYSAPI_enRequestIOResource = 0x1030,
|
||||
/* USER_vSVC(SYSAPI_enRequestIOResource, IOAPI_tenEHIOResource*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enInitialiseIOResource = 0x1031,
|
||||
/* USER_vSVC(SYSAPI_enInitialiseIOResource, IOAPI_tenEHIOResource*, IOAPI_tenEHIOType*, IOAPI_tenAsApplicable*) */
|
||||
|
||||
SYSAPI_enInitialiseCTRLResource = 0x1032,
|
||||
/* USER_vSVC(SYSAPI_enInitialiseCTRLResource, CTRLAPI_tenCTRLType, CTRLAPI_tstPIDCB*, NULL) */
|
||||
|
||||
SYSAPI_enIterateCTRLResource = 0x1033,
|
||||
/* USER_vSVC(SYSAPI_enIterateCTRLResource, CTRLAPI_tenCTRLType*, CTRLAPI_ttPIDIDX*, NULL) */
|
||||
|
||||
SYSAPI_enInitialiseSpreadResource = 0x1034,
|
||||
/* USER_vSVC(SYSAPI_enInitialiseSpreadResource, SPREADAPI_tstSpreadCB*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enCalculateSpread = 0x1035,
|
||||
/* USER_vSVC(SYSAPI_enCalculateSpread, SPREADAPI_ttSpreadIDX*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enInitialiseTableResource = 0x1036,
|
||||
/* USER_vSVC(SYSAPI_enInitialiseTableResource, TABLEAPI_tstTableCB*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enCalculateTable = 0x1037,
|
||||
/* USER_vSVC(SYSAPI_enCalculateTable, TABLEAPI_ttTableIDX*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enAssertDIOResource = 0x1050,
|
||||
/* USER_vSVC(SYSAPI_enAssertDIOResource, IOAPI_tenEHIOResource*, IOAPI_tenTriState*, NULL) */
|
||||
|
||||
SYSAPI_enTriggerADQueue = 0x1051,
|
||||
/* USER_vSVC(SYSAPI_enTriggerADQueue, ADCAPI_tenTrigger*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enRequestIOBusTransfer = 0x1052,
|
||||
/* USER_vSVC(SYSAPI_enRequestIOBusTransfer, IOAPI_tenEHIOResource*, IOAPI_tstTransferCB*, NULL) */
|
||||
|
||||
SYSAPI_enAppendTEPMQueue = 0x1053,
|
||||
/* USER_vSVC(SYSAPI_enAppendTEPMQueue, IOAPI_tenEHIOResource*, TEPMAPI_tstTimedEvent*, TEPMAPI_ttEventCount*) */
|
||||
|
||||
SYSAPI_enWriteDACQueue = 0x1054,
|
||||
/* USER_vSVC(SYSAPI_enWriteDACQueue, IOAPI_tenEHIOResource*, DACAPI_ttOutputVoltage*, NULL) */
|
||||
|
||||
SYSAPI_enSetDiagCallback = 0x1055,
|
||||
/* USER_vSVC(SYSAPI_enSetDiagCallback, DIAGAPI_tenCallBackType*, DIAGAPI_tDataWriteCB*, NULL) */
|
||||
|
||||
SYSAPI_enGetTimerValue = 0x1060,
|
||||
/* USER_vSVC(SYSAPI_enGetTimerValue, IOAPI_tenEHIOResource*, puint32*, NULL) */
|
||||
|
||||
SYSAPI_enGetCRC16 = 0x1061,
|
||||
/* USER_vSVC(SYSAPI_enGetCRC16, NULL, NULL, NULL) TBC */
|
||||
|
||||
SYSAPI_enCheckPartition = 0x1062,
|
||||
/* USER_vSVC(SYSAPI_enCheckPartition, NULL, NULL, NULL) */
|
||||
|
||||
SYSAPI_enSetupWorkingPage = 0x1063,
|
||||
/* USER_vSVC(SYSAPI_enSetupWorkingPage, puint8*, uint16*, NULL) */
|
||||
|
||||
SYSAPI_enNVMWorkingCopy = 0x1064,
|
||||
/* USER_vSVC(SYSAPI_enNVMWorkingCopy, bool*, uint16*, NULL) */
|
||||
|
||||
SYSAPI_enQueueCANMessage = 0x1065,
|
||||
|
||||
SYSAPI_enConfigureUserTEPMInput = 0x1066,
|
||||
|
||||
SYSAPI_enConfigureKernelTEPMOutput = 0x1067,
|
||||
|
||||
SYSAPI_enSetupCrankTriggerEdgePattern = 0x1068,
|
||||
|
||||
SYSAPI_enResetWatchdog = 0x1069,
|
||||
|
||||
SYSAPI_enSetupSyncPointsPattern = 0x1070,
|
||||
/* USER_vSVC(enResetWatchdog, uint16*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enInitialiseMapResource = 0x1071,
|
||||
/* USER_vSVC(SYSAPI_enInitialiseMapResource, MAPSAPI_tstMapCB*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enCalculateMap = 0x1072,
|
||||
/* USER_vSVC(SYSAPI_enCalculateMap, MAPSAPI_ttMapIDX*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enGetSpreadResult = 0x1073,
|
||||
/* USER_vSVC(SYSAPI_enGetSpreadResult, TABLEAPI_ttTableIDX*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enGetDIOResource = 0x1074,
|
||||
/* USER_vSVC(SYSAPI_enGetDIOResource, IOAPI_tenEHIOResource*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enGetRawCommsBuffer = 0x1075,
|
||||
/* USER_vSVC(SYSAPI_enGetRawCommsBuffer, IOAPI_tenEHIOResource*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enTEPMAsyncRequest = 0x1076,
|
||||
/* USER_vSVC(SYSAPI_enTEPMAsyncRequest, NULL, NULL, NULL) */
|
||||
|
||||
SYSAPI_enSetupSimpleCamSync = 0x1077,
|
||||
/* USER_vSVC(SYSAPI_enSetupSimpleCamSync, IOAPI_tenEHIOResource*, bool, NULL) */
|
||||
|
||||
SYSAPI_enSetupWatchdog = 0x1078,
|
||||
/* USER_vSVC(SYSAPI_enSetupWatchdog, puint32, uint32, NULL) */
|
||||
|
||||
SYSAPI_enGetMode1Buffer = 0x1079,
|
||||
/* USER_vSVC(SYSAPI_enGetMode1Buffer, puint32, uint32, NULL) */
|
||||
|
||||
SYSAPI_enGetMode2Buffer = 0x107a,
|
||||
/* USER_vSVC(SYSAPI_enGetMode2Buffer, puint32, uint32, NULL) */
|
||||
|
||||
SYSAPI_enGetMode3Buffer = 0x107b,
|
||||
/* USER_vSVC(SYSAPI_enGetMode3Buffer, puint32, uint32, NULL) */
|
||||
|
||||
SYSAPI_enGetMode4Buffer = 0x107c,
|
||||
/* USER_vSVC(SYSAPI_enGetMode4Buffer, puint32, uint32, NULL) */
|
||||
|
||||
SYSAPI_enGetMode6Buffer = 0x107d,
|
||||
/* USER_vSVC(SYSAPI_enGetMode6Buffer, puint32, uint32, NULL) */
|
||||
|
||||
SYSAPI_enGetMode7Buffer = 0x107e,
|
||||
/* USER_vSVC(SYSAPI_enGetMode7Buffer, puint32, uint32, NULL) */
|
||||
|
||||
SYSAPI_enGetByteQueue = 0x107f,
|
||||
/* USER_vSVC(SYSAPI_enGetByteQueue, IOAPI_tenEHIOResource*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enGetByteQueueBuffer = 0x1080,
|
||||
/* USER_vSVC(SYSAPI_enGetByteQueueBuffer, IOAPI_tenEHIOResource*, NULL, NULL) */
|
||||
|
||||
SYSAPI_enSetFuelCuts = 0x1081,
|
||||
/* USER_vSVC(SYSAPI_enSetFuelCuts, puint32, puint32, NULL) */
|
||||
|
||||
SYSAPI_enSetSparkCuts = 0x1082
|
||||
/* USER_vSVC(SYSAPI_enSetSparkCuts, puint32, puint32, NULL) */
|
||||
} SYSAPI_tenSVCID;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SYSAPI_enOK,
|
||||
SYSAPI_enFail,
|
||||
SYSAPI_enQueueFull,
|
||||
SYSAPI_enBadArgument,
|
||||
SYSAPI_enBadResource,
|
||||
SYSAPI_enResourceAlreadyAllocated,
|
||||
SYSAPI_enMasterResourceUninitialised,
|
||||
SYSAPI_enMasterResourceMismatch,
|
||||
SYSAPI_enBaudRateUnavailable,
|
||||
SYSAPI_enResourceUnavailable,
|
||||
SYSAPI_enBadCallback,
|
||||
SYSAPI_enBadCRC16,
|
||||
SYSAPI_enBadPartition,
|
||||
SYSAPI_enBadNVMWorkingCopy
|
||||
} SYSAPI_tenSVCResult;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SYSAPI_enStartOK,
|
||||
SYSAPI_enResourceRequestFailed,
|
||||
SYSAPI_enResourceInitFailed
|
||||
} SYSAPI_tenStartResult;
|
||||
|
||||
typedef uint32 SYSAPI_ttClientHandle;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SYSAPI_tenSVCResult enSVCResult;
|
||||
SYSAPI_ttClientHandle tClientHandle;/*CR1_117*/
|
||||
SYSAPI_tenSVCID enSVCID;
|
||||
void* pvArg1;
|
||||
void* pvArg2;
|
||||
void* pvArg3;
|
||||
void* pvData;
|
||||
} SYSAPI_tstSVCDataStruct;
|
||||
|
||||
/* typedef of user start, run and terminate function pointers */
|
||||
typedef void (*SYSAPI_tpfUserTaskFunction)(uint32 * const pu32Arg);/*CR1_116*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SYSAPI_tpfUserTaskFunction pfStart;
|
||||
SYSAPI_tpfUserTaskFunction pfRun;
|
||||
SYSAPI_tpfUserTaskFunction pfTerminate;
|
||||
SYSAPI_tpfUserTaskFunction pfCallBack;
|
||||
TASKAPI_tenPriority enPriority;
|
||||
TASKAPI_tenRateMs enRateMs;
|
||||
} SYSAPI_tstUserModuleFunctions;
|
||||
|
||||
|
||||
#endif // SYSAPI_H
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: TablesAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed tables */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: TablesAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef TABLESAPI_H
|
||||
#define TABLESAPI_H
|
||||
|
||||
#include <BUILD.h>
|
||||
#include <TYPES.h>
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef sint16 TABLEAPI_ttTableIDX;/*CR1_118*/
|
||||
typedef void (*TABLEAPI_pfPIDResultCB)(sint32);
|
||||
|
||||
typedef struct BUILD_PACKING
|
||||
{
|
||||
void* pvTableData;
|
||||
void* pvOutputData;
|
||||
TYPE_tenDataType enDataType;
|
||||
sint16 i16TableSize;
|
||||
SPREADAPI_ttSpreadIDX tSpreadIDX;/*CR1_119*/
|
||||
TABLEAPI_pfPIDResultCB pfResultCB;
|
||||
} TABLEAPI_tstTableCB;
|
||||
|
||||
#endif //TABLESAPI_H
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: TaskAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed application tasks */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: TaskAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef TASKAPI_H
|
||||
#define TASKAPI_H
|
||||
|
||||
#include <TYPES.h>
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef enum
|
||||
{
|
||||
TASKAPI_enTaskPrMaxAll = 0u,
|
||||
TASKAPI_enTaskPrMaxCyc = 128u,
|
||||
TASKAPI_enTaskPrLowest = 255u,
|
||||
} TASKAPI_tenPriority;/*CR1_120*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TASKAPI_enTaskCycBad = 0u,
|
||||
TASKAPI_enTask1ms = 1u,
|
||||
TASKAPI_enTask2ms = 2u,
|
||||
TASKAPI_enTask5ms = 5u,
|
||||
TASKAPI_enTask10ms = 10u,
|
||||
TASKAPI_enTask20ms = 20u,
|
||||
TASKAPI_enTask25ms = 25u,
|
||||
TASKAPI_enTask50ms = 50u,
|
||||
TASKAPI_enTask100ms = 100u,
|
||||
TASKAPI_enTask200ms = 200u,
|
||||
TASKAPI_enTask250ms = 250u,
|
||||
TASKAPI_enTaskCycNot = 255u
|
||||
} TASKAPI_tenRateMs;/*CR1_120*/
|
||||
|
||||
|
||||
#endif //TASKAPI_H
|
||||
|
||||
|
|
@ -0,0 +1,139 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* API TITLE: TepmAPI */
|
||||
/* DESCRIPTION: This API provides type definitions for objects and */
|
||||
/* functions required by Kernel managed timed events */
|
||||
/* initialisation, functions and events */
|
||||
/* */
|
||||
/* FILE NAME: TepmAPI.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef TEPMAPI_H
|
||||
#define TEPMAPI_H
|
||||
|
||||
#ifdef KERNEL_WARNINGS
|
||||
#warning define must match kernel value!!!!
|
||||
#endif
|
||||
#define TEPMAPI_nKernelEventsMax 4
|
||||
#define TEPMAPI_nUserEventsMax 4
|
||||
/*CR1_121*/
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
typedef uint32 TEPMAPI_ttEventTime;
|
||||
typedef void (*TEPMAPI_tpfEventCB)(IOAPI_tenEHIOResource, TEPMAPI_ttEventTime);
|
||||
typedef uint32 TEPMAPI_ttEventCount;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEPMAPI_enActionReset,
|
||||
TEPMAPI_enSetHigh,
|
||||
TEPMAPI_enSetLow,
|
||||
TEPMAPI_enToggle,
|
||||
TEPMAPI_enCapRising,
|
||||
TEPMAPI_enCapFalling,
|
||||
TEPMAPI_enCapAny,
|
||||
TEPMAPI_enNoAction,
|
||||
TEPMAPI_enEndProgram,
|
||||
TEPMAPI_enResetProgram
|
||||
} TEPMAPI_tenAction;/*CR1_122*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEPMAPI_enMethodReset,
|
||||
TEPMAPI_enGlobalLinkedTimeStep,
|
||||
TEPMAPI_enGlobalLinkedFractionStep,
|
||||
TEPMAPI_enGlobalLinkedFraction,
|
||||
TEPMAPI_enHardLinkedTimeStep,
|
||||
TEPMAPI_enHardLinkedFractionStep,
|
||||
TEPMAPI_enGlobalAlarm,
|
||||
TEPMAPI_enHardAlarm,
|
||||
TEPMAPI_enMaxDelta,
|
||||
TEPMAPI_enMinDelta,
|
||||
TEPMAPI_enLinkPrimaryProgram,
|
||||
TEPMAPI_enLinkVVT1Input,
|
||||
TEPMAPI_enLinkVVT2Input,
|
||||
TEPMAPI_enLinkVVT3Input,
|
||||
TEPMAPI_enLinkVVT4Input,
|
||||
TEPMAPI_enLinkFreqInput,
|
||||
TEPMAPI_enLinkDutyInput
|
||||
} TEPMAPI_tenMethod;/*CR1_122*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEPMAPI_enDiv1 = 0,
|
||||
TEPMAPI_enDiv2 = 1,
|
||||
TEPMAPI_enDiv4 = 2,
|
||||
TEPMAPI_enDiv8 = 3,
|
||||
TEPMAPI_enDiv16 = 4,
|
||||
TEPMAPI_enDiv32 = 5,
|
||||
TEPMAPI_enDiv64 = 6,
|
||||
TEPMAPI_enDiv128 = 7
|
||||
} TEPMAPI_tenPreScalar;/*CR1_122*/
|
||||
|
||||
typedef enum
|
||||
{
|
||||
TEPMAPI_enCountUp = 0,
|
||||
TEPMAPI_enCountUpDown = 1
|
||||
} TEPMAPI_tenCountType;/*CR1_122*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TEPMAPI_tenAction enAction;
|
||||
TEPMAPI_tenMethod enMethod;
|
||||
TEPMAPI_ttEventTime tEventTime;
|
||||
TEPMAPI_tpfEventCB pfEventCB;
|
||||
} TEPMAPI_tstTimedUserEvent;/*CR1_122*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TEPMAPI_tenAction enAction;
|
||||
TEPMAPI_tenMethod enMethod;
|
||||
TEPMAPI_ttEventTime* ptEventTime;
|
||||
TEPMAPI_tpfEventCB pfEventCB;
|
||||
TEPMAPI_ttEventTime tAccumulate;
|
||||
TEPMAPI_ttEventTime* ptAccumulate;
|
||||
IOAPI_tenEHIOResource enEHIOBitMirrorResource;
|
||||
} TEPMAPI_tstTimedKernelEvent;/*CR1_122*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
TEPMAPI_tenPreScalar enPreScalar;
|
||||
TEPMAPI_tenCountType enCountType;
|
||||
} TEPMAPI_tstTEPMResourceCB;/*CR1_122*/
|
||||
|
||||
typedef struct
|
||||
{
|
||||
TEPMAPI_tenAction enAction;
|
||||
TEPMAPI_tenPreScalar enPreScalar;
|
||||
bool boInterruptEnable;
|
||||
bool boAsyncRequestEnable;
|
||||
uint32 u32Sequence;
|
||||
bool boRecursive;
|
||||
IOAPI_tenEHIOResource enLinkedResource;
|
||||
} TEPMAPI_tstTEPMChannelCB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32HighTime;
|
||||
uint32 u32LowTime;
|
||||
uint32 u32RisingTime;
|
||||
uint32 u32FallingTime;
|
||||
uint32 u32Delay;
|
||||
} TEPMAPI_tstTimerMeasurements;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
bool boCamSyncHighLate;
|
||||
uint32 u32CamSyncSampleToothCount;
|
||||
} TEPMAPI_tstSimpleCamSync;
|
||||
|
||||
|
||||
#endif //TEPMAPI_H
|
||||
|
|
@ -0,0 +1,190 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Air Flow Meter */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for air flow measurement */
|
||||
/* */
|
||||
/* FILE NAME: AFM.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
#define _AFM_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "AFM.h"
|
||||
#include "MAP.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
bool AFM_boNewSample;
|
||||
EXTERN GPM6_ttUg AFM_tManChargeMassOldUg;
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
/*******************************************************************************
|
||||
* Interface : AFM_vADCCallBack
|
||||
*
|
||||
* Implementation : Callback to receive the measured ADC value
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : enEHIOResource enum of the ADC resource
|
||||
* Par2 : u32ADCResult the ADC conversion value
|
||||
*
|
||||
* Return Value : NIL
|
||||
*******************************************************************************/
|
||||
static void AFM_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult);
|
||||
SPREADAPI_ttSpreadIDX AFM_tSpreadBackupAirflowxIDX;
|
||||
SPREADAPI_ttSpreadIDX AFM_tSpreadBackupAirflowyIDX;
|
||||
MAPSAPI_ttMapIDX AFM_tMapBackupAirflowIDX;
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void AFM_vStart(puint32 const pu32Arg)
|
||||
{
|
||||
AFM_boNewSample = FALSE;
|
||||
|
||||
#ifdef BUILD_BSP_AFM_ANALOG
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_tenEHIOType enEHIOType;
|
||||
ADCAPI_tstADCCB stADCCB;
|
||||
|
||||
enEHIOResource = USERCAL_stRAMCAL.u16AFMADResource;
|
||||
enEHIOType = IOAPI_enADSE;
|
||||
stADCCB.enSamplesAv = ADCAPI_en32Samples;
|
||||
stADCCB.pfResultCB = &AFM_vADCCallBack;
|
||||
stADCCB.enTrigger = ADCAPI_enTrigger4;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, (void*)NULL, (void*)NULL);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stADCCB);
|
||||
|
||||
if (SYSAPI_enOK != pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
*pu32Arg |= (uint32)SYSAPI_enResourceRequestFailed;/*CR1_13*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*pu32Arg |= (uint32)SYSAPI_enResourceInitFailed;/*CR1_13*/
|
||||
}
|
||||
#endif
|
||||
|
||||
AFM_tSensorHertz = 0;
|
||||
|
||||
/* Request and initialise required Kernel managed spread for backup airflow x */
|
||||
AFM_tSpreadBackupAirflowxIDX = SETUP_tSetupSpread((void*)&CAM_u32RPMRaw, (void*)&USERCAL_stRAMCAL.aUserBackupAirflowxSpread, TYPE_enUInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for backup airflow y */
|
||||
AFM_tSpreadBackupAirflowyIDX = SETUP_tSetupSpread((void*)&TPS_tThetaFiltered, (void*)&USERCAL_stRAMCAL.aUserBackupAirflowySpread, TYPE_enUInt32, 11, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed map for backup airflow */
|
||||
AFM_tMapBackupAirflowIDX = SETUP_tSetupMap((void*)&USERCAL_stRAMCAL.aUserBackupAirflowMap, (void*)&AFM_tAirFlowBackupRawUg, TYPE_enUInt32, 11, 11, AFM_tSpreadBackupAirflowxIDX, AFM_tSpreadBackupAirflowyIDX, NULL);
|
||||
}
|
||||
|
||||
void AFM_vRun(puint32 const pu32Arg)
|
||||
{
|
||||
uint32 u32Temp;
|
||||
uint8 u8ManifoldTimeConstantFilter;
|
||||
SPREADAPI_tstSpreadResult* pstSpreadResultAirflowBackupX;
|
||||
SPREADAPI_tstSpreadResult* pstSpreadResultAirflowBackupY;
|
||||
uint32 u32TableIDXx = ~0;
|
||||
uint32 u32TableIDXy = ~0;
|
||||
|
||||
if (TRUE == AFM_boNewSample)
|
||||
{
|
||||
USER_xEnterCritical();/*CR1_16*/
|
||||
(void)USERMATH_u16SinglePoleLowPassFilter16((uint16)AFM_u32ADCRaw, AFM_nADFiltVal,
|
||||
&AFM_u32ADCFiltered);
|
||||
AFM_boNewSample = FALSE;
|
||||
USER_xExitCritical();/*CR1_16*/
|
||||
|
||||
u32Temp = AFM_u32ADCFiltered * SENSORS_nADRefVolts;
|
||||
u32Temp /= SENSORS_nADScaleMax;
|
||||
u32Temp /= SENSORS_nVDivRatio;
|
||||
|
||||
AFM_tSensorVolts = u32Temp;
|
||||
|
||||
(void)BOOSTED_boIndexAndCalculateMap(AFM_tSpreadBackupAirflowxIDX, AFM_tSpreadBackupAirflowyIDX, AFM_tMapBackupAirflowIDX);
|
||||
|
||||
u8ManifoldTimeConstantFilter = USERMATH_u8GetFilterFromTimeConstant(0x01, TPS_u32ManifoldVolumeTau );
|
||||
u8ManifoldTimeConstantFilter = ~u8ManifoldTimeConstantFilter;
|
||||
u8ManifoldTimeConstantFilter++;
|
||||
|
||||
AFM_tAirFlowBackupUg = USERMATH_u32SinglePoleLowPassFilter32(AFM_tAirFlowBackupRawUg, u8ManifoldTimeConstantFilter, &AFM_tAirFlowBackupUg);
|
||||
|
||||
if (0 == TPS_u32ThrottleMovingCounter)
|
||||
{
|
||||
/* Get the current x spread for backup airflow */
|
||||
pstSpreadResultAirflowBackupX = BOOSTED_pstGetSpread(AFM_tSpreadBackupAirflowxIDX);
|
||||
|
||||
/* Get the current x spread for backup airflow */
|
||||
pstSpreadResultAirflowBackupY = BOOSTED_pstGetSpread(AFM_tSpreadBackupAirflowyIDX);
|
||||
|
||||
u32TableIDXx = (0x1000u > pstSpreadResultAirflowBackupX->uSpreadData.stSpreadResult.u16SpreadOffset) ? pstSpreadResultAirflowBackupX->uSpreadData.stSpreadResult.u16SpreadIndex : u32TableIDXx;
|
||||
u32TableIDXx = (0xf000u < pstSpreadResultAirflowBackupX->uSpreadData.stSpreadResult.u16SpreadOffset) ? pstSpreadResultAirflowBackupX->uSpreadData.stSpreadResult.u16SpreadIndex + 1 : u32TableIDXx;
|
||||
u32TableIDXy = (0x1000u > pstSpreadResultAirflowBackupY->uSpreadData.stSpreadResult.u16SpreadOffset) ? pstSpreadResultAirflowBackupY->uSpreadData.stSpreadResult.u16SpreadIndex : u32TableIDXy;
|
||||
u32TableIDXy = (0xf000u < pstSpreadResultAirflowBackupY->uSpreadData.stSpreadResult.u16SpreadOffset) ? pstSpreadResultAirflowBackupY->uSpreadData.stSpreadResult.u16SpreadIndex + 1 : u32TableIDXy;
|
||||
|
||||
/* If the indexes are valid then learn the new airflow */
|
||||
if ((0xffffffff != u32TableIDXx) && (0xffffffff != u32TableIDXy))
|
||||
{
|
||||
u32Temp = AFM_tAirFlowAFMUg / 4 + (3 * USERCAL_stRAMCAL.aUserBackupAirflowMap[u32TableIDXx][u32TableIDXy]) / 4;
|
||||
USERCAL_stRAMCAL.aUserBackupAirflowMap[u32TableIDXx][u32TableIDXy] = u32Temp;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate predicted VE method airflow */
|
||||
u32Temp = MAP_u16VE * USERCAL_stRAMCAL.u16CylinderCC * USERCAL_stRAMCAL.u8CylCount / 120;
|
||||
u32Temp *= CAM_u32RPMRaw;
|
||||
u32Temp /= 10000;
|
||||
u32Temp *= MAP_tKiloPaFiltered;
|
||||
u32Temp /= 10000;
|
||||
|
||||
/* Correct for air temperature */
|
||||
u32Temp = (u32Temp * 2980 ) / ((ATS_tTempCPort / 100) + 2730);
|
||||
AFM_tAirFlowVEUg = 1225 * u32Temp;
|
||||
|
||||
#ifdef BUILD_BSP_AFM_FREQ
|
||||
/* Calculate current running VE */
|
||||
u32Temp = USERCAL_stRAMCAL.u16CylinderCC * USERCAL_stRAMCAL.u8CylCount / 120;
|
||||
u32Temp *= CAM_u32RPMFiltered;
|
||||
u32Temp /= 10;
|
||||
u32Temp *= MAP_tKiloPaFiltered;
|
||||
u32Temp /= 10000;
|
||||
u32Temp *= 1225;
|
||||
u32Temp /= 1000;
|
||||
AFM_u16LearnVE = AFM_tAirFlowAFMUg / u32Temp;
|
||||
#endif
|
||||
}
|
||||
|
||||
void AFM_vTerminate(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void AFM_vCallBack(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
static void __attribute__((used)) AFM_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult)
|
||||
{
|
||||
AFM_u32ADCRaw = u32ADCResult;
|
||||
AFM_boNewSample = TRUE;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,63 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Air Flow Meter Sensor Header File */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for air flow measurement */
|
||||
/* */
|
||||
/* FILE NAME: AFM.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef AFM_H
|
||||
#define AFM_H
|
||||
|
||||
#include <string.h>
|
||||
#include "boosted.h"
|
||||
#include "IOAPI.h"
|
||||
#include "USER.h"
|
||||
#include "units.h"
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define AFM_nVoltsFilteredInitVal (uint32)(0u)
|
||||
#define AFM_nADFiltVal (0x10)
|
||||
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _AFM_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
EXTERN uint32 AFM_u32ADCRaw;
|
||||
//ASAM mode=readvalue name="AFM Sensor ADC" type=uint32 offset=0 min=0 max=4095 m=1 b=0 units="dl" format=5.3 help="AFM Sensor ADC Counts"
|
||||
EXTERN uint32 AFM_u32ADCFiltered;
|
||||
EXTERN GPM6_ttHertz AFM_tSensorHertz;/*CR1_88*/
|
||||
//ASAM mode=readvalue name="AFM Sensor Frequency" type=uint32 offset=0 min=0 max=65535 m=1 b=0 units="Hz" format=5.3 help="AFM Sensor Flow"
|
||||
EXTERN GPM6_ttVolts AFM_tSensorVolts;/*CR1_88*/
|
||||
//ASAM mode=readvalue name="AFM Sensor Voltage" type=uint32 offset=0 min=0 max=5 m=0.001 b=0 units="V" format=5.3 help="AFM Sensor Flow"
|
||||
EXTERN GPM6_ttUg AFM_tAirFlowAFMUg;
|
||||
//ASAM mode=readvalue name="AFM Sensor Mass Flow" type=uint32 offset=0 min=0 max=5 m=0.001 b=0 units="V" format=5.3 help="AFM Sensor Flow"
|
||||
EXTERN GPM6_ttUg AFM_tAirFlowBackupUg;
|
||||
//ASAM mode=readvalue name="AFM Sensor Mass Filtered Backup" type=uint32 offset=0 min=0 max=5 m=0.001 b=0 units="V" format=5.3 help="AFM Sensor Flow Filtered"
|
||||
EXTERN GPM6_ttUg AFM_tAirFlowBackupRawUg;
|
||||
EXTERN GPM6_ttUg AFM_tAirFlowAFMRawUg;
|
||||
//ASAM mode=readvalue name="AFM Sensor Mass Flow Raw" type=uint32 offset=0 min=0 max=5 m=0.001 b=0 units="V" format=5.3 help="AFM Sensor Flow Raw"
|
||||
EXTERN GPM6_ttUg AFM_tAirFlowVEUg;
|
||||
EXTERN uint16 AFM_u16LearnVE;
|
||||
//ASAM mode=readvalue name="AFM VE Learn" type=uint16 offset=0 min=0 max=2 m=0.001 b=0 units="dl" format=5.3 help="AFM VE Learn"
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void AFM_vStart(uint32 * const pu32Arg);
|
||||
void AFM_vRun(uint32* const pu32Arg);
|
||||
void AFM_vTerminate(uint32* const pu32Arg);
|
||||
void AFM_vCallBack(puint32 const pu32Arg);
|
||||
|
||||
#endif // AFM_H
|
|
@ -0,0 +1,261 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Air Temperature */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for air temperature */
|
||||
/* measurement */
|
||||
/* FILE NAME: ATS.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _ATS_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "ATS.h"
|
||||
#include "CTS.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
bool ATS_boNewSample;
|
||||
SPREADAPI_ttSpreadIDX ATS_tSpreadSensorIDX;
|
||||
SPREADAPI_ttSpreadIDX ATS_tSpreadEnrichmentIDX;
|
||||
TABLEAPI_ttTableIDX ATS_tTableSensorIDX;
|
||||
TABLEAPI_ttTableIDX ATS_tTableEnrichmentIDX;
|
||||
|
||||
sint32 ATS_i32Enrichment;
|
||||
uint32 ATS_u32SampleCount;
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
/*******************************************************************************
|
||||
* Interface : ATS_vADCCallBack
|
||||
*
|
||||
* Implementation : Callback to receive the measured ADC value
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : enEHIOResource enum of the ADC resource
|
||||
* Par2 : u32ADCResult the ADC conversion value
|
||||
*
|
||||
* Return Value : NIL
|
||||
*******************************************************************************/
|
||||
static void ATS_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult);
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void ATS_vStart(puint32 const pu32Arg)
|
||||
{
|
||||
ATS_u32ADCRaw = 0;
|
||||
ATS_u32FuelMultiplier = 1000;
|
||||
ATS_u32SampleCount = 0;
|
||||
ATS_boNewSample = FALSE;
|
||||
ATS_tTempCRaw = 20000;
|
||||
|
||||
if (FALSE == USERCAL_stRAMCAL.boATSCANPrimary)
|
||||
{
|
||||
/* Request and initialise the ATS ADC input channel */
|
||||
SETUP_boSetupADSE(USERCAL_stRAMCAL.u16ATSADResource, IOAPI_enADSE, ADCAPI_en32Samples, &ATS_vADCCallBack, ADCAPI_enTrigger2, pu32Arg);
|
||||
}
|
||||
|
||||
/* Request and initialise required Kernel managed spread for air sensor */
|
||||
ATS_tSpreadSensorIDX = SETUP_tSetupSpread((void*)&ATS_tSensorVolts, (void*)&USERCAL_stRAMCAL.aUserCoolantSensorSpread, TYPE_enUInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for air sensor */
|
||||
ATS_tTableSensorIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserCoolantSensorTable, (void*)&ATS_tTempCRaw, TYPE_enInt32, 17, ATS_tSpreadSensorIDX, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for air temp enrichment */
|
||||
ATS_tSpreadEnrichmentIDX = SETUP_tSetupSpread((void*)&ATS_tTempCPort, (void*)&USERCAL_stRAMCAL.aUserAirTempCorrectionSpread, TYPE_enInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for air temp enrichment */
|
||||
ATS_tTableEnrichmentIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserAirTempCorrectionTable, (void*)&ATS_i32Enrichment, TYPE_enUInt16, 17, ATS_tSpreadEnrichmentIDX, NULL);
|
||||
}
|
||||
|
||||
void ATS_vRun(puint32 const pu32Arg)
|
||||
{
|
||||
uint32 u32Temp;
|
||||
sint32 s32Temp;
|
||||
#ifdef BUILD_ATS_PULLUP_SENSE
|
||||
volatile static uint32 u32Delta;
|
||||
static uint32 u32LowImpModeCount;
|
||||
static uint32 u32HighImpModeCount;
|
||||
static bool boHotMode;
|
||||
static bool boColdMode;
|
||||
#endif
|
||||
static uint32 u32CANATSMsgCount = 0;
|
||||
static uint8 u8CANATSOld = 0;
|
||||
static uint32 u32RunCount;
|
||||
|
||||
|
||||
if ((TRUE == ATS_boNewSample) || (true == SENSORS_boCANATSNewSample))
|
||||
{
|
||||
ATS_u32SampleCount++;
|
||||
|
||||
if (FALSE == USERCAL_stRAMCAL.boATSCANPrimary)
|
||||
{
|
||||
USER_xEnterCritical();/*CR1_16*/
|
||||
(void)USERMATH_u16SinglePoleLowPassFilter16((uint16)ATS_u32ADCRaw, ATS_nADFiltVal,
|
||||
&ATS_u32ADCFiltered);
|
||||
ATS_boNewSample = FALSE;
|
||||
USER_xExitCritical();/*CR1_16*/
|
||||
|
||||
#ifdef BUILD_ATS_PULLUP_SENSE
|
||||
if ((FALSE == SENSORS_boATSACBiasHigh) && ((0x100 * ATS_u32ADCRaw) > ATS_u32ADCFiltered))
|
||||
{
|
||||
u32Temp = 0x100 * ATS_u32ADCRaw - ATS_u32ADCFiltered;
|
||||
u32Delta = (u32Temp + 3 * u32Delta) / 4;
|
||||
}
|
||||
else if ((TRUE == SENSORS_boATSACBiasHigh) && ((0x100 * ATS_u32ADCRaw) < ATS_u32ADCFiltered))
|
||||
{
|
||||
u32Temp = ATS_u32ADCFiltered - 0x100 * ATS_u32ADCRaw;
|
||||
u32Delta = (u32Temp + 3 * u32Delta) / 4;
|
||||
}
|
||||
|
||||
if (0 == CAM_u32RPMRaw)
|
||||
{
|
||||
if (10000 < u32Delta)
|
||||
{
|
||||
u32HighImpModeCount = 40 > u32HighImpModeCount ? u32HighImpModeCount + 1 : u32HighImpModeCount;
|
||||
u32LowImpModeCount = 2 < u32LowImpModeCount ? u32LowImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
if (7000 > u32Delta)
|
||||
{
|
||||
u32LowImpModeCount = 40 > u32LowImpModeCount ? u32LowImpModeCount + 1 : u32LowImpModeCount;
|
||||
u32HighImpModeCount = 2 < u32HighImpModeCount ? u32HighImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
boColdMode = 35 < u32HighImpModeCount;
|
||||
boHotMode = 35 < u32LowImpModeCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (15000 < u32Delta)
|
||||
{
|
||||
u32HighImpModeCount = 1000 > u32HighImpModeCount ? u32HighImpModeCount + 1 : u32HighImpModeCount;
|
||||
u32LowImpModeCount = 2 < u32LowImpModeCount ? u32LowImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
if (10000 > u32Delta)
|
||||
{
|
||||
u32LowImpModeCount = 1000 > u32LowImpModeCount ? u32LowImpModeCount + 1 : u32LowImpModeCount;
|
||||
u32HighImpModeCount = 2 < u32HighImpModeCount ? u32HighImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
boColdMode = 500 < u32HighImpModeCount;
|
||||
boHotMode = 500 < u32LowImpModeCount;
|
||||
}
|
||||
|
||||
|
||||
if (((FALSE == boHotMode) && (FALSE == boColdMode)) ||
|
||||
((TRUE == boHotMode) && (TRUE == boColdMode)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif //BUILD_BSP_ATS_PULLUP_SENSE
|
||||
|
||||
u32Temp = ATS_u32ADCFiltered * SENSORS_nADRefVolts;
|
||||
u32Temp /= SENSORS_nADScaleMax;
|
||||
u32Temp /= SENSORS_nVDivRatio;
|
||||
ATS_tSensorVolts = u32Temp;
|
||||
|
||||
/* Calculate the current spread for air temp sensor */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&ATS_tSpreadSensorIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current spread for air temp sensor */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&ATS_tTableSensorIDX,
|
||||
NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0xff != SENSORS_u8CANATS)
|
||||
{
|
||||
ATS_tTempCRaw = 1000 * (sint32)(SENSORS_u8CANATS - 40);
|
||||
SENSORS_boCANATSNewSample = FALSE;
|
||||
|
||||
u32CANATSMsgCount++;
|
||||
|
||||
if ((3 < u32CANATSMsgCount) &&
|
||||
(u8CANATSOld == SENSORS_u8CANATS) &&
|
||||
(0 != SENSORS_u8CANATS))
|
||||
{
|
||||
ATS_boATSReady = TRUE;
|
||||
}
|
||||
else if (10 < u32CANATSMsgCount)
|
||||
{
|
||||
ATS_boATSReady = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ATS_tTempCRaw = 0;
|
||||
}
|
||||
|
||||
u8CANATSOld = SENSORS_u8CANATS;
|
||||
}
|
||||
|
||||
|
||||
if ((0 == CAM_u32RPMRaw) || (TRUE == USERCAL_stRAMCAL.boATSCANPrimary))
|
||||
{
|
||||
ATS_tTempCFiltered = ATS_tTempCRaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ATS_tTempCRaw < ATS_tTempCFiltered)
|
||||
{
|
||||
ATS_tTempCFiltered -= 50;
|
||||
}
|
||||
else if (ATS_tTempCRaw > ATS_tTempCFiltered)
|
||||
{
|
||||
ATS_tTempCFiltered += 50;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (0 == (u32RunCount % 0x20))
|
||||
{
|
||||
u32Temp = 110000 > MAP_tKiloPaFiltered ? MAP_tKiloPaFiltered : 110000;
|
||||
s32Temp = ((110 - ((sint32)u32Temp / 1000u)) * CTS_tTempCFiltered) + (((sint32)u32Temp / 1000u) * ATS_tTempCFiltered);
|
||||
ATS_tTempCPort = s32Temp / 110;
|
||||
|
||||
|
||||
/* Calculate the current spread for air temp enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&ATS_tSpreadEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current spread for air temp enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&ATS_tTableEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
s32Temp = ATS_i32Enrichment;
|
||||
ATS_u32FuelMultiplier = (uint32)s32Temp;
|
||||
}
|
||||
|
||||
u32RunCount++;
|
||||
}
|
||||
|
||||
void ATS_vTerminate(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ATS_vCallBack(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void __attribute__((used)) ATS_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult)
|
||||
{
|
||||
ATS_u32ADCRaw = u32ADCResult;
|
||||
ATS_boNewSample = TRUE;
|
||||
}
|
||||
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,55 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Coolant Temperature Header File */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for coolant temperature */
|
||||
/* measurement */
|
||||
/* FILE NAME: ATS.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef ATS_H
|
||||
#define ATS_H
|
||||
|
||||
#include <string.h>
|
||||
#include "IOAPI.h"
|
||||
#include "SENSORS.h"
|
||||
#include "USER.h"
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define ATS_nADFiltVal (0x10)
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _ATS_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
EXTERN uint32 ATS_u32ADCRaw;
|
||||
EXTERN uint32 ATS_u32ADCFiltered;
|
||||
//ASAM mode=readvalue name="Air Sensor Filtered ADC" type=uint32 offset=0 min=0 max=1048575 m=1 b=0 units="counts" format=5.3 help="ATS Sensor ADC"
|
||||
EXTERN GPM6_ttVolts ATS_tSensorVolts;/*CR1_88*/
|
||||
//ASAM mode=readvalue name="ATS Sensor Voltage" type=uint32 offset=0 min=0 max=5 m=0.001 b=0 units="V" format=3.2 help="ATS Sensor Voltage"
|
||||
EXTERN GPM6_ttTempC ATS_tTempCRaw;
|
||||
EXTERN GPM6_ttTempC ATS_tTempCPort;
|
||||
EXTERN GPM6_ttTempC ATS_tTempCFiltered;
|
||||
//ASAM mode=readvalue name="Air Temperature" type=uint32 offset=0 min=0 max=200 m=0.001 b=0 units="degrees C" format=4.1 help="Air Temperature"
|
||||
EXTERN uint32 ATS_u32FuelMultiplier;
|
||||
EXTERN bool ATS_boATSReady;
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void ATS_vStart(uint32 * const pu32Arg);
|
||||
void ATS_vRun(uint32* const pu32Arg);
|
||||
void ATS_vTerminate(uint32* const pu32Arg);
|
||||
void ATS_vThread(void);
|
||||
void ATS_vCallBack(puint32 const pu32Arg);
|
||||
|
||||
#endif // ATS_H
|
||||
|
|
@ -0,0 +1,99 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Setup */
|
||||
/* DESCRIPTION: This code assist with the setup of kernel managed */
|
||||
/* resources */
|
||||
/* */
|
||||
/* FILE NAME: BOOSTED.c */
|
||||
/* REVISION HISTORY: 14-04-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _BOOSTED_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "BOOSTED.h"
|
||||
#include "os.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
bool BOOSTED_boIndexAndCalculateMap(SPREADAPI_ttSpreadIDX tSpreadxIDX, SPREADAPI_ttSpreadIDX tSpreadyIDX, MAPSAPI_ttMapIDX tMapIDX)
|
||||
{
|
||||
bool boRetVal = false;
|
||||
|
||||
if ((-1 != tSpreadxIDX) && (-1 != tSpreadyIDX) && (-1 != tMapIDX))
|
||||
{
|
||||
/* Calculate the current spread for Map IDXx */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&tSpreadxIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Calculate the current spread for Map IDXy */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&tSpreadyIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current value for Map */
|
||||
USER_vSVC(SYSAPI_enCalculateMap, (void*)&tMapIDX,
|
||||
NULL, NULL);
|
||||
|
||||
boRetVal = true;
|
||||
}
|
||||
|
||||
return boRetVal;
|
||||
}
|
||||
|
||||
bool BOOSTED_boIndexAndCalculateTable(SPREADAPI_ttSpreadIDX tSpreadIDX, TABLEAPI_ttTableIDX tTableIDX)
|
||||
{
|
||||
bool boRetVal = false;
|
||||
|
||||
if (-1 != tSpreadIDX)
|
||||
{
|
||||
/* Calculate the current spread for Table IDX */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&tSpreadIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current value for Table */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&tTableIDX,
|
||||
NULL, NULL);
|
||||
|
||||
boRetVal = true;
|
||||
}
|
||||
|
||||
return boRetVal;
|
||||
}
|
||||
|
||||
SPREADAPI_tstSpreadResult* BOOSTED_pstGetSpread(SPREADAPI_ttSpreadIDX tSpreadxIDX)
|
||||
{
|
||||
SPREADAPI_ttSpreadIDX stSpreadxIDX = tSpreadxIDX;
|
||||
|
||||
USER_vSVC(SYSAPI_enGetSpreadResult, (void*)&stSpreadxIDX,
|
||||
NULL, NULL);
|
||||
|
||||
return OS_stSVCDataStruct.pvArg1;
|
||||
}
|
||||
|
||||
void BOOSTED_vResetSVCResult(void)
|
||||
{
|
||||
pstSVCDataStruct->enSVCResult = SYSAPI_enOK;
|
||||
}
|
||||
|
||||
void BOOSTED_vEnableWatchdog(uint16 u16ReloadCount, uint16 u16WindowCount)
|
||||
{
|
||||
USER_vSVC(SYSAPI_enSetupWatchdog, (void*)&u16ReloadCount,
|
||||
(void*)&u16WindowCount, NULL);
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,40 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Setup Header */
|
||||
/* DESCRIPTION: This code assist with the setup of kernel managed */
|
||||
/* resources */
|
||||
/* */
|
||||
/* FILE NAME: BOOSTED.c */
|
||||
/* REVISION HISTORY: 14-04-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef BOOSTED_H
|
||||
#define BOOSTED_H
|
||||
|
||||
#include <string.h>
|
||||
#include "IOAPI.h"
|
||||
#include "MAPSAPI.h"
|
||||
#include "USER.h"
|
||||
#include "SYS.h"
|
||||
#include "SPREADSAPI.h"
|
||||
#include "TABLESAPI.h"
|
||||
#include "TEPMAPI.h"
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
bool BOOSTED_boIndexAndCalculateMap(SPREADAPI_ttSpreadIDX, SPREADAPI_ttSpreadIDX, MAPSAPI_ttMapIDX);
|
||||
bool BOOSTED_boIndexAndCalculateTable(SPREADAPI_ttSpreadIDX, TABLEAPI_ttTableIDX);
|
||||
SPREADAPI_tstSpreadResult* BOOSTED_pstGetSpread(SPREADAPI_ttSpreadIDX);
|
||||
void BOOSTED_vResetSVCResult(void);
|
||||
void BOOSTED_vEnableWatchdog(uint16, uint16);
|
||||
|
||||
#endif // BOOSTED_H
|
||||
|
|
@ -0,0 +1,176 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Battery Voltage */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for battery voltage */
|
||||
/* measurement */
|
||||
/* FILE NAME: BVM.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _BVM_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include <BUILD.h>
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "BVM.h"
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
uint32 BVM_u32ADCRaw;
|
||||
uint32 BVM_u32ADCFiltered;
|
||||
uint32 BVM_u32ADCPreFiltered;
|
||||
bool BVM_boNewSample;
|
||||
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
/*******************************************************************************
|
||||
* Interface : BVM_vADCCallBack
|
||||
*
|
||||
* Implementation : Callback to receive the measured ADC value
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : enEHIOResource enum of the ADC resource
|
||||
* Par2 : u32ADCResult the ADC conversion value
|
||||
*
|
||||
* Return Value : NIL
|
||||
*******************************************************************************/
|
||||
static void BVM_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult);/*CR1_11*//*CR1_10*/
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void BVM_vStart(uint32 * const pu32Arg)
|
||||
{
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_tenEHIOType enEHIOType;
|
||||
ADCAPI_tstADCCB stADCCB;
|
||||
|
||||
BVM_u32ADCFiltered = BVM_nVoltsFilteredInitVal;/*CR1_9*/
|
||||
BVM_u32ADCRaw = 0;/*CR1_9*//*CR1_15*/
|
||||
|
||||
enEHIOResource = BVM_nADInput;
|
||||
enEHIOType = IOAPI_enADSE;
|
||||
stADCCB.enSamplesAv = ADCAPI_en32Samples;
|
||||
stADCCB.pfResultCB = &BVM_vADCCallBack;
|
||||
stADCCB.enTrigger = ADCAPI_enTrigger4;
|
||||
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, (void*)NULL, (void*)NULL);/*CR1_12*/
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stADCCB);
|
||||
|
||||
if (SYSAPI_enOK != pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
*pu32Arg |= (uint32)SYSAPI_enResourceRequestFailed;/*CR1_13*/
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
*pu32Arg |= (uint32)SYSAPI_enResourceInitFailed;/*CR1_13*/
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void BVM_vRun(uint32* const pu32Arg)
|
||||
{
|
||||
static uint32 u32SecondDerivativeLimitNeg = 0;
|
||||
static uint32 u32SecondDerivativeLimitPos = 0;
|
||||
|
||||
if (TRUE == BVM_boNewSample)
|
||||
{
|
||||
/* User can add filtering */
|
||||
BVM_u32ADCPreFiltered = USERMATH_u32SinglePoleLowPassFilter32(BVM_u32ADCRaw, 0x40, &BVM_u32ADCPreFiltered);
|
||||
|
||||
if (BVM_u32ADCPreFiltered > BVM_u32ADCFiltered)
|
||||
{
|
||||
/* New sample higher than pre-filter */
|
||||
if (u32SecondDerivativeLimitPos < (BVM_u32ADCPreFiltered - BVM_u32ADCFiltered))
|
||||
{
|
||||
u32SecondDerivativeLimitPos += BVM_nSecondDerivativeChangeLimit;
|
||||
|
||||
if (u32SecondDerivativeLimitPos < (BVM_u32ADCPreFiltered - BVM_u32ADCFiltered))
|
||||
{
|
||||
BVM_u32ADCFiltered += u32SecondDerivativeLimitPos;
|
||||
}
|
||||
else
|
||||
{
|
||||
BVM_u32ADCFiltered = BVM_u32ADCPreFiltered;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BVM_u32ADCFiltered = BVM_u32ADCPreFiltered;
|
||||
}
|
||||
|
||||
u32SecondDerivativeLimitNeg = BVM_nSecondDerivativeChangeLimit <= u32SecondDerivativeLimitNeg ? u32SecondDerivativeLimitNeg - BVM_nSecondDerivativeChangeLimit : 0;
|
||||
u32SecondDerivativeLimitNeg = BVM_nSecondDerivativeChangeLimit <= u32SecondDerivativeLimitNeg ? u32SecondDerivativeLimitNeg - BVM_nSecondDerivativeChangeLimit : 0;
|
||||
}
|
||||
else if (BVM_u32ADCPreFiltered < BVM_u32ADCFiltered)
|
||||
/* New sample lower than pre-filter */
|
||||
{
|
||||
if (u32SecondDerivativeLimitNeg < (BVM_u32ADCFiltered - BVM_u32ADCPreFiltered))
|
||||
{
|
||||
u32SecondDerivativeLimitNeg += BVM_nSecondDerivativeChangeLimit;
|
||||
|
||||
if (u32SecondDerivativeLimitNeg < (BVM_u32ADCFiltered - BVM_u32ADCPreFiltered))
|
||||
{
|
||||
BVM_u32ADCFiltered -= u32SecondDerivativeLimitNeg;
|
||||
}
|
||||
else
|
||||
{
|
||||
BVM_u32ADCFiltered = BVM_u32ADCPreFiltered;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
BVM_u32ADCFiltered = BVM_u32ADCPreFiltered;
|
||||
}
|
||||
|
||||
u32SecondDerivativeLimitPos = BVM_nSecondDerivativeChangeLimit <= u32SecondDerivativeLimitPos ? u32SecondDerivativeLimitPos - BVM_nSecondDerivativeChangeLimit : 0;
|
||||
u32SecondDerivativeLimitPos = BVM_nSecondDerivativeChangeLimit <= u32SecondDerivativeLimitPos ? u32SecondDerivativeLimitPos - BVM_nSecondDerivativeChangeLimit : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32SecondDerivativeLimitPos = BVM_nSecondDerivativeChangeLimit <= u32SecondDerivativeLimitPos ? u32SecondDerivativeLimitPos - BVM_nSecondDerivativeChangeLimit : 0;
|
||||
u32SecondDerivativeLimitNeg = BVM_nSecondDerivativeChangeLimit <= u32SecondDerivativeLimitNeg ? u32SecondDerivativeLimitNeg - BVM_nSecondDerivativeChangeLimit : 0;
|
||||
}
|
||||
|
||||
BVM_u32ADCFiltered = (uint32)0x7fffffff < BVM_u32ADCFiltered ? 0 : BVM_u32ADCFiltered;
|
||||
|
||||
BVM_tBattVolts = CONV_tADCToVolts(BVM_nADInput, BVM_u32ADCFiltered);
|
||||
BVM_boNewSample = FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
void BVM_vTerminate(uint32* const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void BVM_vCallBack(uint32* const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void BVM_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult)
|
||||
{
|
||||
BVM_u32ADCRaw = u32ADCResult;
|
||||
BVM_boNewSample = TRUE;
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,73 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Battery Voltage Header File */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for battery voltage */
|
||||
/* measurement */
|
||||
/* FILE NAME: BVM.h */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef BVM_H
|
||||
#define BVM_H
|
||||
|
||||
#include <DECLARATIONS.h>
|
||||
#include "ADCAPI.h"
|
||||
#include "CONV.h"
|
||||
#include "IOAPI.h"
|
||||
#include "SYSAPI.h"
|
||||
#include "UNITS.h"
|
||||
#include "USER.h"
|
||||
#include "USERMATH.h"
|
||||
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define BVM_nVoltsFilteredInitVal (uint32)(1000 * 12)
|
||||
#define BVM_nSecondDerivativeChangeLimit 1
|
||||
/*CR1_87*/
|
||||
|
||||
#ifdef BUILD_SPARKDOG_PF
|
||||
#define BVM_nADInput EH_IO_GPSE6
|
||||
#endif //BUILD_SPARKDOG_PF
|
||||
|
||||
#ifdef BUILD_SPARKDOG_TEENSY_ADAPT
|
||||
#define BVM_nADInput EH_IO_GPSE2
|
||||
#endif //BUILD_SPARKDOG_PF
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _BVM_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif //BUILD_MK60
|
||||
|
||||
#ifdef BUILD_MK60
|
||||
#define BVM_nRESAD EH_IO_GPSE7
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_MK64
|
||||
#define BVM_nRESAD EH_IO_UART1_CTS
|
||||
#endif //BUILD_MK64
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
EXTERN GPM6_ttVolts BVM_tBattVolts;/*CR1_88*/
|
||||
//ASAM mode=readvalue name="Battery Voltage" type=uint32 offset=0 min=0 max=20 m=0.001 b=0 units="V" format=5.3 help="Battery Voltage"
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void BVM_vStart(uint32* const pu32Arg);
|
||||
void BVM_vRun(uint32* const pu32Arg);
|
||||
void BVM_vTerminate(uint32* const pu32Arg);
|
||||
void BVM_vCallBack(uint32* const pu32Arg);
|
||||
void BVM_vThread(void);
|
||||
|
||||
#endif // BVM_H
|
||||
|
|
@ -0,0 +1,174 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Cyclic Activity Manager */
|
||||
/* DESCRIPTION: This code module initialises the required */
|
||||
/* resources and functions for cyclic activites */
|
||||
/* */
|
||||
/* FILE NAME: CAM.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _CAM_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "FUEL.h"
|
||||
#include "CAM.h"
|
||||
#include "CTS.h"
|
||||
#include "FME.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
uint32 CAM_u32RPMTimeout;
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void CAM_vStart(puint32 const pu32Arg)
|
||||
{
|
||||
CAM_u32RPMTimeout = 0;
|
||||
FUEL_boFuelPumpOn = TRUE;
|
||||
}
|
||||
|
||||
void CAM_vRun(puint32 const pu32Arg)
|
||||
{
|
||||
uint32_t u32SeqIDX;
|
||||
static uint32 u32EngineStoppedCounter = 0;
|
||||
|
||||
|
||||
if ((CAM_nPeriodRPMTimeout / CAM_nPeriodMs) > CAM_u32RPMTimeout)
|
||||
{
|
||||
CAM_u32RPMTimeout++;
|
||||
}
|
||||
else
|
||||
{
|
||||
CAM_u32RPMRaw = 0;
|
||||
CAM_u32RPMRawOld = 0;
|
||||
}
|
||||
|
||||
if (0 == CAM_u32RPMRaw)
|
||||
{
|
||||
if (USERCAL_stRAMCAL.u8FuelPumpPrimerTime <= CAM_u32EngineStoppedTimer)
|
||||
{
|
||||
FUEL_boFuelPumpOn = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0 == (u32EngineStoppedCounter % (1000u / CAM_nPeriodMs)))
|
||||
{
|
||||
CAM_u32EngineStoppedTimer++;
|
||||
}
|
||||
|
||||
u32EngineStoppedCounter++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CAM_u32EngineStoppedTimer = 0;
|
||||
FUEL_boFuelPumpOn = TRUE;
|
||||
|
||||
if (0 < u32EngineStoppedCounter)
|
||||
{
|
||||
u32EngineStoppedCounter--;
|
||||
|
||||
if (0 == u32EngineStoppedCounter)
|
||||
{
|
||||
FME_vDiagClearHistory();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (u32SeqIDX = 0; u32SeqIDX < 8; u32SeqIDX++)
|
||||
{
|
||||
if (USERCAL_stRAMCAL.au16SeqRPMLimit[u32SeqIDX] < (uint16)CAM_u32RPMRaw)
|
||||
{
|
||||
FUEL_aboSeqRevCutFlag[u32SeqIDX] = TRUE;
|
||||
}
|
||||
else if ((USERCAL_stRAMCAL.au16SeqRPMLimit[u32SeqIDX] - USERCAL_stRAMCAL.u16SeqRPMLimitHyst) > (uint16)CAM_u32RPMRaw)
|
||||
{
|
||||
FUEL_aboSeqRevCutFlag[u32SeqIDX] = FALSE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CAM_vTerminate(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void CAM_vCallBack(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CAM_vEngineSpeedCB(TEPMAPI_ttEventTime tEventTime)
|
||||
{
|
||||
uint32 u32Temp;
|
||||
sint32 s32Temp;
|
||||
|
||||
CAM_u32RPMRawOld = CAM_u32RPMRaw;
|
||||
CAM_u32RPMRaw = CAM_xTicksToRPM(tEventTime);
|
||||
|
||||
s32Temp = CAM_u32RPMRaw - CAM_u32RPMFiltered;
|
||||
s32Temp = ABS(s32Temp);
|
||||
|
||||
if (150 > s32Temp)
|
||||
{
|
||||
if (TRUE == TPS_boThrottleClosed)
|
||||
{
|
||||
CAM_u32RPMFiltered = (CAM_u32RPMRaw + 7 * CAM_u32RPMFiltered) / 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
CAM_u32RPMFiltered = (CAM_u32RPMRaw + CAM_u32RPMFiltered) / 2;
|
||||
|
||||
}
|
||||
|
||||
CAM_u32RPMTransitionCounter = 0 < CAM_u32RPMTransitionCounter ? CAM_u32RPMTransitionCounter - 1 : 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
CAM_u32RPMFiltered = (CAM_u32RPMRaw + CAM_u32RPMFiltered) / 2;
|
||||
CAM_u32RPMTransitionCounter = CAM_nRPMTransitionCount;
|
||||
}
|
||||
|
||||
FUEL_vCalculateFuellingValues();
|
||||
CAM_u32RPMTimeout = 0;
|
||||
|
||||
if (1000000 < CTS_i32StartEnrichmentScaled)
|
||||
{
|
||||
u32Temp = 1000 * (CTS_i32StartEnrichmentScaled - 1000000);
|
||||
u32Temp /= 1050u;
|
||||
u32Temp += 1000000;
|
||||
CTS_i32StartEnrichmentScaled = u32Temp;
|
||||
}
|
||||
|
||||
if (1000000 < CTS_i32PostStartEnrichmentScaled)
|
||||
{
|
||||
u32Temp = 1000 * (CTS_i32PostStartEnrichmentScaled - 1000000);
|
||||
u32Temp /= 1003u;
|
||||
u32Temp += 1000000;
|
||||
CTS_i32PostStartEnrichmentScaled = u32Temp;
|
||||
}
|
||||
|
||||
if (TPS_u32TipInEnrichment > 1000)
|
||||
{
|
||||
TPS_u32TipInEnrichment -= 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
TPS_u32TipInEnrichment = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,57 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Cyclic Activity Manager Header File */
|
||||
/* DESCRIPTION: This code module initialises the required */
|
||||
/* resources and functions for cyclic activites */
|
||||
/* */
|
||||
/* FILE NAME: MAP.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef CAM_H
|
||||
#define CAM_H
|
||||
|
||||
#include <string.h>
|
||||
#include "FUEL.h"
|
||||
#include "IOAPI.h"
|
||||
#include "SENSORS.h"
|
||||
#include "TEPMAPI.h"
|
||||
#include "USER.h"
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define CAM_xTicksToRPM(x) ((60u * SENSORS_nFastFTMFreq) / (4 * x))
|
||||
#define CAM_nPeriodMs (10u)
|
||||
#define CAM_nPeriodRPMTimeout (300u)
|
||||
#define CAM_nRPMTransitionCount (10)
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _CAM_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
EXTERN uint32 CAM_u32RPMRawOld;
|
||||
EXTERN uint32 CAM_u32RPMRaw;
|
||||
//ASAM mode=readvalue name="Engine Speed Raw" type=uint32 offset=0 min=0 max=10000 m=1 b=0 units="RPM" format=4.0 help="Engine Speed"
|
||||
EXTERN uint32 CAM_u32RPMFiltered;
|
||||
//ASAM mode=readvalue name="RPM Transition Counter" type=uint32 offset=0 min=0 max=10000 m=1 b=0 units="RPM" format=4.0 help="RPM Transition Counter"
|
||||
EXTERN uint32 CAM_u32RPMTransitionCounter;
|
||||
EXTERN uint32 CAM_u32EngineStoppedTimer;
|
||||
//ASAM mode=readvalue name="Engine Stopped Timer" type=uint32 offset=0 min=0 max=10000 m=1 b=0 units="s" format=4.0 help="Engine Stopped Timer"
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void CAM_vStart(uint32 * const pu32Arg);
|
||||
void CAM_vRun(uint32* const pu32Arg);
|
||||
void CAM_vTerminate(uint32* const pu32Arg);
|
||||
void CAM_vCallBack(puint32 const pu32Arg);
|
||||
void CAM_vEngineSpeedCB(TEPMAPI_ttEventTime tEventTime);
|
||||
|
||||
#endif // MAP_H
|
||||
|
|
@ -0,0 +1,341 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: CLO2 */
|
||||
/* DESCRIPTION: This code module provides closed loop fuel functions */
|
||||
/* FILE NAME: CLO2.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _CLO2_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "CLO2.h"
|
||||
#include "FUEL.h"
|
||||
|
||||
/* LOCAL MACRO DEFINITIONS ****************************************************/
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
uint32 CLO2_u32SensorStateBank[2];
|
||||
bool CLO2_boSensorState[2];
|
||||
uint32 CLO2_u32ReadyCount[2];
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
|
||||
/* LOCAL CONSTANT DEFINITIONS (STATIC) ****************************************/
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
|
||||
void CLO2_vInit(void)
|
||||
{
|
||||
CLO2_u32STT[0] = 1000;
|
||||
CLO2_u32STT[1] = 1000;
|
||||
|
||||
CLO2_s32ISCESTTrim[0] = 0;
|
||||
CLO2_s32ISCESTTrim[1] = 0;
|
||||
|
||||
CLO2_au16AFRMeasured[0] = ~0;
|
||||
CLO2_au16AFRMeasured[1] = ~0;
|
||||
|
||||
#if 0
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_tenEHIOType enEHIOType;
|
||||
IOAPI_tenDriveStrength enDriveStrength;
|
||||
uint32 u32Arg;
|
||||
|
||||
/* Enable the Oxygen sensor bank 1 discrete input sensor type */
|
||||
enEHIOResource = CLO2_nOxBank1Pin;
|
||||
enEHIOType = IOAPI_enDIOInput;
|
||||
enDriveStrength = IOAPI_enStrong;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, &u32Arg);
|
||||
|
||||
/* Enable the Oxygen sensor bank 2 discrete input sensor type */
|
||||
enEHIOResource = CLO2_nOxBank2Pin;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, &u32Arg);
|
||||
#endif
|
||||
}
|
||||
|
||||
void CLO2_vFilterSensors(void)
|
||||
{
|
||||
#if 0
|
||||
CLO2_boSensorState[0] = SETUP_vGetDigitalIO(CLO2_nOxBank1Pin);
|
||||
|
||||
if (TRUE == CLO2_boSensorState[0])
|
||||
{
|
||||
CLO2_u32SensorStateBank[0] = (7 * CLO2_u32SensorStateBank[0]) / 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLO2_u32SensorStateBank[0] = (7 * CLO2_u32SensorStateBank[0] + 1000) / 8;
|
||||
}
|
||||
|
||||
CLO2_boSensorState[1] = SETUP_vGetDigitalIO(CLO2_nOxBank2Pin);
|
||||
|
||||
if (TRUE == CLO2_boSensorState[1])
|
||||
{
|
||||
CLO2_u32SensorStateBank[1] = (7 * CLO2_u32SensorStateBank[1]) / 8;
|
||||
}
|
||||
else
|
||||
{
|
||||
CLO2_u32SensorStateBank[1] = (7 * CLO2_u32SensorStateBank[1] + 1000) / 8;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void CLO2_vRun(void)
|
||||
{
|
||||
static bool aboSTTRichening[2];
|
||||
uint32 u32Temp;
|
||||
uint32 u32SeqIDX;
|
||||
bool boFuelCutActive = FALSE;
|
||||
uint32 u32CLStep = TRUE == TPS_boThrottleClosed ? USERCAL_stRAMCAL.u32CLStepClosed : USERCAL_stRAMCAL.u32CLStepOpen;
|
||||
uint32 u32CLInc = TRUE == TPS_boThrottleClosed ? USERCAL_stRAMCAL.u32CLIncClosed : USERCAL_stRAMCAL.u32CLIncOpen;
|
||||
|
||||
/* Buffer the auto-tune diag variable */
|
||||
CLO2_u32AutoTuneVE = CLO2_au16AFRMeasured[0] + (FUEL_u16TAFR << 16);
|
||||
|
||||
if ((0 != USERCAL_stRAMCAL.boUEGOCANPrimary) &&
|
||||
(EH_IO_Invalid == USERCAL_stRAMCAL.u16AFRADResource) &&
|
||||
(TRUE == SENSORS_aboCANUEGONewSample[0]))
|
||||
{
|
||||
CLO2_au16AFRMeasured[0] = SENSORS_au16CANAFR[0];
|
||||
SENSORS_aboCANUEGONewSample[0] = FALSE;
|
||||
}
|
||||
|
||||
if ((FALSE == USERCAL_stRAMCAL.u8CLO2Leftenable) && (FALSE == USERCAL_stRAMCAL.u8CLO2Leftenable))
|
||||
{
|
||||
CLO2_u32STT[0] = 1000;
|
||||
CLO2_u32STT[1] = 1000;
|
||||
return;
|
||||
}
|
||||
|
||||
CLO2_u32ReadyCount[0] = (100000 > CLO2_u32ReadyCount[0]) && (0 < CAM_u32RPMRaw) ?
|
||||
CLO2_u32ReadyCount[0] + 1 : CLO2_u32ReadyCount[0];
|
||||
CLO2_u32ReadyCount[1] = (100000 > CLO2_u32ReadyCount[1]) && (0 < CAM_u32RPMRaw) ?
|
||||
CLO2_u32ReadyCount[1] + 1 : CLO2_u32ReadyCount[1];
|
||||
|
||||
for (u32SeqIDX = 0; u32SeqIDX < 8; u32SeqIDX++)
|
||||
{
|
||||
boFuelCutActive |= FUEL_aboSeqOverrunCutFlag[u32SeqIDX];
|
||||
}
|
||||
|
||||
if (200 < CLO2_u32ReadyCount[0])
|
||||
{
|
||||
if (((FUEL_u16TAFR < 1475) && (FUEL_u16TAFR > 1465)) &&
|
||||
(FALSE == boFuelCutActive))
|
||||
{
|
||||
if (800 < CLO2_u32SensorStateBank[0])
|
||||
{
|
||||
if ((TRUE == aboSTTRichening[0]) && (USERCAL_stRAMCAL.u32STTNegLimit < CLO2_u32STT[0])) CLO2_u32STT[0] -= u32CLStep;
|
||||
|
||||
CLO2_u32STT[0] = USERCAL_stRAMCAL.u32STTNegLimit < CLO2_u32STT[0] ? CLO2_u32STT[0] - u32CLInc : CLO2_u32STT[0];
|
||||
aboSTTRichening[0] = FALSE;
|
||||
}
|
||||
else if (200 > CLO2_u32SensorStateBank[0])
|
||||
{
|
||||
if ((FALSE == aboSTTRichening[0]) && (USERCAL_stRAMCAL.u32STTPosLimit > CLO2_u32STT[0])) CLO2_u32STT[0] += u32CLStep;
|
||||
|
||||
CLO2_u32STT[0] = USERCAL_stRAMCAL.u32STTPosLimit > CLO2_u32STT[0] ? CLO2_u32STT[0] + u32CLInc : CLO2_u32STT[0];
|
||||
aboSTTRichening[0] = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLO2_u32STT[0] = 1000;
|
||||
}
|
||||
|
||||
/* If no CAN data yet then just set to neutral */
|
||||
SENSORS_u8CANSTT[0] = 0xff != SENSORS_u8CANSTT[0] ? SENSORS_u8CANSTT[0] : 0x80;
|
||||
SENSORS_u8CANLTT[0] = 0xff != SENSORS_u8CANLTT[0] ? SENSORS_u8CANLTT[0] : 0x80;
|
||||
}
|
||||
|
||||
|
||||
if (200 < CLO2_u32ReadyCount[1])
|
||||
{
|
||||
if (((FUEL_u16TAFR < 1475) && (FUEL_u16TAFR > 1465)) &&
|
||||
(FALSE == boFuelCutActive))
|
||||
{
|
||||
if (800 < CLO2_u32SensorStateBank[1])
|
||||
{
|
||||
if ((TRUE == aboSTTRichening[1]) && (USERCAL_stRAMCAL.u32STTNegLimit < CLO2_u32STT[1])) CLO2_u32STT[1] -= u32CLStep;
|
||||
|
||||
CLO2_u32STT[1] = USERCAL_stRAMCAL.u32STTNegLimit < CLO2_u32STT[1] ? CLO2_u32STT[1] - u32CLInc : CLO2_u32STT[1];
|
||||
aboSTTRichening[1] = FALSE;
|
||||
}
|
||||
else if (200 > CLO2_u32SensorStateBank[1])
|
||||
{
|
||||
if ((FALSE == aboSTTRichening[1]) && (USERCAL_stRAMCAL.u32STTPosLimit > CLO2_u32STT[1])) CLO2_u32STT[1] += u32CLStep;
|
||||
|
||||
CLO2_u32STT[1] = USERCAL_stRAMCAL.u32STTPosLimit > CLO2_u32STT[1] ? CLO2_u32STT[1] + u32CLInc : CLO2_u32STT[1];
|
||||
aboSTTRichening[1] = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLO2_u32STT[1] = 1000;
|
||||
}
|
||||
|
||||
/* If no CAN data yet then just set to neutral */
|
||||
SENSORS_u8CANSTT[1] = 0xff != SENSORS_u8CANSTT[1] ? SENSORS_u8CANSTT[1] : 0x80;
|
||||
SENSORS_u8CANLTT[1] = 0xff != SENSORS_u8CANLTT[1] ? SENSORS_u8CANLTT[1] : 0x80;
|
||||
}
|
||||
|
||||
|
||||
#ifdef BUILD_BSP_STT_CAN
|
||||
const uint8_t au8BiasTable[256] = CLO2_nBiasTableData;
|
||||
static bool aboSimRichening[2];
|
||||
volatile static uint8 au8STTLTT[2];
|
||||
volatile static uint8 au8Count[2];
|
||||
volatile static uint8 au8CountRichLimit[2];
|
||||
volatile static uint8 au8CountLeanLimit[2];
|
||||
static bool aboOutRich[2];
|
||||
static bool aboOutConfigured[2];
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_tenEHIOType enEHIOType;
|
||||
IOAPI_tenDriveStrength enDriveStrength;
|
||||
uint32 u32Arg;
|
||||
|
||||
|
||||
if ((0xff != SENSORS_u8CANSTT[0]) && (0xff != SENSORS_u8CANLTT[0]))
|
||||
{
|
||||
au8STTLTT[0] = 2 * SENSORS_u8CANSTT[0] + SENSORS_u8CANLTT[0];
|
||||
|
||||
au8CountRichLimit[0] = (au8BiasTable[au8STTLTT[0]]) / 15;
|
||||
au8CountLeanLimit[0] = (256 - au8BiasTable[au8STTLTT[0]]) / 15;
|
||||
|
||||
if (TRUE == aboSimRichening[0])
|
||||
{
|
||||
if (++au8Count[0] > au8CountRichLimit[0])
|
||||
{
|
||||
if ((TRUE == aboOutConfigured[0]) &&
|
||||
(FUEL_u16TAFR > 1465))
|
||||
{
|
||||
SETUP_vSetDigitalIOLow(CLO2_nSwitchBank1Pin);
|
||||
}
|
||||
au8Count[0] = 0;
|
||||
aboSimRichening[0] = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (++au8Count[0] > au8CountLeanLimit[0])
|
||||
{
|
||||
if (TRUE == aboOutConfigured[0])
|
||||
{
|
||||
SETUP_vSetDigitalIOHigh(CLO2_nSwitchBank1Pin);
|
||||
}
|
||||
|
||||
au8Count[0] = 0;
|
||||
aboSimRichening[0] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((0xff != SENSORS_u8CANSTT[1]) && (0xff != SENSORS_u8CANLTT[1]))
|
||||
{
|
||||
au8STTLTT[1] = 2 * SENSORS_u8CANSTT[1] + SENSORS_u8CANLTT[1];
|
||||
|
||||
au8CountRichLimit[1] = (au8BiasTable[au8STTLTT[1]]) / 15;
|
||||
au8CountLeanLimit[1] = (256 - au8BiasTable[au8STTLTT[1]]) / 15;
|
||||
|
||||
if (TRUE == aboSimRichening[1])
|
||||
{
|
||||
if (++au8Count[1] > au8CountRichLimit[1])
|
||||
{
|
||||
if ((TRUE == aboOutConfigured[1]) &&
|
||||
(FUEL_u16TAFR > 1465))
|
||||
{
|
||||
SETUP_vSetDigitalIOLow(CLO2_nSwitchBank2Pin);
|
||||
}
|
||||
au8Count[1] = 0;
|
||||
aboSimRichening[1] = FALSE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (++au8Count[1] > au8CountLeanLimit[1])
|
||||
{
|
||||
if (TRUE == aboOutConfigured[1])
|
||||
{
|
||||
SETUP_vSetDigitalIOHigh(CLO2_nSwitchBank2Pin);
|
||||
}
|
||||
|
||||
au8Count[1] = 0;
|
||||
aboSimRichening[1] = TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CLO2_u32STTAvg[0] = ((3 * CLO2_u32STTAvg[0]) / 4) + CLO2_u32STT[0] / 4;
|
||||
CLO2_u32STTAvg[1] = ((3 * CLO2_u32STTAvg[1]) / 4) + CLO2_u32STT[1] / 4;
|
||||
|
||||
CLO2_u32STTAvg[0] = CLO2_u32STT[0] > CLO2_u32STTAvg[0] ? CLO2_u32STTAvg[0] + 1 : CLO2_u32STTAvg[0];
|
||||
CLO2_u32STTAvg[1] = CLO2_u32STT[1] > CLO2_u32STTAvg[1] ? CLO2_u32STTAvg[1] + 1 : CLO2_u32STTAvg[1];
|
||||
|
||||
|
||||
if ((FALSE == aboOutConfigured[0]) && (TRUE == aboOutReady[0]))
|
||||
{
|
||||
enEHIOResource = CLO2_nSwitchBank1Pin;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, &u32Arg);
|
||||
aboOutConfigured[0] = TRUE;
|
||||
}
|
||||
|
||||
if ((FALSE == aboOutConfigured[1]) && (TRUE == aboOutReady[1]))
|
||||
{
|
||||
enEHIOResource = CLO2_nSwitchBank2Pin;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, &u32Arg);
|
||||
aboOutConfigured[1] = TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (TRUE == TPS_boThrottleClosed)
|
||||
{
|
||||
if (1000 < CLO2_u32STT[0])
|
||||
{
|
||||
CLO2_s32ISCESTTrim[0] =
|
||||
~(((CLO2_u32STT[0] - 1000) * USERCAL_stRAMCAL.u32CLO2ESTTrimPos) / (1000 - USERCAL_stRAMCAL.u32STTPosLimit));
|
||||
}
|
||||
else
|
||||
{
|
||||
CLO2_s32ISCESTTrim[0] =
|
||||
(((1000 - CLO2_u32STT[0]) * USERCAL_stRAMCAL.u32CLO2ESTTrimNeg) / (1000 - USERCAL_stRAMCAL.u32STTNegLimit));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLO2_s32ISCESTTrim[0] = 0;
|
||||
}
|
||||
|
||||
if ((TRUE == TPS_boThrottleClosed) && (IAC_enClosedLoop == IAC_enControlState))
|
||||
{
|
||||
if (CLO2_u32STTAvg[1] < CLO2_u32STT[1])
|
||||
{
|
||||
u32Temp = (((CLO2_u32STT[1] - CLO2_u32STTAvg[1]) * USERCAL_stRAMCAL.u32CLO2ESTTrimPos) / 5);
|
||||
u32Temp = USERCAL_stRAMCAL.u32CLO2ESTTrimPos < u32Temp ? USERCAL_stRAMCAL.u32CLO2ESTTrimPos : u32Temp;
|
||||
CLO2_s32ISCESTTrim[1] = ~u32Temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32Temp = (((CLO2_u32STTAvg[1] - CLO2_u32STT[1]) * USERCAL_stRAMCAL.u32CLO2ESTTrimNeg) / 5);
|
||||
u32Temp = USERCAL_stRAMCAL.u32CLO2ESTTrimNeg < u32Temp ? USERCAL_stRAMCAL.u32CLO2ESTTrimNeg : u32Temp;
|
||||
CLO2_s32ISCESTTrim[1] = u32Temp;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CLO2_s32ISCESTTrim[1] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,78 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: CLO2 Header File */
|
||||
/* DESCRIPTION: This code module provides closed loop fuel functions */
|
||||
/* FILE NAME: CLO2.h */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef CLO2_H
|
||||
#define CLO2_H
|
||||
|
||||
#include "IOAPI.h"
|
||||
#include "types.h"
|
||||
#include "SETUP.h"
|
||||
#include "SENSORS.h"
|
||||
#include "TPS.h"
|
||||
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _CLO2_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#define CLO2_nBiasTableData \
|
||||
{\
|
||||
38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,\
|
||||
38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,\
|
||||
38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,\
|
||||
38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,\
|
||||
38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,38,\
|
||||
38,40,42,44,46,48,50,52,54,56,58,60,62,64,66,68,\
|
||||
68,70,72,74,76,78,80,82,84,86,88,90,92,94,96,98,\
|
||||
98,100,102,104,106,108,110,112,114,116,118,120,122,124,126,128,\
|
||||
128,130,132,134,136,138,140,142,144,146,148,150,152,154,156,158,\
|
||||
158,160,162,164,166,168,170,172,174,176,178,180,182,184,186,188,\
|
||||
188,190,192,194,196,198,200,202,204,206,208,210,212,214,216,218,\
|
||||
218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,\
|
||||
218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,\
|
||||
218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,\
|
||||
218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,\
|
||||
218,218,218,218,218,218,218,218,218,218,218,218,218,218,218,218}
|
||||
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
EXTERN uint32 CLO2_u32STTAvg[2];
|
||||
EXTERN uint32 CLO2_u32STT[2];
|
||||
//ASAM mode=readvalue name="STT Bank 1" type=uint32 offset=0 min=0 max=1500 m=1 b=0 units="dl" format=4.0 help="Short Term Trim Bank1"
|
||||
//ASAM mode=readvalue name="STT Bank 2" type=uint32 offset=4 min=0 max=1500 m=1 b=0 units="dl" format=4.0 help="Short Term Trim Bank2"
|
||||
EXTERN uint32 CLO2_u32LTT[2];
|
||||
EXTERN sint32 CLO2_s32ISCESTTrim[2];
|
||||
EXTERN uint16 CLO2_au16AFRMeasured[2];
|
||||
EXTERN uint16 CLO2_au16AFRDisplayMeasured[2];
|
||||
//ASAM mode=readvalue name="AFR Measured 1" type=uint16 offset=0 min=5 max=100 m=0.001 b=0 units="dl" format=4.2 help="Measured AFR Bank1"
|
||||
//ASAM mode=readvalue name="AFR Measured 2" type=uint16 offset=2 min=5 max=100 m=0.001 b=0 units="dl" format=4.2 help="Measured AFR Bank2"
|
||||
EXTERN uint32 CLO2_u32AutoTuneVE;
|
||||
//ASAM mode=readvalue name="VE AUTOTUNE DIAG" type=uint32 offset=0 min=5 max=100 m=0.01 b=0 units="dl" format=4.2 help="Autotune VE Diag"
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void CLO2_vInit(void);
|
||||
void CLO2_vRun(void);
|
||||
void CLO2_vFilterSensors(void);
|
||||
|
||||
|
||||
#endif // CLO2_H
|
||||
|
|
@ -0,0 +1,149 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Conversion */
|
||||
/* DESCRIPTION: This code module provides data conversion functions */
|
||||
/* functions for the user application */
|
||||
/* FILE NAME: CONV.c */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include <BUILD.h>
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "conv.h"
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
GPM6_ttVolts CONV_tADCToVolts(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult)
|
||||
{
|
||||
GPM6_ttVolts tVolts;/*CR1_17*/
|
||||
|
||||
#ifdef BUILD_SPARKDOG_PF
|
||||
switch (enEHIOResource)
|
||||
{
|
||||
case EH_IO_GPSE1:
|
||||
case EH_IO_GPSE2:
|
||||
case EH_IO_GPSE3:
|
||||
case EH_IO_GPSE4:
|
||||
case EH_IO_GPSE5:
|
||||
case EH_IO_GPSE7:
|
||||
case EH_IO_GPSE8:
|
||||
{
|
||||
tVolts = USERCAL_stRAMCAL.userCalADRefH * u32ADCResult;
|
||||
tVolts = (101 * tVolts) / (4095 * 50);
|
||||
break;
|
||||
}
|
||||
case EH_IO_GPSE6:
|
||||
{
|
||||
tVolts = USERCAL_stRAMCAL.userCalADRefH * u32ADCResult;
|
||||
tVolts = (144 * tVolts) / (4095 * 22);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
tVolts = 0;/*CR1_17*/
|
||||
}
|
||||
}
|
||||
#endif //BUILD_SPARKDOG_PF
|
||||
|
||||
#ifdef BUILD_SPARKDOG_TEENSY_ADAPT
|
||||
switch (enEHIOResource)
|
||||
{
|
||||
case EH_IO_GPSE1:
|
||||
case EH_IO_GPSE3:
|
||||
case EH_IO_GPSE4:
|
||||
case EH_IO_GPSE5:
|
||||
case EH_IO_GPSE6:
|
||||
case EH_IO_GPSE7:
|
||||
case EH_IO_GPSE8:
|
||||
case EH_IO_TMR15:
|
||||
case EH_IO_TMR16:
|
||||
{
|
||||
tVolts = USERCAL_stRAMCAL.userCalADRefH * u32ADCResult;
|
||||
tVolts = (101 * tVolts) / (4095 * 50);
|
||||
break;
|
||||
}
|
||||
case EH_IO_GPSE2:
|
||||
{
|
||||
tVolts = USERCAL_stRAMCAL.userCalADRefH * u32ADCResult;
|
||||
tVolts = (144 * tVolts) / (4095 * 22);
|
||||
break;
|
||||
}
|
||||
case EH_IO_IIC1_SCL:
|
||||
{
|
||||
tVolts = (34u * USERCAL_stRAMCAL.userCalVRef445) / 33u
|
||||
- (USERCAL_stRAMCAL.userCalADRefH * u32ADCResult) / (32000);
|
||||
break;
|
||||
}
|
||||
case EH_IO_UART1_CTS:
|
||||
{
|
||||
tVolts = (220u * u32ADCResult) / 69888u;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
tVolts = 0;/*CR1_17*/
|
||||
}
|
||||
}
|
||||
#endif //BUILD_SPARKDOG_TEENSY_ADAPT
|
||||
|
||||
return tVolts;
|
||||
}
|
||||
|
||||
GPM6_ttOhms CONV_tADCToOhms(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult)
|
||||
{
|
||||
GPM6_ttOhms Ohms;
|
||||
|
||||
switch (enEHIOResource)
|
||||
{
|
||||
case EH_I_ADD1:
|
||||
{
|
||||
Ohms = 9 * (u32ADCResult + 8600);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
Ohms = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Ohms;
|
||||
}
|
||||
|
||||
GPM6_ttOhms CONV_tVoltsAmpsToOhms(GPM6_ttVolts tVolts, GPM6_ttAmps tAmps)/*CR1_17*/
|
||||
{
|
||||
GPM6_ttOhms tOhms = GPM6_ttOhmsMAXVAL;
|
||||
|
||||
if (0 != tAmps)/*CR1_20*/
|
||||
{
|
||||
tOhms = (tVolts * 1000u) / tAmps;/*CR1_17*/
|
||||
}
|
||||
|
||||
return tOhms;
|
||||
}
|
||||
|
||||
GPM6_ttAmps CONV_tOhmsVoltsToAmps(GPM6_ttOhms tOhms, GPM6_ttVolts tVolts)/*CR1_17*/
|
||||
{
|
||||
GPM6_ttAmps tAmps = GPM6_ttAmpsMAXVAL;
|
||||
|
||||
if (0 != tOhms)/*CR1_20*/
|
||||
{
|
||||
tAmps = (tVolts * 1000u) / tOhms;/*CR1_17*/
|
||||
}
|
||||
|
||||
return tAmps;
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,67 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Conversion Header File */
|
||||
/* DESCRIPTION: This code module provides data conversion functions */
|
||||
/* functions for the user application */
|
||||
/* FILE NAME: CONV.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef CONV_H
|
||||
#define CONV_H
|
||||
|
||||
#include <DECLARATIONS.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <SYS.h>
|
||||
#include <TYPES.h>
|
||||
#include <USERCAL.h>
|
||||
#include "ioapi.h"/*CR1_94*/
|
||||
#include "units.h"
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
/*******************************************************************************
|
||||
* Interface : <Description of interface>
|
||||
*
|
||||
* Implementation : <Description of implementation>
|
||||
*
|
||||
* Return Value : <Comment on return value >
|
||||
*******************************************************************************/
|
||||
GPM6_ttVolts CONV_tADCToVolts(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult);/*CR1_1*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Interface : <Description of interface>
|
||||
*
|
||||
* Implementation : <Description of implementation>
|
||||
*
|
||||
* Return Value : <Comment on return value >
|
||||
*******************************************************************************/
|
||||
GPM6_ttOhms CONV_tVoltsAmpsToOhms(GPM6_ttVolts tVolts, GPM6_ttAmps tAmps);/*CR1_1*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Interface : <Description of interface>
|
||||
*
|
||||
* Implementation : <Description of implementation>
|
||||
*
|
||||
* Return Value : <Comment on return value >
|
||||
*******************************************************************************/
|
||||
GPM6_ttAmps CONV_tOhmsVoltsToAmps(GPM6_ttOhms tOhms, GPM6_ttVolts tVolts);/*CR1_1*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Interface : <Description of interface>
|
||||
*
|
||||
* Implementation : <Description of implementation>
|
||||
*
|
||||
* Return Value : <Comment on return value >
|
||||
*******************************************************************************/
|
||||
GPM6_ttOhms CONV_tADCToOhms(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult);/*CR1_67*/
|
||||
|
||||
#endif // CONV_H
|
||||
|
|
@ -0,0 +1,369 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Coolant Temperature */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for coolant temperature */
|
||||
/* measurement */
|
||||
/* FILE NAME: CTS.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _CTS_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "CTS.h"
|
||||
#include "RELAYS.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
bool CTS_boNewSample;
|
||||
SPREADAPI_ttSpreadIDX CTS_tSpreadSensorIDX;
|
||||
SPREADAPI_ttSpreadIDX CTS_tSpreadEnrichmentIDX;
|
||||
SPREADAPI_ttSpreadIDX CTS_tSpreadStartEnrichmentIDX;
|
||||
SPREADAPI_ttSpreadIDX CTS_tSpreadPostStartEnrichmentIDX;
|
||||
SPREADAPI_ttSpreadIDX CTS_tSpreadPrimerIDX;
|
||||
TABLEAPI_ttTableIDX CTS_tTableSensorIDX;
|
||||
TABLEAPI_ttTableIDX CTS_tTableEnrichmentIDX;
|
||||
TABLEAPI_ttTableIDX CTS_tTableStartEnrichmentIDX;
|
||||
TABLEAPI_ttTableIDX CTS_tTablePostStartEnrichmentIDX;
|
||||
TABLEAPI_ttTableIDX CTS_tTablePrimerIDX;
|
||||
|
||||
sint32 CTS_i32Enrichment;
|
||||
sint32 CTS_i32StartEnrichment;
|
||||
sint32 CTS_i32PostStartEnrichment;
|
||||
uint32 CTS_u32SampleCount;
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
/*******************************************************************************
|
||||
* Interface : CTS_vADCCallBack
|
||||
*
|
||||
* Implementation : Callback to receive the measured ADC value
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : enEHIOResource enum of the ADC resource
|
||||
* Par2 : u32ADCResult the ADC conversion value
|
||||
*
|
||||
* Return Value : NIL
|
||||
*******************************************************************************/
|
||||
static void CTS_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult);
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void CTS_vStart(puint32 const pu32Arg)
|
||||
{
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_tenEHIOType enEHIOType;
|
||||
IOAPI_tenDriveStrength enDriveStrength;
|
||||
CTS_u32ADCRaw = 0;
|
||||
CTS_u32FuelMultiplier = 1000;
|
||||
CTS_u32SampleCount = 0;
|
||||
CTS_boNewSample = FALSE;
|
||||
CTS_i32StartEnrichment = 1000;
|
||||
CTS_i32StartEnrichmentScaled = 1000 * 1000;
|
||||
CTS_i32PostStartEnrichmentScaled = 1000 * 1000;
|
||||
|
||||
if (FALSE == USERCAL_stRAMCAL.boCTSCANPrimary)
|
||||
{
|
||||
/* Request and initialise the CTS ADC input channel */
|
||||
SETUP_boSetupADSE(USERCAL_stRAMCAL.u16CTSADResource, IOAPI_enADSE, ADCAPI_en32Samples, &CTS_vADCCallBack, ADCAPI_enTrigger2, pu32Arg);
|
||||
}
|
||||
|
||||
/* Request and initialise required Kernel managed spread for coolant sensor */
|
||||
CTS_tSpreadSensorIDX = SETUP_tSetupSpread((void*)&CTS_tSensorVolts, (void*)&USERCAL_stRAMCAL.aUserCoolantSensorSpread, TYPE_enUInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for coolant sensor */
|
||||
CTS_tTableSensorIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserCoolantSensorTable, (void*)&CTS_tTempCRaw, TYPE_enInt32, 17, CTS_tSpreadSensorIDX, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for coolant enrichment */
|
||||
CTS_tSpreadEnrichmentIDX = SETUP_tSetupSpread((void*)&CTS_tTempCFiltered, (void*)&USERCAL_stRAMCAL.aUserCoolantEnrichmentSpread, TYPE_enInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for coolant enrichment */
|
||||
CTS_tTableEnrichmentIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserCoolantEnrichmentTable, (void*)&CTS_i32Enrichment, TYPE_enInt32, 17, CTS_tSpreadEnrichmentIDX, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for coolant starting enrichment */
|
||||
CTS_tSpreadStartEnrichmentIDX = SETUP_tSetupSpread((void*)&CTS_tTempCFiltered, (void*)&USERCAL_stRAMCAL.aUserCoolantStartEnrichmentSpread, TYPE_enInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for coolant starting enrichment */
|
||||
CTS_tTableStartEnrichmentIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserCoolantStartEnrichmentTable, (void*)&CTS_i32StartEnrichment, TYPE_enInt32, 17, CTS_tSpreadStartEnrichmentIDX, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for coolant post starting enrichment */
|
||||
CTS_tSpreadPostStartEnrichmentIDX = SETUP_tSetupSpread((void*)&CTS_tTempCFiltered, (void*)&USERCAL_stRAMCAL.aUserCoolantPostStartEnrichmentSpread, TYPE_enInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for coolant post starting enrichment */
|
||||
CTS_tTablePostStartEnrichmentIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserCoolantPostStartEnrichmentTable, (void*)&CTS_i32PostStartEnrichment, TYPE_enInt32, 17, CTS_tSpreadPostStartEnrichmentIDX, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for primer */
|
||||
CTS_tSpreadPrimerIDX = SETUP_tSetupSpread((void*)&CTS_tTempCFiltered, (void*)&USERCAL_stRAMCAL.aUserPrimerSpread, TYPE_enInt32, 11, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for primer */
|
||||
CTS_tTablePrimerIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserPrimerTable, (void*)&CTS_u32Primer, TYPE_enUInt32, 11, CTS_tSpreadPrimerIDX, NULL);
|
||||
|
||||
/* Setup thermofan relay */
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.enThermoFanRelay)
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.enThermoFanRelay;
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
enDriveStrength = IOAPI_enWeak;
|
||||
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
SETUP_vSetDigitalIOLow(enEHIOResource);
|
||||
}
|
||||
}
|
||||
|
||||
void CTS_vRun(puint32 const pu32Arg)
|
||||
{
|
||||
uint32 u32Temp;
|
||||
sint32 s32Temp;
|
||||
IOAPI_tenTriState enTriState;
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
RELAY_tenBit enBit;
|
||||
#ifdef BUILD_CTS_PULLUP_SENSE
|
||||
volatile static uint32 u32Delta;
|
||||
static uint32 u32LowImpModeCount;
|
||||
static uint32 u32HighImpModeCount;
|
||||
static bool boHotMode;
|
||||
static bool boColdMode;
|
||||
#endif
|
||||
static uint32 u32CANCTSMsgCount = 0;
|
||||
static uint8 u8CANCTSOld = 0;
|
||||
|
||||
|
||||
if ((TRUE == CTS_boNewSample) || (true == SENSORS_boCANCTSNewSample))
|
||||
{
|
||||
CTS_u32SampleCount++;
|
||||
|
||||
if (FALSE == USERCAL_stRAMCAL.boCTSCANPrimary)
|
||||
{
|
||||
USER_xEnterCritical();/*CR1_16*/
|
||||
(void)USERMATH_u16SinglePoleLowPassFilter16((uint16)CTS_u32ADCRaw, CTS_nADFiltVal,
|
||||
&CTS_u32ADCFiltered);
|
||||
CTS_boNewSample = FALSE;
|
||||
USER_xExitCritical();/*CR1_16*/
|
||||
|
||||
#ifdef BUILD_CTS_PULLUP_SENSE
|
||||
if ((FALSE == SENSORS_boCTSACBiasHigh) && ((0x100 * CTS_u32ADCRaw) > CTS_u32ADCFiltered))
|
||||
{
|
||||
u32Temp = 0x100 * CTS_u32ADCRaw - CTS_u32ADCFiltered;
|
||||
u32Delta = (u32Temp + 3 * u32Delta) / 4;
|
||||
}
|
||||
else if ((TRUE == SENSORS_boCTSACBiasHigh) && ((0x100 * CTS_u32ADCRaw) < CTS_u32ADCFiltered))
|
||||
{
|
||||
u32Temp = CTS_u32ADCFiltered - 0x100 * CTS_u32ADCRaw;
|
||||
u32Delta = (u32Temp + 3 * u32Delta) / 4;
|
||||
}
|
||||
|
||||
if (0 == CAM_u32RPMRaw)
|
||||
{
|
||||
if (10000 < u32Delta)
|
||||
{
|
||||
u32HighImpModeCount = 40 > u32HighImpModeCount ? u32HighImpModeCount + 1 : u32HighImpModeCount;
|
||||
u32LowImpModeCount = 2 < u32LowImpModeCount ? u32LowImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
if (7000 > u32Delta)
|
||||
{
|
||||
u32LowImpModeCount = 40 > u32LowImpModeCount ? u32LowImpModeCount + 1 : u32LowImpModeCount;
|
||||
u32HighImpModeCount = 2 < u32HighImpModeCount ? u32HighImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
boColdMode = 35 < u32HighImpModeCount;
|
||||
boHotMode = 35 < u32LowImpModeCount;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (15000 < u32Delta)
|
||||
{
|
||||
u32HighImpModeCount = 1000 > u32HighImpModeCount ? u32HighImpModeCount + 1 : u32HighImpModeCount;
|
||||
u32LowImpModeCount = 2 < u32LowImpModeCount ? u32LowImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
if (10000 > u32Delta)
|
||||
{
|
||||
u32LowImpModeCount = 1000 > u32LowImpModeCount ? u32LowImpModeCount + 1 : u32LowImpModeCount;
|
||||
u32HighImpModeCount = 2 < u32HighImpModeCount ? u32HighImpModeCount - 2 : 0;
|
||||
}
|
||||
|
||||
boColdMode = 500 < u32HighImpModeCount;
|
||||
boHotMode = 500 < u32LowImpModeCount;
|
||||
}
|
||||
|
||||
|
||||
if (((FALSE == boHotMode) && (FALSE == boColdMode)) ||
|
||||
((TRUE == boHotMode) && (TRUE == boColdMode)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
#endif //BUILD_BSP_CTS_PULLUP_SENSE
|
||||
|
||||
u32Temp = CTS_u32ADCFiltered * SENSORS_nADRefVolts;
|
||||
u32Temp /= SENSORS_nADScaleMax;
|
||||
u32Temp /= SENSORS_nVDivRatio;
|
||||
CTS_tSensorVolts = u32Temp;
|
||||
|
||||
/* Calculate the current spread for coolant sensor */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&CTS_tSpreadSensorIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current spread for coolant sensor */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&CTS_tTableSensorIDX,
|
||||
NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (0xff != SENSORS_u8CANCTS)
|
||||
{
|
||||
CTS_tTempCRaw = 1000 * (sint32)(SENSORS_u8CANCTS - 40);
|
||||
SENSORS_boCANCTSNewSample = FALSE;
|
||||
|
||||
u32CANCTSMsgCount++;
|
||||
|
||||
if ((3 < u32CANCTSMsgCount) &&
|
||||
(u8CANCTSOld == SENSORS_u8CANCTS) &&
|
||||
(0 != SENSORS_u8CANCTS))
|
||||
{
|
||||
CTS_boCTSReady = TRUE;
|
||||
}
|
||||
else if (10 < u32CANCTSMsgCount)
|
||||
{
|
||||
CTS_boCTSReady = TRUE;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
CTS_tTempCRaw = 0;
|
||||
}
|
||||
|
||||
u8CANCTSOld = SENSORS_u8CANCTS;
|
||||
}
|
||||
|
||||
|
||||
if (((0 == CAM_u32RPMRaw) && (10000 < BVM_tBattVolts)) || (TRUE == USERCAL_stRAMCAL.boCTSCANPrimary))
|
||||
{
|
||||
/* If at key on but not cranking, or CAN data */
|
||||
CTS_tTempCFiltered = CTS_tTempCRaw;
|
||||
}
|
||||
else if (400 < CAM_u32RPMRaw)
|
||||
{
|
||||
if (CTS_tTempCRaw < CTS_tTempCFiltered)
|
||||
{
|
||||
CTS_tTempCFiltered -= 500;
|
||||
}
|
||||
else if (CTS_tTempCRaw > CTS_tTempCFiltered)
|
||||
{
|
||||
CTS_tTempCFiltered += 500;
|
||||
CTS_tTempCFiltered = CTS_MAXVAL <= CTS_tTempCFiltered ? CTS_MAXVAL : CTS_tTempCFiltered;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/* Calculate the current spread for coolant enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&CTS_tSpreadEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current spread for coolant enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&CTS_tTableEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
|
||||
(void)BOOSTED_boIndexAndCalculateTable(CTS_tSpreadPrimerIDX, CTS_tTablePrimerIDX);
|
||||
|
||||
|
||||
#ifdef BUILD_CTS_PULLUP_SENSE
|
||||
if (TRUE == boHotMode)
|
||||
{
|
||||
CTS_tTempCFiltered = 60000;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Decrease the enrichment linearly at higher rpm */
|
||||
if (1500 < CAM_u32RPMRaw)
|
||||
{
|
||||
u32Temp = 7500 - CAM_u32RPMRaw;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32Temp = 6000;
|
||||
}
|
||||
|
||||
s32Temp = CTS_i32Enrichment - 1000;
|
||||
s32Temp *= u32Temp;
|
||||
s32Temp /= 6000;
|
||||
s32Temp += 1000;
|
||||
s32Temp *= (CTS_i32StartEnrichmentScaled / 1000);
|
||||
s32Temp /= 1000;
|
||||
s32Temp *= (CTS_i32PostStartEnrichmentScaled / 1000);
|
||||
s32Temp /= 1000;
|
||||
CTS_u32FuelMultiplier = (uint32)s32Temp;
|
||||
|
||||
if ((50 < CTS_u32SampleCount) && (0 == CAM_u32RPMRaw))
|
||||
{
|
||||
/* Calculate the current spread for starting coolant enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&CTS_tSpreadStartEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current spread for starting coolant enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&CTS_tTableStartEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Calculate the current spread for post starting coolant enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&CTS_tSpreadPostStartEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current spread for post starting coolant enrichment */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&CTS_tTablePostStartEnrichmentIDX,
|
||||
NULL, NULL);
|
||||
|
||||
CTS_i32StartEnrichmentScaled = 1000 * CTS_i32StartEnrichment;
|
||||
CTS_i32PostStartEnrichmentScaled = 1000 * CTS_i32PostStartEnrichment;
|
||||
}
|
||||
}
|
||||
|
||||
CTS_boRadFanOn = USERCAL_stRAMCAL.s32RadFanOnTemp < CTS_tTempCFiltered ? TRUE : CTS_boRadFanOn;
|
||||
CTS_boRadFanOn = USERCAL_stRAMCAL.s32RadFanOffTemp > CTS_tTempCFiltered ? FALSE : CTS_boRadFanOn;
|
||||
|
||||
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.enThermoFanRelay)
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.enThermoFanRelay;
|
||||
enTriState = TRUE == CTS_boRadFanOn ? IOAPI_enHigh : IOAPI_enLow;
|
||||
|
||||
if (EH_IO_IIC1_SDA > enEHIOResource)
|
||||
{
|
||||
USER_vSVC(SYSAPI_enAssertDIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enTriState, (void*)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
enBit = 1 << (enEHIOResource - EH_IO_IIC1_SDA);
|
||||
RELAYS_vOutputBit(enBit, IOAPI_enHigh == enTriState);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CTS_vTerminate(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void CTS_vCallBack(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
static void CTS_vADCCallBack(IOAPI_tenEHIOResource enEHIOResource, uint32 u32ADCResult)
|
||||
{
|
||||
CTS_u32ADCRaw = u32ADCResult;
|
||||
CTS_boNewSample = TRUE;
|
||||
}
|
||||
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,62 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Coolant Temperature Header File */
|
||||
/* DESCRIPTION: This code module initialises the required ADC */
|
||||
/* resources and functions for coolant temperature */
|
||||
/* measurement */
|
||||
/* FILE NAME: CTS.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef CTS_H
|
||||
#define CTS_H
|
||||
|
||||
#include <string.h>
|
||||
#include "IOAPI.h"
|
||||
#include "SENSORS.h"
|
||||
#include "USER.h"
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define CTS_nADFiltVal (0x10)
|
||||
#define CTS_nFanRelayOutput (RELAY_BIT0)
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _CTS_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
#define CTS_MAXVAL 130000
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
EXTERN uint32 CTS_u32ADCRaw;
|
||||
EXTERN uint32 CTS_u32ADCFiltered;
|
||||
//ASAM mode=readvalue name="Coolant Sensor Filtered ADC" type=uint32 offset=0 min=0 max=1048575 m=1 b=0 units="counts" format=5.3 help="CTS Sensor ADC"
|
||||
EXTERN GPM6_ttVolts CTS_tSensorVolts;/*CR1_88*/
|
||||
//ASAM mode=readvalue name="CTS Sensor Voltage" type=uint32 offset=0 min=0 max=5 m=0.001 b=0 units="V" format=3.2 help="CTS Sensor Voltage"
|
||||
EXTERN GPM6_ttTempC CTS_tTempCRaw;
|
||||
EXTERN GPM6_ttTempC CTS_tTempCFiltered;
|
||||
//ASAM mode=readvalue name="Coolant Temperature" type=uint32 offset=0 min=0 max=200 m=0.001 b=0 units="degrees C" format=4.1 help="Coolant Temperature"
|
||||
EXTERN uint32 CTS_u32Primer;
|
||||
//ASAM mode=readvalue name="Primer" type=uint32 offset=0 min=0 max=200 m=0.001 b=0 units="us" format=4.1 help="Start Primer"
|
||||
EXTERN uint32 CTS_u32FuelMultiplier;
|
||||
EXTERN sint32 CTS_i32StartEnrichmentScaled;
|
||||
EXTERN sint32 CTS_i32PostStartEnrichmentScaled;
|
||||
EXTERN bool CTS_boCTSReady;
|
||||
EXTERN bool CTS_boRadFanOn;
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void CTS_vStart(uint32 * const pu32Arg);
|
||||
void CTS_vRun(uint32* const pu32Arg);
|
||||
void CTS_vTerminate(uint32* const pu32Arg);
|
||||
void CTS_vThread(void);
|
||||
void CTS_vCallBack(puint32 const pu32Arg);
|
||||
|
||||
#endif // CTS_H
|
||||
|
|
@ -0,0 +1,801 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Diagnostics */
|
||||
/* DESCRIPTION: This code module initialises the required comms */
|
||||
/* resources for and provides functions for diagnostics */
|
||||
/* FILE NAME: DIAG.c */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _USERDIAG_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "diag.h"
|
||||
#include "PERUART.h"
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
const USERDIAG_tstIdentifierIB USERDIAG_rastIdentifierIB[] = USER_DIAG_nCIDInfo;
|
||||
DIAGAPI_tenDiagSecurityLevel USERDIAG_enSecLevel;
|
||||
uint32 USERDIAG_u32GlobalTimeTick;
|
||||
//ASAM mode=readvalue name="DIAGGlobalTimeTick" type=uint32 offset=0 min=0 max=10000 m=1 b=0 units="dl" format=6.0 help="Data Logging Global Time Tick"
|
||||
puint8 USERDIAG_pu8Mode1Data;
|
||||
puint8 USERDIAG_pu8Mode2Data;
|
||||
puint8 USERDIAG_pu8Mode3Data;
|
||||
puint8 USERDIAG_pu8Mode4Data;
|
||||
puint8 USERDIAG_pu8Mode6Data;
|
||||
puint8 USERDIAG_pu8Mode7Data;
|
||||
uint16 USERDIAG_rau16Mode1DataOffsets[MODE1_PIDS_COUNT] = USERDIAG_nMode1PIDOffsets;
|
||||
const uint8 USERDIAG_rau8Codes648[] = USERDIAG_nCodes648;
|
||||
const uint8 USERDIAG_rau8Codes1152[] = USERDIAG_nCodes1152;
|
||||
|
||||
CQUEUE_tstQueue* DIAG_pstUARTQueue;
|
||||
uint8* DIAG_pu8UARTBuffer;
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
/*******************************************************************************
|
||||
* Interface : DIAG_vNTOH
|
||||
*
|
||||
* Implementation : Network to Host data endianness conversion
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : Pointer to the data
|
||||
* Par2 : Datacount
|
||||
* Par3 : Datasize in bytes
|
||||
*
|
||||
* Return Value : Nil
|
||||
*******************************************************************************/
|
||||
static void DIAG_vNTOH(puint8 pu8Data, uint8 u8DataCount, uint8 u8DataSize);
|
||||
static SPREADAPI_ttSpreadIDX USERDIAG_stGetSpreadIDX(puint8 pu8Data);
|
||||
|
||||
/* TODO
|
||||
static void USERDIAG_vSnapShot(uint16);
|
||||
*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Interface : USERDIAG_i16GetCIDParamAddress
|
||||
*
|
||||
* Implementation : Serach for the index of a CID within a CID info table
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : The CID being searched for
|
||||
*
|
||||
* Return Value : Index of the found data, -1 for failed to find
|
||||
*******************************************************************************/
|
||||
static sint16 USERDIAG_i16GetCIDParamAddress(uint16);
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void USERDIAG_vStart(puint32 const pu32Arg)
|
||||
{
|
||||
IOAPI_tenEHIOType enEHIOType;
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_tstPortConfigCB stPortConfigCB;
|
||||
DIAGAPI_tenCallBackType enCallBackType;
|
||||
uint32 u32DiagSpreadsIDX;
|
||||
|
||||
USERDIAG_u32GlobalTimeTick = 0;
|
||||
DIAG_u8EngagedGearReport = 255;
|
||||
|
||||
BOOSTED_vResetSVCResult();
|
||||
|
||||
for (u32DiagSpreadsIDX = 0; u32DiagSpreadsIDX < DIAG_nSPREADSRECORDSMAX; u32DiagSpreadsIDX++)
|
||||
{
|
||||
DIAG_astIDXAddressPairs[u32DiagSpreadsIDX].pData = NULL;
|
||||
DIAG_astIDXAddressPairs[u32DiagSpreadsIDX].tSpreadIDX = ~0;
|
||||
}
|
||||
|
||||
for (u32DiagSpreadsIDX = 0; u32DiagSpreadsIDX < DIAG_nSPREADSMAX; u32DiagSpreadsIDX++)
|
||||
{
|
||||
DIAG_apu8SpreadTableAddresses[DIAG_nSPREADSMAX] = NULL;
|
||||
}
|
||||
|
||||
|
||||
#ifdef USERDIAG_nEnableUART
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
/* Setup the USERDIAG UART resources */
|
||||
enEHIOResource = EH_VIO_UART1;
|
||||
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, NULL, NULL);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stPortConfigCB.enPortMode = IOAPI_enPortComms;
|
||||
stPortConfigCB.u32BaudRateHz = USERDIAG_nUARTFrequency;
|
||||
stPortConfigCB.enVIOResource = EH_VIO_UART1;
|
||||
stPortConfigCB.stPinConfig.uPinInfo.stUARTPinInfo.enRXPin = EH_IO_UART1_RX;
|
||||
stPortConfigCB.stPinConfig.uPinInfo.stUARTPinInfo.enTXPin = EH_IO_UART1_TX;
|
||||
stPortConfigCB.stPinConfig.uPinInfo.stUARTPinInfo.enRTSPin = EH_IO_Invalid;
|
||||
stPortConfigCB.stPinConfig.uPinInfo.stUARTPinInfo.enCTSPin = EH_IO_Invalid;
|
||||
stPortConfigCB.enLLProtocol = PROTAPI_enLLNone;
|
||||
stPortConfigCB.enNLProtocol = PROTAPI_enNLNone;
|
||||
stPortConfigCB.enTLProtocol = PROTAPI_enTLNone;
|
||||
stPortConfigCB.pfRXTransferCB = NULL;
|
||||
stPortConfigCB.pfTXTransferCB = NULL;
|
||||
enEHIOType = IOAPI_enUARTBus;
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stPortConfigCB);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
enCallBackType = DIAGAPI_enDataWriteCB;
|
||||
USER_vSVC(SYSAPI_enSetDiagCallback, (void*)&enCallBackType, (void*)USERDIAG_boWriteDataCallBack, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
/* Let's not TX in interrupt mode */
|
||||
UARTHA_vDisableTXInterrupt(enEHIOResource);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
USER_vSVC(SYSAPI_enGetByteQueue, (void*)&enEHIOResource, NULL, NULL);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
DIAG_pstUARTQueue = (CQUEUE_tstQueue*)pstSVCDataStruct->pvArg1;
|
||||
}
|
||||
}
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
USER_vSVC(SYSAPI_enGetByteQueueBuffer, (void*)&enEHIOResource, NULL, NULL);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
DIAG_pu8UARTBuffer = (uint8*)((CQUEUE_tstQueue*)pstSVCDataStruct->pvArg1);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USERDIAG_nEnableCAN
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
/* Setup the USERDIAG CAN resources */
|
||||
enEHIOResource = EH_VIO_CAN1;
|
||||
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, NULL, NULL);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stPortConfigCB.enPortMode = IOAPI_enPortComms;
|
||||
stPortConfigCB.u32BaudRateHz = USERDIAG_nCAN1Frequency;
|
||||
stPortConfigCB.enVIOResource = EH_VIO_CAN1;
|
||||
stPortConfigCB.stPinConfig.uPinInfo.stCANPinInfo.enRXPin = EH_IO_CAN1R;
|
||||
stPortConfigCB.stPinConfig.uPinInfo.stCANPinInfo.enTXPin = EH_IO_CAN1T;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32GlobalCANDiagAddress = 0x7df;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANDiagAddress = 0x7e0;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityAddress[0] = 80;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityAddress[1] = 1440;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityAddress[2] = 1088;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityAddress[3] = 428;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityMask[0] = 0x7ff;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityMask[1] = 0x7ff;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityMask[2] = 0x7ff;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stCANNetInfo.u32CANPriorityMask[3] = 0x7ff;
|
||||
stPortConfigCB.enLLProtocol = PROTAPI_enLLCAN11;
|
||||
stPortConfigCB.enNLProtocol = PROTAPI_enISO15765;
|
||||
stPortConfigCB.enTLProtocol = PROTAPI_enTLUDS;
|
||||
stPortConfigCB.pfRXTransferCB = NULL;
|
||||
stPortConfigCB.pfTXTransferCB = NULL;
|
||||
enEHIOType = IOAPI_enCANBus;
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stPortConfigCB);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
enCallBackType = DIAGAPI_enDataWriteCB;
|
||||
USER_vSVC(SYSAPI_enSetDiagCallback, (void*)&enCallBackType, (void*)USERDIAG_boWriteDataCallBack, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
#ifdef USERDIAG_nEnableUSB
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
/* Setup the USERDIAG USB resources */
|
||||
enEHIOResource = EH_VIO_USB;
|
||||
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, NULL, NULL);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stPortConfigCB.enPortMode = IOAPI_enPortComms;
|
||||
stPortConfigCB.enVIOResource = EH_VIO_USB;
|
||||
stPortConfigCB.enLLProtocol = PROTAPI_enUSB;
|
||||
stPortConfigCB.enNLProtocol = PROTAPI_enISO15765;
|
||||
stPortConfigCB.enTLProtocol = PROTAPI_enTLUDS;
|
||||
stPortConfigCB.pfRXTransferCB = NULL;
|
||||
stPortConfigCB.pfTXTransferCB = NULL;
|
||||
enEHIOType = IOAPI_enUSBChannel;
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stPortConfigCB);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
enCallBackType = DIAGAPI_enDataWriteCB;
|
||||
USER_vSVC(SYSAPI_enSetDiagCallback, (void*)&enCallBackType, (void*)USERDIAG_boWriteDataCallBack, NULL);
|
||||
}
|
||||
}
|
||||
|
||||
USERDIAG_pu8Mode1Data = NULL;
|
||||
USERDIAG_pu8Mode2Data = NULL;
|
||||
USERDIAG_pu8Mode3Data = NULL;
|
||||
USERDIAG_pu8Mode4Data = NULL;
|
||||
USERDIAG_pu8Mode6Data = NULL;
|
||||
USERDIAG_pu8Mode7Data = NULL;
|
||||
|
||||
USER_vSVC(SYSAPI_enGetMode1Buffer, NULL, NULL, NULL);
|
||||
USERDIAG_pu8Mode1Data = pstSVCDataStruct->pvArg1;
|
||||
|
||||
if (NULL != USERDIAG_pu8Mode1Data)
|
||||
{
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Supported1]] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Supported1] + 1] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Supported1] + 2] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Supported1] + 3] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported2]] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported2] + 1] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported2] + 2] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported2] + 3] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported3]] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported3] + 1] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported3] + 2] = 0xff;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_Mode1Supported3] + 3] = 0xff;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef USERDIAG_nEnableENET
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
/* Setup the USERDIAG ENET resources */
|
||||
enEHIOResource = EH_VIO_ENET_CH1;
|
||||
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, NULL, NULL);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stPortConfigCB.enPortMode = IOAPI_enPortComms;
|
||||
stPortConfigCB.enVIOResource = EH_VIO_ENET_CH1;
|
||||
stPortConfigCB.enLLProtocol = PROTAPI_enLL802_3;
|
||||
stPortConfigCB.enNLProtocol = PROTAPI_enISO15765_IP;
|
||||
stPortConfigCB.enTLProtocol = PROTAPI_enTLUDS_UDP;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stLANNetInfo.u16RPCREQSourcePort = USERDIAG_nRPCUDSREQSourcePort;
|
||||
stPortConfigCB.stNetConfig.uNetInfo.stLANNetInfo.u16RPCREQDestPort = USERDIAG_nRPCUDSREQDestPort;
|
||||
stPortConfigCB.pfRXTransferCB = NULL;
|
||||
stPortConfigCB.pfTXTransferCB = NULL;
|
||||
enEHIOType = IOAPI_enENETChannel;
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stPortConfigCB);
|
||||
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
enCallBackType = DIAGAPI_enDataWriteCB;
|
||||
USER_vSVC(SYSAPI_enSetDiagCallback, (void*)&enCallBackType, (void*)USERDIAG_boWriteDataCallBack, NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
void USERDIAG_vRun(puint32 const pu32Arg)
|
||||
{
|
||||
static uint32 u32SpreadIDX;
|
||||
SPREADAPI_ttSpreadIDX tSpreadIDX;
|
||||
SPREADAPI_tstSpreadResult* pstSpreadResult;
|
||||
PROTAPI_tstCANMsg stCANMsg;
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
static uint8 u8Counter10;
|
||||
static uint8 u8Counter20;
|
||||
static uint8 u8Counter1000;
|
||||
static uint8 u8UARTSeq;
|
||||
uint32 u32Temp;
|
||||
uint8 u8Temp;
|
||||
static uint8 u8UARTChecksum;
|
||||
static uint8 au8UARTInBuffer[4];
|
||||
|
||||
USERDIAG_u32GlobalTimeTick++;
|
||||
|
||||
if (DIAG_nSPREADSMAX > u32SpreadIDX)
|
||||
{
|
||||
if (NULL != DIAG_apu8SpreadTableAddresses[u32SpreadIDX])
|
||||
{
|
||||
tSpreadIDX = USERDIAG_stGetSpreadIDX(DIAG_apu8SpreadTableAddresses[u32SpreadIDX]);
|
||||
|
||||
if (-1 != tSpreadIDX)
|
||||
{
|
||||
pstSpreadResult = BOOSTED_pstGetSpread(tSpreadIDX);
|
||||
DIAG_astSpreadResult[u32SpreadIDX].uSpreadData.stSpreadResult.u16SpreadIndex = pstSpreadResult->uSpreadData.stSpreadResult.u16SpreadIndex;
|
||||
DIAG_astSpreadResult[u32SpreadIDX].uSpreadData.stSpreadResult.u16SpreadOffset = pstSpreadResult->uSpreadData.stSpreadResult.u16SpreadOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Just copy the raw uint32 data because this is not a spread */
|
||||
DIAG_astSpreadResult[u32SpreadIDX].uSpreadData.u32Data = *(uint32*)DIAG_apu8SpreadTableAddresses[u32SpreadIDX];
|
||||
}
|
||||
}
|
||||
|
||||
u32SpreadIDX++;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32SpreadIDX = 0;
|
||||
}
|
||||
|
||||
if (NULL != USERDIAG_pu8Mode1Data)
|
||||
{
|
||||
switch (USERDIAG_u32GlobalTimeTick % 10)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case 1:
|
||||
{
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_RPM]] = (4 * CAM_u32RPMRaw) / 0x100;
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_RPM] + 1] = (4 * CAM_u32RPMRaw) & 0xff;
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_IAT]] = (uint8)(((sint32)40000 + ATS_tTempCFiltered) / 1000);
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_ECT]] = (uint8)(((sint32)40000 + CTS_tTempCFiltered) / 1000);
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_TPS]] = (uint8)(TPS_tThetaFiltered / 352);
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_MAP]] = (uint8)(MAP_tKiloPaFiltered / 1000);
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_IgnAdvance]] = (uint8)((EST_tIgnitionAdvanceMtheta / 500) + 128);
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_CalcEngineLoad]] = (uint8)(((MAP_tKiloPaFiltered / 1000) * CAM_u32RPMRaw) / 10000);
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_STT_Bank1]] = (uint8)(3 + (CLO2_u32STT[0] / 8));
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_STT_Bank2]] = (uint8)(3 + (CLO2_u32STT[1] / 8));
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_LTT_Bank1]] = 0x80;
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_LTT_Bank2]] = 0x80;
|
||||
|
||||
USERDIAG_pu8Mode1Data[USERDIAG_rau16Mode1DataOffsets[MODE1_FuelPressure]] = (uint8)(USERCAL_stRAMCAL.u16ReturnlessPressureKPa / 33);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((2 == (USERDIAG_u32GlobalTimeTick % 10)) && (TRUE == DIAG_u8PowerModeActive))
|
||||
{
|
||||
/* 10 millisecond group */
|
||||
stCANMsg.u8DLC = 8;
|
||||
stCANMsg.u32ID = 640;
|
||||
|
||||
if (400 > CAM_u32RPMFiltered)
|
||||
{
|
||||
stCANMsg.u32DWH = 0x01000000;
|
||||
stCANMsg.u32DWL = 0;
|
||||
|
||||
u32Temp = TPS_tThetaFiltered / 300;
|
||||
stCANMsg.u32DWL |= u32Temp;
|
||||
stCANMsg.u32DWL |= (u32Temp << 24);
|
||||
u32Temp = TPS_tThetaFiltered / 251;
|
||||
stCANMsg.u32DWL |= (u32Temp << 8);
|
||||
|
||||
if (6000 < TPS_tThetaFiltered)
|
||||
{
|
||||
u32Temp = (TPS_tThetaFiltered - 6000) / 100;
|
||||
stCANMsg.u32DWL |= (u32Temp << 16);
|
||||
stCANMsg.u32DWH &= 0x00ffffff;
|
||||
}
|
||||
|
||||
DIAG_u8PedalPositionReport = (TPS_tThetaFiltered - 6000) / 100;
|
||||
}
|
||||
else
|
||||
{
|
||||
stCANMsg.u32DWH = 0x01000000 + (((CAM_u32RPMFiltered * 4) % 0x100) << 8) + (CAM_u32RPMFiltered * 4) / 0x100;
|
||||
stCANMsg.u32DWL = 0;
|
||||
stCANMsg.u32DWH |= ((TORQUE_u32OutputTorqueModified & 0xff) << 16);
|
||||
|
||||
DIAG_u8PedalPositionReport = TORQUE_u32TorquePedalEstimateScaled / 100;
|
||||
|
||||
stCANMsg.u32DWL |= (TORQUE_u32OutputTorqueEstimate & 0xff);
|
||||
stCANMsg.u32DWL |= ((TORQUE_u32OutputTorqueEstimate & 0xff) << 24);
|
||||
stCANMsg.u32DWL |= ((TORQUE_u32IdleStabilisationTorque & 0xff) << 8);
|
||||
|
||||
u32Temp = DIAG_u8PedalPositionReport;
|
||||
stCANMsg.u32DWL |= (u32Temp << 16);
|
||||
|
||||
if (6000 < TPS_tThetaFiltered)
|
||||
{
|
||||
stCANMsg.u32DWH &= 0x00ffffff;
|
||||
}
|
||||
}
|
||||
|
||||
enEHIOResource = EH_VIO_CAN1;
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
stCANMsg.u8DLC = 8;
|
||||
stCANMsg.u32ID = 896;
|
||||
stCANMsg.u32DWL = 0x0000fe00;
|
||||
stCANMsg.u32DWH = 0x20830000;
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
stCANMsg.u8DLC = 8;
|
||||
stCANMsg.u32ID = 1160;
|
||||
|
||||
if (28800 < MAP_tKiloPaFiltered)
|
||||
{
|
||||
if (174500 > MAP_tKiloPaFiltered)
|
||||
{
|
||||
u32Temp = ((MAP_tKiloPaFiltered - 28800) / 573) << 8;
|
||||
u32Temp = u32Temp | ((u32Temp) << 8);
|
||||
}
|
||||
else
|
||||
{
|
||||
u32Temp = 0xfefe00;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
u32Temp = 0;
|
||||
}
|
||||
|
||||
u32Temp |= ((u8Counter10 << 28) + 126);
|
||||
stCANMsg.u32DWH = u32Temp;
|
||||
|
||||
stCANMsg.u32DWL = 0xfeffff00;
|
||||
USER_DIAG_APPEND_XOR();
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
u8Counter10 = (u8Counter10 + 1) % 0x10;
|
||||
}
|
||||
|
||||
if ((6 == (USERDIAG_u32GlobalTimeTick % 20)) && (TRUE == DIAG_u8PowerModeActive))
|
||||
{
|
||||
/* 20 millisecond group */
|
||||
stCANMsg.u8DLC = 8;
|
||||
stCANMsg.u32ID = 866;
|
||||
stCANMsg.u32DWH = (u8Counter20 << 24) + 166;
|
||||
stCANMsg.u32DWL = 0xfe000000;
|
||||
enEHIOResource = EH_VIO_CAN1;
|
||||
|
||||
if (8 <= u8Counter20)
|
||||
{
|
||||
stCANMsg.u32DWL += (u8Counter20 + 72);
|
||||
}
|
||||
else
|
||||
{
|
||||
stCANMsg.u32DWL += (u8Counter20 + 88);
|
||||
}
|
||||
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
stCANMsg.u32ID = 644;
|
||||
stCANMsg.u8DLC = 6;
|
||||
stCANMsg.u32DWL = 0;
|
||||
stCANMsg.u32DWH = (u8Counter20 << 24) + (u8Counter20 << 16);
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
stCANMsg.u8DLC = 8;
|
||||
stCANMsg.u32ID = 648;
|
||||
|
||||
stCANMsg.u32DWH = USERDIAG_rau8Codes648[u8Counter20] << 24;
|
||||
stCANMsg.u32DWH |= ((32 << 8) + 6);
|
||||
|
||||
if (0 <= CTS_tTempCFiltered)
|
||||
{
|
||||
u32Temp = CTS_tTempCFiltered / 500;
|
||||
stCANMsg.u32DWH |= (u32Temp << 16);
|
||||
}
|
||||
|
||||
if (TRUE == SENSORS_boBrakePedalPressed)
|
||||
{
|
||||
stCANMsg.u32DWH |= 0x0300;
|
||||
}
|
||||
|
||||
stCANMsg.u32DWL = (76 << 16) + ((TORQUE_u32TorqueModelEstimateScaled & 0xff) << 8) +
|
||||
TORQUE_u32TorqueModelEstimateScaled / 0x100;
|
||||
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
stCANMsg.u32ID = 1152;
|
||||
stCANMsg.u32DWH = USERDIAG_rau8Codes1152[u8Counter20] << 24;
|
||||
stCANMsg.u32DWH |= (44 << 16);
|
||||
stCANMsg.u32DWL = (24 << 24) + (4 << 8);
|
||||
USER_DIAG_APPEND_XOR();
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
stCANMsg.u32ID = 1162;
|
||||
stCANMsg.u32DWL = u8Counter20 << 4;
|
||||
stCANMsg.u32DWH = (u8Counter20 << 28) + (2 << 24) + 2;
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
stCANMsg.u32ID = 1416;
|
||||
stCANMsg.u32DWH = (232 << 24) + (60 << 16) + (127 << 8) + 135;
|
||||
stCANMsg.u32DWL = (52 << 24) + 153;
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
|
||||
u8Counter20 = (u8Counter20 + 1) % 0x10;
|
||||
}
|
||||
|
||||
if ((8 == (USERDIAG_u32GlobalTimeTick % 1000)) && (TRUE == DIAG_u8PowerModeActive))
|
||||
{
|
||||
stCANMsg.u8DLC = 8;
|
||||
stCANMsg.u32ID = 1408;
|
||||
stCANMsg.u32DWH = u8Counter1000 << 24;
|
||||
stCANMsg.u32DWL = 0;
|
||||
enEHIOResource = EH_VIO_CAN1;
|
||||
u8Counter1000 = (u8Counter1000 + 1) % 0x10;
|
||||
USER_vSVC(SYSAPI_enQueueCANMessage, (void*)&enEHIOResource, (void*)&stCANMsg, (void*)NULL);/*CR1_12*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* UART data */
|
||||
else if (19 == (USERDIAG_u32GlobalTimeTick % 64))
|
||||
{
|
||||
u8Temp = 0x3f & USERCAL_stRAMCAL.u8DBSlaveConfig;
|
||||
UARTHA_vSendChar(EH_VIO_UART1, u8Temp + u8UARTSeq);
|
||||
u8UARTChecksum += (u8Temp + u8UARTSeq);
|
||||
u8UARTSeq -= 0x40;
|
||||
}
|
||||
else if (27 == (USERDIAG_u32GlobalTimeTick % 64))
|
||||
{
|
||||
u8Temp = 0x3f & TORQUE_u16ETCScale;
|
||||
UARTHA_vSendChar(EH_VIO_UART1, u8Temp + u8UARTSeq);
|
||||
u8UARTChecksum += (u8Temp + u8UARTSeq);
|
||||
u8UARTSeq -= 0x40;
|
||||
}
|
||||
else if (35 == (USERDIAG_u32GlobalTimeTick % 64))
|
||||
{
|
||||
switch (USERCAL_stRAMCAL.u16DiagType)
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
if (0x1234 == USERCAL_stRAMCAL.u16ETCOverrideKeys)
|
||||
{
|
||||
u8Temp = (uint8)USERCAL_stRAMCAL.u16ETCOverride;
|
||||
}
|
||||
else if ((0 != TORQUE_u16GearShiftCount) && (TRUE == TORQUE_boDownShift))
|
||||
{
|
||||
u8Temp = (TORQUE_u16RevMatchRPM - 800) / 300;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (100000 > MAP_tKiloPaFiltered)//todo chatters here
|
||||
{
|
||||
u8Temp = 0x3f & IAC_u8SlaveTarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
u8Temp = MAP_u8PressureThrottleTrim;
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
if (0 != CAM_u32RPMFiltered)
|
||||
{
|
||||
u8Temp = 0x3f & IAC_u8SlaveTarget;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* ISC neutral point */
|
||||
u8Temp = 0x18;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
u8Temp = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
UARTHA_vSendChar(EH_VIO_UART1, u8Temp + u8UARTSeq);
|
||||
u8UARTChecksum += (u8Temp + u8UARTSeq);
|
||||
u8UARTSeq -= 0x40;
|
||||
}
|
||||
else if (43 == (USERDIAG_u32GlobalTimeTick % 64))
|
||||
{
|
||||
UARTHA_vSendChar(EH_VIO_UART1, u8UARTSeq + (0x3f & u8UARTChecksum));
|
||||
u8UARTChecksum = 0;
|
||||
u8UARTSeq = 0xc0;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
if (FALSE == CQUEUE_xIsEmpty(DIAG_pstUARTQueue))
|
||||
{
|
||||
uint8 u8Temp = DIAG_pu8UARTBuffer[DIAG_pstUARTQueue->u32Tail];
|
||||
CQUEUE_xRemoveItem(DIAG_pstUARTQueue);
|
||||
|
||||
au8UARTInBuffer[3 - (u8Temp >> 6)] = u8Temp;
|
||||
|
||||
if (0xc0 == (u8Temp & 0xc0))
|
||||
{
|
||||
u8Temp = au8UARTInBuffer[1];
|
||||
u8Temp += au8UARTInBuffer[2];
|
||||
u8Temp += au8UARTInBuffer[3];
|
||||
|
||||
if (au8UARTInBuffer[1] == (u8Temp & 0x3f))
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* TODO
|
||||
static void USERDIAG_vSnapShot(uint16 u16FreezeDTC)
|
||||
{
|
||||
memcpy(USERDIAG_pu8Mode2Data, USERDIAG_pu8Mode1Data, USERDIAG_nMode1BufferSize);
|
||||
USERDIAG_pu8Mode2Data[USERDIAG_rau16Mode1DataOffsets[MODE1_FreezeDTC]] = u16FreezeDTC / 0x100;
|
||||
USERDIAG_pu8Mode2Data[USERDIAG_rau16Mode1DataOffsets[MODE1_FreezeDTC] + 1] = u16FreezeDTC / 0x100;
|
||||
}
|
||||
*/
|
||||
|
||||
static SPREADAPI_ttSpreadIDX USERDIAG_stGetSpreadIDX(puint8 pu8Data)
|
||||
{
|
||||
SPREADAPI_ttSpreadIDX tSpreadIDX = -1;
|
||||
uint32 u32AddressPairIDX;
|
||||
|
||||
for (u32AddressPairIDX = 0; u32AddressPairIDX < DIAG_nSPREADSRECORDSMAX; u32AddressPairIDX++)
|
||||
{
|
||||
if (pu8Data == DIAG_astIDXAddressPairs[u32AddressPairIDX].pData)
|
||||
{
|
||||
tSpreadIDX = DIAG_astIDXAddressPairs[u32AddressPairIDX].tSpreadIDX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return tSpreadIDX;
|
||||
}
|
||||
|
||||
void USERDIAG_vAddIDXAddressPair(USERDIAG_tstSpreadIDXAddressPair* pstSpreadIDXAddressPair)
|
||||
{
|
||||
uint32 u32DiagSpreadsIDX;
|
||||
|
||||
for (u32DiagSpreadsIDX = 0; u32DiagSpreadsIDX < DIAG_nSPREADSRECORDSMAX; u32DiagSpreadsIDX++)
|
||||
{
|
||||
if (NULL == DIAG_astIDXAddressPairs[u32DiagSpreadsIDX].pData)
|
||||
{
|
||||
DIAG_astIDXAddressPairs[u32DiagSpreadsIDX].pData = pstSpreadIDXAddressPair->pData;
|
||||
DIAG_astIDXAddressPairs[u32DiagSpreadsIDX].tSpreadIDX = pstSpreadIDXAddressPair->tSpreadIDX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void USERDIAG_vTerminate(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void USERDIAG_vCallBack(uint32* const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
DIAGAPI_tenCBResult USERDIAG_boReadDataCallBack(uint16 u16CID, puint8 pu8Data, uint8 u8DataCount)
|
||||
{
|
||||
return DIAGAPI_enCBOK;/*CR1_25*/
|
||||
}
|
||||
|
||||
DIAGAPI_tenCBResult USERDIAG_boWriteDataCallBack(uint16 u16CID, puint8 pu8Data, uint8 u8DataCount)
|
||||
{
|
||||
sint16 i16CIDIDX;
|
||||
DIAGAPI_tenCBResult enCBResult = DIAGAPI_enRWGenFail;
|
||||
|
||||
i16CIDIDX = USERDIAG_i16GetCIDParamAddress(u16CID);
|
||||
|
||||
if (-1 != i16CIDIDX)
|
||||
{
|
||||
if (USERDIAG_enSecLevel >= USERDIAG_rastIdentifierIB[i16CIDIDX].enSecLevel)
|
||||
{
|
||||
DIAG_vNTOH(pu8Data, u8DataCount, USERDIAG_rastIdentifierIB[i16CIDIDX].u8DataSize);
|
||||
memcpy((void*)USERDIAG_rastIdentifierIB[i16CIDIDX].pu8Data,
|
||||
(void*)pu8Data, USERDIAG_rastIdentifierIB[i16CIDIDX].u8DataCount);
|
||||
enCBResult = DIAGAPI_enCBOK;
|
||||
}
|
||||
else
|
||||
{
|
||||
enCBResult = DIAGAPI_enRWSecurityError;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
enCBResult = DIAGAPI_enRWParamNotFound;
|
||||
}
|
||||
|
||||
return enCBResult;
|
||||
}
|
||||
|
||||
DIAGAPI_tenCBResult USERDIAG_boRoutineControl(DIAGAPI_tenRoutineAction enRoutineAction, puint8 pu8Data, uint8 u8DataCount)
|
||||
{
|
||||
return DIAGAPI_enCBOK;/*CR1_25*/
|
||||
}
|
||||
|
||||
static sint16 USERDIAG_i16GetCIDParamAddress(uint16 u16CID)
|
||||
{
|
||||
uint16 u16IDX;
|
||||
sint16 i16CIDIDX = -1;
|
||||
|
||||
for (u16IDX = 0;
|
||||
u16IDX < (sizeof(USERDIAG_rastIdentifierIB) / sizeof(USERDIAG_tstIdentifierIB));
|
||||
u16IDX++)
|
||||
{
|
||||
if (u16CID == USERDIAG_rastIdentifierIB[u16IDX].u16CID)
|
||||
{
|
||||
i16CIDIDX = u16IDX;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return i16CIDIDX;
|
||||
}
|
||||
|
||||
static void DIAG_vNTOH(puint8 pu8Data, uint8 u8DataCount, uint8 u8DataSize)
|
||||
{
|
||||
uint32 u32Temp;
|
||||
uint16 u16Temp;
|
||||
|
||||
if ((4 > u8DataSize) && (0 == (u8DataCount % u8DataSize)))/*CR1_28*//*CR1_29*/
|
||||
{
|
||||
while (0 < u8DataCount)
|
||||
{
|
||||
switch ((u8DataCount & 0x03) % u8DataSize)/*CR1_27*/
|
||||
{
|
||||
case 0:
|
||||
{
|
||||
memcpy((void*)&u32Temp, (void*)pu8Data, 4);
|
||||
*pu8Data++ = (uint8)((u32Temp & 0xff000000) >> 24);
|
||||
*pu8Data++ = (uint8)((u32Temp & 0xff0000) >> 16);
|
||||
*pu8Data++ = (uint8)((u32Temp & 0xff00) >> 8);
|
||||
*pu8Data++ = (uint8)((u32Temp & 0xff) >> 0);
|
||||
u8DataCount -= 4;
|
||||
break;
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
memcpy((void*)&u16Temp, (void*)pu8Data, 2);
|
||||
*pu8Data++ = (uint8)((u16Temp & 0xff00) >> 8);
|
||||
*pu8Data++ = (uint8)((u16Temp & 0xff) >> 0);
|
||||
u8DataCount -= 2;
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
{
|
||||
u8DataCount = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
||||
|
||||
|
|
@ -0,0 +1,388 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Diagnostics Header File */
|
||||
/* DESCRIPTION: This code module initialises the required comms */
|
||||
/* resources for and provides functions for diagnostics */
|
||||
/* FILE NAME: DIAG.h */
|
||||
/* REVISION HISTORY: 07-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef USERDIAG_H
|
||||
#define USERDIAG_H
|
||||
|
||||
#include <DECLARATIONS.h>
|
||||
#include <string.h>
|
||||
#include "ADCAPI.h"
|
||||
#include "BVM.h"
|
||||
#include "DIAGAPI.h"
|
||||
#include "IOAPI.h"
|
||||
#include "SYSAPI.h"
|
||||
#include "UNITS.h"
|
||||
#include "USER.h"
|
||||
|
||||
|
||||
/* GLOBAL TYPE DEFINITIONS ****************************************************/
|
||||
/*******************************************************************************
|
||||
* Description : Type to hold a CID configuration
|
||||
*******************************************************************************/
|
||||
typedef struct
|
||||
{
|
||||
uint16 u16CID;
|
||||
puint8 pu8Data;
|
||||
uint8 u8DataCount;
|
||||
uint8 u8DataSize;
|
||||
DIAGAPI_tenDiagSecurityLevel enSecLevel;
|
||||
} USERDIAG_tstIdentifierIB;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
SPREADAPI_ttSpreadIDX tSpreadIDX;
|
||||
uint8* pData;
|
||||
} USERDIAG_tstSpreadIDXAddressPair;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
MODE1_Supported1,
|
||||
MODE1_StatSinceDTCClear,
|
||||
MODE1_FreezeDTC,
|
||||
MODE1_FuelSysStatus,
|
||||
MODE1_CalcEngineLoad,
|
||||
MODE1_ECT,
|
||||
MODE1_STT_Bank1,
|
||||
MODE1_LTT_Bank1,
|
||||
MODE1_STT_Bank2,
|
||||
MODE1_LTT_Bank2,
|
||||
MODE1_FuelPressure,
|
||||
MODE1_MAP,
|
||||
MODE1_RPM,
|
||||
MODE1_VSS,
|
||||
MODE1_IgnAdvance,
|
||||
MODE1_IAT,
|
||||
MODE1_MAFMassPerSec,
|
||||
MODE1_TPS,
|
||||
MODE1_CmdSecAirStatus,
|
||||
MODE1_O2SensorsPresent,
|
||||
MODE1_O2Sensor1StatSTFT,
|
||||
MODE1_O2Sensor2StatSTFT,
|
||||
MODE1_O2Sensor3StatSTFT,
|
||||
MODE1_O2Sensor4StatSTFT,
|
||||
MODE1_O2Sensor5StatSTFT,
|
||||
MODE1_O2Sensor6StatSTFT,
|
||||
MODE1_O2Sensor7StatSTFT,
|
||||
MODE1_O2Sensor8StatSTFT,
|
||||
MODE1_OBDStandards,
|
||||
MODE1_O2SensorsPreset4Bank,
|
||||
MODE1_AuxInputStat,
|
||||
MODE1_RunTimeStart,
|
||||
\
|
||||
MODE1_Mode1Supported2,
|
||||
MODE1_DistMIL,
|
||||
MODE1_RailPressure,
|
||||
MODE1_GaugePressure,
|
||||
MODE1_O2Sensor1AFEquivalence,
|
||||
MODE1_O2Sensor2AFEquivalence,
|
||||
MODE1_O2Sensor3AFEquivalence,
|
||||
MODE1_O2Sensor4AFEquivalence,
|
||||
MODE1_O2Sensor5AFEquivalence,
|
||||
MODE1_O2Sensor6AFEquivalence,
|
||||
MODE1_O2Sensor7AFEquivalence,
|
||||
MODE1_O2Sensor8AFEquivalence,
|
||||
MODE1_CommandEGR,
|
||||
MODE1_EGRError,
|
||||
MODE1_CommandEvap,
|
||||
MODE1_FuelLevelInput,
|
||||
MODE1_OKWarmUps,
|
||||
MODE1_DistSinceOK,
|
||||
MODE1_EvapPressure,
|
||||
MODE1_AbsolutePressure,
|
||||
MODE1_O2Sensor1AFEquivalenceB,
|
||||
MODE1_O2Sensor2AFEquivalenceB,
|
||||
MODE1_O2Sensor3AFEquivalenceB,
|
||||
MODE1_O2Sensor4AFEquivalenceB,
|
||||
MODE1_O2Sensor5AFEquivalenceB,
|
||||
MODE1_O2Sensor6AFEquivalenceB,
|
||||
MODE1_O2Sensor7AFEquivalenceB,
|
||||
MODE1_O2Sensor8AFEquivalenceB,
|
||||
MODE1_Catalyst1Temp_Bank1,
|
||||
MODE1_Catalyst2Temp_Bank1,
|
||||
MODE1_Catalyst1Temp_Bank2,
|
||||
MODE1_Catalyst2Temp_Bank2,
|
||||
\
|
||||
MODE1_Mode1Supported3,
|
||||
MODE1_1,
|
||||
MODE1_2,
|
||||
MODE1_3,
|
||||
MODE1_4,
|
||||
MODE1_5,
|
||||
MODE1_6,
|
||||
MODE1_7,
|
||||
MODE1_8,
|
||||
MODE1_9,
|
||||
MODE1_10,
|
||||
MODE1_11,
|
||||
MODE1_12,
|
||||
MODE1_13,
|
||||
MODE1_14,
|
||||
MODE1_15,
|
||||
MODE1_16,
|
||||
MODE1_17,
|
||||
MODE1_18,
|
||||
MODE1_19,
|
||||
MODE1_20,
|
||||
MODE1_21,
|
||||
MODE1_22,
|
||||
MODE1_23,
|
||||
MODE1_24,
|
||||
MODE1_25,
|
||||
MODE1_26,
|
||||
MODE1_27,
|
||||
MODE1_28,
|
||||
MODE1_29,
|
||||
MODE1_30,
|
||||
MODE1_31,
|
||||
MODE1_Mode1Supported4,
|
||||
MODE1_PIDS_COUNT
|
||||
} USERDIAG_tenMode1PIDS;
|
||||
|
||||
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
#define USERDIAG_nUARTFrequency 9600u
|
||||
#define USERDIAG_nCAN2Frequency 500000u
|
||||
#define USERDIAG_nRPCUDSREQSourcePort 0xc398
|
||||
#define USERDIAG_nRPCUDSREQDestPort 0x9c14
|
||||
#define USERDIAG_nRPCUDSRESPSourcePort 0x9c05
|
||||
#define USERDIAG_nRPCUDSRESPDestPort 0x9c15
|
||||
#define USERDIAG_nEnableUART
|
||||
#define USERDIAG_nEnableCAN
|
||||
#define USERDIAG_nEnableUSB
|
||||
#define USERDIAG_nEnableENEToff
|
||||
|
||||
#ifdef BUILD_MK60
|
||||
#define DIAG_nRESCAN EH_VIO_CAN2
|
||||
#endif
|
||||
|
||||
#ifdef BUILD_MK64
|
||||
#define DIAG_nRESCAN EH_VIO_CAN
|
||||
#endif
|
||||
|
||||
#define USER_DIAG_APPEND_XOR() \
|
||||
u32Temp = ((0xff000000 & stCANMsg.u32DWH) >> 24) ^\
|
||||
((0x00ff0000 & stCANMsg.u32DWH) >> 16) ^\
|
||||
((0x0000ff00 & stCANMsg.u32DWH) >> 8) ^\
|
||||
((0x000000ff & stCANMsg.u32DWH) >> 0) ^\
|
||||
((0xff000000 & stCANMsg.u32DWL) >> 24) ^\
|
||||
((0x00ff0000 & stCANMsg.u32DWL) >> 16) ^\
|
||||
((0x0000ff00 & stCANMsg.u32DWL) >> 8);\
|
||||
stCANMsg.u32DWL += u32Temp;
|
||||
|
||||
#define USER_DIAG_nCIDInfo \
|
||||
{ \
|
||||
{ 0x8000, (puint8)&USERCAL_stRAMCAL.userCalADRefH, sizeof(GPM6_ttVolts), 4, DIAGAPI_enSecLevelInactive}, \
|
||||
{ 0x8001, (puint8)&USERCAL_stRAMCAL.userCalVRef445, sizeof(GPM6_ttVolts), 4, DIAGAPI_enSecLevelInactive}, \
|
||||
{ 0x8002, (puint8)&USERCAL_stRAMCAL.userCalVNernstTarget, sizeof(GPM6_ttVolts), 4, DIAGAPI_enSecLevelInactive}, \
|
||||
{ 0x8003, (puint8)&USERCAL_stRAMCAL.userCalRNernstReady, sizeof(GPM6_ttVolts), 4, DIAGAPI_enSecLevelInactive}, \
|
||||
{ 0x8004, (puint8)&USERCAL_stRAMCAL.au32UserCalPumpCurrentPFactor, 2 * sizeof(uint32), 4, DIAGAPI_enSecLevelInactive} \
|
||||
}
|
||||
|
||||
#define USERDIAG_nMode1PIDOffsets \
|
||||
{\
|
||||
0,\
|
||||
4,\
|
||||
8,\
|
||||
10,\
|
||||
12,\
|
||||
13,\
|
||||
14,\
|
||||
15,\
|
||||
16,\
|
||||
17,\
|
||||
18,\
|
||||
19,\
|
||||
20,\
|
||||
22,\
|
||||
23,\
|
||||
24,\
|
||||
25,\
|
||||
27,\
|
||||
28,\
|
||||
29,\
|
||||
30,\
|
||||
32,\
|
||||
34,\
|
||||
36,\
|
||||
38,\
|
||||
40,\
|
||||
42,\
|
||||
44,\
|
||||
46,\
|
||||
47,\
|
||||
48,\
|
||||
49,\
|
||||
51,\
|
||||
55,\
|
||||
57,\
|
||||
59,\
|
||||
61,\
|
||||
65,\
|
||||
69,\
|
||||
73,\
|
||||
77,\
|
||||
81,\
|
||||
85,\
|
||||
89,\
|
||||
93,\
|
||||
94,\
|
||||
95,\
|
||||
96,\
|
||||
97,\
|
||||
98,\
|
||||
100,\
|
||||
102,\
|
||||
103,\
|
||||
107,\
|
||||
111,\
|
||||
115,\
|
||||
119,\
|
||||
123,\
|
||||
127,\
|
||||
131,\
|
||||
135,\
|
||||
137,\
|
||||
139,\
|
||||
141,\
|
||||
143,\
|
||||
147,\
|
||||
151,\
|
||||
153,\
|
||||
155,\
|
||||
157,\
|
||||
158,\
|
||||
159,\
|
||||
160,\
|
||||
161,\
|
||||
162,\
|
||||
163,\
|
||||
164,\
|
||||
165,\
|
||||
167,\
|
||||
169,\
|
||||
173,\
|
||||
177,\
|
||||
178,\
|
||||
179,\
|
||||
181,\
|
||||
183,\
|
||||
185,\
|
||||
187,\
|
||||
189,\
|
||||
191,\
|
||||
193,\
|
||||
194,\
|
||||
195,\
|
||||
196,\
|
||||
198,\
|
||||
200,\
|
||||
201}
|
||||
|
||||
#define USERDIAG_nUARTFrequency 9600u
|
||||
#define USERDIAG_nCAN1Frequency 500000u
|
||||
#define USERDIAG_nMode1BufferSize 256
|
||||
|
||||
#define USERDIAG_nCodes648 {54,54,78,78,78,78,139,139,139,139,232,232,232,232,54,54}
|
||||
#define USERDIAG_nCodes1152 {28,28,81,81,81,81,132,132,132,132,193,193,193,193,28,28}
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _USERDIAG_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
EXTERN uint8 DIAG_u8EngagedGearReport;
|
||||
//ASAM mode=readvalue name="Engaged Gear Report" type=uint8 offset=0 min=0 max=10 m=1 b=0 units="dl" format=1.0 help="Engaged Gear Report"
|
||||
|
||||
EXTERN uint8 DIAG_u8PedalPositionReport;
|
||||
//ASAM mode=readvalue name="Pedal Position Report" type=uint8 offset=0 min=0 max=120 m=0.4 b=0 units="dl" format=2.0 help="Pedal Position Report"
|
||||
|
||||
EXTERN uint8 DIAG_u8GearSelectorReport;
|
||||
//ASAM mode=readvalue name="Gear Selector Report" type=uint8 offset=0 min=0 max=10 m=1 b=0 units="dl" format=1.0 help="Gear Selector Report"
|
||||
|
||||
EXTERN uint8 DIAG_u8PowerModeActive;
|
||||
EXTERN uint16 DIAG_u16PowerModeActiveCount;
|
||||
EXTERN uint16 DIAG_u16PowerModeCode;
|
||||
|
||||
#define DIAG_nSPREADSMAX 5
|
||||
#define DIAG_nSPREADSRECORDSMAX 50
|
||||
|
||||
EXTERN SPREADAPI_tstSpreadResult DIAG_astSpreadResult[DIAG_nSPREADSMAX];
|
||||
//ASAM mode=readvalue name="_DIAG Spread Result Table 0" type=uint32 offset=0 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Result Table"
|
||||
//ASAM mode=readvalue name="_DIAG Spread Result Table 1" type=uint32 offset=4 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Result Table"
|
||||
//ASAM mode=readvalue name="_DIAG Spread Result Table 2" type=uint32 offset=8 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Result Table"
|
||||
//ASAM mode=readvalue name="_DIAG Spread Result Table 3" type=uint32 offset=12 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Result Table"
|
||||
|
||||
EXTERN uint8* DIAG_apu8SpreadTableAddresses[DIAG_nSPREADSMAX];
|
||||
//ASAM mode=writevalue name="_DIAG Spread Address Table 0" type=uint32 offset=0 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Address Table"
|
||||
//ASAM mode=writevalue name="_DIAG Spread Address Table 1" type=uint32 offset=4 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Address Table"
|
||||
//ASAM mode=writevalue name="_DIAG Spread Address Table 2" type=uint32 offset=8 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Address Table"
|
||||
//ASAM mode=writevalue name="_DIAG Spread Address Table 3" type=uint32 offset=12 min=0 max=1 m=1 b=0 units="dl" format=6.0 help="Internal Spread Address Table"
|
||||
EXTERN USERDIAG_tstSpreadIDXAddressPair DIAG_astIDXAddressPairs[DIAG_nSPREADSRECORDSMAX];
|
||||
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void USERDIAG_vStart(uint32* const pu32Arg);
|
||||
void USERDIAG_vRun(uint32* const pu32Arg);
|
||||
void USERDIAG_vTerminate(uint32* const pu32Arg);
|
||||
void USERDIAG_vCallBack(uint32* const pu32Arg);
|
||||
void USERDIAG_vAddIDXAddressPair(USERDIAG_tstSpreadIDXAddressPair* pstSpreadIDXAddressPair);
|
||||
|
||||
/*******************************************************************************
|
||||
* Interface : <Description of interface>
|
||||
*
|
||||
* Implementation : <Description of implementation>
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : <Comment on u8Param1 (line 1)>
|
||||
* Par2 : <Comment on pu16Param2 (line 1)>
|
||||
* <Comment on pu16Param2 (line 2)>
|
||||
*
|
||||
* Return Value : <Comment on return value >
|
||||
*******************************************************************************/
|
||||
DIAGAPI_tenCBResult USERDIAG_boReadDataCallBack(uint16 u16CID, puint8 pu8Data, uint8 u8DataCount);/*CR1_1*/;
|
||||
|
||||
/*******************************************************************************
|
||||
* Interface : <Description of interface>
|
||||
*
|
||||
* Implementation : <Description of implementation>
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : <Comment on u8Param1 (line 1)>
|
||||
* Par2 : <Comment on pu16Param2 (line 1)>
|
||||
* <Comment on pu16Param2 (line 2)>
|
||||
*
|
||||
* Return Value : <Comment on return value >
|
||||
*******************************************************************************/
|
||||
DIAGAPI_tenCBResult USERDIAG_boWriteDataCallBack(uint16 u16CID, puint8 pu8Data, uint8 u8DataCount);/*CR1_1*/
|
||||
|
||||
/*******************************************************************************
|
||||
* Interface : <Description of interface>
|
||||
*
|
||||
* Implementation : <Description of implementation>
|
||||
*
|
||||
* Parameter
|
||||
* Par1 : <Comment on u8Param1 (line 1)>
|
||||
* Par2 : <Comment on pu16Param2 (line 1)>
|
||||
* <Comment on pu16Param2 (line 2)>
|
||||
*
|
||||
* Return Value : <Comment on return value >
|
||||
*******************************************************************************/
|
||||
DIAGAPI_tenCBResult USERDIAG_boRoutineControl(DIAGAPI_tenRoutineAction enRoutineAction, puint8 pu8Data, uint8 u8DataCount);/*CR1_1*/;
|
||||
|
||||
#endif // USERDIAG_H
|
||||
|
|
@ -0,0 +1,651 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Electronic Spark Timing Header File */
|
||||
/* DESCRIPTION: This code module initialises the required */
|
||||
/* resources and functions for electronic spark timing */
|
||||
/* */
|
||||
/* FILE NAME: EST.c */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _EST_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "EST.h"
|
||||
#include "CEMAPI.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
TEPMAPI_tstTimedKernelEvent EST_astTimedKernelEvents[2];
|
||||
SPREADAPI_ttSpreadIDX EST_tSpreadTimingxIDX;
|
||||
SPREADAPI_ttSpreadIDX EST_tSpreadTimingyIDX;
|
||||
SPREADAPI_ttSpreadIDX EST_tSpreadDwellIDX;
|
||||
TABLEAPI_ttTableIDX EST_tMapTimingIDX;
|
||||
TABLEAPI_ttTableIDX EST_tMapTimingStage1IDX;
|
||||
TABLEAPI_ttTableIDX EST_tTableDwellIDX;
|
||||
uint16 EST_u16TimingBase;
|
||||
uint16 EST_u16TimingStaged;
|
||||
uint16 EST_u16Timing;
|
||||
uint16 EST_u16Dwell;
|
||||
|
||||
|
||||
EST_tenIgnitionTimingStage EST_enIgnitionTimingStage;
|
||||
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void EST_vStart(puint32 const pu32Arg)
|
||||
{
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
IOAPI_tenEHIOType enEHIOType;
|
||||
IOAPI_tenDriveStrength enDriveStrength;
|
||||
TEPMAPI_tstTEPMChannelCB stTEPMChannelCB;
|
||||
TEPMAPI_tstTEPMResourceCB stTEPMResourceCB;
|
||||
TEPMAPI_tstTimedUserEvent stTimedEvent;
|
||||
bool boCamSyncLate;
|
||||
uint32 u32CamSyncSampleToothCount;
|
||||
CEM_tstPatternSetupCB stPatternSetupCB;
|
||||
|
||||
IOAPI_tenEdgePolarity enEdgePolarity = USERCAL_stRAMCAL.u8UserPrimaryEdgeSetup;
|
||||
bool boFirstRising = 0 != USERCAL_stRAMCAL.u8UserFirstEdgeRisingPrimary;
|
||||
uint32 u32TriggerType = USERCAL_stRAMCAL.u8TriggerType;
|
||||
|
||||
/* Both peak and hold have a switch on and switch off event per cycle */
|
||||
TEPMAPI_ttEventCount tEventCount = 2;
|
||||
EST_tIgnitionAdvanceMtheta = 0;
|
||||
|
||||
EST_enIgnitionTimingStage = EST_nIgnitionPrimary;
|
||||
EST_enIgnitionTimingRequest = EST_nIgnitionReqPrimary;
|
||||
|
||||
/* Set dwell to 10 degrees - 360 degrees */
|
||||
EST_tStartFractionA = (0x10000 * 120) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionB = (0x10000 * 120) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionC = (0x10000 * 120) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionD = (0x10000 * 120) / EST_nDegreesPerCycle;
|
||||
EST_tDwellUs = 5000u;
|
||||
|
||||
/* Request and initialise FTM for igniters */
|
||||
enEHIOResource = EH_VIO_FTM0;
|
||||
enEHIOType = IOAPI_enTEPM;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, (void*)NULL, (void*)NULL);
|
||||
|
||||
/* ONLY CONFIGURE THE FTM0 MODULE ONCE PER PROJECT! */
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stTEPMResourceCB.enEHIOResource = EH_VIO_FTM0;
|
||||
stTEPMResourceCB.enPreScalar = SENSORS_nFastFTMDivisor;
|
||||
stTEPMResourceCB.enCountType = TEPMAPI_enCountUp;
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stTEPMResourceCB);
|
||||
}
|
||||
|
||||
/* Request and initialise FTM2 for igniters */
|
||||
enEHIOResource = EH_VIO_FTM2;
|
||||
enEHIOType = IOAPI_enTEPM;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource, (void*)NULL, (void*)NULL);
|
||||
|
||||
/* ONLY CONFIGURE THE TC2 MODULE ONCE PER PROJECT! */
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stTEPMResourceCB.enEHIOResource = EH_VIO_FTM2;
|
||||
stTEPMResourceCB.enPreScalar = SENSORS_nFastFTMDivisor;
|
||||
stTEPMResourceCB.enCountType = TEPMAPI_enCountUp;
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stTEPMResourceCB);
|
||||
}
|
||||
|
||||
/* Request and initialise EST_nESTOutput A ***************************/
|
||||
if ((0xffff > USERCAL_stRAMCAL.au32IgnitionSequence[0]) && (EH_IO_Invalid > USERCAL_stRAMCAL.aESTIOResource[0]))
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOResource[0]; //EST_nESTOutputA;
|
||||
enEHIOType = IOAPI_enCaptureCompare;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource,
|
||||
(void*)NULL, (void*)NULL);
|
||||
|
||||
/* Initialise the TEPM channel EST_nESTOutput the dwell timer*/
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stTEPMChannelCB.enAction = TEPMAPI_enSetLow;
|
||||
stTEPMChannelCB.boInterruptEnable = TRUE;
|
||||
stTEPMChannelCB.enPreScalar = 0;
|
||||
stTEPMChannelCB.u32Sequence = USERCAL_stRAMCAL.au32IgnitionSequence[0];
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stTEPMChannelCB);
|
||||
}
|
||||
|
||||
/* Switch igniter on at a fraction of global time */
|
||||
EST_astTimedKernelEvents[0].enAction = TEPMAPI_enSetHigh;
|
||||
EST_astTimedKernelEvents[0].enMethod = TEPMAPI_enGlobalLinkedFraction;
|
||||
EST_astTimedKernelEvents[0].ptEventTime = &EST_tStartFractionA;
|
||||
EST_astTimedKernelEvents[0].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[0];
|
||||
|
||||
/* Switch igniter off at timer ms */
|
||||
EST_astTimedKernelEvents[1].enAction = TEPMAPI_enSetLow;
|
||||
EST_astTimedKernelEvents[1].enMethod = TEPMAPI_enHardLinkedTimeStep;
|
||||
EST_astTimedKernelEvents[1].ptEventTime = &EST_tDwellUs;
|
||||
EST_astTimedKernelEvents[1].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[0];
|
||||
|
||||
USER_vSVC(SYSAPI_enConfigureKernelTEPMOutput, (void*)&enEHIOResource,
|
||||
(void*)&EST_astTimedKernelEvents[0], (void*)&tEventCount);
|
||||
}
|
||||
|
||||
/* Request and initialise EST_nESTOutput B ***************************/
|
||||
if ((0xffff > USERCAL_stRAMCAL.au32IgnitionSequence[1]) && (EH_IO_Invalid > USERCAL_stRAMCAL.aESTIOResource[1]))
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOResource[1]; //EST_nESTOutputB;
|
||||
enEHIOType = IOAPI_enCaptureCompare;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource,
|
||||
(void*)NULL, (void*)NULL);
|
||||
|
||||
/* Initialise the TEPM channel EST_nESTOutput the dwell timer*/
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stTEPMChannelCB.enAction = TEPMAPI_enSetLow;
|
||||
stTEPMChannelCB.boInterruptEnable = TRUE;
|
||||
stTEPMChannelCB.enPreScalar = 0;
|
||||
stTEPMChannelCB.u32Sequence = USERCAL_stRAMCAL.au32IgnitionSequence[1];
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stTEPMChannelCB);
|
||||
}
|
||||
|
||||
/* Switch igniter on at a fraction of global time */
|
||||
EST_astTimedKernelEvents[0].enAction = TEPMAPI_enSetHigh;
|
||||
EST_astTimedKernelEvents[0].enMethod = TEPMAPI_enGlobalLinkedFraction;
|
||||
EST_astTimedKernelEvents[0].ptEventTime = &EST_tStartFractionB;
|
||||
EST_astTimedKernelEvents[0].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[1];
|
||||
|
||||
/* Switch igniter off at timer ms */
|
||||
EST_astTimedKernelEvents[1].enAction = TEPMAPI_enSetLow;
|
||||
EST_astTimedKernelEvents[1].enMethod = TEPMAPI_enHardLinkedTimeStep;
|
||||
EST_astTimedKernelEvents[1].ptEventTime = &EST_tDwellUs;
|
||||
EST_astTimedKernelEvents[1].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[1];
|
||||
|
||||
USER_vSVC(SYSAPI_enConfigureKernelTEPMOutput, (void*)&enEHIOResource,
|
||||
(void*)&EST_astTimedKernelEvents[0], (void*)&tEventCount);
|
||||
}
|
||||
|
||||
/* Request and initialise EST_nESTOutput C ***************************/
|
||||
if ((0xffff > USERCAL_stRAMCAL.au32IgnitionSequence[2]) && (EH_IO_Invalid > USERCAL_stRAMCAL.aESTIOResource[2]))
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOResource[2]; //EST_nESTOutputC;
|
||||
enEHIOType = IOAPI_enCaptureCompare;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource,
|
||||
(void*)NULL, (void*)NULL);
|
||||
|
||||
/* Initialise the TEPM channel EST_nESTOutput the dwell timer*/
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stTEPMChannelCB.enAction = TEPMAPI_enSetLow;
|
||||
stTEPMChannelCB.boInterruptEnable = TRUE;
|
||||
stTEPMChannelCB.enPreScalar = 0;
|
||||
stTEPMChannelCB.u32Sequence = USERCAL_stRAMCAL.au32IgnitionSequence[2];
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stTEPMChannelCB);
|
||||
}
|
||||
|
||||
/* Switch igniter on at a fraction of global time */
|
||||
EST_astTimedKernelEvents[0].enAction = TEPMAPI_enSetHigh;
|
||||
EST_astTimedKernelEvents[0].enMethod = TEPMAPI_enGlobalLinkedFraction;
|
||||
EST_astTimedKernelEvents[0].ptEventTime = &EST_tStartFractionC;
|
||||
EST_astTimedKernelEvents[0].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[2];
|
||||
|
||||
/* Switch igniter off at timer ms */
|
||||
EST_astTimedKernelEvents[1].enAction = TEPMAPI_enSetLow;
|
||||
EST_astTimedKernelEvents[1].enMethod = TEPMAPI_enHardLinkedTimeStep;
|
||||
EST_astTimedKernelEvents[1].ptEventTime = &EST_tDwellUs;
|
||||
EST_astTimedKernelEvents[1].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[2];
|
||||
|
||||
USER_vSVC(SYSAPI_enConfigureKernelTEPMOutput, (void*)&enEHIOResource,
|
||||
(void*)&EST_astTimedKernelEvents[0], (void*)&tEventCount);
|
||||
}
|
||||
|
||||
|
||||
/* Request and initialise EST_nESTOutput D ***************************/
|
||||
if ((0xffff > USERCAL_stRAMCAL.au32IgnitionSequence[3]) && (EH_IO_Invalid > USERCAL_stRAMCAL.aESTIOResource[3]))
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOResource[3]; //EST_nESTOutputD;
|
||||
enEHIOType = IOAPI_enCaptureCompare;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource,
|
||||
(void*)NULL, (void*)NULL);
|
||||
|
||||
/* Initialise the TEPM channel EST_nESTOutput the dwell timer*/
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stTEPMChannelCB.enAction = TEPMAPI_enSetLow;
|
||||
stTEPMChannelCB.boInterruptEnable = TRUE;
|
||||
stTEPMChannelCB.enPreScalar = 0;
|
||||
stTEPMChannelCB.u32Sequence = USERCAL_stRAMCAL.au32IgnitionSequence[3];
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stTEPMChannelCB);
|
||||
}
|
||||
|
||||
/* Switch igniter on at a fraction of global time */
|
||||
EST_astTimedKernelEvents[0].enAction = TEPMAPI_enSetHigh;
|
||||
EST_astTimedKernelEvents[0].enMethod = TEPMAPI_enGlobalLinkedFraction;
|
||||
EST_astTimedKernelEvents[0].ptEventTime = &EST_tStartFractionD;
|
||||
EST_astTimedKernelEvents[0].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[3];
|
||||
|
||||
/* Switch igniter off at timer ms */
|
||||
EST_astTimedKernelEvents[1].enAction = TEPMAPI_enSetLow;
|
||||
EST_astTimedKernelEvents[1].enMethod = TEPMAPI_enHardLinkedTimeStep;
|
||||
EST_astTimedKernelEvents[1].ptEventTime = &EST_tDwellUs;
|
||||
EST_astTimedKernelEvents[1].enEHIOBitMirrorResource = USERCAL_stRAMCAL.aESTIOMuxResource[3];
|
||||
|
||||
USER_vSVC(SYSAPI_enConfigureKernelTEPMOutput, (void*)&enEHIOResource,
|
||||
(void*)&EST_astTimedKernelEvents[0], (void*)&tEventCount);
|
||||
}
|
||||
|
||||
/* Request and initialise required Kernel managed spread for Timingx */
|
||||
EST_tSpreadTimingxIDX = SETUP_tSetupSpread((void*)&CAM_u32RPMFiltered, (void*)&USERCAL_stRAMCAL.aUserTimingxSpread, TYPE_enUInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for Timingy */
|
||||
EST_tSpreadTimingyIDX = SETUP_tSetupSpread((void*)&MAP_tKiloPaFiltered, (void*)&USERCAL_stRAMCAL.aUserTimingySpread, TYPE_enUInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for Timing*/
|
||||
EST_tMapTimingIDX = SETUP_tSetupMap((void*)&USERCAL_stRAMCAL.aUserTimingMap, (void*)&EST_u16TimingBase, TYPE_enUInt16, 17, 17, EST_tSpreadTimingxIDX, EST_tSpreadTimingyIDX, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for Timing*/
|
||||
EST_tMapTimingStage1IDX = SETUP_tSetupMap((void*)&USERCAL_stRAMCAL.aUserTimingMapStage1, (void*)&EST_u16TimingStaged, TYPE_enUInt16, 17, 17, EST_tSpreadTimingxIDX, EST_tSpreadTimingyIDX, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed spread for Dwell */
|
||||
EST_tSpreadDwellIDX = SETUP_tSetupSpread((void*)&BVM_tBattVolts, (void*)&USERCAL_stRAMCAL.aUserDwellSpread, TYPE_enUInt32, 17, SPREADAPI_enSpread4ms, NULL);
|
||||
|
||||
/* Request and initialise required Kernel managed table for Dwell*/
|
||||
EST_tTableDwellIDX = SETUP_tSetupTable((void*)&USERCAL_stRAMCAL.aUserDwellTable, (void*)&EST_u16Dwell, TYPE_enUInt16, 17, EST_tSpreadDwellIDX, NULL);
|
||||
|
||||
stPatternSetupCB.enEdgePolarity = enEdgePolarity;
|
||||
stPatternSetupCB.u32TriggerType = u32TriggerType;
|
||||
stPatternSetupCB.boFirstEdgeRising = boFirstRising;
|
||||
|
||||
USER_vSVC(SYSAPI_enSetupCrankTriggerEdgePattern, (void*)&USERCAL_stRAMCAL.aUserPrimaryTriggerTable[0], (void*)&stPatternSetupCB, NULL);
|
||||
|
||||
USER_vSVC(SYSAPI_enSetupSyncPointsPattern, (void*)&USERCAL_stRAMCAL.aUserSyncPointsTable[0], (void*)&USERCAL_stRAMCAL.u32SyncPhaseRepeats, NULL);
|
||||
|
||||
/* Enable the Motor driver enables */
|
||||
enEHIOResource = EST_nMotor1EnablePin;
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
enDriveStrength = IOAPI_enStrong;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
|
||||
enEHIOResource = EST_nMotor2EnablePin;
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
enDriveStrength = IOAPI_enStrong;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
|
||||
SETUP_vSetDigitalIOHigh(EST_nMotor1EnablePin);
|
||||
SETUP_vSetDigitalIOHigh(EST_nMotor2EnablePin);
|
||||
|
||||
/* Setup simple cam sync resource */
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.enSimpleCamSyncSource)
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.enSimpleCamSyncSource;
|
||||
enEHIOType = IOAPI_enDIOInput;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
|
||||
/* Setup the simple CAM sync */
|
||||
boCamSyncLate = USERCAL_stRAMCAL.boCamSyncHighLate;
|
||||
u32CamSyncSampleToothCount = USERCAL_stRAMCAL.u32CamSyncSampleToothCount;
|
||||
|
||||
SETUP_vSetupSimpleCamSync(enEHIOResource, boCamSyncLate, u32CamSyncSampleToothCount);
|
||||
}
|
||||
|
||||
|
||||
/* Request and initialise VVT1 Input ***************************/
|
||||
if (EH_IO_Invalid > USERCAL_stRAMCAL.aVVTInputResource[0])
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aVVTInputResource[0];
|
||||
enEHIOType = IOAPI_enCaptureCompare;
|
||||
USER_vSVC(SYSAPI_enRequestIOResource, (void*)&enEHIOResource,
|
||||
(void*)NULL, (void*)NULL);
|
||||
|
||||
/* Initialise the VVT1 Input */
|
||||
if (SYSAPI_enOK == pstSVCDataStruct->enSVCResult)
|
||||
{
|
||||
stTEPMChannelCB.enAction = TEPMAPI_enCapAny;
|
||||
stTEPMChannelCB.boInterruptEnable = TRUE;
|
||||
stTEPMChannelCB.boRecursive = FALSE;
|
||||
stTEPMChannelCB.u32Sequence = 0x10000000 + USERCAL_stRAMCAL.aVVTInputType[0];
|
||||
|
||||
USER_vSVC(SYSAPI_enInitialiseIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enEHIOType, (void*)&stTEPMChannelCB);
|
||||
}
|
||||
|
||||
stTimedEvent.enMethod = TEPMAPI_enLinkVVT1Input;
|
||||
stTimedEvent.pfEventCB = NULL;
|
||||
|
||||
USER_vSVC(SYSAPI_enConfigureUserTEPMInput, (void*)&enEHIOResource,
|
||||
(void*)&stTimedEvent, (void*)NULL);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set up EST active output */
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.enESTBypass)
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.enESTBypass;
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
enDriveStrength = IOAPI_enStrong;
|
||||
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* Set up EST mirror outputs */
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.aESTIOMuxResource[0])
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOMuxResource[0];
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
}
|
||||
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.aESTIOMuxResource[1])
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOMuxResource[1];
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
}
|
||||
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.aESTIOMuxResource[2])
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOMuxResource[2];
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
}
|
||||
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.aESTIOMuxResource[3])
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.aESTIOMuxResource[3];
|
||||
enEHIOType = IOAPI_enDIOOutput;
|
||||
SETUP_vSetupDigitalIO(enEHIOResource, enEHIOType, enDriveStrength, pu32Arg);
|
||||
}
|
||||
}
|
||||
|
||||
void EST_vRun(puint32 const pu32Arg)
|
||||
{
|
||||
uint32 u32DwellDegrees;
|
||||
uint32 u32DelayDegrees;
|
||||
uint32 u32DwellUsMax;
|
||||
uint32 u32DwellUs;
|
||||
uint32 u32Temp;
|
||||
sint32 s32ESTTrims[2];
|
||||
static uint32 u32CrankDwell;
|
||||
static uint32 u32BypassCount;
|
||||
uint32 u32Dwell;
|
||||
IOAPI_tenTriState enTriState;
|
||||
IOAPI_tenEHIOResource enEHIOResource;
|
||||
bool boESTAltMapRequestActive;
|
||||
|
||||
boESTAltMapRequestActive = SENSORS_boGetAuxActive(SENSORS_enAUX_LAUNCH_LOW);
|
||||
boESTAltMapRequestActive |= SENSORS_boGetAuxActive(SENSORS_enAUX_LAUNCH_HIGH);
|
||||
|
||||
|
||||
/* Calculate timing based on timing map request */
|
||||
if ((EST_nIgnitionReqPrimary == EST_enIgnitionTimingRequest) &&
|
||||
(FALSE == boESTAltMapRequestActive))
|
||||
{
|
||||
//TODO
|
||||
/* Calculate the current spread for Timingx */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&EST_tSpreadTimingxIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Calculate the current spread for Timingy */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&EST_tSpreadTimingyIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current timing value for Timing */
|
||||
USER_vSVC(SYSAPI_enCalculateMap, (void*)&EST_tMapTimingIDX,
|
||||
NULL, NULL);
|
||||
|
||||
if (EST_u16Timing > EST_u16TimingBase)
|
||||
{
|
||||
if ((EST_u16Timing - EST_u16TimingBase) >= USERCAL_stRAMCAL.u16ESTNegRateMax)
|
||||
{
|
||||
if (EST_u16Timing >= USERCAL_stRAMCAL.u16ESTNegRateMax)
|
||||
{
|
||||
EST_u16Timing -= USERCAL_stRAMCAL.u16ESTNegRateMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_u16Timing = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_u16Timing = EST_u16TimingBase;
|
||||
}
|
||||
}
|
||||
else if (EST_u16Timing < EST_u16TimingBase)
|
||||
{
|
||||
if ((EST_u16TimingBase - EST_u16Timing) >= USERCAL_stRAMCAL.u16ESTPosRateMax)
|
||||
{
|
||||
EST_u16Timing += USERCAL_stRAMCAL.u16ESTNegRateMax;
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_u16Timing = EST_u16TimingBase;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if ((EST_nIgnitionReqDSGStage1 == EST_enIgnitionTimingRequest) ||
|
||||
(EST_nIgnitionReqDSGStage2 == EST_enIgnitionTimingRequest) ||
|
||||
(EST_nIgnitionReqDSGCutsStage3 == EST_enIgnitionTimingRequest) ||
|
||||
(TRUE == boESTAltMapRequestActive))
|
||||
{
|
||||
/* Calculate the current spread for Timingx */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&EST_tSpreadTimingxIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Calculate the current spread for Timingy */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&EST_tSpreadTimingyIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current timing value for Timing */
|
||||
USER_vSVC(SYSAPI_enCalculateMap, (void*)&EST_tMapTimingStage1IDX,
|
||||
NULL, NULL);
|
||||
|
||||
if (TRUE == boESTAltMapRequestActive)
|
||||
{
|
||||
EST_u16Timing = EST_u16TimingStaged;
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_u16Timing = ((TORQUE_u32ESTTorqueModifier * EST_u16TimingBase) +
|
||||
((0x100 - TORQUE_u32ESTTorqueModifier) * EST_u16TimingStaged)) / 0x100;
|
||||
}
|
||||
}
|
||||
|
||||
/* Calculate the current spread for dwell */
|
||||
USER_vSVC(SYSAPI_enCalculateSpread, (void*)&EST_tSpreadDwellIDX,
|
||||
NULL, NULL);
|
||||
|
||||
/* Lookup the current dwell value for dwell */
|
||||
USER_vSVC(SYSAPI_enCalculateTable, (void*)&EST_tTableDwellIDX,
|
||||
NULL, NULL);
|
||||
|
||||
CPU_xEnterCritical();
|
||||
|
||||
u32DwellUsMax = (60000000 / CAM_u32RPMRaw) - EST_nDwellOffMinUs;
|
||||
|
||||
if (300 > CAM_u32RPMFiltered)
|
||||
{
|
||||
u32CrankDwell = USERCAL_stRAMCAL.aUserDwellTable[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
u32CrankDwell = 50 < u32CrankDwell ? u32CrankDwell - 50 : 0;
|
||||
}
|
||||
|
||||
u32Dwell = MAX(u32CrankDwell, EST_u16Dwell);
|
||||
|
||||
if (TRUE == USERCAL_stRAMCAL.boOBDISCADV)
|
||||
{
|
||||
if (0 < IAC_s32ISCESTTrim[0])
|
||||
{
|
||||
EST_tIgnitionAdvanceMtheta = IAC_s32ISCESTTrim[0] + USERCAL_stRAMCAL.u16TimingMainOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_tIgnitionAdvanceMtheta = 100 * EST_u16Timing + USERCAL_stRAMCAL.u16TimingMainOffset;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
s32ESTTrims[0] = CLO2_s32ISCESTTrim[0] + IAC_s32ISCESTTrim[0];
|
||||
s32ESTTrims[1] = CLO2_s32ISCESTTrim[1] + IAC_s32ISCESTTrim[1];
|
||||
|
||||
if (0 <= s32ESTTrims[1])
|
||||
{
|
||||
EST_tIgnitionAdvanceMtheta = 100 * EST_u16Timing + USERCAL_stRAMCAL.u16TimingMainOffset + (uint16)s32ESTTrims[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_tIgnitionAdvanceMtheta = 100 * EST_u16Timing + USERCAL_stRAMCAL.u16TimingMainOffset;
|
||||
|
||||
if (0 < (s32ESTTrims[1] + (sint32)EST_tIgnitionAdvanceMtheta))
|
||||
{
|
||||
EST_tIgnitionAdvanceMtheta = (uint16)(s32ESTTrims[1] + (sint32)EST_tIgnitionAdvanceMtheta);
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_tIgnitionAdvanceMtheta = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (USERCAL_stRAMCAL.u16TimingMainOffset <= EST_tIgnitionAdvanceMtheta)
|
||||
{
|
||||
EST_tIgnitionAdvanceMthetaBTDC = EST_tIgnitionAdvanceMtheta - USERCAL_stRAMCAL.u16TimingMainOffset;
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_tIgnitionAdvanceMthetaBTDC = 0;
|
||||
}
|
||||
|
||||
CPU_xExitCritical();
|
||||
|
||||
u32DwellUs = MIN(u32DwellUsMax, (uint32)u32Dwell);
|
||||
|
||||
u32Temp = 600000 / CAM_u32RPMRaw;
|
||||
|
||||
if (0 == USERCAL_stRAMCAL.u8WastedSparkEnable)
|
||||
{
|
||||
u32DwellDegrees = (u32DwellUs * EST_nDegreesPerCycle) / u32Temp;
|
||||
u32DelayDegrees = 20 * EST_nDegreesPerCycle - u32DwellDegrees / 10 - (EST_tIgnitionAdvanceMtheta / 100);
|
||||
}
|
||||
else
|
||||
{
|
||||
u32DwellDegrees = (u32DwellUs * EST_nDegreesPerCycle) / u32Temp;
|
||||
u32DelayDegrees = 10 * EST_nDegreesPerCycle - u32DwellDegrees / 10 - (EST_tIgnitionAdvanceMtheta / 100);
|
||||
}
|
||||
|
||||
/* Calculate EST start and end angles */
|
||||
switch (USERCAL_stRAMCAL.u8CylCount)
|
||||
{
|
||||
case 4:
|
||||
{
|
||||
if (0 == USERCAL_stRAMCAL.u8WastedSparkEnable)
|
||||
{
|
||||
EST_tStartFractionA = (6554 * u32DelayDegrees) / (2 * EST_nDegreesPerCycle);
|
||||
EST_tStartFractionB = ((6554 * u32DelayDegrees) / (2 * EST_nDegreesPerCycle));
|
||||
EST_tStartFractionC = ((6554 * u32DelayDegrees) / (2 * EST_nDegreesPerCycle));
|
||||
EST_tStartFractionD = ((6554 * u32DelayDegrees) / (2 * EST_nDegreesPerCycle));
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_tStartFractionA = (6554 * u32DelayDegrees) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionB = ((6554 * u32DelayDegrees) / EST_nDegreesPerCycle);
|
||||
EST_tStartFractionC = (6554 * u32DelayDegrees) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionD = ((6554 * u32DelayDegrees) / EST_nDegreesPerCycle);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case 8:
|
||||
{
|
||||
CPU_xEnterCritical();
|
||||
if (1850 < u32DelayDegrees)
|
||||
{
|
||||
//EST_tStartFractionA = (6554 * (u32DelayDegrees - 1800)) / EST_nDegreesPerCycle;
|
||||
//EST_tStartFractionB = (6554 * (u32DelayDegrees - 1800)) / EST_nDegreesPerCycle;
|
||||
//EST_tStartFractionC = (6554 * (u32DelayDegrees - 1800)) / EST_nDegreesPerCycle;
|
||||
//EST_tStartFractionD = (6554 * (u32DelayDegrees - 1800)) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionA = (6554 * (u32DelayDegrees)) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionB = (6554 * (u32DelayDegrees)) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionC = (6554 * (u32DelayDegrees)) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionD = (6554 * (u32DelayDegrees)) / EST_nDegreesPerCycle;
|
||||
}
|
||||
else
|
||||
{
|
||||
EST_tStartFractionA = (6554 * 50) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionB = (6554 * 50) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionC = (6554 * 50) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionD = (6554 * 50) / EST_nDegreesPerCycle;
|
||||
}
|
||||
CPU_xExitCritical();
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
EST_tStartFractionA = (6554 * u32DelayDegrees) / EST_nDegreesPerCycle;
|
||||
EST_tStartFractionB = ((6554 * u32DelayDegrees) / EST_nDegreesPerCycle);
|
||||
EST_tStartFractionC = ((6554 * u32DelayDegrees) / EST_nDegreesPerCycle);
|
||||
EST_tStartFractionD = ((6554 * u32DelayDegrees) / EST_nDegreesPerCycle);
|
||||
}
|
||||
}
|
||||
|
||||
EST_tDwellUs = EST_xUsToSlowTicks(u32DwellUs);
|
||||
|
||||
/* Set the EST active output */
|
||||
if (EH_IO_Invalid != USERCAL_stRAMCAL.enESTBypass)
|
||||
{
|
||||
u32BypassCount = (500 < CAM_u32RPMRaw) && (~0 != u32BypassCount) ? u32BypassCount + 1 : u32BypassCount;
|
||||
u32BypassCount = 0 == CAM_u32RPMRaw ? 0 : u32BypassCount;
|
||||
|
||||
if (500 < u32BypassCount)
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.enESTBypass;
|
||||
enTriState = IOAPI_enLow;
|
||||
USER_vSVC(SYSAPI_enAssertDIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enTriState, (void*)NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
enEHIOResource = USERCAL_stRAMCAL.enESTBypass;
|
||||
enTriState = IOAPI_enHigh;
|
||||
USER_vSVC(SYSAPI_enAssertDIOResource, (void*)&enEHIOResource,
|
||||
(void*)&enTriState, (void*)NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void EST_vTerminate(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void EST_vCallBack(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,92 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Electronic Spark Timing Header File */
|
||||
/* DESCRIPTION: This code module initialises the required */
|
||||
/* resources and functions for electronic spark timing */
|
||||
/* */
|
||||
/* FILE NAME: EST.h */
|
||||
/* REVISION HISTORY: 28-03-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef EST_H
|
||||
#define EST_H
|
||||
|
||||
#include <string.h>
|
||||
#include "IOAPI.h"
|
||||
#include "TEPMAPI.h"
|
||||
#include "USER.h"
|
||||
#include "cpuabstract.h"
|
||||
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _EST_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EST_nIgnitionPrimary,
|
||||
EST_nIgnitionStage1,
|
||||
EST_nIgnitionStage2,
|
||||
EST_nIgnitionStage3,
|
||||
} EST_tenIgnitionTimingStage;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
EST_nIgnitionReqPrimary,
|
||||
EST_nIgnitionReqDSGStage1,
|
||||
EST_nIgnitionReqDSGStage2,
|
||||
EST_nIgnitionReqDSGCutsStage3,
|
||||
EST_nIgnitionReqStage3,
|
||||
} EST_tenIgnitionTimingRequest;
|
||||
|
||||
#ifdef BUILD_SPARKDOG_PF
|
||||
#define EST_nMotor1EnablePin EH_IO_GP4
|
||||
#define EST_nMotor2EnablePin EH_IO_GP4
|
||||
#endif //BUILD_SPARKDOG_PF
|
||||
|
||||
#ifdef BUILD_SPARKDOG_TEENSY_ADAPT
|
||||
#define EST_nMotor1EnablePin EH_IO_GP3
|
||||
#define EST_nMotor2EnablePin EH_IO_GP2
|
||||
#endif
|
||||
|
||||
#define EST_nSlowFTMDivisor TEPMAPI_enDiv128
|
||||
#define EST_nDwellOffMinUs 1500u
|
||||
#define EST_nDegreesPerCycle 360u
|
||||
#define EST_xUsToSlowTicks(x) (((SENSORS_nSlowFTMFreq / 100u) * (x)) / 10000u)
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
|
||||
EXTERN TEPMAPI_ttEventTime EST_tStartFractionD;
|
||||
EXTERN TEPMAPI_ttEventTime EST_tStartFractionC;
|
||||
EXTERN TEPMAPI_ttEventTime EST_tStartFractionB;
|
||||
EXTERN TEPMAPI_ttEventTime EST_tStartFractionA;
|
||||
//ASAM mode=readvalue name="EST Start Fraction" type=uint16 offset=0 min=0 max=1 m=0.00001526 b=0 units="dl" format=6.0 help="EST Dwell Start Fraction"
|
||||
EXTERN TEPMAPI_ttEventTime EST_tDwellUs;
|
||||
//ASAM mode=readvalue name="EST Dwell Fraction" type=uint16 offset=0 min=0 max=1 m=0.00001526 b=0 units="dl" format=6.0 help="EST Dwell Fraction"
|
||||
EXTERN GPM6_ttMTheta EST_tIgnitionAdvanceMtheta;
|
||||
EXTERN GPM6_ttMTheta EST_tIgnitionAdvanceMthetaBTDC;
|
||||
//ASAM mode=readvalue name="EST Ignition Advance" type=uint32 offset=0 min=0 max=50 m=0.001 b=0 units="degrees" format=5.3 help="EST Ignition Advance"
|
||||
|
||||
EXTERN EST_tenIgnitionTimingRequest EST_enIgnitionTimingRequest;
|
||||
//ASAM mode=readvalue name="EST Timing Request Mode" type=uint16 offset=0 min=0 max=10 units="ENUMERATION PRIMARY=0 STAGE1=1 STAGE2=2 STAGE3=3 STAGE4=4" format=1.0 help="EST Dwell Start Fraction"
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void EST_vStart(uint32 * const pu32Arg);
|
||||
void EST_vRun(uint32* const pu32Arg);
|
||||
void EST_vTerminate(uint32* const pu32Arg);
|
||||
void EST_vCallBack(puint32 const pu32Arg);
|
||||
|
||||
|
||||
#endif // EST_H
|
||||
|
|
@ -0,0 +1,109 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Fuel Film Model */
|
||||
/* DESCRIPTION: This code module calculates the fuel film load */
|
||||
/* for manifold wetting compensation */
|
||||
/* */
|
||||
/* FILE NAME: FILM.c */
|
||||
/* REVISION HISTORY: 28-04-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _FILM_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "MAP.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
GPM6_ttNg FILM_tFilmLoadUg;
|
||||
GPM6_ttNg FILM_tFilmLoadUgOld;
|
||||
sint32 FILM_s32FilmLoadUgDelta;
|
||||
uint32 FILM_u32FilmCallCount;
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void FILM_vStart(puint32 const pu32Arg)
|
||||
{
|
||||
FILM_tFilmLoadUg = 0;
|
||||
FILM_tFilmLoadUgOld = 0;
|
||||
FILM_u32FilmCallCount = 0;
|
||||
FILM_s32FilmLoadUgDeltaApplied = 0;
|
||||
}
|
||||
|
||||
void FILM_vRun(puint32 const pu32Arg)
|
||||
{
|
||||
sint32 s32Temp;
|
||||
uint32 u32Temp;
|
||||
|
||||
FILM_u32FilmCallCount++;
|
||||
|
||||
if (0 < CAM_u32RPMRaw)
|
||||
{
|
||||
/* Accumulate film with TPS based wall impact coefficient */
|
||||
u32Temp = (TPS_tThetaFiltered + 5000) / 950u;
|
||||
u32Temp *= FUEL_tPredictedFuelFlowUg;
|
||||
u32Temp /= 10000u;
|
||||
u32Temp += FILM_tFilmLoadUg;
|
||||
}
|
||||
else
|
||||
{
|
||||
u32Temp = FILM_tFilmLoadUg;
|
||||
}
|
||||
|
||||
|
||||
/* Temporary film evaporation code */
|
||||
s32Temp = CTS_tTempCFiltered + (110000 - MAP_tKiloPaFiltered);
|
||||
s32Temp /= 5000;
|
||||
s32Temp = 1000 - s32Temp;
|
||||
u32Temp /= 100;
|
||||
u32Temp *= ((uint32)s32Temp);
|
||||
u32Temp /= 100;
|
||||
|
||||
FILM_tFilmLoadUg = MIN(u32Temp, 15000000);
|
||||
|
||||
if (0 == (FILM_u32FilmCallCount % 0x2))
|
||||
{
|
||||
FILM_s32FilmLoadUgDelta = (sint32)FILM_tFilmLoadUg - (sint32)FILM_tFilmLoadUgOld;
|
||||
FILM_tFilmLoadUgOld = FILM_tFilmLoadUg;
|
||||
}
|
||||
|
||||
/* Clip the accumulate / evaporate derivative */
|
||||
if (0 <= FILM_s32FilmLoadUgDelta)
|
||||
{
|
||||
s32Temp = (500 > FILM_s32FilmLoadUgDelta) ?
|
||||
0 : 20 * FILM_s32FilmLoadUgDelta;
|
||||
FILM_s32FilmLoadUgDeltaApplied = (80000 < s32Temp) ?
|
||||
80000 : s32Temp;
|
||||
}
|
||||
else
|
||||
{
|
||||
s32Temp = (-500 < FILM_s32FilmLoadUgDelta) ?
|
||||
0 : 20 * FILM_s32FilmLoadUgDelta;
|
||||
FILM_s32FilmLoadUgDeltaApplied = (-80000 > s32Temp) ?
|
||||
-80000 : s32Temp;
|
||||
}
|
||||
}
|
||||
|
||||
void FILM_vTerminate(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
void FILM_vCallBack(puint32 const pu32Arg)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,43 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: Fuel Film Model Header File */
|
||||
/* DESCRIPTION: This code module calculates the fuel film load */
|
||||
/* for manifold wetting compensation */
|
||||
/* */
|
||||
/* FILE NAME: FILM.h */
|
||||
/* REVISION HISTORY: 28-04-2016 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef FILM_H
|
||||
#define FILM_H
|
||||
|
||||
#include <string.h>
|
||||
#include "IOAPI.h"
|
||||
#include "USER.h"
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
|
||||
|
||||
#ifdef EXTERN
|
||||
#undef EXTERN
|
||||
#endif
|
||||
#ifdef _FILM_C
|
||||
#define EXTERN
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
EXTERN sint32 FILM_s32FilmLoadUgDeltaApplied;
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void FILM_vStart(uint32 * const pu32Arg);
|
||||
void FILM_vRun(uint32* const pu32Arg);
|
||||
void FILM_vTerminate(uint32* const pu32Arg);
|
||||
void FILM_vCallBack(puint32 const pu32Arg);
|
||||
|
||||
#endif // MAP_H
|
|
@ -0,0 +1,148 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: FME */
|
||||
/* DESCRIPTION: This code assist with failure mode effects */
|
||||
/* processing */
|
||||
/* */
|
||||
/* FILE NAME: FME.c */
|
||||
/* REVISION HISTORY: 24-06-2020 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#define _FME_C
|
||||
|
||||
/******************************************************************************/
|
||||
/* HEADER FILES */
|
||||
/******************************************************************************/
|
||||
#include "build.h"
|
||||
|
||||
#ifdef BUILD_USER
|
||||
|
||||
#include "FME.h"
|
||||
|
||||
|
||||
/* LOCAL VARIABLE DEFINITIONS (STATIC) ****************************************/
|
||||
const FME_tstDiagControlData FME_astDiagControlData[FME_enDiagCount] = FME_nControlData;
|
||||
FME_tstDiagRunningData FME_astDiagRunningData[FME_enDiagCount];
|
||||
//ASAM mode=readvalue name="PPS Rationality Fault" parent="FME_astDiagRunningData" type=uint16 offset=8 min=0 max=2 units="ENUMERATION NO_FAULT=0 FAULT_ACTIVE=1 FAULT_CLEARED=2" format=3.0 help="FAULT"
|
||||
//ASAM mode=readvalue name="Throttle Rationality Fault" parent="FME_astDiagRunningData" type=uint16 offset=20 min=0 max=2 units="ENUMERATION NO_FAULT=0 FAULT_ACTIVE=1 FAULT_CLEARED=2" format=3.0 help="FAULT"
|
||||
//ASAM mode=readvalue name="TPSM Fault" parent="FME_astDiagRunningData" type=uint16 offset=32 min=0 max=2 units="ENUMERATION NO_FAULT=0 FAULT_ACTIVE=1 FAULT_CLEARED=2" format=3.0 help="FAULT"
|
||||
//ASAM mode=readvalue name="PPSM Fault" parent="FME_astDiagRunningData" type=uint16 offset=44 min=0 max=2 units="ENUMERATION NO_FAULT=0 FAULT_ACTIVE=1 FAULT_CLEARED=2" format=3.0 help="FAULT"
|
||||
//ASAM mode=readvalue name="PPSS Fault" parent="FME_astDiagRunningData" type=uint16 offset=56 min=0 max=2 units="ENUMERATION NO_FAULT=0 FAULT_ACTIVE=1 FAULT_CLEARED=2" format=3.0 help="FAULT"
|
||||
|
||||
|
||||
/* LOCAL FUNCTION PROTOTYPES (STATIC) *****************************************/
|
||||
static void FME_vConditionFault(FME_tenDiags, bool);
|
||||
|
||||
/* GLOBAL FUNCTION DEFINITIONS ************************************************/
|
||||
void FME_enUpdateDiagState(FME_tenDiags enDiags, uint32 u32Data1, uint32 u32Data2)
|
||||
{
|
||||
switch (FME_astDiagControlData[enDiags].enDiagtype)
|
||||
{
|
||||
case FME_enRelationship:
|
||||
{
|
||||
if (FME_enPPSPair == enDiags)
|
||||
{
|
||||
uint32 u32Temp = (500 * u32Data1) / u32Data2;
|
||||
|
||||
FME_astDiagRunningData[enDiags].u32FilterData =
|
||||
u32Temp / 8 + 7 * (FME_astDiagRunningData[enDiags].u32FilterData / 8);
|
||||
|
||||
if ((800 > FME_astDiagRunningData[enDiags].u32FilterData) ||
|
||||
(1200 < FME_astDiagRunningData[enDiags].u32FilterData))
|
||||
{
|
||||
FME_vConditionFault(enDiags, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
FME_vConditionFault(enDiags, FALSE);
|
||||
}
|
||||
}
|
||||
if (FME_enPedalTransfer == enDiags)
|
||||
{
|
||||
if (u32Data1 < u32Data2)
|
||||
{
|
||||
FME_vConditionFault(enDiags, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
FME_vConditionFault(enDiags, FALSE);
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
case FME_enSingle:
|
||||
{
|
||||
FME_astDiagRunningData[enDiags].u32FilterData =
|
||||
u32Data1 / 4 + 3 * (FME_astDiagRunningData[enDiags].u32FilterData / 4);
|
||||
|
||||
if ((FME_astDiagControlData[enDiags].u32FilterDataMin > FME_astDiagRunningData[enDiags].u32FilterData) ||
|
||||
(FME_astDiagControlData[enDiags].u32FilterDataMax < FME_astDiagRunningData[enDiags].u32FilterData))
|
||||
{
|
||||
FME_vConditionFault(enDiags, TRUE);
|
||||
}
|
||||
else
|
||||
{
|
||||
FME_vConditionFault(enDiags, FALSE);
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
inline FME_tenFaultState FME_enGetDiagState(FME_tenDiags enDiags)
|
||||
{
|
||||
return FME_astDiagRunningData[enDiags].enFaultState;
|
||||
}
|
||||
|
||||
static void FME_vConditionFault(FME_tenDiags enDiags, bool boFaultActive)
|
||||
{
|
||||
if (TRUE == boFaultActive)
|
||||
{
|
||||
FME_astDiagRunningData[enDiags].u32FaultCounts =
|
||||
FME_astDiagControlData[enDiags].u32FaultCountLimit > FME_astDiagRunningData[enDiags].u32FaultCounts ?
|
||||
FME_astDiagRunningData[enDiags].u32FaultCounts + 1 :
|
||||
FME_astDiagRunningData[enDiags].u32FaultCounts;
|
||||
}
|
||||
else
|
||||
{
|
||||
FME_astDiagRunningData[enDiags].u32FaultCounts =
|
||||
0 < FME_astDiagRunningData[enDiags].u32FaultCounts ?
|
||||
FME_astDiagRunningData[enDiags].u32FaultCounts - 1 :
|
||||
FME_astDiagRunningData[enDiags].u32FaultCounts;
|
||||
}
|
||||
|
||||
if ((FME_enNoFault == FME_astDiagRunningData[enDiags].enFaultState) &&
|
||||
(FME_astDiagControlData[enDiags].u32FaultCountLimit == FME_astDiagRunningData[enDiags].u32FaultCounts))
|
||||
{
|
||||
FME_astDiagRunningData[enDiags].enFaultState = FME_enFaultActive;
|
||||
}
|
||||
else if ((FME_enFaultCleared == FME_astDiagRunningData[enDiags].enFaultState) &&
|
||||
(FME_astDiagControlData[enDiags].u32FaultCountLimit == FME_astDiagRunningData[enDiags].u32FaultCounts))
|
||||
{
|
||||
FME_astDiagRunningData[enDiags].enFaultState = FME_enFaultActive;
|
||||
}
|
||||
else if ((FME_enFaultActive == FME_astDiagRunningData[enDiags].enFaultState) &&
|
||||
(0 == FME_astDiagRunningData[enDiags].u32FaultCounts))
|
||||
{
|
||||
FME_astDiagRunningData[enDiags].enFaultState = FME_enFaultCleared;
|
||||
}
|
||||
}
|
||||
|
||||
void FME_vDiagClearHistory(void)
|
||||
{
|
||||
uint32 u32FaultIDX;
|
||||
|
||||
for (u32FaultIDX = 0; u32FaultIDX < FME_enDiagCount; u32FaultIDX++)
|
||||
{
|
||||
FME_astDiagRunningData[u32FaultIDX].enFaultState = FME_enNoFault;
|
||||
}
|
||||
}
|
||||
|
||||
#endif //BUILD_USER
|
|
@ -0,0 +1,83 @@
|
|||
/******************************************************************************/
|
||||
/* Copyright (c) 2016 MD Automotive Controls. Original Work. */
|
||||
/* License: http://www.gnu.org/licenses/gpl.html GPL version 2 or higher */
|
||||
/******************************************************************************/
|
||||
/* CONTEXT:USER_APP */
|
||||
/* PACKAGE TITLE: FME Header */
|
||||
/* DESCRIPTION: This code assist with failure mode effects */
|
||||
/* processing */
|
||||
/* */
|
||||
/* FILE NAME: FME.c */
|
||||
/* REVISION HISTORY: 24-06-2020 | 1.0 | Initial revision */
|
||||
/* */
|
||||
/******************************************************************************/
|
||||
#ifndef FME_H
|
||||
#define FME_H
|
||||
|
||||
#include <string.h>
|
||||
#include "IOAPI.h"
|
||||
#include "USER.h"
|
||||
#include "SYS.h"
|
||||
|
||||
/* GLOBAL MACRO DEFINITIONS ***************************************************/
|
||||
typedef enum
|
||||
{
|
||||
FME_enPPSPair,
|
||||
FME_enPedalTransfer,
|
||||
FME_enTPSMSingle,
|
||||
FME_enPPSMSingle,
|
||||
FME_enPPSSSingle,
|
||||
FME_enDiagCount
|
||||
} FME_tenDiags;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FME_enRelationship,
|
||||
FME_enSingle,
|
||||
FME_enDiagTypesCount
|
||||
} FME_tenDiagTypes;
|
||||
|
||||
typedef enum
|
||||
{
|
||||
FME_enNoFault,
|
||||
FME_enFaultActive,
|
||||
FME_enFaultCleared
|
||||
} FME_tenFaultState;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
FME_tenDiagTypes enDiagtype;
|
||||
uint32 u32FilterDataMin;
|
||||
uint32 u32FilterDataMax;
|
||||
uint32 u32FaultCountLimit;
|
||||
} FME_tstDiagControlData;
|
||||
|
||||
typedef struct
|
||||
{
|
||||
uint32 u32FilterData;
|
||||
uint32 u32FaultCounts;
|
||||
FME_tenFaultState enFaultState;
|
||||
} FME_tstDiagRunningData;
|
||||
|
||||
#define FME_nControlData \
|
||||
{ \
|
||||
{FME_enRelationship, 800, 3000, 200},\
|
||||
{FME_enRelationship, 800, 3000, 500},\
|
||||
{FME_enSingle, 250, 2900, 30},\
|
||||
{FME_enSingle, 250, 2900, 30},\
|
||||
{FME_enSingle, 190, 1450, 30},\
|
||||
}\
|
||||
|
||||
#define FME_nBLIP_THROTTLE_DELTA_MAX 1000
|
||||
#define FME_nOVERRIDE_DELTA_MAX 500
|
||||
|
||||
/* GLOBAL VARIABLE DECLARATIONS ***********************************************/
|
||||
|
||||
|
||||
/* GLOBAL FUNCTION DECLARATIONS ***********************************************/
|
||||
void FME_enUpdateDiagState(FME_tenDiags enDiags, uint32 u32Data1, uint32 u32Data2);
|
||||
FME_tenFaultState FME_enGetDiagState(FME_tenDiags enDiags);
|
||||
void FME_vDiagClearHistory(void);
|
||||
|
||||
#endif // FME_H
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue