Initial commit: TC264 smart car project with IPS200 menu system
- IPS200 display menu with real-time status and parameter settings - Camera image processing and line tracking - IMU attitude solution and PID control - WiFi SPI oscilloscope data transmission
This commit is contained in:
commit
843447835d
660 files changed
+443632
No files matched your search
@@ -0,0 +1,127 @@
|
||||
/**
|
||||
* \file Assert.c
|
||||
* \brief Assert functions.
|
||||
*
|
||||
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-27 20:08:29 GMT$
|
||||
*
|
||||
* IMPORTANT NOTICE
|
||||
*
|
||||
*
|
||||
* Use of this file is subject to the terms of use agreed between (i) you or
|
||||
* the company in which ordinary course of business you are acting and (ii)
|
||||
* Infineon Technologies AG or its licensees. If and as long as no such
|
||||
* terms of use are agreed, use of this file is subject to following:
|
||||
|
||||
|
||||
* Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person or
|
||||
* organization obtaining a copy of the software and accompanying
|
||||
* documentation covered by this license (the "Software") to use, reproduce,
|
||||
* display, distribute, execute, and transmit the Software, and to prepare
|
||||
* derivative works of the Software, and to permit third-parties to whom the
|
||||
* Software is furnished to do so, all subject to the following:
|
||||
|
||||
* The copyright notices in the Software and this entire statement, including
|
||||
* the above license grant, this restriction and the following disclaimer, must
|
||||
* be included in all copies of the Software, in whole or in part, and all
|
||||
* derivative works of the Software, unless such copies or derivative works are
|
||||
* solely in the form of machine-executable object code generated by a source
|
||||
* language processor.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Assert.h"
|
||||
|
||||
#if IFX_CFG_ASSERT_STDIO == 1
|
||||
/** Current standard IO used for the IFX_ASSERT and IFX_VALIDATE */
|
||||
IfxStdIf_DPipe *Assert_io = NULL_PTR;
|
||||
#endif
|
||||
|
||||
#if IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT > IFX_VERBOSE_LEVEL_OFF
|
||||
uint32 Assert_verboseLevel = IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT;
|
||||
#endif
|
||||
|
||||
#if IFX_CFG_ASSERT_STDIO == 1
|
||||
void Ifx_Assert_setStandardIo(IfxStdIf_DPipe *standardIo)
|
||||
{
|
||||
Assert_io = standardIo;
|
||||
}
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/** \internal
|
||||
* Text used to display the king of assertion
|
||||
*/
|
||||
const pchar Assert_level[6] = {
|
||||
"OFF",
|
||||
"FAILURE",
|
||||
"ERROR",
|
||||
"WARNING",
|
||||
"INFO",
|
||||
"DEBUG"
|
||||
};
|
||||
|
||||
void Ifx_Assert_doLevel(uint8 level, pchar __assertion, pchar __file, unsigned int __line, pchar __function)
|
||||
{
|
||||
#if IFX_CFG_ASSERT_USE_BREAKPOINT == 1
|
||||
|
||||
if (level <= IFX_VERBOSE_LEVEL_ERROR)
|
||||
{
|
||||
__debug();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if IFX_CFG_ASSERT_STDIO == 1
|
||||
|
||||
if (Assert_io != NULL_PTR)
|
||||
{
|
||||
IfxStdIf_DPipe_print(Assert_io, "ASSERTION %s '%s' in %s:%u (function '%s()')" ENDL, Assert_level[level],
|
||||
__assertion, __file, __line, __function);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
boolean Ifx_Assert_doValidate(boolean expr, uint8 level, pchar __assertion, pchar __file, unsigned int __line, pchar __function)
|
||||
{
|
||||
if (!((expr) || (level > Assert_verboseLevel)))
|
||||
{
|
||||
#if IFX_CFG_ASSERT_USE_BREAKPOINT == 1
|
||||
|
||||
if (level <= IFX_VERBOSE_LEVEL_ERROR)
|
||||
{
|
||||
__debug();
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#if IFX_CFG_ASSERT_STDIO == 1
|
||||
|
||||
if (Assert_io != NULL_PTR)
|
||||
{
|
||||
IfxStdIf_DPipe_print(Assert_io, "VALIDATION %s '%s' in %s:%u (function '%s()')" ENDL, Assert_level[level],
|
||||
__assertion, __file, __line, __function);
|
||||
}
|
||||
|
||||
#endif
|
||||
}
|
||||
else
|
||||
{}
|
||||
|
||||
return expr;
|
||||
}
|
||||
@@ -0,0 +1,209 @@
|
||||
/**
|
||||
* \file Assert.h
|
||||
* \brief Assert functions.
|
||||
* \ingroup library_srvsw_sysse_bsp_assert
|
||||
*
|
||||
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-28 14:15:34 GMT$
|
||||
*
|
||||
* IMPORTANT NOTICE
|
||||
*
|
||||
*
|
||||
* Use of this file is subject to the terms of use agreed between (i) you or
|
||||
* the company in which ordinary course of business you are acting and (ii)
|
||||
* Infineon Technologies AG or its licensees. If and as long as no such
|
||||
* terms of use are agreed, use of this file is subject to following:
|
||||
|
||||
|
||||
* Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person or
|
||||
* organization obtaining a copy of the software and accompanying
|
||||
* documentation covered by this license (the "Software") to use, reproduce,
|
||||
* display, distribute, execute, and transmit the Software, and to prepare
|
||||
* derivative works of the Software, and to permit third-parties to whom the
|
||||
* Software is furnished to do so, all subject to the following:
|
||||
|
||||
* The copyright notices in the Software and this entire statement, including
|
||||
* the above license grant, this restriction and the following disclaimer, must
|
||||
* be included in all copies of the Software, in whole or in part, and all
|
||||
* derivative works of the Software, unless such copies or derivative works are
|
||||
* solely in the form of machine-executable object code generated by a source
|
||||
* language processor.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*
|
||||
* \defgroup library_srvsw_sysse_bsp_assert Assertion
|
||||
* This module implements assertion functions.
|
||||
* \ingroup library_srvsw_sysse_bsp
|
||||
*/
|
||||
|
||||
#ifndef ASSERT_H
|
||||
#define ASSERT_H 1
|
||||
|
||||
#include "_Utilities/Ifx_Assert.h"
|
||||
|
||||
/** \addtogroup library_srvsw_sysse_bsp_assert
|
||||
* Global configuration settings (Ifx_Cfg.h) :
|
||||
* - IFX_CFG_ASSERT_STDIO: if IFX_CFG_ASSERT_STDIO=1, the assertion is output to the io
|
||||
* defined by \ref Ifx_Assert_setStandardIo (). if IFX_CFG_ASSERT_STDIO=0, no text
|
||||
* output is done.
|
||||
* Default is IFX_CFG_ASSERT_STDIO=0
|
||||
* - IFX_CFG_ASSERT_USE_BREAKPOINT: if IFX_CFG_ASSERT_USE_BREAKPOINT=1, a debug instruction is
|
||||
* inserted in case an assertion occurs with a level of
|
||||
* \ref IFX_VERBOSE_LEVEL_FAILURE or \ref IFX_VERBOSE_LEVEL_ERROR. If IFX_CFG_ASSERT_USE_BREAKPOINT=0 then
|
||||
* no debug instruction is inserted.
|
||||
* Default is IFX_CFG_ASSERT_USE_BREAKPOINT=0.
|
||||
* - IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT: Set the assertion limit,
|
||||
* assertion with a level below or equal to the limit are taken in
|
||||
* account, other are ignored. range=[\ref IFX_VERBOSE_LEVEL_OFF, \ref IFX_VERBOSE_LEVEL_FAILURE,
|
||||
* \ref IFX_VERBOSE_LEVEL_ERROR, \ref IFX_VERBOSE_LEVEL_WARNING, \ref IFX_VERBOSE_LEVEL_INFO,
|
||||
* \ref IFX_VERBOSE_LEVEL_DEBUG]
|
||||
* Default is IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT=\ref IFX_VERBOSE_LEVEL_INFO.
|
||||
*
|
||||
* Do not include this file but use # include "_Utilities/Ifx_Assert.h" instead
|
||||
* \{ */
|
||||
|
||||
#ifndef IFX_CFG_ASSERT_STDIO
|
||||
# define IFX_CFG_ASSERT_STDIO (0) /**< \brief If set to 1, the assert message is send to the Assert_io interface */
|
||||
#endif
|
||||
|
||||
#if IFX_CFG_ASSERT_STDIO == 1
|
||||
# include "StdIf/IfxStdIf_DPipe.h"
|
||||
#endif
|
||||
|
||||
#ifndef IFX_CFG_ASSERT_USE_BREAKPOINT
|
||||
# define IFX_CFG_ASSERT_USE_BREAKPOINT (0) /**< \brief If set to 1, the assert function will break the execution (breakpoint) */
|
||||
#endif
|
||||
|
||||
#ifndef IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT
|
||||
/** \brief defines the assertion default level
|
||||
*
|
||||
* If not defined, the default assert level is set to IFX_VERBOSE_LEVEL_INFO
|
||||
* */
|
||||
#define IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT (IFX_VERBOSE_LEVEL_INFO)
|
||||
#endif
|
||||
|
||||
/** \brief Set the standard output used for \ref IFX_ASSERT and \ref IFX_VALIDATE
|
||||
*
|
||||
* For example the standard IO could redirect the output to a serial interface, CAN interface, ...
|
||||
*
|
||||
* \param standardIo Specifies the standard output used
|
||||
*
|
||||
* Enable only if (IFX_CFG_ASSERT_STDIO!=0)
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
#if IFX_CFG_ASSERT_STDIO == 1
|
||||
IFX_EXTERN void Ifx_Assert_setStandardIo(IfxStdIf_DPipe *standardIo);
|
||||
#else
|
||||
#define Ifx_Assert_setStandardIo(standardIo) ((void)0)
|
||||
#endif
|
||||
|
||||
/** \internal
|
||||
* \brief Execute the assertion and display the assertion message
|
||||
*
|
||||
* Do not call this function directly, use IFX_ASSERT() instead
|
||||
*
|
||||
* \param level assertion level
|
||||
* \param __assertion test as string, is displayed with the assertion message
|
||||
* \param __file file in which the assertion occurred
|
||||
* \param __line line number where the assertion occurred
|
||||
* \param __function name of the function in which the assertion occurred
|
||||
* \return void
|
||||
*/
|
||||
IFX_EXTERN void Ifx_Assert_doLevel(uint8 level, pchar __assertion, pchar __file, unsigned int __line, pchar __function);
|
||||
|
||||
/** \internal
|
||||
* \brief Execute the assertion and display the assertion message.
|
||||
*
|
||||
* Do not call this function directly, use IFX_VALIDATE() instead
|
||||
*
|
||||
* \param expr expression value, assertion occurs if FALSE
|
||||
* \param level assertion level
|
||||
* \param __assertion test as string, is displayed with the assertion message
|
||||
* \param __file file in which the assertion occurred
|
||||
* \param __line line number where the assertion occurred
|
||||
* \param __function name of the function in which the assertion occurred
|
||||
* \return expr
|
||||
*/
|
||||
IFX_EXTERN boolean Ifx_Assert_doValidate(boolean expr, uint8 level, pchar __assertion, pchar __file, unsigned int __line, pchar __function);
|
||||
|
||||
#if IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT > IFX_VERBOSE_LEVEL_OFF
|
||||
IFX_EXTERN uint32 Assert_verboseLevel; /**< \bri-ef Current verbose level, this value is initialised to IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT */
|
||||
|
||||
#else
|
||||
|
||||
# undef IFX_CFG_ASSERT_STDIO
|
||||
# define IFX_CFG_ASSERT_STDIO (0)
|
||||
|
||||
#endif
|
||||
|
||||
#undef IFX_ASSERT
|
||||
#undef IFX_VALIDATE
|
||||
|
||||
/** \brief Assertion function (assert)
|
||||
*
|
||||
* If expr is FALSE, then an assertion message is displayed. The message
|
||||
* indicates the assertion level, the file, line and function where the
|
||||
* assertion occurred, and also display expr as text. In case the debug break
|
||||
* point is enabled then a debug instruction will also be inserted so that the debugger stops
|
||||
*
|
||||
* If expr is true, nothing is additional done.
|
||||
*
|
||||
* The expr expression is ignored (code disabled) in case the assertion level set by IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT is \ref IFX_VERBOSE_LEVEL_OFF.
|
||||
*
|
||||
* The output needs to the be set with the function Ifx_Assert_setStandardIo() in order for the message to be displayed.
|
||||
*
|
||||
* \param level level of the assertion, range=[\ref IFX_VERBOSE_LEVEL_OFF, \ref IFX_VERBOSE_LEVEL_FAILURE,
|
||||
* \ref IFX_VERBOSE_LEVEL_ERROR, \ref IFX_VERBOSE_LEVEL_WARNING, \ref IFX_VERBOSE_LEVEL_INFO,
|
||||
* \ref IFX_VERBOSE_LEVEL_DEBUG]
|
||||
* \param expr expression to be tested. If FALSE the assertion is executed else nothing is done
|
||||
*
|
||||
* \return void
|
||||
*/
|
||||
#if IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT > IFX_VERBOSE_LEVEL_OFF
|
||||
# define IFX_ASSERT(level, expr) (((expr) || (level > Assert_verboseLevel)) ? ((void)0) : Ifx_Assert_doLevel(level,#expr, __FILE__, __LINE__, __func__))
|
||||
#else
|
||||
# define IFX_ASSERT(level, expr) ((void)0)
|
||||
#endif
|
||||
|
||||
/** \brief Assertion function (validate)
|
||||
*
|
||||
* If expr is FALSE, then an assertion message is displayed. The message
|
||||
* indicates the assertion level, the file, line and function where the
|
||||
* assertion occurred, and also display expr as text. In case the debug
|
||||
* break point is enabled then a debug instruction will also be inserted so
|
||||
* that the debugger stops.
|
||||
*
|
||||
* \ref IFX_VALIDATE differs from \ref IFX_ASSERT in the way that the expr expression is
|
||||
* evaluated whatever the assertion level set by IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT.
|
||||
*
|
||||
* The output needs to the be set with the function Ifx_Assert_setStandardIo() in order for the message to be displayed.
|
||||
*
|
||||
* \param level level of the assertion, range=[\ref IFX_VERBOSE_LEVEL_OFF, \ref IFX_VERBOSE_LEVEL_FAILURE,
|
||||
* \ref IFX_VERBOSE_LEVEL_ERROR, \ref IFX_VERBOSE_LEVEL_WARNING, \ref IFX_VERBOSE_LEVEL_INFO,
|
||||
* \ref IFX_VERBOSE_LEVEL_DEBUG]
|
||||
* \param expr expression to be tested. If FALSE the assertion is executed else nothing is done
|
||||
*
|
||||
* \return void
|
||||
*/
|
||||
#if IFX_CFG_ASSERT_VERBOSE_LEVEL_DEFAULT > IFX_VERBOSE_LEVEL_OFF
|
||||
# define IFX_VALIDATE(level, expr) (Ifx_Assert_doValidate(expr, level,#expr, __FILE__, __LINE__, __func__))
|
||||
#else
|
||||
# define IFX_VALIDATE(level, expr) (expr)
|
||||
#endif
|
||||
|
||||
/** \} */
|
||||
|
||||
//#include "_Utilities/Ifx_Assert.h" /* Needs to be at the end of the file */
|
||||
|
||||
#endif
|
||||
@@ -0,0 +1,96 @@
|
||||
/**
|
||||
* \file Bsp.c
|
||||
* \brief Board support package
|
||||
* \ingroup library_srvsw_sysse_bsp_bsp
|
||||
*
|
||||
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-28 14:15:34 GMT$
|
||||
*
|
||||
* IMPORTANT NOTICE
|
||||
*
|
||||
*
|
||||
* Use of this file is subject to the terms of use agreed between (i) you or
|
||||
* the company in which ordinary course of business you are acting and (ii)
|
||||
* Infineon Technologies AG or its licensees. If and as long as no such
|
||||
* terms of use are agreed, use of this file is subject to following:
|
||||
|
||||
|
||||
* Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person or
|
||||
* organization obtaining a copy of the software and accompanying
|
||||
* documentation covered by this license (the "Software") to use, reproduce,
|
||||
* display, distribute, execute, and transmit the Software, and to prepare
|
||||
* derivative works of the Software, and to permit third-parties to whom the
|
||||
* Software is furnished to do so, all subject to the following:
|
||||
|
||||
* The copyright notices in the Software and this entire statement, including
|
||||
* the above license grant, this restriction and the following disclaimer, must
|
||||
* be included in all copies of the Software, in whole or in part, and all
|
||||
* derivative works of the Software, unless such copies or derivative works are
|
||||
* solely in the form of machine-executable object code generated by a source
|
||||
* language processor.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
#include "Bsp.h"
|
||||
|
||||
Ifx_TickTime TimeConst[TIMER_COUNT];
|
||||
|
||||
/** \brief Initialize the time constants.
|
||||
*
|
||||
* Initialize the time constants TimeConst_0s, TimeConst_100ns, TimeConst_1us,
|
||||
* TimeConst_10us, TimeConst_100us, TimeConst_1ms, TimeConst_10ms, TimeConst_100ms,
|
||||
* TimeConst_1s, TimeConst_10s
|
||||
* \return None.
|
||||
*/
|
||||
void initTime(void)
|
||||
{
|
||||
sint32 Fsys = IfxStm_getFrequency(BSP_DEFAULT_TIMER);
|
||||
|
||||
TimeConst[TIMER_INDEX_10NS] = Fsys / (1000000000 / 10);
|
||||
TimeConst[TIMER_INDEX_100NS] = Fsys / (1000000000 / 100);
|
||||
TimeConst[TIMER_INDEX_1US] = Fsys / (1000000 / 1);
|
||||
TimeConst[TIMER_INDEX_10US] = Fsys / (1000000 / 10);
|
||||
TimeConst[TIMER_INDEX_100US] = Fsys / (1000000 / 100);
|
||||
TimeConst[TIMER_INDEX_1MS] = Fsys / (1000 / 1);
|
||||
TimeConst[TIMER_INDEX_10MS] = Fsys / (1000 / 10);
|
||||
TimeConst[TIMER_INDEX_100MS] = Fsys / (1000 / 100);
|
||||
TimeConst[TIMER_INDEX_1S] = Fsys * (1);
|
||||
TimeConst[TIMER_INDEX_10S] = Fsys * (10);
|
||||
TimeConst[TIMER_INDEX_100S] = Fsys * (100);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Wait function.
|
||||
*
|
||||
* This is an empty function that just spend some time waiting.
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
void waitPoll(void)
|
||||
{}
|
||||
|
||||
/** \brief Wait time function.
|
||||
*
|
||||
* This is an empty function that that returns after the timeout elapsed. The
|
||||
* minimal time spend in the function is guaranteed, but not the max time.
|
||||
*
|
||||
* \param timeout Specifies the time the function waits for before returning
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
void waitTime(Ifx_TickTime timeout)
|
||||
{
|
||||
wait(timeout);
|
||||
}
|
||||
@@ -0,0 +1,443 @@
|
||||
/**
|
||||
* \file Bsp.h
|
||||
* \brief Board support package
|
||||
* \ingroup library_srvsw_sysse_bsp_bsp
|
||||
*
|
||||
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-28 14:15:35 GMT$
|
||||
*
|
||||
* IMPORTANT NOTICE
|
||||
*
|
||||
*
|
||||
* Use of this file is subject to the terms of use agreed between (i) you or
|
||||
* the company in which ordinary course of business you are acting and (ii)
|
||||
* Infineon Technologies AG or its licensees. If and as long as no such
|
||||
* terms of use are agreed, use of this file is subject to following:
|
||||
|
||||
|
||||
* Boost Software License - Version 1.0 - August 17th, 2003
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person or
|
||||
* organization obtaining a copy of the software and accompanying
|
||||
* documentation covered by this license (the "Software") to use, reproduce,
|
||||
* display, distribute, execute, and transmit the Software, and to prepare
|
||||
* derivative works of the Software, and to permit third-parties to whom the
|
||||
* Software is furnished to do so, all subject to the following:
|
||||
|
||||
* The copyright notices in the Software and this entire statement, including
|
||||
* the above license grant, this restriction and the following disclaimer, must
|
||||
* be included in all copies of the Software, in whole or in part, and all
|
||||
* derivative works of the Software, unless such copies or derivative works are
|
||||
* solely in the form of machine-executable object code generated by a source
|
||||
* language processor.
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
|
||||
* SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
|
||||
* FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
|
||||
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
|
||||
* DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*
|
||||
* \defgroup library_srvsw_sysse_bsp_bsp Board support package
|
||||
* This module implements the board support package
|
||||
* \ingroup library_srvsw_sysse_bsp
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef BSP_H
|
||||
#define BSP_H 1
|
||||
|
||||
#include "Ifx_Cfg.h" /* Do not remove this include */
|
||||
#include "Cpu/Std/IfxCpu_Intrinsics.h" /* Do not remove this include */
|
||||
#include "_Utilities/Ifx_Assert.h" /* Do not remove this include */
|
||||
|
||||
#include "Cpu/Std/IfxCpu.h"
|
||||
#include "Port/Std/IfxPort.h"
|
||||
#include "Src/Std/IfxSrc.h"
|
||||
#include "Stm/Std/IfxStm.h"
|
||||
#include "Scu/Std/IfxScuCcu.h"
|
||||
|
||||
#ifndef BSP_DEFAULT_TIMER
|
||||
/** Defined the default timer used */
|
||||
#define BSP_DEFAULT_TIMER (&MODULE_STM0)
|
||||
#endif
|
||||
|
||||
/******************************************************************************/
|
||||
/* Function prototypes */
|
||||
/******************************************************************************/
|
||||
|
||||
/** \addtogroup library_srvsw_sysse_bsp_bsp
|
||||
* \{ */
|
||||
/** \name Interrupt APIs
|
||||
* \{ */
|
||||
IFX_INLINE boolean areInterruptsEnabled(void);
|
||||
IFX_INLINE boolean disableInterrupts(void);
|
||||
IFX_INLINE void enableInterrupts(void);
|
||||
IFX_INLINE void restoreInterrupts(boolean enabled);
|
||||
IFX_INLINE void forceDisableInterrupts(void);
|
||||
/** \} */
|
||||
/** \} */
|
||||
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
/******************************************************************************/
|
||||
|
||||
/** \brief Return the status of the global interrupts
|
||||
*
|
||||
* \retval TRUE if the global interrupts are enabled.
|
||||
* \retval FALSE if the global interrupts are disabled.
|
||||
*
|
||||
* \see restoreInterrupts(), disableInterrupts()
|
||||
*/
|
||||
IFX_INLINE boolean areInterruptsEnabled(void)
|
||||
{
|
||||
return IfxCpu_areInterruptsEnabled();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Disable the global interrupts
|
||||
*
|
||||
* \retval TRUE if the global interrupts were enabled before the call to the function.
|
||||
* \retval FALSE if the global interrupts are disabled before the call to the function.
|
||||
*
|
||||
* \see areInterruptsEnabled(), restoreInterrupts()
|
||||
*/
|
||||
IFX_INLINE boolean disableInterrupts(void)
|
||||
{
|
||||
return IfxCpu_disableInterrupts();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Disable the global interrupts forcefully
|
||||
*
|
||||
*
|
||||
* \see areInterruptsEnabled(), restoreInterrupts()
|
||||
*/
|
||||
IFX_INLINE void forceDisableInterrupts(void)
|
||||
{
|
||||
IfxCpu_forceDisableInterrupts();
|
||||
}
|
||||
|
||||
|
||||
/** \brief enable the global interrupts
|
||||
*
|
||||
*/
|
||||
IFX_INLINE void enableInterrupts(void)
|
||||
{
|
||||
IfxCpu_enableInterrupts();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Restore the state of the global interrupts.
|
||||
*
|
||||
* \param enabled if TRUE, re-enable the global interrupts, else do nothing.
|
||||
*
|
||||
* \return None.
|
||||
*
|
||||
* \see areInterruptsEnabled(), disableInterrupts()
|
||||
*/
|
||||
IFX_INLINE void restoreInterrupts(boolean enabled)
|
||||
{
|
||||
IfxCpu_restoreInterrupts(enabled);
|
||||
}
|
||||
|
||||
|
||||
/******************************************************************************/
|
||||
/* Macros */
|
||||
/******************************************************************************/
|
||||
#define TIMER_COUNT (11) /**< \internal \brief number of timer values defined */
|
||||
#define TIMER_INDEX_10NS (0) /**< \internal \brief Index of the time value 10ns*/
|
||||
#define TIMER_INDEX_100NS (1) /**< \internal \brief Index of the time value 100ns*/
|
||||
#define TIMER_INDEX_1US (2) /**< \internal \brief Index of the time value 1us*/
|
||||
#define TIMER_INDEX_10US (3) /**< \internal \brief Index of the time value 10us*/
|
||||
#define TIMER_INDEX_100US (4) /**< \internal \brief Index of the time value 100us*/
|
||||
#define TIMER_INDEX_1MS (5) /**< \internal \brief Index of the time value 1ms*/
|
||||
#define TIMER_INDEX_10MS (6) /**< \internal \brief Index of the time value 10ms*/
|
||||
#define TIMER_INDEX_100MS (7) /**< \internal \brief Index of the time value 100ms*/
|
||||
#define TIMER_INDEX_1S (8) /**< \internal \brief Index of the time value 1s*/
|
||||
#define TIMER_INDEX_10S (9) /**< \internal \brief Index of the time value 10s*/
|
||||
#define TIMER_INDEX_100S (10) /**< \internal \brief Index of the time value 100s*/
|
||||
|
||||
/** \internal
|
||||
* Array containing the time constants. This variable should not be used in the application. TimeConst_0s, TimeConst_10ns, ... should be used instead
|
||||
*
|
||||
*/
|
||||
IFX_EXTERN Ifx_TickTime TimeConst[TIMER_COUNT];
|
||||
|
||||
/******************************************************************************/
|
||||
/* Function prototypes */
|
||||
/******************************************************************************/
|
||||
/** \addtogroup library_srvsw_sysse_bsp_bsp
|
||||
* \{ */
|
||||
/** \name Time APIs
|
||||
* \{ */
|
||||
IFX_INLINE Ifx_TickTime addTTime(Ifx_TickTime a, Ifx_TickTime b);
|
||||
IFX_INLINE Ifx_TickTime elapsed(Ifx_TickTime since);
|
||||
IFX_INLINE Ifx_TickTime getDeadLine(Ifx_TickTime timeout);
|
||||
IFX_INLINE Ifx_TickTime getTimeout(Ifx_TickTime deadline);
|
||||
IFX_EXTERN void initTime(void);
|
||||
IFX_INLINE boolean isDeadLine(Ifx_TickTime deadLine);
|
||||
IFX_INLINE Ifx_TickTime now(void);
|
||||
IFX_INLINE Ifx_TickTime nowWithoutCriticalSection(void);
|
||||
IFX_INLINE boolean poll(volatile boolean *test, Ifx_TickTime timeout);
|
||||
IFX_INLINE Ifx_TickTime timingNoInterruptEnd(Ifx_TickTime since, boolean interruptEnabled);
|
||||
IFX_INLINE Ifx_TickTime timingNoInterruptStart(boolean *interruptEnabled);
|
||||
IFX_INLINE void wait(Ifx_TickTime timeout);
|
||||
IFX_EXTERN void waitPoll(void);
|
||||
IFX_EXTERN void waitTime(Ifx_TickTime timeout);
|
||||
|
||||
/** Prototype for wait() functions */
|
||||
typedef void (*WaitTimeFunction)(Ifx_TickTime timeout);
|
||||
|
||||
#define TimeConst_0s ((Ifx_TickTime)0) /**< \brief time constant equal to 1s */
|
||||
#define TimeConst_10ns (TimeConst[TIMER_INDEX_10NS]) /**< \brief time constant equal to 10ns */
|
||||
#define TimeConst_100ns (TimeConst[TIMER_INDEX_100NS]) /**< \brief time constant equal to 100ns */
|
||||
#define TimeConst_1us (TimeConst[TIMER_INDEX_1US]) /**< \brief time constant equal to 1us */
|
||||
#define TimeConst_10us (TimeConst[TIMER_INDEX_10US]) /**< \brief time constant equal to 10us */
|
||||
#define TimeConst_100us (TimeConst[TIMER_INDEX_100US]) /**< \brief time constant equal to 100us */
|
||||
#define TimeConst_1ms (TimeConst[TIMER_INDEX_1MS]) /**< \brief time constant equal to 1ms */
|
||||
#define TimeConst_10ms (TimeConst[TIMER_INDEX_10MS]) /**< \brief time constant equal to 10ms */
|
||||
#define TimeConst_100ms (TimeConst[TIMER_INDEX_100MS]) /**< \brief time constant equal to 100ms */
|
||||
#define TimeConst_1s (TimeConst[TIMER_INDEX_1S]) /**< \brief time constant equal to 1s */
|
||||
#define TimeConst_10s (TimeConst[TIMER_INDEX_10S]) /**< \brief time constant equal to 10s */
|
||||
#define TimeConst_100s (TimeConst[TIMER_INDEX_100S]) /**< \brief time constant equal to 100s */
|
||||
|
||||
/**\}*/
|
||||
/**\}*/
|
||||
/******************************************************************************/
|
||||
/* Functions */
|
||||
/******************************************************************************/
|
||||
|
||||
/** \brief Return system timer value (critical section).
|
||||
*
|
||||
* The function IfxStm_get() is called in a critical section, disabling
|
||||
* the interrupts. The system timer value is limited to TIME_INFINITE.
|
||||
*
|
||||
* \return Returns system timer value.
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime now(void)
|
||||
{
|
||||
Ifx_TickTime stmNow;
|
||||
boolean interruptState;
|
||||
|
||||
interruptState = disableInterrupts();
|
||||
stmNow = (Ifx_TickTime)IfxStm_get(BSP_DEFAULT_TIMER) & TIME_INFINITE;
|
||||
restoreInterrupts(interruptState);
|
||||
|
||||
return stmNow;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return system timer value (without critical section).
|
||||
*
|
||||
* The function IfxStm_get() is called. The system timer value is limited to TIME_INFINITE.
|
||||
*
|
||||
* \return Returns system timer value.
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime nowWithoutCriticalSection(void)
|
||||
{
|
||||
Ifx_TickTime stmNow;
|
||||
|
||||
stmNow = (Ifx_TickTime)IfxStm_get(BSP_DEFAULT_TIMER) & TIME_INFINITE;
|
||||
|
||||
return stmNow;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Add 2 Ifx_TickTime values and return the result
|
||||
*
|
||||
* \param a parameter a
|
||||
* \param b parameter b
|
||||
*
|
||||
* \return a + b. If either a or b is TIME_INFINITE, the result is TIME_INFINITE
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime addTTime(Ifx_TickTime a, Ifx_TickTime b)
|
||||
{
|
||||
Ifx_TickTime result;
|
||||
|
||||
if ((a == TIME_INFINITE) || (b == TIME_INFINITE))
|
||||
{
|
||||
result = TIME_INFINITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = a + b; /* FIXME check for overflow */
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return the elapsed time in ticks.
|
||||
*
|
||||
* Return the elapsed time between the current time and the time passed as parameter
|
||||
*
|
||||
* \return Returns the elapsed time.
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime elapsed(Ifx_TickTime since)
|
||||
{
|
||||
return now() - since;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return the time dead line.
|
||||
*
|
||||
* \param timeout Specifies the dead line from now: Deadline = Now + Timeout
|
||||
*
|
||||
* \return Return the time dead line.
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime getDeadLine(Ifx_TickTime timeout)
|
||||
{
|
||||
Ifx_TickTime deadLine;
|
||||
|
||||
if (timeout == TIME_INFINITE)
|
||||
{
|
||||
deadLine = TIME_INFINITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
deadLine = now() + timeout;
|
||||
}
|
||||
|
||||
return deadLine;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return the time until the dead line.
|
||||
*
|
||||
* \param deadline Specifies the dead line from now: Deadline = Now + Timeout
|
||||
*
|
||||
* \return Return the time until the dead line.
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime getTimeout(Ifx_TickTime deadline)
|
||||
{
|
||||
Ifx_TickTime timeout;
|
||||
|
||||
if (deadline == TIME_INFINITE)
|
||||
{
|
||||
timeout = TIME_INFINITE;
|
||||
}
|
||||
else
|
||||
{
|
||||
timeout = deadline - now();
|
||||
}
|
||||
|
||||
return timeout;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return TRUE if the dead line is over.
|
||||
*
|
||||
* \param deadLine Specifies the dead line.
|
||||
*
|
||||
* \retval TRUE Returns TRUE if the dead line is over
|
||||
* \retval FALSE Returns FALSE if the dead line is not yet over
|
||||
*/
|
||||
IFX_INLINE boolean isDeadLine(Ifx_TickTime deadLine)
|
||||
{
|
||||
boolean result;
|
||||
|
||||
if (deadLine == TIME_INFINITE)
|
||||
{
|
||||
result = FALSE;
|
||||
}
|
||||
else
|
||||
{
|
||||
result = now() >= deadLine;
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Poll a variable for a time.
|
||||
*
|
||||
* \param test Specifies the variable to test.
|
||||
* \param timeout Specifies the maximal time the variable will be tested
|
||||
*
|
||||
* \retval TRUE Returns TRUE if the variable gets TRUE before the timeout elapse
|
||||
* \retval FALSE Returns FALSE if the variable is FALSE as the timeout elapse
|
||||
*/
|
||||
IFX_INLINE boolean poll(volatile boolean *test, Ifx_TickTime timeout)
|
||||
{
|
||||
Ifx_TickTime deadLine = getDeadLine(timeout);
|
||||
|
||||
while ((*test == FALSE) && (isDeadLine(deadLine) == FALSE))
|
||||
{}
|
||||
|
||||
return *test;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return the elapsed time in system timer ticks, and enable the interrupts.
|
||||
*
|
||||
* The interrupts are enable by the function
|
||||
*
|
||||
* \param since time returned by timingNoInterruptStart()
|
||||
* \param interruptEnabled If TRUE, the interrupts will be enabled before the function exit. This parameter should be set to the value returned by \ref timingNoInterruptStart()
|
||||
*
|
||||
* \return Returns the elapsed time.
|
||||
*
|
||||
* \see timingNoInterruptStart()
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime timingNoInterruptEnd(Ifx_TickTime since, boolean interruptEnabled)
|
||||
{
|
||||
Ifx_TickTime stmNow;
|
||||
|
||||
stmNow = nowWithoutCriticalSection();
|
||||
restoreInterrupts(interruptEnabled);
|
||||
|
||||
return stmNow - since;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Disable the interrupt and return system timer value.
|
||||
*
|
||||
* The interrupt remains disabled after the function call
|
||||
*
|
||||
* \return Returns system timer value.
|
||||
*
|
||||
* \see timingNoInterruptEnd()
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime timingNoInterruptStart(boolean *interruptEnabled)
|
||||
{
|
||||
*interruptEnabled = disableInterrupts();
|
||||
|
||||
return nowWithoutCriticalSection();
|
||||
}
|
||||
|
||||
|
||||
/** \brief Wait for a while.
|
||||
*
|
||||
* \param timeout Specifies the waiting time
|
||||
*
|
||||
* \return None.
|
||||
*/
|
||||
IFX_INLINE void wait(Ifx_TickTime timeout)
|
||||
{
|
||||
Ifx_TickTime deadLine = getDeadLine(timeout);
|
||||
|
||||
while (isDeadLine(deadLine) == FALSE)
|
||||
{}
|
||||
}
|
||||
|
||||
|
||||
#define PIN_DRIVER_STRONG_SHARP IfxPort_PadDriver_cmosAutomotiveSpeed1
|
||||
#define Pin_setState(pin, mode) IfxPort_setPinState((pin)->port, (pin)->pinIndex, (mode))
|
||||
#define Pin_setGroupState(pin, mask, data) IfxPort_setGroupState((pin)->port, (pin)->pinIndex, (mask), (data))
|
||||
#define Pin_setMode(pin, mode) IfxPort_setPinMode((pin)->port, (pin)->pinIndex, (mode))
|
||||
#define Pin_setDriver(pin, mode) IfxPort_setPinPadDriver((pin)->port, (pin)->pinIndex, (mode))
|
||||
#define Pin_setStateHigh(pin) IfxPort_setPinHigh((pin)->port, (pin)->pinIndex)
|
||||
#define Pin_setStateLow(pin) IfxPort_setPinLow((pin)->port, (pin)->pinIndex)
|
||||
#define Pin_getState(pin) IfxPort_getPinState((pin)->port, (pin)->pinIndex)
|
||||
#define Pin_setGroupModeOutput(pin, mask, mode, outputIdx) IfxPort_setGroupModeOutput((pin)->port, (pin)->pinIndex, (mask), (mode), (outputIdx))
|
||||
#define Pin_setGroupModeInput(pin, mask, mode) IfxPort_setGroupModeInput((pin)->port, (pin)->pinIndex, (mask), (mode))
|
||||
#define Pin_setGroupState(pin, mask, data) IfxPort_setGroupState((pin)->port, (pin)->pinIndex, (mask), (data))
|
||||
#define Pin_getGroupState(pin, mask) IfxPort_getGroupState((pin)->port, (pin)->pinIndex, (mask))
|
||||
#define Pin_enableEmgStop(pin) IfxPort_enableEmergencyStop((pin)->port, (pin)->pinIndex)
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
#endif /* BSP_H */
|
||||
@@ -0,0 +1,5 @@
|
||||
/**
|
||||
* \defgroup library_srvsw_sysse_bsp Board support package
|
||||
* \ingroup library_srvsw_sysse
|
||||
*
|
||||
*/
|
||||
Reference in new issue
Block a user