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:
32343 committed 2026-05-10 21:38:49 +08:00
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
*
*/
@@ -0,0 +1,130 @@
/**
* \file Ifx_Console.c
* \brief Main Ifx_Console module implementation file
*
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
* $Date: 2014-03-13 15:49:47 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 <string.h>
#include <stdio.h>
#include <stdarg.h>
#include "Ifx_Console.h"
#include "_Utilities/Ifx_Assert.h"
#include "Cpu/Std/IfxCpu_Intrinsics.h"
Ifx_Console Ifx_g_console;
/**
* \brief Initialize the \ref Ifx_g_console object.
* \param standardIo Pointer to the IfxStdIf_DPipe object used by the \ref Ifx_g_console.
*/
void Ifx_Console_init(IfxStdIf_DPipe *standardIo)
{
Ifx_g_console.standardIo = standardIo;
Ifx_g_console.align = 0;
}
/**
* \brief Print formatted string into \ref Ifx_g_console.
* \param format printf-compatible formatted string.
* \retval TRUE if the string is printed successfully
* \retval FALSE if the function failed.
*/
boolean Ifx_Console_print(pchar format, ...)
{
if (!Ifx_g_console.standardIo->txDisabled)
{
char message[STDIF_DPIPE_MAX_PRINT_SIZE + 1];
Ifx_SizeT count;
va_list args;
va_start(args, format);
vsprintf((char *)message, format, args);
va_end(args);
count = (Ifx_SizeT)strlen(message);
IFX_ASSERT(IFX_VERBOSE_LEVEL_ERROR, count < STDIF_DPIPE_MAX_PRINT_SIZE);
return IfxStdIf_DPipe_write(Ifx_g_console.standardIo, (void *)message, &count, TIME_INFINITE);
}
else
{
return TRUE;
}
}
/**
* \brief Print formatted string into \ref Ifx_g_console.
* Indented with a number of spaces.
* \param format printf-compatible formatted string.
* \retval TRUE if the string is printed successfully
* \retval FALSE if the function failed.
*/
boolean Ifx_Console_printAlign(pchar format, ...)
{
if (!Ifx_g_console.standardIo->txDisabled)
{
char message[STDIF_DPIPE_MAX_PRINT_SIZE + 1];
Ifx_SizeT align, count;
char spaces[17] = " ";
va_list args;
va_start(args, format);
vsprintf((char *)message, format, args);
va_end(args);
count = (Ifx_SizeT)strlen(message);
IFX_ASSERT(IFX_VERBOSE_LEVEL_ERROR, count < STDIF_DPIPE_MAX_PRINT_SIZE);
align = Ifx_g_console.align;
while (align > 0)
{
Ifx_SizeT scount;
scount = __min(align, 10);
IfxStdIf_DPipe_write(Ifx_g_console.standardIo, (void *)spaces, &scount, TIME_INFINITE);
align = align - scount;
}
return IfxStdIf_DPipe_write(Ifx_g_console.standardIo, (void *)message, &count, TIME_INFINITE);
}
else
{
return TRUE;
}
}
@@ -0,0 +1,115 @@
/**
* \file Ifx_Console.h
* \brief Main Console module header file
*
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
* $Date: 2014-02-28 14:15:36 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_comm_console Console
* This module implements "Main Console" functions
* \ingroup library_srvsw_sysse_comm
*
*/
#ifndef IFX_CONSOLE_H
#define IFX_CONSOLE_H 1
#include "StdIf/IfxStdIf_DPipe.h"
//----------------------------------------------------------------------------------------
#if !defined(IFX_CFG_CONSOLE_INDENT_SIZE)
#define IFX_CFG_CONSOLE_INDENT_SIZE (4) /**<\brief Default indentation/alignment size */
#endif
typedef struct
{
IfxStdIf_DPipe *standardIo; /**<\brief Pointer to the \ref IfxStdIf_DPipe object used as general console */
sint16 align; /**<\brief Variable for storing the actual (left)indentation level of the \ref Ifx_g_console */
} Ifx_Console;
IFX_EXTERN Ifx_Console Ifx_g_console; /**< \brief Default main console global variable */
//----------------------------------------------------------------------------------------
/** \addtogroup library_srvsw_sysse_comm_console
* \{ */
#ifndef CONSOLE
/* FIXME (Alann to discuss with Dian) there is no requirement to define multiple console, CONSOLE should be removed, and APIs used instead */
/** \brief Alias \ref Ifx_g_console object (by value) */
#define CONSOLE Ifx_g_console
/** \brief Return pointer to the default console object
*
* User can override this function by defining new \ref CONSOLE macro and this function
* externally, e.g. inside Ifx_Cfg.h file.*/
IFX_INLINE IfxStdIf_DPipe *Ifx_Console_getIo(void)
{
return Ifx_g_console.standardIo;
}
#endif
IFX_EXTERN void Ifx_Console_init(IfxStdIf_DPipe *standardIo);
IFX_EXTERN boolean Ifx_Console_print(pchar format, ...);
IFX_EXTERN boolean Ifx_Console_printAlign(pchar format, ...);
/**
* \brief Decrement the alignment/indentation using the given value
* \param value the increment. If value == 0, \ref IFX_CFG_CONSOLE_INDENT_SIZE will be used.
*/
IFX_INLINE void Ifx_Console_decrAlign(sint16 value)
{
value = (sint16)(Ifx_g_console.align - ((value == 0U) ? IFX_CFG_CONSOLE_INDENT_SIZE : value));
Ifx_g_console.align = (value > 0) ? value : 0;
}
/**
* \brief Increment the alignment/indentation using the given value
* \param value the increment. If value == 0, \ref IFX_CFG_CONSOLE_INDENT_SIZE will be used.
*/
IFX_INLINE void Ifx_Console_incrAlign(sint16 value)
{
Ifx_g_console.align += ((value == 0) ? (sint16)IFX_CFG_CONSOLE_INDENT_SIZE : value);
}
/** \} */
//----------------------------------------------------------------------------------------
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,474 @@
/**
* \file Ifx_Shell.h
* \brief Shell functions.
* \ingroup library_srvsw_sysse_comm_shell
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_comm_shell Shell
* This module implements the Shell functions.
* It parses a command line and call the corresponding command execution.
* Multiple command list can be used in parallel.
*
* Only full command match is accepted.
*
* New feature / change:
* - Prefix can be defined for each command list
* - Help for a single command is displayed with "help <command>"
* - help for a command list is displayed with "help <listPrefix>"
* - command short cut is not allowed
* - command with identical start option "opt1 opt2" and "opt1 opt3" are accepted, and root to different handlers
* - Enhanced help info print
*
* Help text xyntax:
* - /p indicates a parameter description, can be multi-line, lines must be separated with ENDL
* - /s Indicates a syntax help
*
* Example of help list:
* \code
* Ifx_Shell_Command Ifx_g_OsciShell_commands[] =
* {
* {IFX_OSCI_SHELL_PREFIX, " : Oscilloscope functions"
* , NULL_PTR, NULL_PTR },
* {"run", " : run the oscilloscope"ENDL
* "/s run [single|auto|normal]"
* , NULL_PTR, &Ifx_OsciShell_run },
* {"stop", " : stop oscilloscope"
* , NULL_PTR, &Ifx_OsciShell_stop },
* {"trigger", " : trigger settings"ENDL
* "/s trigger [force|single|level <value>|raising|falling|source <chNum>|interval <value>]"ENDL
* "/p force: Force the trigger"ENDL
* "/p single: Single the trigger"ENDL
* "/p level <value>: Set trigger level to value"ENDL
* "/p [raising|falling]: Set trigger to raising or falling edges"ENDL
* "/p source <chNum>: Set trigger channel number"ENDL
* "<chNum> can be obtained with 'channel' command"ENDL
* "/p interval <value>: Set sampling interval to value"
*
* , NULL_PTR, &Ifx_OsciShell_trigger },
* {"status", " : display status"
* , NULL_PTR, &Ifx_OsciShell_status },
* {"channel", " : channel information"ENDL
* "/s channel: Show the channels information"ENDL
* "/s channel <ch> <sig>: Assign a signal to a channel"
* , NULL_PTR, &Ifx_OsciShell_channel },
* {"analyze", " : signal analysis of a ch"ENDL
* "/s analyze <ch>: analyze the input channel <ch>"
* , NULL_PTR, &Ifx_OsciShell_analyze },
* {"simulate", " : simulate a signal"ENDL
* "/s simulate <ch> <op> <wave> <freq> <ampl> <offs> <phase> : Simulate a signal generation"ENDL
* "/p <ch> : {0 .. Channel count}"ENDL
* "/p <op> : {add,sub,mul,clr}"ENDL
* "/p <wave> : {sine,square}"ENDL
* "/p <freq> : -INF .. INF"ENDL
* "/p <offs> : -INF .. INF"ENDL
* "/p <ampl> : -INF .. INF"ENDL
* "/p <phase>: 0 .. 360 [degree]"ENDL
* "/s simulate <ch> atan <ych> <xch>: Compute atan(ych/xch) and store in channel <ch>"
* , NULL_PTR, &Ifx_OsciShell_simulate},
* {"dump", " : dump values (all channels)"ENDL
* "/s dump <ch> [hex]"ENDL
* "/p <ch>: Dump the values of the channel <ch>"ENDL
* "/p hex: If hex is specified, values will be in hexadecimal"
* , NULL_PTR, &Ifx_OsciShell_dump },
* IFX_SHELL_COMMAND_LIST_END,
* };
* \endcode
*
* To enable help command, include the below command in the main command list
* {"help", SHELL_HELP_DESCRIPTION_TEXT , &\<Ifx_Shell\>, &Ifx_Shell_showHelp, },
*
* \ingroup library_srvsw_sysse_comm
*
*/
#ifndef IFX_SHELL_H
#define IFX_SHELL_H 1
//----------------------------------------------------------------------------------------
#include "StdIf/IfxStdIf_DPipe.h"
#include "Ifx_Cfg.h"
//----------------------------------------------------------------------------------------
#define IFX_SHELL_NULL_CHAR '\0'
#ifndef IFX_CFG_SHELL_CMD_HISTORY_SIZE
#define IFX_CFG_SHELL_CMD_HISTORY_SIZE (10) /**<\brief Number of commands to store in history */
#endif
#ifndef IFX_CFG_SHELL_CMD_LINE_SIZE
#define IFX_CFG_SHELL_CMD_LINE_SIZE (128) /**<\brief max command line IFX_CFG_SHELL_CMD_LINE_SIZE - 1 */
#endif
#ifndef IFX_CFG_SHELL_COMMAND_LISTS
#define IFX_CFG_SHELL_COMMAND_LISTS (1) /**<\brief Number of command lists */
#endif
#ifndef IFX_CFG_SHELL_PROMPT
#define IFX_CFG_SHELL_PROMPT "Shell>" /**<\brief Shell prompt */
#endif
#define SHELL_HELP_DESCRIPTION_TEXT \
" : Display command list, and command help."ENDL \
"/s help: show all commands"ENDL \
"/s help <command>: show the command details"
/** \brief Marker for end of command list, the end of list is detected by commandLine=NULL */
#define IFX_SHELL_COMMAND_LIST_END {0, 0, 0, 0}
/** \brief Marker for end of syntax list */
#define IFX_SHELL_SYNTAX_LIST_END {0, 0}
/** \brief Signifies no item in use in command history list */
#define IFX_SHELL_CMD_HISTORY_NO_ITEM (-1)
//----------------------------------------------------------------------------------------
/** \brief Result code definition used after each executed Shell command */
typedef enum
{
Ifx_Shell_ResultCode_unknown = (128),
Ifx_Shell_ResultCode_nok = (129),
Ifx_Shell_ResultCode_undefined = (130),
Ifx_Shell_ResultCode_ok = (255)
} Ifx_Shell_ResultCode;
/** \brief Definition of a callback function which handles a Shell command */
typedef boolean (*Ifx_Shell_Call)(pchar args, void *data, IfxStdIf_DPipe *io);
/** \brief Shell command object */
typedef struct
{
pchar commandLine;
pchar help;
void *data;
Ifx_Shell_Call call;
} Ifx_Shell_Command;
/** \brief Command line editing state */
typedef struct
{
char *cmdStr; /**< \brief Pointer to current string containing command line as so far processed */
Ifx_SizeT cursor; /**< \brief Pointer to variable containing position of cursor in so-far-processed command line */
Ifx_SizeT length; /**< \brief Pointer to variable containing total length of command line */
boolean historyAdd; /**< \brief If TRUE, when Enter is pressed, the current cmdLine should be added to the command history (in parent) */
Ifx_SizeT historyItem; /**< \brief Item ID in command history list, or IFX_SHELL_CMD_HISTORY_NO_ITEM if not using list (e.g. new command) */
} Ifx_Shell_CmdLine;
/** \brief Shell command processing state */
typedef enum
{
IFX_SHELL_CMD_STATE_NORMAL, /**< \brief Normal - no special sequences being processed */
IFX_SHELL_CMD_STATE_ESCAPE, /**< \brief Escape character has been pressed */
IFX_SHELL_CMD_STATE_ESCAPE_BRACKET, /**< \brief ESC [ pressed */
IFX_SHELL_CMD_STATE_ESCAPE_BRACKET_NUMBER /**< \brief ESC [ (number) pressed */
} Ifx_Shell_CmdState;
/** \brief Shell protocol configuration */
typedef struct
{
boolean (*start)(void *protocol, IfxStdIf_DPipe *io);
void (*execute)(void *protocol);
void (*onStart)(void *protocol, void *data);
void *onStartData;
void *object;
boolean started;
} Ifx_Shell_Protocol;
/** \brief Shell control flags */
typedef struct
{
uint16 showPrompt : 1;
uint16 enabled : 1;
uint16 sendResultCode : 1;
uint16 echo : 1;
uint16 echoError : 1;
} Ifx_Shell_Flags;
/** \brief internal Shell run-time data */
typedef struct
{
char echo[2];
char inputbuffer[IFX_CFG_SHELL_CMD_LINE_SIZE + 1];
char cmdStr[IFX_CFG_SHELL_CMD_LINE_SIZE];
Ifx_Shell_CmdState cmdState;
char escBracketNum;
} Ifx_Shell_Runtime;
typedef Ifx_Shell_Command *Ifx_Shell_CommandList;
typedef const Ifx_Shell_Command *Ifx_Shell_CommandListConst;
/**
* \brief Shell object definition
*/
typedef struct
{
IfxStdIf_DPipe *io; /**< \brief Pointer to IfxStdIf_DPipe object used by the Shell */
Ifx_Shell_Flags control; /**< \brief control flags */
/** \brief Array of pointers to the history entries */
char *cmdHistory[IFX_CFG_SHELL_CMD_HISTORY_SIZE];
/** \brief Current status of command line editing (saves passing many parameters around) */
Ifx_Shell_CmdLine cmd;
Ifx_Shell_Runtime locals; /**< \brief Runtime data */
/** \brief Array of pointers to command list. The pointed location shall be constant
* during Shell lifetime, e.g. stored in non-volatile memory or as global variable
*
* The 1st item in the list is use as a group command prefix if its "call" parameter is NULL pointer, else it is use as other entries.
* In case "call" is NULL, the corresponding 'data' is ignored, and the 'help' is displayed.
*
**/
Ifx_Shell_CommandListConst commandList[IFX_CFG_SHELL_COMMAND_LISTS];
Ifx_Shell_Protocol protocol; /**< \brief Protocol handler data */
} Ifx_Shell;
/**
* \brief Shell configuration.
*/
typedef struct
{
IfxStdIf_DPipe *standardIo; /**<\brief Pointer to a IfxStdIf_DPipe object used by the Shell */
boolean echo; /**<\brief Specifies whether each command shall be echoed back to user */
boolean showPrompt; /**<\brief Specifies whether the IFX_CFG_SHELL_PROMPT shall be displayed after each command */
boolean sendResultCode; /**<\brief Specifies whether the Ifx_Shell_ResultCode shall be sent to user */
Ifx_Shell_CommandListConst commandList[IFX_CFG_SHELL_COMMAND_LISTS]; /**< \brief Specifies pointer to the command list */
Ifx_Shell_Protocol protocol; /**<\brief Configuration for the Ifx_Shell_Protocol */
} Ifx_Shell_Config;
/**
* \brief Shell Syntax Description.
*/
typedef struct
{
pchar syntax; /**<\brief syntax */
pchar description; /**<\brief description */
} Ifx_Shell_Syntax;
//----------------------------------------------------------------------------------------
/** \addtogroup library_srvsw_sysse_comm_shell
* \{ */
/** \name Basic functionality
* \{ */
/** Set the config default parameter
*
* \param config Pointer to the configuration structure to be initialized
*/
void Ifx_Shell_initConfig(Ifx_Shell_Config *config);
/**
* \brief Initialize the shell
* \param shell Pointer to the \ref Ifx_Shell object
* \param config Pointer to the configuration structure
*/
IFX_EXTERN boolean Ifx_Shell_init(Ifx_Shell *shell, const Ifx_Shell_Config *config);
/**
* \brief Deinitialise the shell
* \param shell Pointer to the \ref Ifx_Shell object
*/
IFX_EXTERN void Ifx_Shell_deinit(Ifx_Shell *shell);
/**
* \brief Clear the receive buffer and enable the shell
* \param shell Pointer to the \ref Ifx_Shell object
*/
IFX_EXTERN void Ifx_Shell_enable(Ifx_Shell *shell);
/**
* \brief Disable the shell
* \param shell Pointer to the \ref Ifx_Shell object
*/
IFX_EXTERN void Ifx_Shell_disable(Ifx_Shell *shell);
/**
* \brief Process the shell.
*
* This function shall be called within a loop or periodic timer to guarantee the correct
* processing of the incoming/received data.
*
* \param shell Pointer to the \ref Ifx_Shell object
*/
IFX_EXTERN void Ifx_Shell_process(Ifx_Shell *shell);
/** \} */
//----------------------------------------------------------------------------------------
/** \name Parsing functions
* \{ */
/**
* \brief Within the context of Shell.call, skip the whitespaces of the args string.
* \param args Pointer to the original string
* \return Pointer to the string after skipping the whitespaces
*/
IFX_EXTERN pchar Ifx_Shell_skipWhitespace(pchar args);
/**
* \brief Match string pointed by the *argsPtr with a given token
* \param argsPtr Pointer to the argument null-terminated string
* \param token Pointer to the token string to match
* \retval TRUE if the given token match with the string pointed by argsPtr
*/
IFX_EXTERN boolean Ifx_Shell_matchToken(pchar *argsPtr, pchar token);
/**
* \brief Parse a token
* Return the next token in tokenBuffer and move the argsPtr pointer after this token
* \param argsPtr Pointer to the argument null-terminated string
* \param tokenBuffer Pointer to the value storage
* \param bufferLength Maximum parsing length
*/
IFX_EXTERN boolean Ifx_Shell_parseToken(pchar *argsPtr, char *tokenBuffer, int bufferLength);
/**
* \brief Parse an address
* \param argsPtr Pointer to the argument null-terminated string
* \param address Pointer to the value storage
*/
IFX_EXTERN boolean Ifx_Shell_parseAddress(pchar *argsPtr, void **address);
/**
* \brief Parse a signed 32-bit integer value
* \param argsPtr Pointer to the argument null-terminated string
* \param value Pointer to the value storage
*/
IFX_EXTERN boolean Ifx_Shell_parseSInt32(pchar *argsPtr, sint32 *value);
/**
* \brief Parse an unsigned 32-bit integer value
* \param argsPtr Pointer to the argument null-terminated string
* \param value Pointer to the value storage
* \param hex if TRUE, hex parsing will be done, else decimal parsing
*/
IFX_EXTERN boolean Ifx_Shell_parseUInt32(pchar *argsPtr, uint32 *value, boolean hex);
/**
* \brief Parse a signed 64-bit integer value
* \param argsPtr Pointer to the argument null-terminated string
* \param value Pointer to the value storage
*/
IFX_EXTERN boolean Ifx_Shell_parseSInt64(pchar *argsPtr, sint64 *value);
/**
* \brief Parse an unsigned 64-bit integer value
* \param argsPtr Pointer to the argument null-terminated string
* \param value Pointer to the value storage
* \param hex if TRUE, hex parsing will be done, else decimal parsing
*/
IFX_EXTERN boolean Ifx_Shell_parseUInt64(pchar *argsPtr, uint64 *value, boolean hex);
/**
* \brief Parse a 64-bit (double precision) floating-point value
* \param argsPtr Pointer to the argument null-terminated string
* \param value Pointer to the value storage
*/
IFX_EXTERN boolean Ifx_Shell_parseFloat64(pchar *argsPtr, float64 *value);
/**
* \brief Parse a 32-bit (single precision) floating-point value
* \param argsPtr Pointer to the argument null-terminated string
* \param value Pointer to the value storage
*/
IFX_EXTERN boolean Ifx_Shell_parseFloat32(pchar *argsPtr, float32 *value);
/** \} */
//----------------------------------------------------------------------------------------
/** \name Command list functions
* \{ */
/**
* \brief Find command in command List
* \param commandList Pointer to the first entry of an array of \ref Ifx_Shell_Command
* \param commandLine Pointer to null-terminated string containings the command to search.
* \param args Pointer to the argument null-terminated string
* \param match Return the number of arguments that matches
*/
IFX_EXTERN const Ifx_Shell_Command *Ifx_Shell_commandFind(Ifx_Shell_CommandListConst commandList, pchar commandLine, pchar *args, uint32 *match);
/**
* \brief Implementation of \ref Ifx_Shell_Call. Show the help menu from single command list.
* \param commandList Pointer to an array of Ifx_Shell_Command
* \param io Pointer to the IfxStdIf_DPipe object
* \param briefOnly if TRUE, show only the brief description, else show the full description
* \param singleCommand If TRUE, only show the 1st command pointed by commandList, else show the full list
*/
IFX_EXTERN boolean Ifx_Shell_showHelpSingle(Ifx_Shell_CommandListConst commandList, IfxStdIf_DPipe *io, boolean briefOnly, boolean singleCommand);
/**
* \brief Implementation of \ref Ifx_Shell_Call. Show the help menu and list of commands.
* \param args The argument null-terminated string
* \param shellPtr Pointer to a Shell object
* \param io Pointer to \ref IfxStdIf_DPipe object
*/
IFX_EXTERN boolean Ifx_Shell_showHelp(pchar args, void *shellPtr, IfxStdIf_DPipe *io);
/**
* \brief Implementation of \ref Ifx_Shell_Call. print the syntax.
* \param syntaxList Pointer to syntax list
* \param io Pointer to \ref IfxStdIf_DPipe object
*/
IFX_EXTERN void Ifx_Shell_printSyntax(const Ifx_Shell_Syntax *syntaxList, IfxStdIf_DPipe *io);
/** \} */
//----------------------------------------------------------------------------------------
/** \name Sub protocol functions
* \{ */
/**
* \brief Implementation of \ref Ifx_Shell_Call. Start the Shell protocol.
* \param args The argument null-terminated string
* \param data Pointer to \ref Ifx_Shell object
* \param io Pointer to \ref IfxStdIf_DPipe object
*/
IFX_EXTERN boolean Ifx_Shell_protocolStart(pchar args, void *data, IfxStdIf_DPipe *io);
/**
* \brief Implementation of \ref Ifx_Shell_Call. Start the ShellBb protocol.
* \param args The argument null-terminated string
* \param data Pointer to \ref Ifx_Shell object
* \param io Pointer to \ref IfxStdIf_DPipe object
*/
IFX_EXTERN boolean Ifx_Shell_bbProtocolStart(pchar args, void *data, IfxStdIf_DPipe *io);
/** \} */
//----------------------------------------------------------------------------------------
/** \} */
#endif
@@ -0,0 +1,4 @@
/**
* \defgroup library_srvsw_sysse_comm Communication
* \ingroup library_srvsw_sysse
*/
@@ -0,0 +1,168 @@
/**
* \file Ifx_GlobalResources.h
* \brief Handling of global resources
*
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
* $Date: 2014-02-27 20:08:36 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 "Ifx_GlobalResources.h"
/** \brief Global resource object */
typedef struct
{
const Ifx_GlobalResources_Item *table; /**< \brief Pointer to the global resource table */
sint32 size; /**< \brief Size of the global resource table */
} Ifx_GlobalResources;
#if IFX_CFG_GLOBAL_RESOURCES_ENABLED
Ifx_GlobalResources ifx_GlobalResource;
#endif
void *Ifx_GlobalResources_get(sint32 id)
{
void *result;
#if IFX_CFG_GLOBAL_RESOURCES_ENABLED
if (id < ifx_GlobalResource.size)
{
result = ifx_GlobalResource.table[id].resource;
}
else
{
result = NULL_PTR;
}
#else
result = NULL_PTR;
#endif
return result;
}
sint32 Ifx_GlobalResources_getIndex(void *resource)
{
sint32 id = -1;
#if IFX_CFG_GLOBAL_RESOURCES_ENABLED
int i;
for (i = 0; i < ifx_GlobalResource.size; i++)
{
if (resource == ifx_GlobalResource.table[i].resource)
{
id = i;
}
else
{}
}
#else
#endif
return id;
}
const Ifx_GlobalResources_Item *Ifx_GlobalResources_getItem(sint32 id)
{
const Ifx_GlobalResources_Item *result;
#if IFX_CFG_GLOBAL_RESOURCES_ENABLED
if (id < ifx_GlobalResource.size)
{
result = &ifx_GlobalResource.table[id];
}
else
{
result = NULL_PTR;
}
#else
result = NULL_PTR;
#endif
return result;
}
pchar Ifx_GlobalResources_getName(sint32 id)
{
pchar name;
#if IFX_CFG_GLOBAL_RESOURCES_ENABLED
if (id < ifx_GlobalResource.size)
{
name = ifx_GlobalResource.table[id].name;
}
else
{
name = "unknown";
}
#else
name = "unknown";
#endif
return name;
}
boolean Ifx_GlobalResources_init(const Ifx_GlobalResources_Item *table, uint32 size)
{
boolean result;
#if IFX_CFG_GLOBAL_RESOURCES_ENABLED
ifx_GlobalResource.table = table;
ifx_GlobalResource.size = size;
result = TRUE;
#else
result = FALSE;
#endif
return result;
}
@@ -0,0 +1,107 @@
/**
* \file Ifx_GlobalResources.h
* \brief Handling of global resources
*
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
* $Date: 2014-02-28 14:15:39 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_general_globalresources Global resources
* This module implements the global resources handling
* \ingroup library_srvsw_sysse_general
*/
#ifndef IFX_GLOBALRESOURCES_H
#define IFX_GLOBALRESOURCES_H 1
#include "Ifx_Cfg.h"
#include "Cpu/Std/Ifx_Types.h"
#ifndef IFX_CFG_GLOBAL_RESOURCES_ENABLED
#define IFX_CFG_GLOBAL_RESOURCES_ENABLED (0)
#endif
typedef struct
{
void *resource;
pchar name;
} Ifx_GlobalResources_Item;
/** \addtogroup library_srvsw_sysse_general_globalresources
* \{ */
/** Return a pointer to the global resource
*
* \param id index of the Ifx_GlobalResources_Item in the table, the index starts with 0
*
* \return return Ifx_GlobalResources_Item.resource
*/
IFX_EXTERN void *Ifx_GlobalResources_get(sint32 id);
/** \brief Returns the global resource index.
*
* \return Returns the global resource index, -1 if not found
*/
IFX_EXTERN sint32 Ifx_GlobalResources_getIndex(void *resource);
/** Return a pointer to the global resource item
*
* \param id index of the Ifx_GlobalResources_Item in the table, the index starts with 0
*
* \return return the Ifx_GlobalResources_Item
*/
IFX_EXTERN const Ifx_GlobalResources_Item *Ifx_GlobalResources_getItem(sint32 id);
/** Return a the resource name as an NULL terminated string
*
* \param id index of the Ifx_GlobalResources_Item in the table, the index starts with 0
*
* \return return Ifx_GlobalResources_Item.name
*/
IFX_EXTERN pchar Ifx_GlobalResources_getName(sint32 id);
/** Initialize the global resource handler
*
* \param table pointer to an array of Ifx_GlobalResources_Item
* \param size number of item in the table corresponds to sizeof(table)
*
* return returns TRUE in case of success else FALSE
*
*/
IFX_EXTERN boolean Ifx_GlobalResources_init(const Ifx_GlobalResources_Item *table, uint32 size);
/** \} */
#endif /* IFX_GLOBALRESOURCES_H */
@@ -0,0 +1,4 @@
/**
* \defgroup library_srvsw_sysse_general General
* \ingroup library_srvsw_sysse
*/
@@ -0,0 +1,464 @@
/**
* \file Ifx_AngleTrkF32.c
* \brief Angle-tracking observer for sin/cos analog position sensor
*
*
* \version disabled
* \copyright Copyright (c) 2019 Infineon Technologies AG. All rights reserved.
*
*
* 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.
*
*/
//________________________________________________________________________________________
// INCLUDES
#include "Ifx_AngleTrkF32.h"
#include <math.h>
#include "string.h"
#include "Ifx_LutAtan2F32.h"
//________________________________________________________________________________________
// LOCAL DEFINITIONS
#define IFX_ANGLETRKF32_ATAN2F Ifx_LutAtan2F32_float32
//________________________________________________________________________________________
// LOCAL FUNCTION PROTOTYPES
void Ifx_AngleTrkF32_setUserSampling(Ifx_AngleTrkF32 *aObsv, float32 Ts);
//________________________________________________________________________________________
// GLOBAL VARIABLES
//________________________________________________________________________________________
// LOCAL VARIABLES
//________________________________________________________________________________________
// LOCAL FUNCTION IMPLEMENTATIONS
IFX_INLINE float32 Ifx_AngleTrkF32_bound(float32 angle, float32 periodPerRotation)
{
IFX_UNUSED_PARAMETER(periodPerRotation);
float32 fullPeriod = 2 * IFX_PI;
if (angle >= (fullPeriod / 2))
{
angle = angle - fullPeriod;
}
else if (angle < (-fullPeriod / 2))
{
angle = angle + fullPeriod;
}
else
{}
return angle;
}
IFX_INLINE float32 Ifx_AngleTrkF32_boundInput(float32 input)
{
return Ifx_AngleTrkF32_bound(input, 1);
}
float32 round_f(float32 val)
{
/*lint -e632 -e633 -e524*/
sint32 val_i = (sint32)val;
/*lint +e632 +e633 +e524*/
if ((val - (float32)val_i) > 0.5)
{
val = (float32)(val_i + 1);
}
else
{
val = (float32)val_i;
}
return val;
}
//________________________________________________________________________________________
// PUBLIC FUNCTION IMPLEMENTATIONS
#define ATO_T (15e-3f)
#define ATO_K (39.05f)
#define ATO_PSI (1.5f * IFX_PI)
void Ifx_AngleTrkF32_setControlGains(Ifx_AngleTrkF32_CfgData *cfgData, float32 K, float32 T, float32 psi)
{
cfgData->kp = ((2 * K) + (psi * psi) + 1) / (T * T);
cfgData->ki = K * ((psi * psi) + 1) / (T * T * T);
cfgData->kd = (K + 2) / T;
}
/** \brief Fill config with default values */
void Ifx_AngleTrkF32_initConfig(Ifx_AngleTrkF32_Config *config, sint16 *sinIn, sint16 *cosIn)
{
Ifx_AngleTrkF32_CfgData cfgData;
Ifx_AngleTrkF32_setControlGains(&cfgData, ATO_K, ATO_T, ATO_PSI);
config->kp = cfgData.kp;
config->ki = cfgData.ki;
config->kd = cfgData.kd;
config->sinIn = sinIn;
config->cosIn = cosIn;
config->errorThreshold = 5.0f / 180 * IFX_PI;
config->sqrAmplMax = (sint32)((1.01f * 1.01f) * 2048);
config->sqrAmplMin = (sint32)((0.99f * 0.99f) * 2048);
config->speedLpfFc = 100;
config->periodPerRotation = 1;
config->reversed = FALSE;
config->offset = 0;
config->resolution = (1UL << 12);/** \brief 12-bit default resolution */
}
void Ifx_AngleTrkF32_setUserSampling(Ifx_AngleTrkF32 *aObsv, float32 Ts)
{
aObsv->base.Ts = Ts;
aObsv->halfTs = aObsv->base.Ts / 2.0F;
}
/** \brief Initialize the Angle Tracking object
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
* \param config Pointer to the configuration data
* \param Ts sampling period in seconds
*/
void Ifx_AngleTrkF32_init(Ifx_AngleTrkF32 *aObsv, const Ifx_AngleTrkF32_Config *config, float32 Ts)
{
aObsv->base.offset = config->offset;
aObsv->base.resolution = config->resolution;
aObsv->base.reversed = config->reversed;
aObsv->base.Ts = Ts;
aObsv->base.rawPosition = 0;
aObsv->base.direction = IfxStdIf_Pos_Dir_unknown;
aObsv->base.turn = 0;
aObsv->base.status.status = 0;
aObsv->base.periodPerRotation = config->periodPerRotation;
aObsv->base.positionConst = 1.0 / (float32)aObsv->base.resolution * 2.0 * IFX_PI;
aObsv->cfgData.kd = config->kd;
aObsv->cfgData.ki = config->ki;
aObsv->cfgData.kp = config->kp;
aObsv->cfgData.errorThreshold = config->errorThreshold;
aObsv->cfgData.sqrAmplMax = config->sqrAmplMax;
aObsv->cfgData.sqrAmplMin = config->sqrAmplMin;
aObsv->sinIn = config->sinIn;
aObsv->cosIn = config->cosIn;
if (!__neqf(config->kp, 0) && !__neqf(config->ki, 0) && !__neqf(config->kp, 0))
{ /* all gains are zero, use default */
/* FIXME might not be requied as set by Ifx_AngleTrkF32_initConfig() */
Ifx_AngleTrkF32_setControlGains(&aObsv->cfgData, ATO_K, ATO_T, ATO_PSI);
}
Ifx_AngleTrkF32_setUserSampling(aObsv, Ts);
aObsv->angleErr = 0.0F;
aObsv->angleEst = 0.0F;
aObsv->accelEst = 0.0F;
aObsv->speedEstA = 0.0F;
aObsv->speedEstB = 0.0F;
aObsv->angleRef = 0.0F;
{
#if IFX_CFG_ANGLETRKF32_SPEED_FILTER
Ifx_LowPassPt1F32_Config lpfConfig;
lpfConfig.gain = 1.0F;
lpfConfig.cutOffFrequency = (2 * IFX_PI * config->speedLpfFc);
lpfConfig.samplingTime = Ts;
Ifx_LowPassPt1F32_init(&aObsv->speedLpf, &lpfConfig);
#endif
}
}
/** \brief Step function of Ifx_AngleTrkF32 should be called at every sampling period provided
* during initialisation (call to Ifx_AngleTrkF32_init()).
*
* \note This function is automatically called by Ifx_AngleTrkF32_update()
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
* \param sinIn sine input signal. The offset shall be zero.
* \param cosIn cosine input signal. The offset shall be zero.
* \param phase phase of input signal.
* \note This function returns the angular position in radians
* \note The amplitude of both sinIn and cosIn signal shall be the same.
*/
float32 Ifx_AngleTrkF32_step(Ifx_AngleTrkF32 *aObsv, sint16 sinIn, sint16 cosIn, float32 phase)
{
float32 angleRef, angleEst, dAccel, dSpeed, dAngle;
if (aObsv->base.reversed != FALSE)
{
angleRef = IFX_ANGLETRKF32_ATAN2F((float32)cosIn, (float32)sinIn);
}
else
{
angleRef = IFX_ANGLETRKF32_ATAN2F((float32)sinIn, (float32)cosIn);
}
aObsv->angleAtan = angleRef;
angleRef = angleRef + phase;
aObsv->angleRef = angleRef;
// Acceleration, zero-order-hold integrator:
dAccel = aObsv->cfgData.ki * aObsv->angleErr;
aObsv->accelEst = aObsv->accelEst + (dAccel * aObsv->base.Ts);
// Speed, zero-order-hold integrator:
dSpeed = ((aObsv->cfgData.kp * aObsv->angleErr) + aObsv->accelEst);
aObsv->speedEstA = aObsv->speedEstA + (dSpeed * aObsv->base.Ts);
// Angle, first-order-hold integrator:
dAngle = ((aObsv->cfgData.kd * aObsv->angleErr) + aObsv->speedEstA);
angleEst = aObsv->angleEst + ((dAngle + aObsv->speedEstB) * aObsv->halfTs);
aObsv->speedEstB = dAngle;
aObsv->angleEst = Ifx_AngleTrkF32_boundInput(angleEst);
// Error, is calculated here to compensate one period delay
aObsv->angleErr = Ifx_AngleTrkF32_boundInput(aObsv->angleRef - aObsv->angleEst);
aObsv->base.direction = aObsv->speedEstB > 0 ? IfxStdIf_Pos_Dir_forward : IfxStdIf_Pos_Dir_backward;
#if IFX_CFG_ANGLETRKF32_SPEED_FILTER
// Filter speed:
Ifx_LowPassPt1F32_do(&aObsv->speedLpf, aObsv->speedEstB);
#endif
return aObsv->angleEst;
}
/** \brief Set the position offset (in ticks)
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
* \param offset Position offset in ticks
*/
void Ifx_AngleTrkF32_setOffset(Ifx_AngleTrkF32 *aObsv, IfxStdIf_Pos_RawAngle offset)
{
Ifx_AngleTrkF32_PosIf *base = &aObsv->base;
base->offset = offset;
}
/** \brief Update the status flags.
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
* \param sinIn Sinus value
* \param cosIn Cosinus value
* \note This function is automatically called by Ifx_AngleTrkF32_update()
*/
void Ifx_AngleTrkF32_updateStatus(Ifx_AngleTrkF32 *aObsv, sint16 sinIn, sint16 cosIn)
{
Ifx_AngleTrkF32_PosIf *base = &aObsv->base;
sint32 sqrAmpl = ((sint32)sinIn * (sint32)sinIn) + ((sint32)cosIn * (sint32)cosIn);
base->status.B.signalLoss = (sqrAmpl < aObsv->cfgData.sqrAmplMin);
base->status.B.signalDegradation = (sqrAmpl > aObsv->cfgData.sqrAmplMax);
base->status.B.trackingLoss = __absf(aObsv->angleErr) > aObsv->cfgData.errorThreshold;
}
/** \brief Update the object directly from its analog input
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
*/
void Ifx_AngleTrkF32_update(Ifx_AngleTrkF32 *aObsv)
{
Ifx_AngleTrkF32_PosIf *base = &aObsv->base;
float32 angleEst = Ifx_AngleTrkF32_step(aObsv, *aObsv->sinIn, *aObsv->cosIn, 0);
IfxStdIf_Pos_RawAngle newPosition = (IfxStdIf_Pos_RawAngle)(angleEst * (aObsv->base.resolution / 2) / IFX_PI);
newPosition = newPosition & (aObsv->base.resolution - 1);
base->rawPosition = newPosition;
Ifx_AngleTrkF32_updateStatus(aObsv, *aObsv->sinIn, *aObsv->cosIn);
}
/** \brief Returns the actual position
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
* \note This function returns the angular position in ticks [0 .. Ifx_AngleTrkF32.base.resolution-1] (represents 0..360 degree)
*/
IfxStdIf_Pos_RawAngle Ifx_AngleTrkF32_getRawPosition(Ifx_AngleTrkF32 *aObsv)
{
Ifx_AngleTrkF32_PosIf *base = &aObsv->base;
return base->rawPosition;
}
/** \brief Returns the Speed
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
*/
float32 Ifx_AngleTrkF32_getSpeed(Ifx_AngleTrkF32 *aObsv)
{
#if !IFX_CFG_ANGLETRKF32_FILTERED_SPEED
return aObsv->speedEstB; /* note: using speedEstB has better dynamic */
#else
return aObsv->speedLpf.out; /* note: using filtered speed has less ripples */
#endif
}
/*>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>*/
float32 Ifx_AngleTrkF32_getAbsolutePosition(Ifx_AngleTrkF32 *driver)
{
return ((float32)driver->base.turn + (float32)driver->base.rawPosition / (float32)driver->base.resolution) * 2.0 * IFX_PI;
}
IfxStdIf_Pos_Dir Ifx_AngleTrkF32_getDirection(Ifx_AngleTrkF32 *driver)
{
return driver->base.direction;
}
IfxStdIf_Pos_Status Ifx_AngleTrkF32_getFault(Ifx_AngleTrkF32 *driver)
{
return driver->base.status;
}
sint32 Ifx_AngleTrkF32_getOffset(Ifx_AngleTrkF32 *driver)
{
return driver->base.offset;
}
uint16 Ifx_AngleTrkF32_getPeriodPerRotation(Ifx_AngleTrkF32 *driver)
{
return driver->base.periodPerRotation;
}
float32 Ifx_AngleTrkF32_getPosition(Ifx_AngleTrkF32 *driver)
{
return (float32)driver->base.rawPosition * driver->base.positionConst;
}
float32 Ifx_AngleTrkF32_getRefreshPeriod(Ifx_AngleTrkF32 *driver)
{
return driver->base.Ts;
}
sint32 Ifx_AngleTrkF32_getResolution(Ifx_AngleTrkF32 *driver)
{
return driver->base.resolution;
}
IfxStdIf_Pos_SensorType Ifx_AngleTrkF32_getSensorType(Ifx_AngleTrkF32 *driver)
{
IFX_UNUSED_PARAMETER(driver);
return IfxStdIf_Pos_SensorType_angletrk;
}
sint32 Ifx_AngleTrkF32_getTurn(Ifx_AngleTrkF32 *driver)
{
return driver->base.turn;
}
void Ifx_AngleTrkF32_resetFaults(Ifx_AngleTrkF32 *driver)
{
driver->base.status.status = 0;
}
void Ifx_AngleTrkF32_setRefreshPeriod(Ifx_AngleTrkF32 *driver, float32 updatePeriod)
{
driver->base.Ts = updatePeriod;
}
void Ifx_AngleTrkF32_reset(Ifx_AngleTrkF32 *driver)
{
driver->base.rawPosition = 0;
driver->base.direction = IfxStdIf_Pos_Dir_unknown;
driver->base.turn = 0;
driver->angleErr = 0.0F;
driver->angleEst = 0.0F;
driver->accelEst = 0.0F;
driver->speedEstA = 0.0F;
driver->speedEstB = 0.0F;
driver->angleRef = 0.0F;
#if IFX_CFG_ANGLETRKF32_SPEED_FILTER
Ifx_LowPassPt1F32_reset(&driver->speedLpf);
#endif
driver->base.status.status = 0;
}
boolean Ifx_AngleTrkF32_stdIfPosInit(IfxStdIf_Pos *stdif, Ifx_AngleTrkF32 *driver)
{
/* Ensure the stdif is reset to zeros */
memset(stdif, 0, sizeof(IfxStdIf_Pos));
/* Set the driver */
stdif->driver = driver;
/* *INDENT-OFF* Note: this file was indented manually by the author. */
/* Set the API link */
stdif->onZeroIrq =(IfxStdIf_Pos_OnZeroIrq )NULL_PTR;
stdif->getAbsolutePosition=(IfxStdIf_Pos_GetAbsolutePosition )&Ifx_AngleTrkF32_getAbsolutePosition;
stdif->getDirection =(IfxStdIf_Pos_GetDirection )&Ifx_AngleTrkF32_getDirection;
stdif->getFault =(IfxStdIf_Pos_GetFault )&Ifx_AngleTrkF32_getFault;
stdif->getOffset =(IfxStdIf_Pos_GetOffset )&Ifx_AngleTrkF32_getOffset;
stdif->getPeriodPerRotation =(IfxStdIf_Pos_GetPeriodPerRotation )&Ifx_AngleTrkF32_getPeriodPerRotation;
stdif->getPosition =(IfxStdIf_Pos_GetPosition )&Ifx_AngleTrkF32_getPosition;
stdif->getRawPosition =(IfxStdIf_Pos_GetRawPosition )&Ifx_AngleTrkF32_getRawPosition;
stdif->getRefreshPeriod =(IfxStdIf_Pos_GetRefreshPeriod )&Ifx_AngleTrkF32_getRefreshPeriod;
stdif->getResolution =(IfxStdIf_Pos_GetResolution )&Ifx_AngleTrkF32_getResolution;
stdif->getSensorType =(IfxStdIf_Pos_GetSensorType )&Ifx_AngleTrkF32_getSensorType;
stdif->reset =(IfxStdIf_Pos_Reset )&Ifx_AngleTrkF32_reset;
stdif->resetFaults =(IfxStdIf_Pos_ResetFaults )&Ifx_AngleTrkF32_resetFaults;
stdif->getSpeed =(IfxStdIf_Pos_GetSpeed )&Ifx_AngleTrkF32_getSpeed;
stdif->update =(IfxStdIf_Pos_Update )&Ifx_AngleTrkF32_update;
stdif->setPosition =(IfxStdIf_Pos_SetPosition )NULL_PTR;
stdif->setRawPosition =(IfxStdIf_Pos_SetRawPosition )NULL_PTR;
stdif->setSpeed =(IfxStdIf_Pos_SetSpeed )NULL_PTR;
stdif->setOffset =(IfxStdIf_Pos_SetOffset )&Ifx_AngleTrkF32_setOffset;
stdif->setRefreshPeriod =(IfxStdIf_Pos_SetRefreshPeriod )&Ifx_AngleTrkF32_setRefreshPeriod;
stdif->getTurn =(IfxStdIf_Pos_GetTurn )&Ifx_AngleTrkF32_getTurn;
/* *INDENT-ON* */
return TRUE;
}
@@ -0,0 +1,309 @@
/**
* \file Ifx_AngleTrkF32.h
* \brief Angle-tracking observer for sin/cos analog position sensor
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_angletrk Angle-Tracking Observer
* This driver implements \ref library_srvsw_stdif_posif using 3rd order Angle-Tracking Observer algorithm.
* \ingroup library_srvsw_sysse_math_f32
*
*/
#ifndef IFX_ANGLETRKF32_H
#define IFX_ANGLETRKF32_H
//________________________________________________________________________________________
// INCLUDES
#include "StdIf/IfxStdIf_Pos.h"
#include "SysSe/Math/Ifx_LowPassPt1F32.h"
//________________________________________________________________________________________
// CONFIGURATION DEFINES
#ifndef IFX_CFG_ANGLETRKF32_SPEED_FILTER
#define IFX_CFG_ANGLETRKF32_SPEED_FILTER (1)
#endif
/** \brief Specify whether the speed reading is filtered by low-pass filter or not */
#ifndef IFX_CFG_ANGLETRKF32_FILTERED_SPEED
#define IFX_CFG_ANGLETRKF32_FILTERED_SPEED (1)
#endif
//________________________________________________________________________________________
// DATA STRUCTURES
/** \brief Angle Tracking Observer configuration */
typedef struct
{
float32 kp; /**< \brief Proportional gain */
float32 ki; /**< \brief Integrator gain */
float32 kd; /**< \brief Derivative gain */
float32 speedLpfFc; /**< \brief Cut-off frequency of speed low-pass filter. */
float32 errorThreshold; /**< \brief Threshold of error value in the tracking loop */
sint32 sqrAmplMax; /**< \brief Maximum value for square of signal amplitudes */
sint32 sqrAmplMin; /**< \brief Minimum value for square of signal amplitudes */
uint16 periodPerRotation; /**< \brief Number of electrical periods per mechanical rotation */
boolean reversed; /**< \brief TRUE: reversed direction, FALSE: straight direction */
sint32 resolution; /**< \brief Sensor resolution */
IfxStdIf_Pos_RawAngle offset; /**< \brief Offset in ticks. [0 .. (\ref Ifx_AngleTrkF32_Config.resolution - 1)] */
sint16 *sinIn; /**< \brief Pointer to SIN input variable */
sint16 *cosIn; /**< \brief Pointer to COS input variable */
} Ifx_AngleTrkF32_Config;
typedef struct
{
float32 kp; /**< \brief Proportional gain */
float32 ki; /**< \brief Integrator gain */
float32 kd; /**< \brief Derivative gain */
float32 errorThreshold; /**< \brief Threshold of error value in the tracking loop */
sint32 sqrAmplMax; /**< \brief Maximum value for square of signal amplitudes */
sint32 sqrAmplMin; /**< \brief Minimum value for square of signal amplitudes */
} Ifx_AngleTrkF32_CfgData;
typedef struct
{
IfxStdIf_Pos_RawAngle rawPosition; /**< \brief raw position in ticks. \note: the value already contains the offset */
sint32 turn; /**< \brief number of mechanical turns. FIXME to be implemented */
IfxStdIf_Pos_Dir direction; /**< \brief rotation direction */
IfxStdIf_Pos_Status status; /**< \brief error code (0 = no error) */
/* configuration */
IfxStdIf_Pos_RawAngle offset; /**< \brief raw position offset */
boolean reversed; /**< \brief reverse direction */
uint16 periodPerRotation; /**< \brief sensor 'electrical' periods per mechanical rotation */
IfxStdIf_Pos_RawAngle resolution; /**< \brief resolution of this position sensor interface */
float32 Ts; /**< \brief update period in seconds */
float32 positionConst; /**< \brief constant for calculating mechanical position (in rad) from raw position */
} Ifx_AngleTrkF32_PosIf;
/** \brief Angle Tracking Observer object */
typedef struct
{
Ifx_AngleTrkF32_PosIf base;
Ifx_AngleTrkF32_CfgData cfgData;
sint16 *sinIn; /**< \brief Pointer to SIN input variable */
sint16 *cosIn; /**< \brief Pointer to COS input variable */
float32 halfTs;
float32 angleAtan;
float32 angleRef;
float32 angleEst;
float32 speedEstA;
float32 speedEstB;
float32 accelEst;
float32 angleErr;
Ifx_LowPassPt1F32 speedLpf; /**< Only used if IFX_CFG_ANGLETRKF32_SPEED_FILTER is set */
} Ifx_AngleTrkF32;
/** \addtogroup library_srvsw_sysse_math_f32_angletrk
* \{ */
//________________________________________________________________________________________
// PUBLIC FUNCTION PROTOTYPES
/** \name Initialisation functions
* Example use:
* \code
* extern sint16 g_SinInput, g_CosInput;
* Ifx_AngleTrkF32_Config driverConfig;
* Ifx_AngleTrkF32 driverData;
* Ifx_AngleTrkF32_initConfig(&driverConfig, &g_SinInput, g_CosInput);
* driverConfig.errorThreshold = 5.0 / 180 * IFX_PI; // 5 degree error
* driverConfig.sqrAmplMax = 1.01 * 1.01;
* driverConfig.sqrAmplMin = 0.99 * 0.99;
* driverConfig.speedLpfFc = 100;
* driverConfig.periodPerRotation = 1;
* driverConfig.reversed = FALSE;
* driverConfig.offset = 0;
* Ifx_AngleTrkF32_init(&driverData, &driverConfig);
* \endcode
* Prototypes:
* \{ */
IFX_EXTERN void Ifx_AngleTrkF32_init(Ifx_AngleTrkF32 *aObsv, const Ifx_AngleTrkF32_Config *config, float32 Ts);
IFX_EXTERN void Ifx_AngleTrkF32_initConfig(Ifx_AngleTrkF32_Config *config, sint16 *sinIn, sint16 *cosIn);
/** \} */
/** \name Protected functions
* These functions are not for end-user but may be used by another driver which extends
* the functionality of library_srvsw_sysse_math_f32_angletrk
* \{ */
IFX_EXTERN float32 Ifx_AngleTrkF32_step(Ifx_AngleTrkF32 *aObsv, sint16 sinIn, sint16 cosIn, float32 phase);
IFX_EXTERN void Ifx_AngleTrkF32_updateStatus(Ifx_AngleTrkF32 *aObsv, sint16 sinIn, sint16 cosIn);
IFX_INLINE float32 Ifx_AngleTrkF32_getLoopSpeed(Ifx_AngleTrkF32 *aObsv);
/** \} */
/** \} */
/** \brief get the speed.
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
*/
IFX_INLINE float32 Ifx_AngleTrkF32_getLoopSpeed(Ifx_AngleTrkF32 *aObsv)
{
return aObsv->speedEstB; /* note: using speedEstB has better dynamic */
/* return aObsv->speedLpf.out; */
}
/** \addtogroup library_srvsw_sysse_math_f32_angletrk
* \{ */
/******************************************************************************/
/*-------------------------Global Function Prototypes-------------------------*/
/******************************************************************************/
/** \brief \see IfxStdIf_Pos_GetAbsolutePosition
* \param driver driver handle
* \return absolute position
*/
IFX_EXTERN float32 Ifx_AngleTrkF32_getAbsolutePosition(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetDirection
* \param driver driver handle
* \return direction
*/
IFX_EXTERN IfxStdIf_Pos_Dir Ifx_AngleTrkF32_getDirection(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetFault
* \param driver driver handle
* \return Fault
*/
IFX_EXTERN IfxStdIf_Pos_Status Ifx_AngleTrkF32_getFault(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetOffset
* \param driver driver handle
* \return offset address
*/
IFX_EXTERN sint32 Ifx_AngleTrkF32_getOffset(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetPeriodPerRotation
* \param driver driver handle
* \return Period per rotation
*/
IFX_EXTERN uint16 Ifx_AngleTrkF32_getPeriodPerRotation(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetPosition
* \param driver driver handle
* \return position
*/
IFX_EXTERN float32 Ifx_AngleTrkF32_getPosition(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetRawPosition
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
* \return position in ticks
*/
IFX_EXTERN IfxStdIf_Pos_RawAngle Ifx_AngleTrkF32_getRawPosition(Ifx_AngleTrkF32 *aObsv);
/** \brief \see IfxStdIf_Pos_GetRefreshPeriod
* \param driver driver handle
* \return update period
*/
IFX_EXTERN float32 Ifx_AngleTrkF32_getRefreshPeriod(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetResolution
* \param driver driver handle
* \return resolution
*/
IFX_EXTERN sint32 Ifx_AngleTrkF32_getResolution(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetTurn
* \param driver driver handle
* \return Returns the number of turns
*/
IFX_EXTERN sint32 Ifx_AngleTrkF32_getTurn(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetSensorType
* \param driver driver handle
* \return sensor type
*/
IFX_EXTERN IfxStdIf_Pos_SensorType Ifx_AngleTrkF32_getSensorType(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_GetSpeed
* \param aObsv Pointer to the Ifx_AngleTrkF32 object
* \return speed
*/
IFX_EXTERN float32 Ifx_AngleTrkF32_getSpeed(Ifx_AngleTrkF32 *aObsv);
/** \brief \see IfxStdIf_Pos_Reset
* \param driver driver handle
* \return None
*/
IFX_EXTERN void Ifx_AngleTrkF32_reset(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_ResetFaults
* \param driver driver handle
* \return None
*/
IFX_EXTERN void Ifx_AngleTrkF32_resetFaults(Ifx_AngleTrkF32 *driver);
/** \brief \see IfxStdIf_Pos_SetOffset
* \param aObsv driver handle
* \param offset offset
* \return None
*/
IFX_EXTERN void Ifx_AngleTrkF32_setOffset(Ifx_AngleTrkF32 *aObsv, IfxStdIf_Pos_RawAngle offset);
/** \brief \see IfxStdIf_Pos_SetRefreshPeriod
* \param driver driver handle
* \param updatePeriod update period
* \return None
*/
IFX_EXTERN void Ifx_AngleTrkF32_setRefreshPeriod(Ifx_AngleTrkF32 *driver, float32 updatePeriod);
/** \brief \see IfxStdIf_Pos_Update
* \param aObsv driver handle
* \return None
*/
IFX_EXTERN void Ifx_AngleTrkF32_update(Ifx_AngleTrkF32 *aObsv);
/** \} */
/******************************************************************************/
/*-------------------------Global Function Prototypes-------------------------*/
/******************************************************************************/
/** \brief Initializes the standard interface "Pos"
* \param stdif Standard interface position object
* \param driver Virtual position sensor
* \return TRUE on success else FALSE
*/
IFX_EXTERN boolean Ifx_AngleTrkF32_stdIfPosInit(IfxStdIf_Pos *stdif, Ifx_AngleTrkF32 *driver);
#endif /* IFX_ANGLETRKF32_H */
@@ -0,0 +1,390 @@
/**
* \file Ifx_Cf32.c
* \brief Floating point signal, vector, and matrix library
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_Cf32.h"
#include <float.h>
#include <stdio.h>
void CplxVecRst_f32(cfloat32 *X, short nX)
{
for ( ; nX > 0; nX--)
{
X->real = X->imag = 0.0;
X++;
}
}
void CplxVecCpy_f32S(cfloat32 *X, short *S, short nS, short incrS)
{
for ( ; nS > 0; nS--)
{
(*X).imag = 0.0;
(*X).real = *(S);
X++; S += incrS;
}
}
void CplxVecCpy_f32(cfloat32 *X, cfloat32 *S, short nS)
{
for ( ; nS > 0; nS--)
{
*X = *S;
X++; S++;
}
}
float32 *CplxVecPwr_f32(cfloat32 *X, short nX)
{
unsigned short i;
float32 *r = (float32 *)X;
for (i = 0; i < nX; i++)
{
*r = IFX_Cf32_dot(X);
r++; X++;
}
return &r[-nX];
}
float32 *CplxVecMag_f32(cfloat32 *X, short nX)
{
unsigned short i;
float32 *r = (float32 *)X;
for (i = 0; i < nX; i++)
{
*r = IFX_Cf32_mag(X);
r++; X++;
}
return &r[-nX];
}
void CplxVecMul_f32(cfloat32 *X, const cfloat32 *mul, short nX)
{
for ( ; nX > 0; nX--)
{
*X = IFX_Cf32_mul(X, mul);
X++;
}
}
void VecPwrdB_f32(float32 *X, short nX)
{
unsigned short i;
for (i = 0; i < nX; i++)
{
*X = (float32)20.0 * log10f(*X);
X++;
}
}
void VecPwrdB_SF(sint16 *R, float32 *X, short nX)
{
unsigned short i;
for (i = 0; i < nX; i++)
{
*R = (sint16)(20.0 * log10f(*X));
R++; X++;
}
}
float32 VecMaxIdx_f32(float32 *X, short nX, sint16 *minIdx, sint16 *maxIdx)
{
float32 maxPeak = FLT_MIN;
unsigned short m;
for (m = 0; m < nX; m++)
{
if (*X > maxPeak)
{
maxPeak = *X;
*minIdx = m;
}
if (*X >= maxPeak)
{
*maxIdx = m;
}
X++;
}
return maxPeak;
}
float32 VecMinIdx_f32(float32 *X, short nX, sint16 *minIdx, sint16 *maxIdx)
{
float32 minPeak = FLT_MAX;
short m;
for (m = 0; m < nX; m++)
{
if (*X < minPeak)
{
minPeak = *X;
*minIdx = m;
}
if (*X <= minPeak)
{
*maxIdx = m;
}
X++;
}
return minPeak;
}
void VecOfs_f32(float32 *X, float32 offset, short nX)
{
unsigned short i;
for (i = 0; i < nX; i++)
{
*X -= offset;
X++;
}
}
void VecGain_f32(float32 *X, float32 gain, short nX)
{
unsigned short i;
for (i = 0; i < nX; i++)
{
*X = *X * gain;
X++;
}
}
float32 VecSum_f32(float32 *X, short nX)
{
float32 sumX = 0;
unsigned short i;
for (i = 0; i < nX; i++)
{
sumX += *X;
X++;
}
return sumX;
}
float32 VecAvg_f32(float32 *X, short nX)
{
return VecSum_f32(X, nX) / nX;
}
float32 VecMax_f32(float32 *X, short nX)
{
unsigned short i;
float32 r = FLT_MIN;
for (i = 0; i < nX; i++)
{
r = __maxf(r, *X);
X++;
}
return r;
}
float32 VecMin_f32(float32 *X, short nX)
{
unsigned short i;
float32 r = FLT_MAX;
for (i = 0; i < nX; i++)
{
r = __minf(r, *X);
X++;
}
return r;
}
void VecHalfSwap_f32(float32 *X, short nX)
{
unsigned short i;
unsigned short half = nX / 2;
float32 *F = &X[half];
for (i = 0; i < half; i++)
{
float32 tmp = *F;
*F = *X;
*X = tmp;
F++; X++;
}
}
/* NOTE:
* (nX <= nW) && ((nW % nX) == 0) && ((nX % 2) == 0)
* (symW != 0) when the window is symmetrical */
void VecWin_f32(float32 *X, const float32 *W, short nX, short nW, short incrX, short symW)
{
short step = nW / nX;
short i;
if (symW != 0)
{ /* symmetrical window, using half of the length */
for (i = 0; i < nX / 2; i++)
{
*X = *X * *W;
X = &X[incrX];
W = &W[step];
}
W = &W[-step];
for ( ; i < nX; i++)
{
*X = *X * *W;
X = &X[incrX];
W = &W[-step];
}
}
}
#ifdef __WIN32__
#define ENDL "\r\n"
void DataF_printf(FILE *fp, pchar fileName, float32 *data, long nX, int enclosed)
{
long i;
if (fileName != NULL)
{
fp = fopen(fileName, "w+");
}
if (fp != NULL)
{
if (enclosed)
{
for (i = 0; i < nX; i++)
{
fprintf(fp, "_DATAF(%10.20f),"ENDL, *data);
data = &data[1];
}
}
else
{
for (i = 0; i < nX; i++)
{
fprintf(fp, "%10.20f,"ENDL, *data);
data = &data[1];
}
}
}
if (fileName != NULL)
{
fclose(fp);
}
}
void Cplx_f32_printf(FILE *fp, pchar fileName, cfloat32 *data, long nX, int encloseData)
{
long i;
if (fileName != NULL)
{
fp = fopen(fileName, "w+");
}
if (fp != NULL)
{
if (encloseData)
{
for (i = 0; i < nX; i++)
{
fprintf(fp, "{_DATAF(%10.20f), _DATAF(%10.20f)},"ENDL, data->real, data->imag);
data = &data[1];
}
}
else
{
for (i = 0; i < nX; i++)
{
fprintf(fp, "%10.20f, %10.20f"ENDL, data->real, data->imag);
data = &data[1];
}
}
}
if (fileName != NULL)
{
fclose(fp);
}
}
#endif
@@ -0,0 +1,184 @@
/**
* \file Ifx_Cf32.h
* \brief Floating point signal, vector, and matrix library
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_cf32 Floating point signal, vector, and matrix library
* \ingroup library_srvsw_sysse_math_f32
*/
#ifndef IFX_CF32_H
#define IFX_CF32_H
#include "Cpu/Std/IfxCpu_Intrinsics.h"
#include <math.h>
#define _DATAF(val) ((float32)(val))
/* Complex Arithmetic --------------------------------------------------------*/
IFX_INLINE cfloat32 IFX_Cf32_exp(const cfloat32 *c)
{
float32 f = (float32)expf(c->real);
cfloat32 R;
R.real = f * (float32)cosf(c->imag);
R.imag = f * (float32)sinf(c->imag);
return R;
}
IFX_INLINE cfloat32 IFX_Cf32_mul(const cfloat32 *a, const cfloat32 *b)
{
cfloat32 R;
R.real = (a->real * b->real) - (a->imag * b->imag);
R.imag = (a->imag * b->real) + (a->real * b->imag);
return R;
}
IFX_INLINE cfloat32 IFX_Cf32_amp(const cfloat32 *a, float32 gain)
{
cfloat32 R;
R.real = a->real * gain;
R.imag = a->imag * gain;
return R;
}
IFX_INLINE float32 IFX_Cf32_dot(const cfloat32 *b)
{
return (b->real * b->real) + (b->imag * b->imag);
}
IFX_INLINE float32 IFX_Cf32_mag(const cfloat32 *c)
{
return (float32)sqrtf(IFX_Cf32_dot(c));
}
IFX_INLINE cfloat32 IFX_Cf32_div(const cfloat32 *a, const cfloat32 *b)
{
float32 denom = IFX_Cf32_dot(b);
cfloat32 R;
R.real = ((a->real * b->real) + (a->imag * b->imag)) / denom;
R.imag = ((a->imag * b->real) - (a->real * b->imag)) / denom;
return R;
}
IFX_INLINE cfloat32 IFX_Cf32_add(const cfloat32 *a, const cfloat32 *b)
{
cfloat32 R;
R.real = (a->real + b->real);
R.imag = (a->imag + b->imag);
return R;
}
IFX_INLINE cfloat32 IFX_Cf32_sub(const cfloat32 *a, const cfloat32 *b)
{
cfloat32 R;
R.real = (a->real - b->real);
R.imag = (a->imag - b->imag);
return R;
}
IFX_INLINE void IFX_Cf32_set(cfloat32 *a, float32 re, float32 im)
{
a->real = re;
a->imag = im;
}
IFX_INLINE void IFX_Cf32_reset(cfloat32 *a)
{
IFX_Cf32_set(a, 0.0, 0.0);
}
IFX_INLINE cfloat32 IFX_Cf32_saturate(cfloat32 *a, float32 *ampl, float32 limit)
{
cfloat32 R = *a;
*ampl = IFX_Cf32_mag(a);
if (*ampl > limit)
{
float32 scale = limit / *ampl;
R.imag = R.imag * scale;
R.real = R.real * scale;
}
return R;
}
IFX_EXTERN void CplxVecCpy_f32S(cfloat32 *X, short *S, short nS, short incrS);
IFX_EXTERN void CplxVecRst_f32(cfloat32 *X, short nX);
IFX_EXTERN void CplxVecCpy_f32(cfloat32 *X, cfloat32 *S, short nS);
IFX_EXTERN float32 *CplxVecPwr_f32(cfloat32 *X, short nX);
IFX_EXTERN float32 *CplxVecMag_f32(cfloat32 *X, short nX);
IFX_EXTERN void CplxVecMul_f32(cfloat32 *X, const cfloat32 *mul, short nX);
/* Vector Operation ----------------------------------------------------------*/
IFX_EXTERN void VecWin_f32(float32 *X, const float32 *W, short nX, short nW, short incrX, short symW);
IFX_EXTERN void VecPwrdB_f32(float32 *X, short nX);
IFX_EXTERN void VecPwrdB_SF(sint16 *R, float32 *X, short nX);
IFX_EXTERN void VecGain_f32(float32 *X, float32 gain, short nX);
IFX_EXTERN void VecOfs_f32(float32 *X, float32 offset, short nX);
IFX_EXTERN float32 VecSum_f32(float32 *X, short nX);
IFX_EXTERN float32 VecAvg_f32(float32 *X, short nX);
IFX_EXTERN float32 VecMax_f32(float32 *X, short nX);
IFX_EXTERN float32 VecMin_f32(float32 *X, short nX);
IFX_EXTERN float32 VecMinIdx_f32(float32 *X, short nX, sint16 *minIdx, sint16 *maxIdx);
IFX_EXTERN float32 VecMaxIdx_f32(float32 *X, short nX, sint16 *minIdx, sint16 *maxIdx);
IFX_EXTERN void VecHalfSwap_f32(float32 *X, short nX);
/* Helper functions ----------------------------------------------------------*/
#ifdef __WIN32__
#include <stdio.h>
void Cplx_f32_printf(FILE *fp, pchar fileName, cfloat32 *data, long nX, int encloseData);
#else
#define Cplx_f32_printf(...)
#endif
#endif /* IFX_CF32_H */
@@ -0,0 +1,656 @@
/**
* \file Ifx_Crc.c
* \brief CRC algorithm
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_Crc.h"
uint32 Ifx_Crc_reflect(uint32 crc, sint32 bitnum);
boolean Ifx_Crc_init(Ifc_Crc *driver, const Ifc_Crc_Table *table, sint32 direct, sint32 refout, uint32 crcinit, uint32 crcxor)
{
sint32 i;
uint32 bit, crc;
if (crcinit != (crcinit & table->crcmask))
{
//IfxStdIf_DPipe_print(io,"ERROR, invalid crcinit."ENDL);
return FALSE;
}
if (crcxor != (crcxor & table->crcmask))
{
//IfxStdIf_DPipe_print(io,"ERROR, invalid crcxor."ENDL);
return FALSE;
}
driver->table = table;
driver->crcxor = crcxor;
driver->refout = refout;
// compute missing initial CRC value
if (!direct)
{
driver->crcinit_nondirect = crcinit;
crc = crcinit;
for (i = 0; i < table->order; i++)
{
bit = crc & table->crchighbit;
crc <<= 1;
if (bit)
{
crc ^= table->polynom;
}
}
crc &= table->crcmask;
driver->crcinit_direct = crc;
}
else
{
driver->crcinit_direct = crcinit;
crc = crcinit;
for (i = 0; i < table->order; i++)
{
bit = crc & 1;
if (bit)
{
crc ^= table->polynom;
}
crc >>= 1;
if (bit)
{
crc |= table->crchighbit;
}
}
driver->crcinit_nondirect = crc;
}
return TRUE;
}
boolean Ifx_Crc_createTable(Ifc_Crc_Table *table, sint32 order, uint32 polynom, sint32 refin)
{
uint32 crcmask;
// at first, compute constant bit masks for whole CRC and CRC high bit
crcmask = ((((uint32)1 << (order - 1)) - 1) << 1) | 1;
// check parameters
if ((order < 1) || (order > 32))
{
//IfxStdIf_DPipe_print(io,"ERROR, invalid order, it must be between 1..32."ENDL);
return FALSE;
}
if (polynom != (polynom & crcmask))
{
//IfxStdIf_DPipe_print(io,"ERROR, invalid polynom."ENDL);
return FALSE;
}
table->order = order;
table->polynom = polynom;
table->refin = refin;
table->crchighbit = (uint32)1 << (order - 1);
table->crcmask = crcmask;
// generate lookup table
// make CRC lookup table used by table algorithms
{
sint32 i, j;
uint32 bit, crc;
for (i = 0; i < 256; i++)
{
crc = (uint32)i;
if (refin)
{
crc = Ifx_Crc_reflect(crc, 8);
}
crc <<= order - 8;
for (j = 0; j < 8; j++)
{
bit = crc & table->crchighbit;
crc <<= 1;
if (bit)
{
crc ^= polynom;
}
}
if (refin)
{
crc = Ifx_Crc_reflect(crc, order);
}
crc &= crcmask;
if (order <= 8)
{
uint8 *crctab = (uint8 *)((uint32)table + sizeof(Ifc_Crc_Table));
crctab[i] = (uint8)crc;
}
else if (order <= 16)
{
uint16 *crctab = (uint16 *)((uint32)table + sizeof(Ifc_Crc_Table));
crctab[i] = (uint16)crc;
}
else
{
uint32 *crctab = (uint32 *)((uint32)table + sizeof(Ifc_Crc_Table));
crctab[i] = crc;
}
}
}
return TRUE;
}
// subroutines
uint32 Ifx_Crc_reflect(uint32 crc, sint32 bitnum)
{
// reflects the lower 'bitnum' bits of 'crc'
uint32 i, j = 1, crcout = 0;
for (i = (uint32)1 << (bitnum - 1); i; i >>= 1)
{
if (crc & i)
{
crcout |= j;
}
j <<= 1;
}
return crcout;
}
uint32 Ifx_Crc_tableFast(Ifc_Crc *driver, uint8 *p, uint32 len)
{
// fast lookup table algorithm without augmented zero bytes, e.g. used in pkzip.
// only usable with polynom orders of 8, 16, 24 or 32.
uint32 crc = driver->crcinit_direct;
sint32 orderMinusHeight = driver->table->order - 8;
if (driver->table->refin)
{
crc = Ifx_Crc_reflect(crc, driver->table->order);
}
if (driver->table->order <= 8)
{
uint8 *crctab = (uint8 *)((uint32)driver->table + sizeof(Ifc_Crc_Table));
if (!driver->table->refin)
{
while (len--)
{
crc = (crc << 8) ^ crctab[((crc >> (orderMinusHeight)) & 0xff) ^ *p++];
}
}
else
{
while (len--)
{
crc = (crc >> 8) ^ crctab[(crc & 0xff) ^ *p++];
}
}
}
else if (driver->table->order <= 16)
{
uint16 *crctab = (uint16 *)((uint32)driver->table + sizeof(Ifc_Crc_Table));
if (!driver->table->refin)
{
while (len--)
{
crc = (crc << 8) ^ crctab[((crc >> (orderMinusHeight)) & 0xff) ^ *p++];
}
}
else
{
while (len--)
{
crc = (crc >> 8) ^ crctab[(crc & 0xff) ^ *p++];
}
}
}
else
{
uint32 *crctab = (uint32 *)((uint32)driver->table + sizeof(Ifc_Crc_Table));
if (!driver->table->refin)
{
while (len--)
{
crc = (crc << 8) ^ crctab[((crc >> (orderMinusHeight)) & 0xff) ^ *p++];
}
}
else
{
while (len--)
{
crc = (crc >> 8) ^ crctab[(crc & 0xff) ^ *p++];
}
}
}
if (driver->refout ^ driver->table->refin)
{
crc = Ifx_Crc_reflect(crc, driver->table->order);
}
crc ^= driver->crcxor;
crc &= driver->table->crcmask;
return crc;
}
uint32 Ifx_Crc_table(Ifc_Crc *driver, uint8 *p, uint32 len)
{
// normal lookup table algorithm with augmented zero bytes.
// only usable with polynom orders of 8, 16, 24 or 32.
uint32 crc = driver->crcinit_nondirect;
sint32 orderMinusHeight = driver->table->order - 8;
if (driver->table->refin)
{
crc = Ifx_Crc_reflect(crc, driver->table->order);
}
if (driver->table->order <= 8)
{
uint8 *crctab = (uint8 *)((uint32)driver->table + sizeof(Ifc_Crc_Table));
if (!driver->table->refin)
{
while (len--)
{
crc = ((crc << 8) | *p++) ^ crctab[(crc >> (orderMinusHeight)) & 0xff];
}
}
else
{
while (len--)
{
crc = ((crc >> 8) | (*p++ << (orderMinusHeight))) ^ crctab[crc & 0xff];
}
}
if (!driver->table->refin)
{
while (++len < (driver->table->order >> 3))
{
crc = (crc << 8) ^ crctab[(crc >> (orderMinusHeight)) & 0xff];
}
}
else
{
while (++len < (driver->table->order >> 3))
{
crc = (crc >> 8) ^ crctab[crc & 0xff];
}
}
}
else if (driver->table->order <= 16)
{
uint16 *crctab = (uint16 *)((uint32)driver->table + sizeof(Ifc_Crc_Table));
if (!driver->table->refin)
{
while (len--)
{
crc = ((crc << 8) | *p++) ^ crctab[(crc >> (orderMinusHeight)) & 0xff];
}
}
else
{
while (len--)
{
crc = ((crc >> 8) | (*p++ << (orderMinusHeight))) ^ crctab[crc & 0xff];
}
}
if (!driver->table->refin)
{
while (++len < (driver->table->order >> 3))
{
crc = (crc << 8) ^ crctab[(crc >> (orderMinusHeight)) & 0xff];
}
}
else
{
while (++len < (driver->table->order >> 3))
{
crc = (crc >> 8) ^ crctab[crc & 0xff];
}
}
}
else if (driver->table->order <= 32)
{
uint32 *crctab = (uint32 *)((uint32)driver->table + sizeof(Ifc_Crc_Table));
if (!driver->table->refin)
{
while (len--)
{
crc = ((crc << 8) | *p++) ^ crctab[(crc >> (orderMinusHeight)) & 0xff];
}
}
else
{
while (len--)
{
crc = ((crc >> 8) | (*p++ << (orderMinusHeight))) ^ crctab[crc & 0xff];
}
}
if (!driver->table->refin)
{
while (++len < (driver->table->order >> 3))
{
crc = (crc << 8) ^ crctab[(crc >> (orderMinusHeight)) & 0xff];
}
}
else
{
while (++len < (driver->table->order >> 3))
{
crc = (crc >> 8) ^ crctab[crc & 0xff];
}
}
}
if (driver->refout ^ driver->table->refin)
{
crc = Ifx_Crc_reflect(crc, driver->table->order);
}
crc ^= driver->crcxor;
crc &= driver->table->crcmask;
return crc;
}
uint32 Ifx_Crc_bitByBit(Ifc_Crc *driver, uint8 *p, uint32 len)
{
// bit by bit algorithm with augmented zero bytes.
// does not use lookup table, suited for polynom driver->table->orders between 1...32.
uint32 i, j, c, bit;
uint32 crc = driver->crcinit_nondirect;
for (i = 0; i < len; i++)
{
c = (uint32)*p++;
if (driver->table->refin)
{
c = Ifx_Crc_reflect(c, 8);
}
for (j = 0x80; j; j >>= 1)
{
bit = crc & driver->table->crchighbit;
crc <<= 1;
if (c & j)
{
crc |= 1;
}
if (bit)
{
crc ^= driver->table->polynom;
}
}
}
for (i = 0; i < driver->table->order; i++)
{
bit = crc & driver->table->crchighbit;
crc <<= 1;
if (bit)
{
crc ^= driver->table->polynom;
}
}
if (driver->refout)
{
crc = Ifx_Crc_reflect(crc, driver->table->order);
}
crc ^= driver->crcxor;
crc &= driver->table->crcmask;
return crc;
}
uint32 Ifx_Crc_bitByBitFast(Ifc_Crc *driver, uint8 *p, uint32 len)
{
// fast bit by bit algorithm without augmented zero bytes.
// does not use lookup table, suited for polynom driver->table->orders between 1...32.
uint32 i, j, c, bit;
uint32 crc = driver->crcinit_direct;
for (i = 0; i < len; i++)
{
c = (uint32)*p++;
if (driver->table->refin)
{
c = Ifx_Crc_reflect(c, 8);
}
for (j = 0x80; j; j >>= 1)
{
bit = crc & driver->table->crchighbit;
crc <<= 1;
if (c & j)
{
bit ^= driver->table->crchighbit;
}
if (bit)
{
crc ^= driver->table->polynom;
}
}
}
if (driver->refout)
{
crc = Ifx_Crc_reflect(crc, driver->table->order);
}
crc ^= driver->crcxor;
crc &= driver->table->crcmask;
return crc;
}
#if CRC_ENABLE_DPIPE
void Ifx_Crc_printTable(Ifc_Crc_Table *table, IfxStdIf_DPipe *io)
{
sint32 i = 0;
uint32 typeSize;
if (table->order <= 8)
{
typeSize = 8;
}
else if (table->order <= 16)
{
typeSize = 16;
}
else
{
typeSize = 32;
}
IfxStdIf_DPipe_print(io, ENDL "Ifc_Crc_Table%d <tabe name> = {"ENDL, typeSize);
IfxStdIf_DPipe_print(io, " .data.order=%d,"ENDL, table->order);
IfxStdIf_DPipe_print(io, " .data.polynom=0x%X,"ENDL, table->polynom);
IfxStdIf_DPipe_print(io, " .data.refin=%d,"ENDL, table->refin);
IfxStdIf_DPipe_print(io, " .data.crchighbit=%d,"ENDL, table->crchighbit);
IfxStdIf_DPipe_print(io, " .data.crcmask=0x%X,"ENDL, table->crcmask);
IfxStdIf_DPipe_print(io, " .crctab={"ENDL);
IfxStdIf_DPipe_print(io, " ");
while (i < 256)
{
if (table->order <= 4)
{
uint8 *crctab = (uint8 *)((uint32)table + sizeof(Ifc_Crc_Table));
IfxStdIf_DPipe_print(io, "0x%01X, ", crctab[i]);
}
else if (table->order <= 8)
{
uint8 *crctab = (uint8 *)((uint32)table + sizeof(Ifc_Crc_Table));
IfxStdIf_DPipe_print(io, "0x%02X, ", crctab[i]);
}
else if (table->order <= 16)
{
uint16 *crctab = (uint16 *)((uint32)table + sizeof(Ifc_Crc_Table));
IfxStdIf_DPipe_print(io, "0x%04X, ", crctab[i]);
}
else if (table->order <= 24)
{
uint32 *crctab = (uint32 *)((uint32)table + sizeof(Ifc_Crc_Table));
IfxStdIf_DPipe_print(io, "0x%06X, ", crctab[i]);
}
else
{
uint32 *crctab = (uint32 *)((uint32)table + sizeof(Ifc_Crc_Table));
IfxStdIf_DPipe_print(io, "0x%08X, ", crctab[i]);
}
i++;
if ((i % 16) == 0)
{
IfxStdIf_DPipe_print(io, ENDL " ");
}
}
IfxStdIf_DPipe_print(io, " }"ENDL);
IfxStdIf_DPipe_print(io, "};"ENDL);
}
boolean Ifx_Crc_Test(Ifc_Crc *driver, uint8 *string, uint32 length, IfxStdIf_DPipe *io)
{
IfxStdIf_DPipe_print(io, ""ENDL);
IfxStdIf_DPipe_print(io, "CRC tester v1.1 written on 13/01/2003 by Sven Reifegerste (zorc/reflex)"ENDL);
IfxStdIf_DPipe_print(io, "-----------------------------------------------------------------------"ENDL);
IfxStdIf_DPipe_print(io, ""ENDL);
IfxStdIf_DPipe_print(io, "Parameters:"ENDL);
IfxStdIf_DPipe_print(io, ""ENDL);
IfxStdIf_DPipe_print(io, " polynom : 0x%x"ENDL, driver->table->polynom);
IfxStdIf_DPipe_print(io, " order : %d"ENDL, driver->table->order);
IfxStdIf_DPipe_print(io, " crcinit : 0x%x direct, 0x%x nondirect"ENDL, driver->crcinit_direct, driver->crcinit_nondirect);
IfxStdIf_DPipe_print(io, " crcxor : 0x%x"ENDL, driver->crcxor);
IfxStdIf_DPipe_print(io, " refin : %d"ENDL, driver->table->refin);
IfxStdIf_DPipe_print(io, " refout : %d"ENDL, driver->refout);
IfxStdIf_DPipe_print(io, ""ENDL);
// IfxStdIf_DPipe_print(io," data string : '%s' (%d bytes)"ENDL, string, stringLength);
IfxStdIf_DPipe_print(io, ""ENDL);
IfxStdIf_DPipe_print(io, "Results:"ENDL);
IfxStdIf_DPipe_print(io, ""ENDL);
#if 0
IfxCpu_Perf perf;
uint32 result;
IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_normal);
result = Ifx_Crc_bitByBit(driver, (uint8 *)string, length);
perf = IfxCpu_stopCounters();
IfxStdIf_DPipe_print(io, " crc bit by bit : 0x%X, %d cycles"ENDL, result, perf.clock.counter);
IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_normal);
result = Ifx_Crc_bitByBitFast(driver, (uint8 *)string, length);
perf = IfxCpu_stopCounters();
IfxStdIf_DPipe_print(io, " crc bit by bit fast : 0x%X, %d cycles"ENDL, result, perf.clock.counter);
IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_normal);
result = Ifx_Crc_table(driver, (uint8 *)string, length);
perf = IfxCpu_stopCounters();
IfxStdIf_DPipe_print(io, " crc table : 0x%X, %d cycles"ENDL, result, perf.clock.counter);
IfxCpu_resetAndStartCounters(IfxCpu_CounterMode_normal);
result = Ifx_Crc_tableFast(driver, (uint8 *)string, length);
perf = IfxCpu_stopCounters();
IfxStdIf_DPipe_print(io, " crc table fast : 0x%X, %d cycles"ENDL, result, perf.clock.counter);
#endif
return TRUE;
}
#endif
@@ -0,0 +1,130 @@
/**
* \file Ifx_Crc.h
* \brief CRC algorithm
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_crc CRC
* This module implements CRC algorithm
* \ingroup library_srvsw_sysse_math
*
*/
#ifndef IFX_CRC_H
#define IFX_CRC_H 1
//---------------------------------------------------------------------------
#include "Cpu/Std/Ifx_Types.h"
#ifndef CRC_ENABLE_DPIPE
#define CRC_ENABLE_DPIPE 0
#endif
#if CRC_ENABLE_DPIPE
#include "IfxStdIf_DPipe.h"
#endif
//---------------------------------------------------------------------------
typedef struct
{
sint32 order;
uint32 polynom;
sint32 refin;
uint32 crchighbit;
uint32 crcmask;
}Ifc_Crc_Table;
typedef struct
{
Ifc_Crc_Table data; /**< \brief CRC data, must be 1st member of the struct */
uint8 crctab[256]; /**< \brief CRC Table, must be 2st member of the struct */
}Ifc_Crc_Table8;
typedef struct
{
Ifc_Crc_Table data; /**< \brief CRC data, must be 1st member of the struct */
uint16 crctab[256]; /**< \brief CRC Table, must be 2st member of the struct */
}Ifc_Crc_Table16;
typedef struct
{
Ifc_Crc_Table data; /**< \brief CRC data, must be 1st member of the struct */
uint32 crctab[256]; /**< \brief CRC Table, must be 2st member of the struct */
}Ifc_Crc_Table32;
typedef struct
{
uint32 crcxor;
sint32 refout;
uint32 crcinit_direct;
uint32 crcinit_nondirect;
const Ifc_Crc_Table *table;
}Ifc_Crc;
/** \addtogroup library_srvsw_sysse_math_crc
* \{ */
/**
* \param direct [0,1] specifies the kind of algorithm: 1=direct, no augmented zero bits
* \param driver pointer to the crc driver
* \param table pointer to crc table
* \param direct direct
* \param crcinit is the initial CRC value belonging to that algorithm
* \param crcxor is the final XOR value
* \param refout [0,1] specifies if the CRC will be reflected before XOR
* \param table pointer to the table: Ifc_Crc_Table8, Ifc_Crc_Table16, Ifc_Crc_Table32
*/
boolean Ifx_Crc_init(Ifc_Crc *driver, const Ifc_Crc_Table *table, sint32 direct, sint32 refout, uint32 crcinit, uint32 crcxor);
/**
* \param table pointer to the crc table
* \param order [1..32] is the CRC polynom order, counted without the leading '1' bit
* \param polynom is the CRC polynom without leading '1' bit
* \param refin [0,1] specifies if a data byte is reflected before processing (UART) or not
*/
boolean Ifx_Crc_createTable(Ifc_Crc_Table *table, sint32 order, uint32 polynom, sint32 refin);
#if CRC_ENABLE_DPIPE
boolean Ifx_Crc_Test(Ifc_Crc *driver, uint8 *string, uint32 length, IfxStdIf_DPipe *io);
void Ifx_Crc_printTable(Ifc_Crc_Table *table, IfxStdIf_DPipe *io);
#endif
uint32 Ifx_Crc_tableFast(Ifc_Crc *driver, uint8 *p, uint32 len);
uint32 Ifx_Crc_table(Ifc_Crc *driver, uint8 *p, uint32 len);
uint32 Ifx_Crc_bitByBit(Ifc_Crc *driver, uint8 *p, uint32 len);
uint32 Ifx_Crc_bitByBitFast(Ifc_Crc *driver, uint8 *p, uint32 len);
/** \} */
//---------------------------------------------------------------------------
#endif // IFX_CRC_H
@@ -0,0 +1,185 @@
/**
* \file Ifx_FftF32.c
* \brief Floating-point Fast Fourier Transform
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_FftF32.h"
#include <math.h>
//#include "Compiler.h"
cfloat32 *Ifx_FftF32_generateTwiddleFactor(cfloat32 *TF, short nX)
{
int i;
double Theta;
// prepare twiddle coefficients
for (i = 0; i < nX / 2; i++)
{
Theta = 2 * IFX_PI * i / nX;
TF[i].real = (float32)(cosf(Theta));
TF[i].imag = (float32)(-sinf(Theta));
}
return TF;
}
/******************************************************************************/
unsigned short Ifx_FftF32_reverseBits(unsigned short n, unsigned bits)
{
/* This code is from:
* http://graphics.stanford.edu/~seander/bithacks.html
* */
unsigned long v = n; // 32-bit word to reverse bit order
// swap odd and even bits
v = ((v >> 1) & 0x55555555UL) | ((v & 0x55555555UL) << 1);
// swap consecutive pairs
v = ((v >> 2) & 0x33333333UL) | ((v & 0x33333333UL) << 2);
// swap nibbles ...
v = ((v >> 4) & 0x0F0F0F0FUL) | ((v & 0x0F0F0F0FUL) << 4);
// swap bytes
v = ((v >> 8) & 0x00FF00FFUL) | ((v & 0x00FF00FFUL) << 8);
// swap 2-byte long pairs
v = (v >> 16) | (v << 16);
v = v >> (32 - bits);
return (unsigned short)v;
}
/******************************************************************************/
void Ifx_FftF32_radix2DecimationInTime(cfloat32 *R, unsigned long p)
{
/* http://www.engineeringproductivitytools.com/stuff/T0001/PT04.HTM#Head317
* */
/*Perform in place Ifx_FftF32_radix2DecimationInTime of 2^p points (=size of f)
* N.B. The input array f is in bit reversed order! So all the
* 'even' input samples are in the 'top' half, all the 'odd'
* input samples are in the 'bottom' halR..etc (recursively).
*/
/*Ifx_FftF32_radix2DecimationInTime*/
unsigned long Bp, Np, Npx, P, b, k, BaseT, BaseB;
cfloat32 top, bot;
/*initialise pass parameters*/
Bp = 1 << (p - 1); /*No. of blocks*/
Np = 2; /*No. of points in each block*/
/*perform p passes*/
for (P = 0; P < p; P++)
{
/*pass loop*/
Npx = Np >> 1; /*No. of butterflies*/
BaseT = 0; /*Reset even base index*/
for (b = 0; b < Bp; b++)
{
/*block loop*/
BaseB = BaseT + Npx; /*calc odd base index*/
for (k = 0; k < Npx; k++)
{
//printf("P = %d; b = %d; Np = %d; k = %d\n", P, b, Np, k);
/*butterfly loop*/
top = Ifx_FftF32_lookUpTwiddleFactor(Np, k);
bot = IFX_Cf32_mul(&R[BaseB + k], &top); /*twiddle the odd n results*/
top = R[BaseT + k];
R[BaseT + k] = IFX_Cf32_add(&top, &bot); /*top subset*/
R[BaseB + k] = IFX_Cf32_sub(&top, &bot); /*bottom subset*/
} /*butterfly loop*/
BaseT = BaseT + Np; /*start of next block*/
} /*block loop*/
/*calc parameters for next pass*/
Bp = Bp >> 1; /*half as many blocks*/
Np = Np << 1; /*twice as many points in each block*/
} /*pass loop*/
} /*Ifx_FftF32_radix2DecimationInTime*/
cfloat32 *Ifx_FftF32_radix2(cfloat32 *R, const cfloat32 *X, unsigned short nX)
{
unsigned int logN = 31 - __clz(nX);
unsigned short n, k;
/* Arrange in bit-reversed index */
for (n = 0; n < nX; n++)
{
//k = Ifx_FftF32_reverseBits(n, logN);
k = Ifx_FftF32_lookUpReversedBits(n, logN);
R[k] = X[n];
}
Ifx_FftF32_radix2DecimationInTime(R, logN);
return R;
}
cfloat32 *Ifx_FftF32_radix2I(cfloat32 *R, const cfloat32 *X, unsigned short nX)
{
unsigned int logN = 31 - __clz(nX);
unsigned short n, k = 0;
/* Arrange in bit-reversed index, and conjugate the input */
for (n = 0; n < nX; n++)
{
//k = Ifx_FftF32_reverseBits(n, logN);
k = Ifx_FftF32_lookUpReversedBits(n, logN);
R[k].real = X[n].real;
R[k].imag = -X[n].imag;
}
Ifx_FftF32_radix2DecimationInTime(R, logN);
/* Conjugate the output */
for (n = 0; n < nX; n++)
{
R[n].imag = -R[n].imag;
}
return R;
}
@@ -0,0 +1,115 @@
/**
* \file Ifx_FftF32.h
* \brief Floating-point Fast Fourier Transform
* \ingroup library_srvsw_sysse_math_f32_fft
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_fft Floating-point FFT
* This module implements the Fast Fourier Transform in single precision floating-point
* \ingroup library_srvsw_sysse_math_f32
*
*/
#ifndef IFX_FFTF32_H
#define IFX_FFTF32_H
#include "Ifx_Cf32.h"
/** \brief Maximum FFT resolution (bits).
* If redefined, then \ref Ifx_g_FftF32_bitReverseTable and \ref Ifx_g_FftF32_twiddleTable shall be regenerated. */
#define IFX_FFTF32_MAX_RESOLUTION (14)
/** \brief Maximum FFT length.
* If redefined, then \ref Ifx_g_FftF32_bitReverseTable and \ref Ifx_g_FftF32_twiddleTable shall be regenerated. */
#define IFX_FFTF32_MAX_LENGTH (1U << IFX_FFTF32_MAX_RESOLUTION)
/** \brief Bit reversal table */
IFX_EXTERN IFX_CONST uint16 Ifx_g_FftF32_bitReverseTable[IFX_FFTF32_MAX_LENGTH];
/** \brief Twiddle factor table */
IFX_EXTERN IFX_CONST cfloat32 Ifx_g_FftF32_twiddleTable[IFX_FFTF32_MAX_LENGTH / 2];
//----------------------------------------------------------------------------------------
/** \addtogroup library_srvsw_sysse_math_f32_fft
* \{ */
/** \name Transform functions
* \{ */
/** \brief Twiddle factor generator */
IFX_EXTERN cfloat32 *Ifx_FftF32_generateTwiddleFactor(cfloat32 *TF, sint16 nX);
/** \brief Radix-2 Fast-Fourier Transform */
IFX_EXTERN cfloat32 *Ifx_FftF32_radix2(cfloat32 *R, const cfloat32 *X, uint16 nX);
/** \brief Radix-2 Inverse Fast-Fourier Transform */
IFX_EXTERN cfloat32 *Ifx_FftF32_radix2I(cfloat32 *R, const cfloat32 *X, uint16 nX);
/** \} */
//----------------------------------------------------------------------------------------
/** \name Utility functions
* \{ */
/** \brief Lookup from \ref Ifx_g_FftF32_bitReverseTable the bit-reversed \<n\> with \<bits\> as number of bits */
IFX_INLINE uint16 Ifx_FftF32_lookUpReversedBits(uint16 n, unsigned bits)
{
unsigned shift = IFX_FFTF32_MAX_RESOLUTION - bits;
uint16 index = Ifx_g_FftF32_bitReverseTable[n];
return index >> shift;
}
/** \brief Lookup from \ref Ifx_g_FftF32_twiddleTable the twiddle factor for N, k */
IFX_INLINE cfloat32 Ifx_FftF32_lookUpTwiddleFactor(sint32 N, sint32 k)
{
return Ifx_g_FftF32_twiddleTable[k * IFX_FFTF32_MAX_LENGTH / N];
}
/** \brief Calculate the bit-reversed \<n\> with \<bits\> as number of bits */
IFX_EXTERN uint16 Ifx_FftF32_reverseBits(uint16 n, unsigned bits);
/** \} */
//----------------------------------------------------------------------------------------
/** \} */
#endif /* IFX_FFTF32_H */
@@ -0,0 +1,92 @@
/**
* \file Ifx_IntegralF32.c
* \brief Discrete integral approximation
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_IntegralF32.h"
void Ifx_IntegralF32_reset(Ifx_IntegralF32 *ci)
{
ci->uk = 0;
ci->ik = 0;
}
void Ifx_IntegralF32_init(Ifx_IntegralF32 *ci, float32 gain, float32 Ts)
{
ci->delta = gain * Ts / 2;
}
float32 Ifx_IntegralF32_step(Ifx_IntegralF32 *ci, float32 ik)
{
ci->uk = ci->uk + (ik + ci->ik) * ci->delta;
ci->ik = ik;
return ci->uk;
}
void Ifx_ClpxFloat32_Integral_reset(Ifx_ClpxFloat32_Integral *ci)
{
ci->uk.real = 0;
ci->uk.imag = 0;
ci->ik.real = 0;
ci->ik.imag = 0;
}
void Ifx_ClpxFloat32_Integral_init(Ifx_ClpxFloat32_Integral *ci, float32 gain, float32 Ts)
{
Ifx_ClpxFloat32_Integral_reset(ci);
ci->delta = gain * Ts / 2;
}
cfloat32 Ifx_ClpxFloat32_Integral_step(Ifx_ClpxFloat32_Integral *ci, cfloat32 ik)
{
ci->uk.real = ci->uk.real + (ik.real + ci->ik.real) * ci->delta;
ci->uk.imag = ci->uk.imag + (ik.imag + ci->ik.imag) * ci->delta;
ci->ik = ik;
return ci->uk;
}
@@ -0,0 +1,109 @@
/**
* \file Ifx_IntegralF32.h
* \brief Discrete integral approximation
* \ingroup library_srvsw_sysse_math_f32_integral
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_integral Discrete Integral Approximation
* \ingroup library_srvsw_sysse_math_f32
*
*/
#ifndef INTEGRAL_H
#define INTEGRAL_H
#include "Ifx_Cf32.h"
/** \brief Integrator object for float32 data type */
typedef struct
{
float32 uk;
float32 ik;
float32 delta;
} Ifx_IntegralF32;
/** \brief Integrator object for cfloat32 data type */
typedef struct
{
cfloat32 uk;
cfloat32 ik;
float32 delta;
} Ifx_ClpxFloat32_Integral;
/** \addtogroup library_srvsw_sysse_math_f32_integral
* \{ */
/** \brief Initialize the integrator object
* \param ci Pointer to the integrator object
* \param gain Integrator gain
* \param Ts Sampling period */
void Ifx_IntegralF32_init(Ifx_IntegralF32 *ci, float32 gain, float32 Ts);
/** \brief Step function of the integrator object
* \param ci Pointer to the integrator object
* \param ik input value
* \return most actual integrator value */
float32 Ifx_IntegralF32_step(Ifx_IntegralF32 *ci, float32 ik);
/** \brief Reset the integrator object
* \param ci Pointer to the integrator object */
void Ifx_IntegralF32_reset(Ifx_IntegralF32 *ci);
/** \brief Initialize the integrator object
* \param ci Pointer to the integrator object
* \param gain Integrator gain
* \param Ts Sampling period */
void Ifx_ClpxFloat32_Integral_init(Ifx_ClpxFloat32_Integral *ci, float32 gain, float32 Ts);
/** \brief Step function of the integrator object
* \param ci Pointer to the integrator object
* \param ik input value
* \return most actual integrator value */
cfloat32 Ifx_ClpxFloat32_Integral_step(Ifx_ClpxFloat32_Integral *ci, cfloat32 ik);
/** \brief Reset the integrator object
* \param ci Pointer to the integrator object */
void Ifx_ClpxFloat32_Integral_reset(Ifx_ClpxFloat32_Integral *ci);
/**\}*/
#endif /* INTEGRAL_H */
@@ -0,0 +1,80 @@
/**
* \file Ifx_LowPassPt1F32.c
* \brief Low pass filter PT1
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "SysSe/Math/Ifx_LowPassPt1F32.h"
//------------------------------------------------------------------------------
/** \brief Set the low pass filter configuration
*
* This function sets the low pass filter configuration and reset the filter output.
*
* \param filter Specifies PT1 filter.
* \param config Specifies the PT1 filter configuration.
*
* \return None
*/
void Ifx_LowPassPt1F32_init(Ifx_LowPassPt1F32 *filter, const Ifx_LowPassPt1F32_Config *config)
{
float32 tStar;
float32 T = 1 / config->cutOffFrequency;
tStar = 1 / (T / config->samplingTime + 1);
filter->a = config->gain * tStar;
filter->b = tStar;
filter->out = 0;
}
/** \brief Execute the low pass filter
* \param filter Specifies PT1 filter.
* \param input Specifies the filter input.
*
* \return Returns the filter output
*/
float32 Ifx_LowPassPt1F32_do(Ifx_LowPassPt1F32 *filter, float32 input)
{
filter->out = filter->out + filter->a * input - filter->b * filter->out;
return filter->out;
}
@@ -0,0 +1,100 @@
/**
* \file Ifx_LowPassPt1F32.h
* \brief Low pass filter PT1
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_lowpasspt1 Low-pass Filter: Type PT1
* This module implements a PT1 low pass filter.
* http://de.wikipedia.org/wiki/PT1-Glied
*
* Formula: \n
* \f$ y_k = y_{k-1} + a * x_k - b * y_{k-1} \f$ \n
* with \f$(T^* = \frac{T_s}{T+T_s})\f$, \f$(a = K*T^*)\f$, \f$(b = T^*)\f$
* with \f$(T_s: Sample time)\f$, \f$(K: Gain)\f$, \f$(T = \frac{1}{\omega_0})\f$
*
* \ingroup library_srvsw_sysse_math_f32
*
*/
#if !defined(IFX_LOWPASSPT1F32)
#define IFX_LOWPASSPT1F32
//------------------------------------------------------------------------------
#include "Cpu/Std/Ifx_Types.h"
//------------------------------------------------------------------------------
/** \brief PT1 object definition.
*/
typedef struct
{
float32 a; /**< \brief a parameter */
float32 b; /**< \brief b parameter */
float32 out; /**< \brief last output */
} Ifx_LowPassPt1F32;
/** \brief PT1 configuration */
typedef struct
{
float32 cutOffFrequency; /**< \brief Cut off frequency */
float32 gain; /**< \brief Gain */
float32 samplingTime; /**< \brief Sampling time */
} Ifx_LowPassPt1F32_Config;
//------------------------------------------------------------------------------
/** \addtogroup library_srvsw_sysse_math_f32_lowpasspt1
* \{ */
IFX_EXTERN void Ifx_LowPassPt1F32_init(Ifx_LowPassPt1F32 *filter, const Ifx_LowPassPt1F32_Config *config);
IFX_INLINE void Ifx_LowPassPt1F32_reset(Ifx_LowPassPt1F32 *filter);
IFX_EXTERN float32 Ifx_LowPassPt1F32_do(Ifx_LowPassPt1F32 *filter, float32 input);
/** \} */
//------------------------------------------------------------------------------
/** \brief Reset the internal filter variable
* \param filter Specifies PT1 filter.
*/
IFX_INLINE void Ifx_LowPassPt1F32_reset(Ifx_LowPassPt1F32 *filter)
{
filter->out = 0.0;
}
//------------------------------------------------------------------------------
#endif
@@ -0,0 +1,97 @@
/**
* \file Ifx_Lut.h
* \brief Lookup defintion with fixed-point angle data type
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_lut Look-ups
* \ingroup library_srvsw_sysse_math
*
* \defgroup library_srvsw_sysse_math_f32_lut Look-ups float32
* \ingroup library_srvsw_sysse_math_lut
*
*/
#ifndef IFX_LUT_H
#define IFX_LUT_H
//________________________________________________________________________________________
#include "Cpu/Std/IfxCpu_Intrinsics.h"
//________________________________________________________________________________________
#ifndef IFX_LUT_TABLE_CONST
/** \brief 0 = Lookup tables are generated and stored in RAM,
* 1 = Lookup tables are precompiled and stored in FLASH */
#define IFX_LUT_TABLE_CONST (1)
#endif
#if (IFX_LUT_TABLE_CONST != 0)
/** \brief Lookup table type modifier (stored in ROM) */
# define IFX_LUT_TABLE const
#else
/** \brief Lookup table type modifier (stored in RAM) */
# define IFX_LUT_TABLE
#endif
/** \brief Define the resolution (in bits) of cosinus and sinus table \ingroup library_srvsw_sysse_math_lut */
#define IFX_LUT_ANGLE_BITS (12)
/** \brief Define the cosinus and sinus table size \ingroup library_srvsw_sysse_math_lut */
#define IFX_LUT_ANGLE_RESOLUTION (1 << IFX_LUT_ANGLE_BITS)
/** \brief Value used as 180 degree angle */
#define IFX_LUT_ANGLE_PI (IFX_LUT_ANGLE_RESOLUTION / 2)
//________________________________________________________________________________________
/** \brief Fixed-point angle type.
*
* Resolution is defined by \ref IFX_LUT_ANGLE_RESOLUTION */
typedef sint32 Ifx_Lut_FxpAngle;
/** \brief Convert from float32 angle in radian into fixed-point angle type */
#define IFX_LUT_F32_TO_FXPANGLE(f) ((Ifx_Lut_FxpAngle)(f / IFX_PI * IFX_LUT_ANGLE_PI))
/** \brief Convert from fixed-point angle type to float32 angle in radian */
#define IFX_LUT_FXPANGLE_TO_F32(fx) ((float32)fx * IFX_PI / IFX_LUT_ANGLE_PI)
//________________________________________________________________________________________
#if (1U << IFX_LUT_ANGLE_BITS) != IFX_LUT_ANGLE_RESOLUTION
#error (1U << IFX_LUT_ANGLE_BITS) != IFX_LUT_ANGLE_RESOLUTION
#endif
//________________________________________________________________________________________
#endif /* IFX_LUT_H */
@@ -0,0 +1,204 @@
/**
* \file Ifx_LutAtan2F32.c
* \brief ATAN2 lookup functions with fixed-point angle data type
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_LutAtan2F32.h"
#include <math.h>
void Ifx_LutAtan2F32_init(void)
{
#if IFX_LUT_TABLE_CONST == 0
{ /* generate arctan table */
sint32 k;
float32 Step, value;
Step = (double)IFX_LUT_ATAN_LIMIT_LOW / IFX_LUT_ATAN_SIZE_LOW;
for (k = 0; k < IFX_LUTATAN2F32_SIZE; k++)
{
Ifx_g_LutAtan2F32_FxpAngle_table[k] = IFX_LUT_F32_TO_FXPANGLE(atanf(k / Step));
}
}
#endif
}
IFX_INLINE Ifx_Lut_FxpAngle Ifx_LutAtan2F32_fxpAnglePrivate(float32 valf)
{
uint32 vali;
valf = IFX_LUTATAN2F32_SIZE * valf;
vali = (uint32)valf;
if ((valf - (float32)vali) > 0.5)
{ /* Round to nearest */
vali++;
}
return Ifx_g_LutAtan2F32_FxpAngle_table[vali];
}
IFX_INLINE float32 Ifx_LutAtan2F32_float32Private(float32 val)
{ /* FIXME round to nearest ?? */
return Ifx_g_LutAtan2F32_table[(int)(val * IFX_LUTATAN2F32_SIZE)];
}
Ifx_Lut_FxpAngle Ifx_LutAtan2F32_fxpAngle(float32 x, float32 y)
{
Ifx_Lut_FxpAngle angle;
float32 fx = (float32)x;
float32 fy = (float32)y;
if (y < 0)
{
if (x < 0)
{
if (-y < -x)
{ // 180 .. 225 deg
angle = -IFX_LUT_ANGLE_PI + Ifx_LutAtan2F32_fxpAnglePrivate(-fy / -fx);
}
else
{ // 225 .. 270 deg
angle = -(IFX_LUT_ANGLE_PI / 2) - Ifx_LutAtan2F32_fxpAnglePrivate(-fx / -fy);
}
}
else // x >= 0
{
if (-y < x)
{ // 315 .. 360 deg
angle = -Ifx_LutAtan2F32_fxpAnglePrivate(-fy / fx); // ok
}
else
{ // 225 .. 270 deg
angle = -(IFX_LUT_ANGLE_PI / 2) + Ifx_LutAtan2F32_fxpAnglePrivate(fx / -fy);
}
}
}
else // y >= 0
{
if (x < 0)
{
if (y < -x)
{ // 135 .. 180 deg
angle = IFX_LUT_ANGLE_PI - Ifx_LutAtan2F32_fxpAnglePrivate(fy / -fx); // ok
}
else
{ // 90 .. 135 deg
angle = (IFX_LUT_ANGLE_PI / 2) + Ifx_LutAtan2F32_fxpAnglePrivate(-fx / fy); // ok
}
}
else // x >= 0
{
if (y < x)
{ // 0 .. 45 deg
angle = Ifx_LutAtan2F32_fxpAnglePrivate(fy / fx); // ok
}
else
{ // 45 .. 90 deg
angle = (IFX_LUT_ANGLE_PI / 2) - Ifx_LutAtan2F32_fxpAnglePrivate(fx / fy); // ok
}
}
}
return angle & (IFX_LUT_ANGLE_RESOLUTION - 1);
}
float32 Ifx_LutAtan2F32_float32(float32 y, float32 x)
{
float32 angle;
if (y < 0)
{
if (x < 0)
{
if (-y < -x)
{ // 180 .. 225 deg
angle = -IFX_PI + Ifx_LutAtan2F32_float32Private(-y / -x);
}
else
{ // 225 .. 270 deg
angle = -(IFX_PI / 2) - Ifx_LutAtan2F32_float32Private(-x / -y);
}
}
else // x >= 0
{
if (-y < x)
{ // 315 .. 360 deg
angle = -Ifx_LutAtan2F32_float32Private(-y / x); // ok
}
else
{ // 225 .. 270 deg
angle = -(IFX_PI / 2) + Ifx_LutAtan2F32_float32Private(x / -y);
}
}
}
else // y >= 0
{
if (x < 0)
{
if (y < -x)
{ // 135 .. 180 deg
angle = IFX_PI - Ifx_LutAtan2F32_float32Private(y / -x); // ok
}
else
{ // 90 .. 135 deg
angle = (IFX_PI / 2) + Ifx_LutAtan2F32_float32Private(-x / y); // ok
}
}
else // x >= 0
{
if (y < x)
{ // 0 .. 45 deg
angle = Ifx_LutAtan2F32_float32Private(y / x); // ok
}
else
{ // 45 .. 90 deg
angle = (IFX_PI / 2) - Ifx_LutAtan2F32_float32Private(x / y); // ok
}
}
}
return angle;
}
@@ -0,0 +1,76 @@
/**
* \file Ifx_LutAtan2F32.h
* \brief Floating point signal, vector, and matrix library
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_lut_atan2 ATAN lookup table
* \ingroup library_srvsw_sysse_math_f32_lut
*/
#ifndef IFX_LUTATAN2F32_H
#define IFX_LUTATAN2F32_H
//----------------------------------------------------------------------------------------
#include "Ifx_Lut.h"
//----------------------------------------------------------------------------------------
#define IFX_LUTATAN2F32_SIZE (1024) /**< \brief size of Ifx_LutAtan2F32 table */
//----------------------------------------------------------------------------------------
/** \brief Table I for Ifx_LutAtan2F32_fxpAngle() */
IFX_EXTERN IFX_LUT_TABLE Ifx_Lut_FxpAngle Ifx_g_LutAtan2F32_FxpAngle_table[IFX_LUTATAN2F32_SIZE + 1];
IFX_EXTERN IFX_LUT_TABLE float32 Ifx_g_LutAtan2F32_table[IFX_LUTATAN2F32_SIZE + 1];
/** \brief Initialise the lookup tables
* \ingroup library_srvsw_sysse_math_lut_atan2
*/
IFX_EXTERN void Ifx_LutAtan2F32_init(void);
/**
* \brief Look-up arcus tangent value of y/x.
* \return fxpAngle 0 .. (IFX_LUT_ANGLE_RESOLUTION - 1), which represents 0 .. 2*IFX_PI
* \ingroup library_srvsw_sysse_math_lut_atan2
*/
IFX_EXTERN Ifx_Lut_FxpAngle Ifx_LutAtan2F32_fxpAngle(float32 x, float32 y);
IFX_EXTERN float32 Ifx_LutAtan2F32_float32(float32 y, float32 x);
#endif
File diff suppressed because it is too large. Load diff
@@ -0,0 +1,96 @@
/**
* \file Ifx_LutIndexedLinearF32.h
* \brief Look-up functionality
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_lut_indexedLinear Indexes look-up table (with linear interpolation)
* \ingroup library_srvsw_sysse_math_f32_lut
*
*/
#ifndef IFX_LUTINDEXEDLINEARF32_H
#define IFX_LUTINDEXEDLINEARF32_H
//________________________________________________________________________________________
// INCLUDES
#include "Cpu/Std/Ifx_Types.h"
typedef struct
{
float32 gain; /**< \brief channel gain */
float32 offset; /**< \brief channel offset */
} Ifx_LutIndexedLinearF32_Item;
typedef struct
{
uint16 segmentCount;
sint8 shift;
const Ifx_LutIndexedLinearF32_Item *segments;
} Ifx_LutIndexedLinearF32;
//________________________________________________________________________________________
// FUNCTION PROTOTYPES
/** \addtogroup library_srvsw_sysse_math_f32_lut_indexedLinear
* \{ */
IFX_INLINE float32 Ifx_LutIndexedLinearF32_search(const Ifx_LutIndexedLinearF32 *ml, uint32 index);
/** \} */
//________________________________________________________________________________________
// INLINE FUNCTION IMPLEMENTATION
/** \brief Look-up table search
*
*
* \param ml pointer to the multi-segment object
* \param index
* \return interpolated value */
IFX_INLINE float32 Ifx_LutIndexedLinearF32_search(const Ifx_LutIndexedLinearF32 *ml, uint32 index)
{
uint32 i;
i = index >> ml->shift;
return (ml->segments[i].gain * index) + ml->segments[i].offset;
}
#endif /* IFX_LUTINDEXEDLINEARF32_H */
@@ -0,0 +1,201 @@
/**
* \file Ifx_LutLSincosF32.c
* \brief Table data for linear interpolation Sin/Cos lookup functions
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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.
*
* $Revision: 614 $
* $Date: 2013-03-04 14:09:48 +0100 (Mon, 04 Mar 2013) $
*
*/
#include "Ifx_Lut.h"
#include "Ifx_LutIndexedLinearF32.h"
#if IFX_LUT_TABLE_CONST == 0
/* FIXME Table size not consistent */
IFX_LUT_TABLE float32 Ifx_g_LutLSincosF32_table[IFX_LUT_ANGLE_RESOLUTION + (IFX_LUT_ANGLE_RESOLUTION / 4)];
IFX_LUT_TABLE Ifx_LutIndexedLinearF32 Ifx_g_LutLSincosF32;
#else
#if (IFX_LUT_ANGLE_RESOLUTION != 4096)
#error "Inconsistent between Lookup Table and configuration. Please regenerate."
#endif
/*lint -e915*/
#define IFX_F32_LUTL_SINCOS_ELEMENT_COUNT (128)
const Ifx_LutIndexedLinearF32_Item Ifx_g_LutLSincosF32_table[128] = {
{0.00153336482273181, 0 },
{0.00152967081256696, 0.000118208325275426},
{0.00152229169143129, 0.000590472077958315},
{0.00151124523627395, 0.00165093177306225 },
{0.00149655805897299, 0.00353089046758576 },
{0.00147826554222495, 0.00645769314727157 },
{0.00145641175430493, 0.010653620427916 },
{0.00143104934290218, 0.0163348005821319 },
{0.00140223940828726, 0.0237101438435514 },
{0.00137005135611611, 0.0329803028688421 },
{0.00133456273022575, 0.0443366631537574 },
{0.00129585902582439, 0.057960367103036 },
{0.00125403348352597, 0.074021375345628 },
{0.00120918686472538, 0.0926775687666757 },
{0.0011614272088554, 0.114073894596426 },
{0.00111086957311029, 0.138341559754081 },
{0.00105763575526286, 0.165597274491961 },
{0.00100185400024306, 0.195942549222735 },
{0.00094365869118462, 0.229463047240396 },
{0.000883190025684388, 0.266227995864537 },
{0.000820593678053965, 0.306289658348008 },
{0.000756020448377588, 0.349682868690533 },
{0.000689625899221512, 0.39642463129641 },
{0.000621569980870106, 0.446513787203045 },
{0.00055201664599169, 0.499930748389669 },
{0.000481133454662129, 0.556637301453318 },
{0.00040909117069797, 0.616576481711498 },
{0.000336063350271452, 0.67967251856001 },
{0.000262225923798456, 0.745830852679814 },
{0.000187756772106744, 0.814938225449723 },
{0.000112835297905487, 0.886862840682929 },
{3.76419935883623E-05, 0.961454598565517 },
{-3.76419935883623E-05, 1.03854540143448 },
{-0.000112835297905484, 1.11794953079336 },
{-0.000187756772106747, 1.19946409472434 },
{-0.000262225923798456, 1.28286954461905 },
{-0.000336063350271452, 1.36793025991594 },
{-0.00040909117069797, 1.45439519930094 },
{-0.000481133454662129, 1.54199861660136 },
{-0.00055201664599169, 1.63046083938065 },
{-0.000621569980870103, 1.71948910802502 },
{-0.000689625899221512, 1.80877847290207 },
{-0.000756020448377592, 1.89801274696784 },
{-0.000820593678053958, 1.98686551100252 },
{-0.000883190025684391, 2.07500116846617 },
{-0.00094365869118462, 2.1620760467865 },
{-0.00100185400024307, 2.24773954172053 },
{-0.00105763575526286, 2.3316353012703 },
{-0.00111086957311028, 2.41340244548394 },
{-0.00116142720885541, 2.4926768183323 },
{-0.00120918686472538, 2.56909226772425 },
{-0.00125403348352598, 2.64228194960683 },
{-0.00129585902582439, 2.71187965199138 },
{-0.00133456273022575, 2.77752113465609 },
{-0.00137005135611612, 2.83884548019465 },
{-0.00140223940828725, 2.89549645201585 },
{-0.00143104934290217, 2.94712385484579 },
{-0.00145641175430494, 2.99338489324442 },
{-0.00147826554222495, 3.03394552362397 },
{-0.00149655805897298, 3.06848179524426 },
{-0.00151124523627396, 3.09668117566214 },
{-0.00152229169143128, 3.11824385612922 },
{-0.00152967081256696, 3.13288403246242 },
{-0.00153336482273181, 3.14033115695474 },
{-0.00153336482273181, 3.14033115695474 },
{-0.00152967081256696, 3.13264761581187 },
{-0.00152229169143128, 3.11706291197331 },
{-0.00151124523627396, 3.09337931211601 },
{-0.00149655805897298, 3.06142001430908 },
{-0.00147826554222495, 3.02103013732942 },
{-0.00145641175430494, 2.9720776523886 },
{-0.00143104934290217, 2.91445425368152 },
{-0.00140223940828725, 2.84807616432874 },
{-0.00137005135611612, 2.77288487445697 },
{-0.00133456273022575, 2.68884780834857 },
{-0.00129585902582439, 2.59595891778531 },
{-0.00125403348352598, 2.49423919891558 },
{-0.00120918686472538, 2.38373713019089 },
{-0.00116142720885541, 2.26452902913946 },
{-0.00111086957311028, 2.13671932597577 },
{-0.00105763575526286, 2.00044075228637 },
{-0.00100185400024306, 1.85585444327504 },
{-0.000943658691184637, 1.70314995230575 },
{-0.000883190025684381, 1.54254517673707 },
{-0.000820593678053962, 1.3742861943065 },
{-0.000756020448377592, 1.19864700958678 },
{-0.000689625899221506, 1.01592921030923 },
{-0.000621569980870106, 0.826461533618933 },
{-0.000552016645991697, 0.630599342601331 },
{-0.000481133454662126, 0.428724013694713 },
{-0.000409091170697973, 0.221242235877955 },
{-0.000336063350271448, 0.00858522279591345 },
{-0.000262225923798456, -0.208792160740577 },
{-0.000187756772106751, -0.430412356175091 },
{-0.000112835297905484, -0.655776150572502 },
{-3.76419935883623E-05, -0.884363795696551 },
{3.76419935883623E-05, -1.11563620430345 },
{0.000112835297905484, -1.34903622090379 },
{0.000187756772106751, -1.58398996399897 },
{0.000262225923798452, -1.81990823655828 },
{0.000336063350271452, -2.05618800127188 },
{0.00040909117069797, -2.29221391689038 },
{0.000481133454662126, -2.52735993174939 },
{0.000552016645991697, -2.76099093037165 },
{0.000621569980870103, -2.99246442884699 },
{0.000689625899221509, -3.22113231450771 },
{0.000756020448377588, -3.44634262524513 },
{0.000820593678053962, -3.66744136365704 },
{0.000883190025684381, -3.88377434106776 },
{0.000943658691184637, -4.09468904633266 },
{0.00100185400024306, -4.29953653421829 },
{0.00105763575526286, -4.49767332804863 },
{0.00111086957311028, -4.6884633312138 },
{0.0011614272088554, -4.87127974206814 },
{0.0012091868647254, -5.04550696668189 },
{0.00125403348352597, -5.21054252386801 },
{0.00129585902582438, -5.36579893687972 },
{0.00133456273022575, -5.51070560615843 },
{0.00137005135611611, -5.64471065752041 },
{0.00140223940828725, -5.76728276018815 },
{0.0014310493429022, -5.87791290910954 },
{0.00145641175430492, -5.97611616606088 },
{0.00147826554222495, -6.06143335410066 },
{0.00149655805897298, -6.13343270002092 },
{0.00151124523627395, -6.19171141955115 },
{0.00152229169143131, -6.2358972401806 },
{0.00152967081256695, -6.2656498565995 },
{0.00153336482273181, -6.28066231390948 },
};
const Ifx_LutIndexedLinearF32 Ifx_g_LutLSincosF32 = {
.segmentCount = IFX_F32_LUTL_SINCOS_ELEMENT_COUNT,
.shift = 5,
.segments = Ifx_g_LutLSincosF32_table
};
#endif
@@ -0,0 +1,107 @@
/**
* \file Ifx_LutLSincosF32.h
* \brief Sin/Cos linear approximated lookup functions with fixed-point angle data type
* \ingroup library_srvsw_sysse_math_lut_lsincos
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_lut_lsincos Linear trigonometric Look-ups
* \ingroup library_srvsw_sysse_math_f32_lut
*
*/
#ifndef IFX_LUTLSINCOSF32_H
#define IFX_LUTLSINCOSF32_H
//________________________________________________________________________________________
#include "SysSe/Math/IFX_Cf32.h"
#include "Ifx_Lut.h"
#include "Ifx_LutIndexedLinearF32.h"
//________________________________________________________________________________________
/**
* \brief Look-up table for sin */
IFX_EXTERN const Ifx_LutIndexedLinearF32 Ifx_g_LutLSincosF32;
/**
* \brief Sine lookup function
* \param fxpAngle 0 .. (IFX_LUT_ANGLE_RESOLUTION - 1)
* \return sin(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \ingroup library_srvsw_sysse_math_lut_lsincos
*/
IFX_INLINE float32 Ifx_LutLSincosF32_sin(Ifx_Lut_FxpAngle fxpAngle)
{
fxpAngle = fxpAngle & (IFX_LUT_ANGLE_RESOLUTION - 1);
return Ifx_LutIndexedLinearF32_search(&Ifx_g_LutLSincosF32, fxpAngle);
}
/**
* \brief Cosine lookup function
* \param fxpAngle 0 .. (IFX_LUT_ANGLE_RESOLUTION - 1), which represents 0 .. 2*IFX_PI
* \return cos(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \ingroup library_srvsw_sysse_math_lut_lsincos
*/
IFX_INLINE float32 Ifx_LutLSincosF32_cos(Ifx_Lut_FxpAngle fxpAngle)
{
return Ifx_LutLSincosF32_sin((IFX_LUT_ANGLE_PI / 2) - fxpAngle);
}
/**
* \brief Sine and Cosine lookup function
* \param fxpAngle 0 .. (IFX_LUT_ANGLE_RESOLUTION - 1), which represents 0 .. 2*IFX_PI
* \retval real = cos(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \retval imag = sin(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \ingroup library_srvsw_sysse_math_lut_lsincos
*/
IFX_INLINE cfloat32 Ifx_LutLSincosF32_cossin(Ifx_Lut_FxpAngle fxpAngle)
{
cfloat32 result;
result.imag = Ifx_LutLSincosF32_sin(fxpAngle);
result.real = Ifx_LutLSincosF32_sin((IFX_LUT_ANGLE_PI / 2) - fxpAngle);
return result;
}
//________________________________________________________________________________________
#endif
@@ -0,0 +1,99 @@
/**
* \file Ifx_LutLinearF32.c
* \brief Linear look-up function
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_LutLinearF32.h"
/** \brief Look-up table with binary search implementation
*
* Value inside table will be linearly interpolated.
* Value outside table will be linearly extrapolated.
*
* \param ml pointer to the multi-segment object
* \param index
* \return linear interpolated value */
float32 Ifx_LutLinearF32_searchBin(const Ifx_LutLinearF32 *ml, float32 index)
{
sint16 imin;
sint16 imax;
sint16 imid;
imin = 0;
imax = ml->segmentCount - 1;
if (ml->segments[1].boundary > ml->segments[0].boundary)
{
while (imin < imax)
{
imid = imin + (imax - imin) / 2;
if (index > ml->segments[imid].boundary)
{
imin = imid + 1;
}
else
{
imax = imid;
}
}
}
else
{
while (imin < imax)
{
imid = imin + (imax - imin) / 2;
if (index < ml->segments[imid].boundary)
{
imin = imid + 1;
}
else
{
imax = imid;
}
}
}
return (ml->segments[imin].gain * index) + ml->segments[imin].offset;
}
@@ -0,0 +1,125 @@
/**
* \file Ifx_LutLinearF32.h
* \brief Look-up functionality
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_lut_linear Look-up table (with linear interpolation)
* \ingroup library_srvsw_sysse_math_f32_lut
*
*/
#ifndef IFX_LUTLINEARF32_H
#define IFX_LUTLINEARF32_H
//________________________________________________________________________________________
// INCLUDES
#include "Cpu/Std/Ifx_Types.h"
typedef struct
{
float32 gain; /**< \brief channel gain */
float32 offset; /**< \brief channel offset */
float32 boundary; /**< \brief segment input upper limit */
} Ifx_LutLinearF32_Item;
typedef struct
{
sint8 segmentCount;
const Ifx_LutLinearF32_Item *segments;
} Ifx_LutLinearF32;
//________________________________________________________________________________________
// FUNCTION PROTOTYPES
/** \addtogroup library_srvsw_sysse_math_f32_lut_linear
* \{ */
IFX_EXTERN float32 Ifx_LutLinearF32_searchBin(const Ifx_LutLinearF32 *ml, float32 index);
IFX_INLINE float32 Ifx_LutLinearF32_searchNegSeq(const Ifx_LutLinearF32 *ml, float32 index);
IFX_INLINE float32 Ifx_LutLinearF32_searchPosSeq(const Ifx_LutLinearF32 *ml, float32 index);
/** \} */
//________________________________________________________________________________________
// INLINE FUNCTION IMPLEMENTATION
/** \brief Look-up table with positive sequential search implementation
*
* Value inside table will be linearly interpolated
* Value outside table will be linearly extrapolated
*
* \param ml pointer to the multi-segment object
* \param index
* \return interpolated value */
IFX_INLINE float32 Ifx_LutLinearF32_searchPosSeq(const Ifx_LutLinearF32 *ml, float32 index)
{
sint8 i = 0;
while ((index > ml->segments[i].boundary) && (i < ml->segmentCount - 1))
{
i++;
}
return (ml->segments[i].gain * index) + ml->segments[i].offset;
}
/** \brief Look-up table with negative sequential search implementation
*
* Value inside table will be linearly interpolated
* Value outside table will be linearly extrapolated
*
* \param ml pointer to the multi-segment object
* \param index
* \return interpolated value */
IFX_INLINE float32 Ifx_LutLinearF32_searchNegSeq(const Ifx_LutLinearF32 *ml, float32 index)
{
sint8 i = ml->segmentCount - 1;
while ((i - 1 >= 0) && (index > ml->segments[i - 1].boundary))
{
i--;
}
return (ml->segments[i].gain * index) + ml->segments[i].offset;
}
#endif /* IFX_LUTLINEARF32_H */
@@ -0,0 +1,90 @@
/**
* \file Ifx_LutSincosF32.c
* \brief Sin/Cos lookup functions with fixed-point angle data type
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_LutSincosF32.h"
#include <math.h>
void Ifx_LutSincosF32_init(void)
{
#if IFX_LUT_TABLE_CONST == 0
{ /* generate sin and cos table */
sint32 k;
for (k = 0; k <= (IFX_LUT_ANGLE_PI / 2); k++)
{
Ifx_g_LutSincosF32_table[k] = sinf((IFX_PI * 2 * k) / IFX_LUT_ANGLE_RESOLUTION);
}
}
#endif
}
float32 Ifx_LutSincosF32_sin(Ifx_Lut_FxpAngle fxpAngle)
{
float32 result;
fxpAngle = fxpAngle & (IFX_LUT_ANGLE_RESOLUTION - 1);
if (fxpAngle < (IFX_LUT_ANGLE_PI / 2))
{
result = Ifx_g_LutSincosF32_table[fxpAngle];
}
else if (fxpAngle < IFX_LUT_ANGLE_PI)
{
fxpAngle = IFX_LUT_ANGLE_PI - fxpAngle;
result = Ifx_g_LutSincosF32_table[fxpAngle];
}
else if (fxpAngle < (IFX_LUT_ANGLE_PI / 2 * 3))
{
fxpAngle = fxpAngle - IFX_LUT_ANGLE_PI;
result = -Ifx_g_LutSincosF32_table[fxpAngle];
}
else
{
fxpAngle = IFX_LUT_ANGLE_RESOLUTION - fxpAngle;
result = -Ifx_g_LutSincosF32_table[fxpAngle];
}
return result;
}
@@ -0,0 +1,107 @@
/**
* \file Ifx_LutSincosF32.h
* \brief Sin/Cos lookup functions with fixed-point angle data type
* \ingroup library_srvsw_sysse_math_lut_sincos
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_lut_sincos Sinus and cosinus Look-ups
* \ingroup library_srvsw_sysse_math_f32_lut
*
*/
#ifndef IFX_LUTSINCOSF32_H
#define IFX_LUTSINCOSF32_H
//________________________________________________________________________________________
#include "SysSe/Math/Ifx_Cf32.h"
#include "Ifx_Lut.h"
//________________________________________________________________________________________
/**
* \brief Look-up table for sin(IFX_PI*2*k/IFX_LUT_ANGLE_RESOLUTION),
* where k = 0..IFX_LUT_ANGLE_RESOLUTION */
IFX_EXTERN IFX_LUT_TABLE float32 Ifx_g_LutSincosF32_table[(IFX_LUT_ANGLE_PI / 2) + 1];
/** \brief Initialise the lookup tables
* \note This is not required if (\ref IFX_LUT_TABLE_CONST == 1)
* \ingroup library_srvsw_sysse_math_lut_sincos
*/
IFX_EXTERN void Ifx_LutSincosF32_init(void);
/**
* \brief Sine lookup function
* \param fxpAngle 0 .. (IFX_LUT_ANGLE_RESOLUTION - 1)
* \return sin(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \ingroup library_srvsw_sysse_math_lut_sincos
*/
IFX_EXTERN float32 Ifx_LutSincosF32_sin(Ifx_Lut_FxpAngle fxpAngle);
/**
* \brief Cosine lookup function
* \param fxpAngle 0 .. (IFX_LUT_ANGLE_RESOLUTION - 1), which represents 0 .. 2*IFX_PI
* \return cos(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \ingroup library_srvsw_sysse_math_lut_sincos
*/
IFX_INLINE float32 Ifx_LutSincosF32_cos(Ifx_Lut_FxpAngle fxpAngle)
{
return Ifx_LutSincosF32_sin((IFX_LUT_ANGLE_PI / 2) - fxpAngle);
}
/**
* \brief Sine and Cosine lookup function
* \param fxpAngle 0 .. (IFX_LUT_ANGLE_RESOLUTION - 1), which represents 0 .. 2*IFX_PI
* \retval real = cos(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \retval imag = sin(2*IFX_PI*fxpAngle/IFX_LUT_ANGLE_RESOLUTION)
* \ingroup library_srvsw_sysse_math_lut_sincos
*/
IFX_INLINE cfloat32 Ifx_LutSincosF32_cossin(Ifx_Lut_FxpAngle fxpAngle)
{
cfloat32 result;
result.imag = Ifx_LutSincosF32_sin(fxpAngle);
result.real = Ifx_LutSincosF32_sin((IFX_LUT_ANGLE_PI / 2) - fxpAngle);
return result;
}
//________________________________________________________________________________________
#endif
@@ -0,0 +1,71 @@
/**
* \file Ifx_RampF32.c
* \brief Ramp function
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "SysSe/Math/Ifx_RampF32.h"
/**
* \brief Execute the Ramp function
*
* NOTE: shall be called every 'period'.
* The period was defined by Ifx_RampF32_init() or Ifx_RampF32_setSlewRate()
*
* \param ramp Pointer to the Ifx_RampF32 object
* \return Actual value
*/
float32 Ifx_RampF32_step(Ifx_RampF32 *ramp)
{
if (ramp->uk < ramp->ik)
{
ramp->uk = __minf(ramp->ik, ramp->uk + ramp->delta);
}
else if (ramp->uk > ramp->ik)
{
ramp->uk = __maxf(ramp->ik, ramp->uk - ramp->delta);
}
else
{}
return ramp->uk;
}
@@ -0,0 +1,150 @@
/**
* \file Ifx_RampF32.h
* \brief Ramp function
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_ramp Ramp
* \ingroup library_srvsw_sysse_math_f32
*
*/
#ifndef IFX_RAMPF32_H
#define IFX_RAMPF32_H
#include "Cpu/Std/IfxCpu_Intrinsics.h"
/**
* \brief Ifx_RampF32 object definition
*/
typedef struct
{
float32 uk;
float32 ik;
float32 delta;
} Ifx_RampF32;
//________________________________________________________________________________________
// FUNCTION PROTOTYPES
/** \addtogroup library_srvsw_sysse_math_f32_ramp
* \{ */
IFX_INLINE void Ifx_RampF32_init(Ifx_RampF32 *ramp, float32 slewRate, float32 period);
IFX_INLINE void Ifx_RampF32_reset(Ifx_RampF32 *ramp);
IFX_INLINE void Ifx_RampF32_setSlewRate(Ifx_RampF32 *ramp, float32 slewRate, float32 period);
IFX_INLINE void Ifx_RampF32_setRef(Ifx_RampF32 *ramp, float32 ref);
IFX_INLINE float32 Ifx_RampF32_getValue(Ifx_RampF32 *ramp);
IFX_EXTERN float32 Ifx_RampF32_step(Ifx_RampF32 *ramp);
/** \} */
//________________________________________________________________________________________
// INLINE FUNCTION IMPLEMENTATION
/**
* \brief Reset internal values
* \param ramp Pointer to the Ifx_RampF32 object
*/
IFX_INLINE void Ifx_RampF32_reset(Ifx_RampF32 *ramp)
{
ramp->ik = 0;
ramp->uk = 0;
}
/**
* \brief Get the reference value
* \param ramp Pointer to the Ifx_RampF32 object
* \return Returns the ref value
*/
IFX_INLINE float32 Ifx_RampF32_getRef(Ifx_RampF32 *ramp)
{
return ramp->ik;
}
/**
* \brief Set the maximum slew rate
* \param ramp Pointer to the Ifx_RampF32 object
* \param slewRate Maximum slew rate, value per second
* \param period Sampling period of the Ifx_RampF32_step() function
*/
IFX_INLINE void Ifx_RampF32_setSlewRate(Ifx_RampF32 *ramp, float32 slewRate, float32 period)
{
ramp->delta = slewRate * period;
}
/**
* \brief Initialize the Ifx_RampF32 object.
* \param ramp Pointer to the Ifx_RampF32 object
* \param slewRate Maximum slew rate, value per second
* \param period Sampling period of the Ifx_RampF32_step() function
*/
IFX_INLINE void Ifx_RampF32_init(Ifx_RampF32 *ramp, float32 slewRate, float32 period)
{
Ifx_RampF32_setSlewRate(ramp, slewRate, period);
Ifx_RampF32_reset(ramp);
}
/**
* \brief Set the reference value
* \param ramp Pointer to the Ifx_RampF32 object
* \param ref Reference value
*/
IFX_INLINE void Ifx_RampF32_setRef(Ifx_RampF32 *ramp, float32 ref)
{
ramp->ik = ref;
}
/**
* \brief Get the actual output value
* \param ramp Pointer to the Ifx_RampF32 object
* \return Actual value
*/
IFX_INLINE float32 Ifx_RampF32_getValue(Ifx_RampF32 *ramp)
{
return ramp->uk;
}
#endif /* IFX_RAMPF32_H */
@@ -0,0 +1,74 @@
/**
* \file Ifx_WndF32.h
* \brief Windowing function
* \ingroup library_srvsw_sysse_math_f32_wnd
*
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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_math_f32_wnd Window functions
* \ingroup library_srvsw_sysse_math_f32
*/
#ifndef IFX_WNDF32_H
#define IFX_WNDF32_H
#include "Ifx_Cf32.h"
#define IFX_WNDF32_TABLE_LENGTH (1024)
/** \addtogroup library_srvsw_sysse_math_f32_wnd
* \{ */
IFX_EXTERN CONST_CFG float32 Ifx_g_WndF32_hannTable[IFX_WNDF32_TABLE_LENGTH / 2];
IFX_EXTERN CONST_CFG float32 Ifx_g_WndF32_blackmanHarrisTable[IFX_WNDF32_TABLE_LENGTH / 2];
/** \brief Apply a window to complex array x which has nX length.
*
* Example: Ifx_WndF32_apply(x, Ifx_g_WndF32_hannTable, 1024); */
IFX_INLINE void Ifx_WndF32_apply(cfloat32 *x, CONST_CFG float32 *window, short nX)
{
VecWin_f32(&x->real, window, nX, IFX_WNDF32_TABLE_LENGTH, 2, 1);
}
/** \} */
#endif /* IFX_WNDF32_H */
@@ -0,0 +1,565 @@
/**
* \file Ifx_WndF32_BlackmanHarrisTable.c
* \brief Lookup table for Blackman-Harris window function
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_WndF32.h"
#if IFX_WNDF32_TABLE_LENGTH != 1024
#error This was generated with IFX_WNDF32_TABLE_LENGTH = 1024. Please regenerate.
#endif
CONST_CFG float32 Ifx_g_WndF32_blackmanHarrisTable[(IFX_WNDF32_TABLE_LENGTH / 2)] = {
_DATAF(0.000060000000000001),
_DATAF(6.05336435769415E-05),
_DATAF(6.21351621010909E-05),
_DATAF(6.48063189517042E-05),
_DATAF(6.85500530901977E-05),
_DATAF(7.33704790552552E-05),
_DATAF(7.92728869546643E-05),
_DATAF(8.62637424542366E-05),
_DATAF(9.43506867646833E-05),
_DATAF(0.000103542536623254),
_DATAF(0.000113849284272844),
_DATAF(0.00012528209743509),
_DATAF(0.000137853319279022),
_DATAF(0.000151576468382483),
_DATAF(0.000166466238687386),
_DATAF(0.000182538499446352),
_DATAF(0.000199810295160321),
_DATAF(0.000218299845506252),
_DATAF(0.000238026545253333),
_DATAF(0.000259010964166398),
_DATAF(0.000281274846895671),
_DATAF(0.000304841112851225),
_DATAF(0.000329733856060103),
_DATAF(0.000355978345005534),
_DATAF(0.000383601022445701),
_DATAF(0.00041262950521132),
_DATAF(0.000443092583978778),
_DATAF(0.000475020223018621),
_DATAF(0.000508443559916298),
_DATAF(0.000543394905263906),
_DATAF(0.000579907742319714),
_DATAF(0.000618016726635444),
_DATAF(0.000657757685646449),
_DATAF(0.000699167618224639),
_DATAF(0.000742284694190907),
_DATAF(0.000787148253784491),
_DATAF(0.000833798807087666),
_DATAF(0.000882278033402194),
_DATAF(0.000932628780575385),
_DATAF(0.000984895064273818),
_DATAF(0.00103912206720055),
_DATAF(0.00109535613825471),
_DATAF(0.00115364479162906),
_DATAF(0.00121403670584417),
_DATAF(0.00127658172271511),
_DATAF(0.00134133084624859),
_DATAF(0.0014083362414667),
_DATAF(0.00147765123315459),
_DATAF(0.00154933030452976),
_DATAF(0.0016234290958281),
_DATAF(0.00170000440280525),
_DATAF(0.00177911417514856),
_DATAF(0.00186081751479774),
_DATAF(0.00194517467416997),
_DATAF(0.00203224705428634),
_DATAF(0.00212209720279637),
_DATAF(0.0022147888118974),
_DATAF(0.00231038671614482),
_DATAF(0.00240895689015029),
_DATAF(0.00251056644616419),
_DATAF(0.00261528363153874),
_DATAF(0.00272317782606849),
_DATAF(0.0028343195392042),
_DATAF(0.00294878040713723),
_DATAF(0.00306663318975018),
_DATAF(0.00318795176743033),
_DATAF(0.00331281113774309),
_DATAF(0.00344128741195982),
_DATAF(0.00357345781143924),
_DATAF(0.00370940066385603),
_DATAF(0.00384919539927517),
_DATAF(0.00399292254606638),
_DATAF(0.00414066372665728),
_DATAF(0.00429250165311901),
_DATAF(0.00444852012258346),
_DATAF(0.00460880401248608),
_DATAF(0.00477343927563203),
_DATAF(0.0049425129350816),
_DATAF(0.00511611307885149),
_DATAF(0.00529432885442795),
_DATAF(0.00547725046308894),
_DATAF(0.00566496915403105),
_DATAF(0.00585757721829767),
_DATAF(0.00605516798250564),
_DATAF(0.00625783580236627),
_DATAF(0.00646567605599707),
_DATAF(0.00667878513702144),
_DATAF(0.00689726044745254),
_DATAF(0.00712120039035792),
_DATAF(0.00735070436230157),
_DATAF(0.00758587274556064),
_DATAF(0.00782680690011242),
_DATAF(0.00807360915538975),
_DATAF(0.00832638280180106),
_DATAF(0.00858523208201078),
_DATAF(0.0088502621819799),
_DATAF(0.00912157922176039),
_DATAF(0.00939929024604285),
_DATAF(0.00968350321445337),
_DATAF(0.00997432699159716),
_DATAF(0.0102718713368455),
_DATAF(0.010576246893865),
_DATAF(0.0108875651798833),
_DATAF(0.0112059385746926),
_DATAF(0.0115314803093847),
_DATAF(0.011864304454818),
_DATAF(0.0122045259098121),
_DATAF(0.0125522603890683),
_DATAF(0.0129076244108144),
_DATAF(0.0132707352841705),
_DATAF(0.013641711096234),
_DATAF(0.0140206706988822),
_DATAF(0.0144077336952905),
_DATAF(0.0148030204261634),
_DATAF(0.0152066519556773),
_DATAF(0.0156187500571341),
_DATAF(0.0160394371983217),
_DATAF(0.0164688365265826),
_DATAF(0.0169070718535868),
_DATAF(0.0173542676398092),
_DATAF(0.0178105489787098),
_DATAF(0.0182760415806149),
_DATAF(0.0187508717562994),
_DATAF(0.0192351664002677),
_DATAF(0.0197290529737345),
_DATAF(0.020232659487302),
_DATAF(0.0207461144833353),
_DATAF(0.0212695470180336),
_DATAF(0.0218030866431987),
_DATAF(0.0223468633876972),
_DATAF(0.0229010077386208),
_DATAF(0.0234656506221394),
_DATAF(0.0240409233840514),
_DATAF(0.0246269577700285),
_DATAF(0.0252238859055558),
_DATAF(0.025831840275569),
_DATAF(0.026450953703786),
_DATAF(0.0270813593317373),
_DATAF(0.0277231905974923),
_DATAF(0.0283765812140843),
_DATAF(0.0290416651476349),
_DATAF(0.029718576595178),
_DATAF(0.0304074499621848),
_DATAF(0.031108419839792),
_DATAF(0.0318216209817327),
_DATAF(0.0325471882809733),
_DATAF(0.0332852567460565),
_DATAF(0.0340359614771537),
_DATAF(0.0347994376418264),
_DATAF(0.0355758204505013),
_DATAF(0.036365245131659),
_DATAF(0.0371678469067388),
_DATAF(0.0379837609647635),
_DATAF(0.038813122436685),
_DATAF(0.039656066369453),
_DATAF(0.0405127276998116),
_DATAF(0.041383241227825),
_DATAF(0.0422677415901346),
_DATAF(0.0431663632329524),
_DATAF(0.0440792403847932),
_DATAF(0.0450065070289477),
_DATAF(0.0459482968757025),
_DATAF(0.0469047433343071),
_DATAF(0.0478759794846953),
_DATAF(0.0488621380489625),
_DATAF(0.0498633513626023),
_DATAF(0.0508797513455092),
_DATAF(0.0519114694727488),
_DATAF(0.0529586367451015),
_DATAF(0.0540213836593831),
_DATAF(0.0550998401785474),
_DATAF(0.0561941357015757),
_DATAF(0.0573043990331573),
_DATAF(0.0584307583531662),
_DATAF(0.0595733411859395),
_DATAF(0.0607322743693613),
_DATAF(0.06190768402376),
_DATAF(0.0630996955206202),
_DATAF(0.0643084334511193),
_DATAF(0.0655340215944914),
_DATAF(0.0667765828862246),
_DATAF(0.0680362393860989),
_DATAF(0.0693131122460692),
_DATAF(0.0706073216779996),
_DATAF(0.0719189869212565),
_DATAF(0.0732482262101651),
_DATAF(0.0745951567413363),
_DATAF(0.0759598946408714),
_DATAF(0.0773425549314486),
_DATAF(0.0787432514993022),
_DATAF(0.0801620970610963),
_DATAF(0.0815992031307037),
_DATAF(0.083054679985896),
_DATAF(0.0845286366349502),
_DATAF(0.0860211807831818),
_DATAF(0.0875324187994092),
_DATAF(0.0890624556823589),
_DATAF(0.0906113950270166),
_DATAF(0.092179338990934),
_DATAF(0.0937663882604969),
_DATAF(0.0953726420171649),
_DATAF(0.0969981979036867),
_DATAF(0.0986431519903029),
_DATAF(0.100307598740941),
_DATAF(0.101991630979414),
_DATAF(0.103695339855624),
_DATAF(0.105418814811791),
_DATAF(0.107162143548701),
_DATAF(0.108925411991991),
_DATAF(0.110708704258479),
_DATAF(0.112512102622539),
_DATAF(0.114335687482543),
_DATAF(0.116179537327367),
_DATAF(0.118043728702971),
_DATAF(0.119928336179073),
_DATAF(0.121833432315909),
_DATAF(0.123759087631096),
_DATAF(0.125705370566615),
_DATAF(0.127672347455906),
_DATAF(0.129660082491093),
_DATAF(0.131668637690355),
_DATAF(0.133698072865431),
_DATAF(0.135748445589297),
_DATAF(0.137819811163995),
_DATAF(0.139912222588642),
_DATAF(0.142025730527626),
_DATAF(0.144160383278985),
_DATAF(0.146316226742996),
_DATAF(0.14849330439097),
_DATAF(0.150691657234271),
_DATAF(0.152911323793562),
_DATAF(0.155152340068285),
_DATAF(0.157414739506395),
_DATAF(0.15969855297435),
_DATAF(0.162003808727361),
_DATAF(0.164330532379924),
_DATAF(0.166678746876629),
_DATAF(0.169048472463272),
_DATAF(0.171439726658257),
_DATAF(0.173852524224323),
_DATAF(0.176286877140581),
_DATAF(0.178742794574886),
_DATAF(0.181220282856548),
_DATAF(0.183719345449389),
_DATAF(0.186239982925158),
_DATAF(0.188782192937316),
_DATAF(0.191345970195187),
_DATAF(0.193931306438502),
_DATAF(0.196538190412331),
_DATAF(0.199166607842421),
_DATAF(0.201816541410937),
_DATAF(0.204487970732631),
_DATAF(0.207180872331433),
_DATAF(0.209895219617483),
_DATAF(0.212630982864606),
_DATAF(0.21538812918824),
_DATAF(0.218166622523828),
_DATAF(0.220966423605681),
_DATAF(0.223787489946321),
_DATAF(0.226629775816306),
_DATAF(0.229493232224558),
_DATAF(0.232377806899193),
_DATAF(0.235283444268855),
_DATAF(0.238210085444584),
_DATAF(0.241157668202195),
_DATAF(0.244126126965209),
_DATAF(0.247115392788316),
_DATAF(0.25012539334139),
_DATAF(0.253156052894067),
_DATAF(0.256207292300887),
_DATAF(0.259279028987005),
_DATAF(0.262371176934486),
_DATAF(0.265483646669187),
_DATAF(0.268616345248233),
_DATAF(0.271769176248094),
_DATAF(0.27494203975327),
_DATAF(0.278134832345589),
_DATAF(0.281347447094127),
_DATAF(0.284579773545761),
_DATAF(0.287831697716344),
_DATAF(0.291103102082533),
_DATAF(0.294393865574252),
_DATAF(0.297703863567812),
_DATAF(0.301032967879694),
_DATAF(0.30438104676098),
_DATAF(0.307747964892468),
_DATAF(0.311133583380456),
_DATAF(0.314537759753201),
_DATAF(0.317960347958064),
_DATAF(0.321401198359353),
_DATAF(0.324860157736845),
_DATAF(0.328337069285016),
_DATAF(0.331831772612977),
_DATAF(0.335344103745104),
_DATAF(0.338873895122394),
_DATAF(0.342420975604529),
_DATAF(0.345985170472656),
_DATAF(0.3495663014329),
_DATAF(0.353164186620592),
_DATAF(0.356778640605235),
_DATAF(0.360409474396196),
_DATAF(0.364056495449141),
_DATAF(0.367719507673201),
_DATAF(0.371398311438886),
_DATAF(0.375092703586736),
_DATAF(0.378802477436722),
_DATAF(0.382527422798394),
_DATAF(0.386267325981779),
_DATAF(0.39002196980903),
_DATAF(0.393791133626826),
_DATAF(0.397574593319535),
_DATAF(0.401372121323116),
_DATAF(0.4051834866398),
_DATAF(0.409008454853506),
_DATAF(0.412846788146031),
_DATAF(0.416698245313995),
_DATAF(0.420562581786534),
_DATAF(0.424439549643771),
_DATAF(0.428328897636028),
_DATAF(0.432230371203805),
_DATAF(0.436143712498517),
_DATAF(0.440068660403987),
_DATAF(0.444004950558688),
_DATAF(0.447952315378757),
_DATAF(0.451910484081743),
_DATAF(0.455879182711121),
_DATAF(0.459858134161553),
_DATAF(0.463847058204895),
_DATAF(0.46784567151695),
_DATAF(0.471853687704974),
_DATAF(0.475870817335914),
_DATAF(0.479896767965388),
_DATAF(0.483931244167404),
_DATAF(0.487973947564809),
_DATAF(0.492024576860471),
_DATAF(0.496082827869183),
_DATAF(0.500148393550297),
_DATAF(0.50422096404107),
_DATAF(0.508300226690728),
_DATAF(0.512385866095238),
_DATAF(0.516477564132795),
_DATAF(0.520575),
_DATAF(0.524677850248738),
_DATAF(0.528785788823753),
_DATAF(0.532898487100904),
_DATAF(0.537015613926103),
_DATAF(0.541136835654929),
_DATAF(0.545261816192918),
_DATAF(0.549390217036503),
_DATAF(0.553521697314626),
_DATAF(0.557655913830994),
_DATAF(0.561792521106979),
_DATAF(0.565931171425163),
_DATAF(0.570071514873506),
_DATAF(0.574213199390142),
_DATAF(0.578355870808795),
_DATAF(0.582499172904798),
_DATAF(0.586642747441718),
_DATAF(0.590786234218577),
_DATAF(0.594929271117651),
_DATAF(0.599071494152859),
_DATAF(0.603212537518709),
_DATAF(0.607352033639815),
_DATAF(0.611489613220962),
_DATAF(0.615624905297715),
_DATAF(0.619757537287565),
_DATAF(0.623887135041594),
_DATAF(0.628013322896669),
_DATAF(0.632135723728129),
_DATAF(0.636253959002978),
_DATAF(0.640367648833561),
_DATAF(0.644476412031722),
_DATAF(0.648579866163425),
_DATAF(0.652677627603835),
_DATAF(0.656769311592843),
_DATAF(0.660854532291033),
_DATAF(0.664932902836069),
_DATAF(0.669004035399499),
_DATAF(0.673067541243964),
_DATAF(0.6771230307808),
_DATAF(0.681170113628019),
_DATAF(0.685208398668663),
_DATAF(0.689237494109519),
_DATAF(0.693257007540177),
_DATAF(0.697266545992425),
_DATAF(0.701265715999973),
_DATAF(0.705254123658479),
_DATAF(0.70923137468589),
_DATAF(0.713197074483052),
_DATAF(0.717150828194615),
_DATAF(0.721092240770188),
_DATAF(0.72502091702575),
_DATAF(0.7289364617053),
_DATAF(0.732838479542731),
_DATAF(0.736726575323917),
_DATAF(0.740600353949007),
_DATAF(0.744459420494891),
_DATAF(0.748303380277859),
_DATAF(0.752131838916412),
_DATAF(0.755944402394215),
_DATAF(0.759740677123202),
_DATAF(0.763520270006787),
_DATAF(0.76728278850319),
_DATAF(0.771027840688865),
_DATAF(0.774755035321995),
_DATAF(0.778463981906066),
_DATAF(0.782154290753498),
_DATAF(0.785825573049304),
_DATAF(0.789477440914794),
_DATAF(0.793109507471277),
_DATAF(0.796721386903776),
_DATAF(0.800312694524721),
_DATAF(0.803883046837616),
_DATAF(0.807432061600672),
_DATAF(0.810959357890378),
_DATAF(0.814464556165),
_DATAF(0.817947278328014),
_DATAF(0.821407147791419),
_DATAF(0.824843789538964),
_DATAF(0.82825683018923),
_DATAF(0.831645898058594),
_DATAF(0.835010623224019),
_DATAF(0.8383506375857),
_DATAF(0.841665574929516),
_DATAF(0.844955070989297),
_DATAF(0.848218763508878),
_DATAF(0.851456292303937),
_DATAF(0.854667299323595),
_DATAF(0.85785142871177),
_DATAF(0.861008326868267),
_DATAF(0.864137642509598),
_DATAF(0.867239026729501),
_DATAF(0.87031213305917),
_DATAF(0.87335661752716),
_DATAF(0.876372138718963),
_DATAF(0.879358357836245),
_DATAF(0.882314938755719),
_DATAF(0.885241548087659),
_DATAF(0.888137855234021),
_DATAF(0.891003532446169),
_DATAF(0.8938382548822),
_DATAF(0.896641700663836),
_DATAF(0.899413550932886),
_DATAF(0.90215348990726),
_DATAF(0.90486120493652),
_DATAF(0.907536386556961),
_DATAF(0.9101787285462),
_DATAF(0.912787927977272),
_DATAF(0.915363685272211),
_DATAF(0.917905704255112),
_DATAF(0.92041369220465),
_DATAF(0.922887359906061),
_DATAF(0.925326421702555),
_DATAF(0.927730595546164),
_DATAF(0.930099603048002),
_DATAF(0.932433169527932),
_DATAF(0.93473102406363),
_DATAF(0.936992899539027),
_DATAF(0.939218532692123),
_DATAF(0.941407664162166),
_DATAF(0.943560038536173),
_DATAF(0.945675404394792),
_DATAF(0.947753514357501),
_DATAF(0.949794125127105),
_DATAF(0.951796997533564),
_DATAF(0.953761896577093),
_DATAF(0.955688591470572),
_DATAF(0.957576855681214),
_DATAF(0.959426466971513),
_DATAF(0.961237207439446),
_DATAF(0.963008863557916),
_DATAF(0.964741226213449),
_DATAF(0.966434090744106),
_DATAF(0.968087256976625),
_DATAF(0.969700529262773),
_DATAF(0.971273716514903),
_DATAF(0.972806632240705),
_DATAF(0.974299094577144),
_DATAF(0.975750926323582),
_DATAF(0.977161954974065),
_DATAF(0.978532012748779),
_DATAF(0.979860936624663),
_DATAF(0.981148568365171),
_DATAF(0.982394754549168),
_DATAF(0.98359934659898),
_DATAF(0.984762200807557),
_DATAF(0.985883178364764),
_DATAF(0.986962145382792),
_DATAF(0.987998972920675),
_DATAF(0.988993537007913),
_DATAF(0.989945718667196),
_DATAF(0.990855403936222),
_DATAF(0.991722483888599),
_DATAF(0.992546854653837),
_DATAF(0.993328417436418),
_DATAF(0.994067078533934),
_DATAF(0.994762749354304),
_DATAF(0.995415346432055),
_DATAF(0.996024791443661),
_DATAF(0.996591011221945),
_DATAF(0.997113937769534),
_DATAF(0.997593508271372),
_DATAF(0.998029665106271),
_DATAF(0.99842235585752),
_DATAF(0.998771533322532),
_DATAF(0.999077155521532),
_DATAF(0.99933918570529),
_DATAF(0.999557592361884),
_DATAF(0.999732349222509),
_DATAF(0.999863435266309),
_DATAF(0.999950834724255),
_DATAF(0.999994537082046),
};
@@ -0,0 +1,565 @@
/**
* \file Ifx_WndF32_HannTable.c
* \brief Lookup table for Hann window function
*
*
* \version disabled
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
*
* 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 "Ifx_WndF32.h"
#if IFX_WNDF32_TABLE_LENGTH != 1024
#error This was generated with IFX_WNDF32_TABLE_LENGTH = 1024. Please regenerate.
#endif
CONST_CFG float32 Ifx_g_WndF32_hannTable[(IFX_WNDF32_TABLE_LENGTH / 2)] = {
_DATAF(0.00000000000000000000),
_DATAF(0.00000943076884141192),
_DATAF(0.00003772272248170339),
_DATAF(0.00008487478771712631),
_DATAF(0.00015088518557604402),
_DATAF(0.00023575144587084651),
_DATAF(0.00033947033807635307),
_DATAF(0.00046203794772736728),
_DATAF(0.00060344970552250743),
_DATAF(0.00076370022725313902),
_DATAF(0.00094278343021869659),
_DATAF(0.00114069262053817510),
_DATAF(0.00135742034763097760),
_DATAF(0.00159295846242457630),
_DATAF(0.00184729788452386860),
_DATAF(0.00212042918428778650),
_DATAF(0.00241234223358333110),
_DATAF(0.00272302562370896340),
_DATAF(0.00305246794596314430),
_DATAF(0.00340065662749111650),
_DATAF(0.00376757839694619180),
_DATAF(0.00415321951732039450),
_DATAF(0.00455756578594446180),
_DATAF(0.00498060183599591260),
_DATAF(0.00542231136932969090),
_DATAF(0.00588267762213945390),
_DATAF(0.00636168383061885830),
_DATAF(0.00685931136831641200),
_DATAF(0.00737554160878062250),
_DATAF(0.00791035499423742290),
_DATAF(0.00846373196691274640),
_DATAF(0.00903565157204866410),
_DATAF(0.00962609145790338520),
_DATAF(0.01023502927273511900),
_DATAF(0.01086244266480207400),
_DATAF(0.01150830835103988600),
_DATAF(0.01217260118573904000),
_DATAF(0.01285529602319002200),
_DATAF(0.01355636864900589000),
_DATAF(0.01427579019218683200),
_DATAF(0.01501353550702333500),
_DATAF(0.01576957479119300800),
_DATAF(0.01654388196766376500),
_DATAF(0.01733642630279064200),
_DATAF(0.01814717799425125100),
_DATAF(0.01897610723972320600),
_DATAF(0.01982318051159381900),
_DATAF(0.02068836987018585200),
_DATAF(0.02157163806259632100),
_DATAF(0.02247295528650283800),
_DATAF(0.02339228615164756800),
_DATAF(0.02432959713041782400),
_DATAF(0.02528485096991062200),
_DATAF(0.02625801227986812600),
_DATAF(0.02724904380738735200),
_DATAF(0.02825791016221046400),
_DATAF(0.02928457222878933000),
_DATAF(0.03032899089157581300),
_DATAF(0.03139112517237663300),
_DATAF(0.03247094154357910200),
_DATAF(0.03356838971376419100),
_DATAF(0.03468343615531921400),
_DATAF(0.03581603243947029100),
_DATAF(0.03696614131331443800),
_DATAF(0.03813371807336807300),
_DATAF(0.03931871801614761400),
_DATAF(0.04052109271287918100),
_DATAF(0.04174080491065979000),
_DATAF(0.04297780245542526200),
_DATAF(0.04423204064369201700),
_DATAF(0.04550346732139587400),
_DATAF(0.04679204523563385000),
_DATAF(0.04809771478176116900),
_DATAF(0.04942043498158454900),
_DATAF(0.05076014995574951200),
_DATAF(0.05211681500077247600),
_DATAF(0.05349037423729896500),
_DATAF(0.05488077551126480100),
_DATAF(0.05628796666860580400),
_DATAF(0.05771189928054809600),
_DATAF(0.05915251374244689900),
_DATAF(0.06060976162552833600),
_DATAF(0.06208358332514762900),
_DATAF(0.06357392668724060100),
_DATAF(0.06508072465658187900),
_DATAF(0.06660393625497818000),
_DATAF(0.06814350187778472900),
_DATAF(0.06969934701919555700),
_DATAF(0.07127143442630767800),
_DATAF(0.07285968959331512500),
_DATAF(0.07446406036615371700),
_DATAF(0.07608447968959808300),
_DATAF(0.07772088795900344800),
_DATAF(0.07937323302030563400),
_DATAF(0.08104144036769866900),
_DATAF(0.08272545784711837800),
_DATAF(0.08442521095275878900),
_DATAF(0.08614064753055572500),
_DATAF(0.08787168562412262000),
_DATAF(0.08961828052997589100),
_DATAF(0.09138035029172897300),
_DATAF(0.09315783530473709100),
_DATAF(0.09495066851377487200),
_DATAF(0.09675878286361694300),
_DATAF(0.09858211129903793300),
_DATAF(0.10042057186365128000),
_DATAF(0.10227411240339279000),
_DATAF(0.10414265841245651000),
_DATAF(0.10602613538503647000),
_DATAF(0.10792447626590729000),
_DATAF(0.10983760654926300000),
_DATAF(0.11176545172929764000),
_DATAF(0.11370794475078583000),
_DATAF(0.11566501110792160000),
_DATAF(0.11763656884431839000),
_DATAF(0.11962255835533142000),
_DATAF(0.12162289768457413000),
_DATAF(0.12363750487565994000),
_DATAF(0.12566630542278290000),
_DATAF(0.12770923972129822000),
_DATAF(0.12976621091365814000),
_DATAF(0.13183714449405670000),
_DATAF(0.13392198085784912000),
_DATAF(0.13602061569690704000),
_DATAF(0.13813297450542450000),
_DATAF(0.14025899767875671000),
_DATAF(0.14239858090877533000),
_DATAF(0.14455166459083557000),
_DATAF(0.14671814441680908000),
_DATAF(0.14889796078205109000),
_DATAF(0.15109102427959442000),
_DATAF(0.15329724550247192000),
_DATAF(0.15551653504371643000),
_DATAF(0.15774883329868317000),
_DATAF(0.15999403595924377000),
_DATAF(0.16225206851959229000),
_DATAF(0.16452284157276154000),
_DATAF(0.16680626571178436000),
_DATAF(0.16910226643085480000),
_DATAF(0.17141073942184448000),
_DATAF(0.17373161017894745000),
_DATAF(0.17606478929519653000),
_DATAF(0.17841020226478577000),
_DATAF(0.18076772987842560000),
_DATAF(0.18313729763031006000),
_DATAF(0.18551883101463318000),
_DATAF(0.18791222572326660000),
_DATAF(0.19031739234924316000),
_DATAF(0.19273422658443451000),
_DATAF(0.19516266882419586000),
_DATAF(0.19760259985923767000),
_DATAF(0.20005394518375397000),
_DATAF(0.20251661539077759000),
_DATAF(0.20499049127101898000),
_DATAF(0.20747549831867218000),
_DATAF(0.20997154712677002000),
_DATAF(0.21247853338718414000),
_DATAF(0.21499636769294739000),
_DATAF(0.21752494573593140000),
_DATAF(0.22006417810916901000),
_DATAF(0.22261397540569305000),
_DATAF(0.22517424821853638000),
_DATAF(0.22774487733840942000),
_DATAF(0.23032577335834503000),
_DATAF(0.23291684687137604000),
_DATAF(0.23551799356937408000),
_DATAF(0.23812912404537201000),
_DATAF(0.24075011909008026000),
_DATAF(0.24338090419769287000),
_DATAF(0.24602137506008148000),
_DATAF(0.24867141246795654000),
_DATAF(0.25133094191551208000),
_DATAF(0.25399985909461975000),
_DATAF(0.25667804479598999000),
_DATAF(0.25936540961265564000),
_DATAF(0.26206183433532715000),
_DATAF(0.26476725935935974000),
_DATAF(0.26748156547546387000),
_DATAF(0.27020460367202759000),
_DATAF(0.27293634414672852000),
_DATAF(0.27567663788795471000),
_DATAF(0.27842539548873901000),
_DATAF(0.28118252754211426000),
_DATAF(0.28394788503646851000),
_DATAF(0.28672140836715698000),
_DATAF(0.28950297832489014000),
_DATAF(0.29229250550270081000),
_DATAF(0.29508984088897705000),
_DATAF(0.29789492487907410000),
_DATAF(0.30070760846138000000),
_DATAF(0.30352783203125000000),
_DATAF(0.30635544657707214000),
_DATAF(0.30919039249420166000),
_DATAF(0.31203252077102661000),
_DATAF(0.31488174200057983000),
_DATAF(0.31773793697357178000),
_DATAF(0.32060101628303528000),
_DATAF(0.32347086071968079000),
_DATAF(0.32634738087654114000),
_DATAF(0.32923042774200439000),
_DATAF(0.33211994171142578000),
_DATAF(0.33501577377319336000),
_DATAF(0.33791780471801758000),
_DATAF(0.34082597494125366000),
_DATAF(0.34374016523361206000),
_DATAF(0.34666022658348083000),
_DATAF(0.34958606958389282000),
_DATAF(0.35251760482788086000),
_DATAF(0.35545471310615540000),
_DATAF(0.35839724540710449000),
_DATAF(0.36134514212608337000),
_DATAF(0.36429825425148010000),
_DATAF(0.36725649237632751000),
_DATAF(0.37021973729133606000),
_DATAF(0.37318786978721619000),
_DATAF(0.37616080045700073000),
_DATAF(0.37913838028907776000),
_DATAF(0.38212051987648010000),
_DATAF(0.38510712981224060000),
_DATAF(0.38809806108474731000),
_DATAF(0.39109322428703308000),
_DATAF(0.39409247040748596000),
_DATAF(0.39709573984146118000),
_DATAF(0.40010288357734680000),
_DATAF(0.40311378240585327000),
_DATAF(0.40612834692001343000),
_DATAF(0.40914645791053772000),
_DATAF(0.41216799616813660000),
_DATAF(0.41519284248352051000),
_DATAF(0.41822087764739990000),
_DATAF(0.42125201225280762000),
_DATAF(0.42428609728813171000),
_DATAF(0.42732307314872742000),
_DATAF(0.43036276102066040000),
_DATAF(0.43340510129928589000),
_DATAF(0.43644991517066956000),
_DATAF(0.43949717283248901000),
_DATAF(0.44254666566848755000),
_DATAF(0.44559836387634277000),
_DATAF(0.44865208864212036000),
_DATAF(0.45170778036117554000),
_DATAF(0.45476526021957397000),
_DATAF(0.45782446861267090000),
_DATAF(0.46088525652885437000),
_DATAF(0.46394753456115723000),
_DATAF(0.46701115369796753000),
_DATAF(0.47007602453231812000),
_DATAF(0.47314202785491943000),
_DATAF(0.47620904445648193000),
_DATAF(0.47927695512771606000),
_DATAF(0.48234564065933228000),
_DATAF(0.48541501164436340000),
_DATAF(0.48848491907119751000),
_DATAF(0.49155527353286743000),
_DATAF(0.49462592601776123000),
_DATAF(0.49769678711891174000),
_DATAF(0.50076776742935181000),
_DATAF(0.50383865833282471000),
_DATAF(0.50690943002700806000),
_DATAF(0.50997996330261230000),
_DATAF(0.51305007934570313000),
_DATAF(0.51611977815628052000),
_DATAF(0.51918876171112061000),
_DATAF(0.52225708961486816000),
_DATAF(0.52532458305358887000),
_DATAF(0.52839112281799316000),
_DATAF(0.53145653009414673000),
_DATAF(0.53452080488204956000),
_DATAF(0.53758376836776733000),
_DATAF(0.54064530134201050000),
_DATAF(0.54370534420013428000),
_DATAF(0.54676371812820435000),
_DATAF(0.54982030391693115000),
_DATAF(0.55287504196166992000),
_DATAF(0.55592775344848633000),
_DATAF(0.55897837877273560000),
_DATAF(0.56202673912048340000),
_DATAF(0.56507277488708496000),
_DATAF(0.56811636686325073000),
_DATAF(0.57115739583969116000),
_DATAF(0.57419574260711670000),
_DATAF(0.57723128795623779000),
_DATAF(0.58026391267776489000),
_DATAF(0.58329355716705322000),
_DATAF(0.58631998300552368000),
_DATAF(0.58934319019317627000),
_DATAF(0.59236299991607666000),
_DATAF(0.59537935256958008000),
_DATAF(0.59839212894439697000),
_DATAF(0.60140115022659302000),
_DATAF(0.60440635681152344000),
_DATAF(0.60740762948989868000),
_DATAF(0.61040484905242920000),
_DATAF(0.61339795589447021000),
_DATAF(0.61638671159744263000),
_DATAF(0.61937111616134644000),
_DATAF(0.62235099077224731000),
_DATAF(0.62532627582550049000),
_DATAF(0.62829679250717163000),
_DATAF(0.63126254081726074000),
_DATAF(0.63422328233718872000),
_DATAF(0.63717895746231079000),
_DATAF(0.64012944698333740000),
_DATAF(0.64307469129562378000),
_DATAF(0.64601451158523560000),
_DATAF(0.64894884824752808000),
_DATAF(0.65187758207321167000),
_DATAF(0.65480053424835205000),
_DATAF(0.65771764516830444000),
_DATAF(0.66062885522842407000),
_DATAF(0.66353398561477661000),
_DATAF(0.66643291711807251000),
_DATAF(0.66932559013366699000),
_DATAF(0.67221188545227051000),
_DATAF(0.67509168386459351000),
_DATAF(0.67796486616134644000),
_DATAF(0.68083137273788452000),
_DATAF(0.68369102478027344000),
_DATAF(0.68654376268386841000),
_DATAF(0.68938946723937988000),
_DATAF(0.69222795963287354000),
_DATAF(0.69505929946899414000),
_DATAF(0.69788318872451782000),
_DATAF(0.70069968700408936000),
_DATAF(0.70350855588912964000),
_DATAF(0.70630979537963867000),
_DATAF(0.70910322666168213000),
_DATAF(0.71188879013061523000),
_DATAF(0.71466636657714844000),
_DATAF(0.71743583679199219000),
_DATAF(0.72019708156585693000),
_DATAF(0.72295004129409790000),
_DATAF(0.72569459676742554000),
_DATAF(0.72843056917190552000),
_DATAF(0.73115801811218262000),
_DATAF(0.73387670516967773000),
_DATAF(0.73658657073974609000),
_DATAF(0.73928749561309814000),
_DATAF(0.74197942018508911000),
_DATAF(0.74466222524642944000),
_DATAF(0.74733579158782959000),
_DATAF(0.75000000000000000000),
_DATAF(0.75265479087829590000),
_DATAF(0.75530004501342773000),
_DATAF(0.75793570280075073000),
_DATAF(0.76056158542633057000),
_DATAF(0.76317769289016724000),
_DATAF(0.76578384637832642000),
_DATAF(0.76837992668151855000),
_DATAF(0.77096593379974365000),
_DATAF(0.77354174852371216000),
_DATAF(0.77610719203948975000),
_DATAF(0.77866220474243164000),
_DATAF(0.78120678663253784000),
_DATAF(0.78374069929122925000),
_DATAF(0.78626388311386108000),
_DATAF(0.78877633810043335000),
_DATAF(0.79127782583236694000),
_DATAF(0.79376840591430664000),
_DATAF(0.79624783992767334000),
_DATAF(0.79871612787246704000),
_DATAF(0.80117315053939819000),
_DATAF(0.80361878871917725000),
_DATAF(0.80605298280715942000),
_DATAF(0.80847567319869995000),
_DATAF(0.81088668107986450000),
_DATAF(0.81328594684600830000),
_DATAF(0.81567341089248657000),
_DATAF(0.81804895401000977000),
_DATAF(0.82041257619857788000),
_DATAF(0.82276403903961182000),
_DATAF(0.82510334253311157000),
_DATAF(0.82743036746978760000),
_DATAF(0.82974505424499512000),
_DATAF(0.83204728364944458000),
_DATAF(0.83433699607849121000),
_DATAF(0.83661413192749023000),
_DATAF(0.83887857198715210000),
_DATAF(0.84113019704818726000),
_DATAF(0.84336894750595093000),
_DATAF(0.84559476375579834000),
_DATAF(0.84780752658843994000),
_DATAF(0.85000717639923096000),
_DATAF(0.85219359397888184000),
_DATAF(0.85436677932739258000),
_DATAF(0.85652655363082886000),
_DATAF(0.85867291688919067000),
_DATAF(0.86080569028854370000),
_DATAF(0.86292493343353271000),
_DATAF(0.86503040790557861000),
_DATAF(0.86712217330932617000),
_DATAF(0.86920005083084106000),
_DATAF(0.87126404047012329000),
_DATAF(0.87331396341323853000),
_DATAF(0.87534987926483154000),
_DATAF(0.87737154960632324000),
_DATAF(0.87937903404235840000),
_DATAF(0.88137221336364746000),
_DATAF(0.88335102796554565000),
_DATAF(0.88531535863876343000),
_DATAF(0.88726514577865601000),
_DATAF(0.88920032978057861000),
_DATAF(0.89112079143524170000),
_DATAF(0.89302653074264526000),
_DATAF(0.89491748809814453000),
_DATAF(0.89679348468780518000),
_DATAF(0.89865452051162720000),
_DATAF(0.90050053596496582000),
_DATAF(0.90233147144317627000),
_DATAF(0.90414720773696899000),
_DATAF(0.90594768524169922000),
_DATAF(0.90773284435272217000),
_DATAF(0.90950262546539307000),
_DATAF(0.91125696897506714000),
_DATAF(0.91299575567245483000),
_DATAF(0.91471904516220093000),
_DATAF(0.91642659902572632000),
_DATAF(0.91811853647232056000),
_DATAF(0.91979461908340454000),
_DATAF(0.92145490646362305000),
_DATAF(0.92309933900833130000),
_DATAF(0.92472773790359497000),
_DATAF(0.92634016275405884000),
_DATAF(0.92793643474578857000),
_DATAF(0.92951661348342896000),
_DATAF(0.93108057975769043000),
_DATAF(0.93262833356857300000),
_DATAF(0.93415969610214233000),
_DATAF(0.93567472696304321000),
_DATAF(0.93717330694198608000),
_DATAF(0.93865537643432617000),
_DATAF(0.94012093544006348000),
_DATAF(0.94156986474990845000),
_DATAF(0.94300216436386108000),
_DATAF(0.94441771507263184000),
_DATAF(0.94581651687622070000),
_DATAF(0.94719851016998291000),
_DATAF(0.94856363534927368000),
_DATAF(0.94991183280944824000),
_DATAF(0.95124304294586182000),
_DATAF(0.95255726575851440000),
_DATAF(0.95385438203811646000),
_DATAF(0.95513439178466797000),
_DATAF(0.95639723539352417000),
_DATAF(0.95764285326004028000),
_DATAF(0.95887118577957153000),
_DATAF(0.96008229255676270000),
_DATAF(0.96127593517303467000),
_DATAF(0.96245223283767700000),
_DATAF(0.96361112594604492000),
_DATAF(0.96475243568420410000),
_DATAF(0.96587628126144409000),
_DATAF(0.96698254346847534000),
_DATAF(0.96807116270065308000),
_DATAF(0.96914213895797729000),
_DATAF(0.97019541263580322000),
_DATAF(0.97123098373413086000),
_DATAF(0.97224873304367065000),
_DATAF(0.97324872016906738000),
_DATAF(0.97423082590103149000),
_DATAF(0.97519499063491821000),
_DATAF(0.97614127397537231000),
_DATAF(0.97706961631774902000),
_DATAF(0.97797995805740356000),
_DATAF(0.97887223958969116000),
_DATAF(0.97974646091461182000),
_DATAF(0.98060262203216553000),
_DATAF(0.98144060373306274000),
_DATAF(0.98226046562194824000),
_DATAF(0.98306214809417725000),
_DATAF(0.98384553194046021000),
_DATAF(0.98461073637008667000),
_DATAF(0.98535764217376709000),
_DATAF(0.98608618974685669000),
_DATAF(0.98679643869400024000),
_DATAF(0.98748832941055298000),
_DATAF(0.98816186189651489000),
_DATAF(0.98881691694259644000),
_DATAF(0.98945355415344238000),
_DATAF(0.99007177352905273000),
_DATAF(0.99067145586013794000),
_DATAF(0.99125260114669800000),
_DATAF(0.99181526899337769000),
_DATAF(0.99235939979553223000),
_DATAF(0.99288487434387207000),
_DATAF(0.99339181184768677000),
_DATAF(0.99388015270233154000),
_DATAF(0.99434983730316162000),
_DATAF(0.99480086565017700000),
_DATAF(0.99523323774337769000),
_DATAF(0.99564695358276367000),
_DATAF(0.99604195356369019000),
_DATAF(0.99641823768615723000),
_DATAF(0.99677580595016479000),
_DATAF(0.99711459875106812000),
_DATAF(0.99743467569351196000),
_DATAF(0.99773597717285156000),
_DATAF(0.99801850318908691000),
_DATAF(0.99828219413757324000),
_DATAF(0.99852716922760010000),
_DATAF(0.99875330924987793000),
_DATAF(0.99896061420440674000),
_DATAF(0.99914908409118652000),
_DATAF(0.99931877851486206000),
_DATAF(0.99946963787078857000),
_DATAF(0.99960160255432129000),
_DATAF(0.99971473217010498000),
_DATAF(0.99980902671813965000),
_DATAF(0.99988448619842529000),
_DATAF(0.99994105100631714000),
_DATAF(0.99997878074645996000),
_DATAF(0.99999761581420898000),
};
@@ -0,0 +1,7 @@
/**
* \defgroup library_srvsw_sysse_math Math
* \ingroup library_srvsw_sysse
*
* \defgroup library_srvsw_sysse_math_f32 Math 32bit floating point
* \ingroup library_srvsw_sysse_math
*/
@@ -0,0 +1,73 @@
/**
* \file Ifx_DateTime.c
* \brief Date and time functions.
*
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
* $Date: 2014-02-27 20:08:37 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 "Ifx_DateTime.h"
#include "SysSe/Bsp/Bsp.h"
/* FIXME make compatible to unix time */
sint32 g_DateTimeOffset;
/** \brief Get the real time
* Note that this function is valid only if DateTime_set() has been called */
void DateTime_get(Ifx_DateTime *dt)
{
sint32 seconds = (sint32)(now() / TimeConst_1s);
seconds = seconds + g_DateTimeOffset;
dt->hours = seconds / 3600;
dt->minutes = seconds / 60;
dt->minutes = dt->minutes % 60;
dt->seconds = seconds % 60;
}
/** \brief Set the real time */
void DateTime_set(Ifx_DateTime *dt)
{
sint32 seconds = dt->seconds - ((sint32)(now() / TimeConst_1s));
seconds = seconds + (3600 * dt->hours);
seconds = seconds + (60 * dt->minutes);
g_DateTimeOffset = seconds;
}
@@ -0,0 +1,63 @@
/**
* \file Ifx_DateTime.h
* \brief Date and time functions.
*
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
*
* $Date: 2014-02-28 14:15:40 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_time_datetime DateTime
* This module implements the Date-Time functions.
* \ingroup library_srvsw_sysse_time
*/
#ifndef REALTIME_H_
#define REALTIME_H_ 1
#include "Cpu/Std/Ifx_Types.h"
typedef struct
{
sint32 hours;
sint32 minutes;
sint32 seconds;
} Ifx_DateTime;
/** \addtogroup library_srvsw_sysse_time_datetime
* \{ */
IFX_EXTERN void DateTime_set(Ifx_DateTime *time);
IFX_EXTERN void DateTime_get(Ifx_DateTime *time);
/** \} */
#endif /* REALTIME_H_ */
@@ -0,0 +1,5 @@
/**
* \defgroup library_srvsw_sysse_time Time
* \ingroup library_srvsw_sysse
*
*/
@@ -0,0 +1,5 @@
/**
* \defgroup library_srvsw_sysse System Engineering
* \ingroup library_srvsw
*
*/