初始化仓库
This commit is contained in:
120
libraries/infineon_libraries/Service/CpuGeneric/StdIf/IfxStdIf.h
Normal file
120
libraries/infineon_libraries/Service/CpuGeneric/StdIf/IfxStdIf.h
Normal file
@@ -0,0 +1,120 @@
|
||||
/**
|
||||
* \file IfxStdIf.h
|
||||
* \brief Standard interface types
|
||||
* \ingroup IfxLld
|
||||
*
|
||||
* \copyright Copyright (c) 2018 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-27 20:08:23 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_stdif Standard interface
|
||||
* \ingroup library_srvsw
|
||||
*
|
||||
*
|
||||
*
|
||||
* \par Terms
|
||||
*
|
||||
* Term | Description
|
||||
* ------------------------- | -------
|
||||
* Standard Interface | Interface defined in this document
|
||||
* Interface Driver | Specific device driver as defined by the iLLD
|
||||
* Standard Interface Driver | Specific interface driver which implements the Standard Interface
|
||||
* API used at runtime | API that are used after initialization
|
||||
* Module | Hardware functional block / IP
|
||||
*
|
||||
* \par Overview
|
||||
* The Standard Interface provides generic runtime API written in C for common use case application. It abstracts the underlaying Interface Driver,
|
||||
* i.e. the runtime API is completely device independent. It provides generic API for common use case application.
|
||||
*
|
||||
* Example of Standard Interface:
|
||||
* - Serial communication interface
|
||||
* - PWM interface
|
||||
* - Position sensor interface
|
||||
* - Timer interface
|
||||
* - EEPROM interface
|
||||
*
|
||||
* The target is to be able to exchange the microcontroller or external connected devices on which the application is based with a minimal impact
|
||||
* on the application code, to reduce the application software development and maintenance effort. This is archived by the Standard Interface,
|
||||
* for which, changing the hardware only requires the update of the device configuration settings and the device initialization code. The API used
|
||||
* at runtime, which represents the majority and the complexitity of the related code keep unchanged.
|
||||
*
|
||||
* Motivation: because the current software developed for the automotive applications mainly don<6F>t use C++, the Standard Interface provides a common
|
||||
* definition for the device driver and an alternative layer for different hardware instead of using C++ interface wrapper class.
|
||||
*
|
||||
*
|
||||
* The below figure shows the layers used and an example of APIs used by the application.
|
||||
* \image html "StandardInterfaceLayers.png" "Standard interface layers"
|
||||
* \image html "StandardInterfaceDataPipeExample.png" "Standard interface example: Serial interface as data pipe"
|
||||
* \image html "StandardInterfaceTimerExample.png" "Standard interface example: Timer"
|
||||
*
|
||||
* The Standard Interface is implemented by Standard Interface wrapper by providing the function pointer to the custom functions. This gives
|
||||
* the possibility to the programmer to use it or not. When used, it increases the code portability but slightly decreases the performance in
|
||||
* term of run time execution and code size. When not used, the performance is not affected.
|
||||
*
|
||||
*
|
||||
* \par Definition
|
||||
* The standard interface requires the definition of at least two components: the standard interface component and the standard interface wrapper
|
||||
* component. The standard interface component defines for each standard interface a standard interface object and a set of standard APIs used at
|
||||
* runtime by the application. The standard interface wrapper component initializes the standard interface component by linking it to the interface
|
||||
* driver.
|
||||
*
|
||||
* \attention: The application shall explicitly use the API provided by the standard interface component at runtime to access driver<65>s parameters
|
||||
* (setter/ getter) or action (methods). Trying to access members of the standard interface component directly though the object may not guaranty
|
||||
* future code compatibility. The same applies to the interface driver (reminder).
|
||||
*
|
||||
*
|
||||
* \par Convention
|
||||
*
|
||||
* The Standard interface defines the following files:
|
||||
* Path/File | Description
|
||||
* ----------------------------------------------- | -----------------
|
||||
* 1_SrvSw/StdIf/IfxStdIf.h | Global standard interface definitions
|
||||
* 1_SrvSw/StdIf/IfxStdIf_\<standard interface\>.h | Specific standard interface definitions
|
||||
* TCxxx/\<Module\>/Ifx\<Module\>_\<interface\>.h/c | Specific standard interface wrapper initialization API are reconized by the name Ifx<Module>_<interface>_StdIf<std interface>Init()
|
||||
* TCxxx/\<Module\>/Ifx\<Module\>_\<interface\>.h/c | Specific standard interface wrapper function API are named according to the interface driver naming rules
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef IFXSTDIF_H_
|
||||
#define IFXSTDIF_H_ 1
|
||||
|
||||
#include "Cpu/Std/Ifx_Types.h"
|
||||
|
||||
typedef void *IfxStdIf_InterfaceDriver; /**< \brief Pointer to the specific interface driver */
|
||||
|
||||
#endif /* IFXSTDIF_H_ */
|
||||
@@ -0,0 +1,72 @@
|
||||
/**
|
||||
* \file IfxStdIf_DPipe.c
|
||||
* \brief Standard interface: Data Pipe
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-27 20:08:23 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 "IfxStdIf_DPipe.h"
|
||||
#include "_Utilities/Ifx_Assert.h"
|
||||
|
||||
#include <string.h>
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
void IfxStdIf_DPipe_print(IfxStdIf_DPipe *stdIf, pchar format, ...)
|
||||
{
|
||||
if (!stdIf->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(stdIf, (void *)message, &count, TIME_INFINITE);
|
||||
}
|
||||
else
|
||||
{
|
||||
//return TRUE;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,401 @@
|
||||
/**
|
||||
* \file IfxStdIf_DPipe.h
|
||||
* \brief Standard interface: Data Pipe
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-27 20:08:24 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_stdif_dpipe Standard interface: Data Pipe
|
||||
* \ingroup library_srvsw_stdif
|
||||
*
|
||||
* The standard interafce data pipe (DPipe) abstract the hardware used for data transfer. It provide, after proper initialization an hardware independant way to write
|
||||
* and read data to/from as communciation channel.
|
||||
*
|
||||
* \par Porting StandardIo to DPipe
|
||||
* replace all
|
||||
* - StandardIo type with IfxStdIf_DPipe
|
||||
* - StandardIo_print with IfxStdIf_DPipe_print
|
||||
* delete StandardIo.c and StandardIo.h
|
||||
* Include "StdIf/IfxStdIf_DPipe.h" instead of "SysSe/Bsp/StandardIo.h"
|
||||
*
|
||||
* The following files are already ported: Ifx_Console, Ifx_Shell
|
||||
*
|
||||
*/
|
||||
#ifndef STDIF_DPIPE_H_
|
||||
#define STDIF_DPIPE_H_ 1
|
||||
|
||||
#include "IfxStdIf.h"
|
||||
//----------------------------------------------------------------------------------------
|
||||
#ifndef ENDL
|
||||
# define ENDL "\r\n"
|
||||
#endif
|
||||
|
||||
/** \brief Forward declaration */
|
||||
typedef struct IfxStdIf_DPipe_ IfxStdIf_DPipe;
|
||||
|
||||
typedef volatile boolean *IfxStdIf_DPipe_WriteEvent;
|
||||
typedef volatile boolean *IfxStdIf_DPipe_ReadEvent;
|
||||
|
||||
/** \brief Size of the buffer allocated on the stack for the print function */
|
||||
#define STDIF_DPIPE_MAX_PRINT_SIZE (255)
|
||||
|
||||
/** \brief Write binary data into the \ref IfxStdIf_DPipe.
|
||||
*
|
||||
* Initially the parameter 'count' specifies count of data to write.
|
||||
* After execution the data pointed by 'count' specifies the data actually written
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
* \param data Pointer to the start of data
|
||||
* \param count Pointer to the count of data (in bytes).
|
||||
* \param timeout in system timer ticks
|
||||
*
|
||||
* \retval TRUE Returns TRUE if all items could be written
|
||||
* \retval FALSE Returns FALSE if not all the items could be written
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_DPipe_Write)(IfxStdIf_InterfaceDriver stdIf, void *data, Ifx_SizeT *count, Ifx_TickTime timeout);
|
||||
|
||||
/** \brief Read data from the \ref IfxStdIf_DPipe object
|
||||
*
|
||||
* Initially the parameter 'count' specifies count of data to read.
|
||||
* After execution the data pointed by 'count' specifies the data actually read.
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
* \param data Pointer to the start of data
|
||||
* \param count Pointer to the count of data (in bytes).
|
||||
* \param timeout in system timer ticks
|
||||
*
|
||||
* \retval TRUE Returns TRUE if all items could be read
|
||||
* \retval FALSE Returns FALSE if not all the items could be read
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_DPipe_Read)(IfxStdIf_InterfaceDriver stdIf, void *data, Ifx_SizeT *count, Ifx_TickTime timeout);
|
||||
|
||||
/** \brief Returns the number of bytes in the rx buffer
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return Returns the number of bytes in the rx buffer
|
||||
*/
|
||||
typedef sint32 (*IfxStdIf_DPipe_GetReadCount)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Returns read event object
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return Returns read event object
|
||||
*/
|
||||
typedef IfxStdIf_DPipe_ReadEvent (*IfxStdIf_DPipe_GetReadEvent)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Returns number of bytes send
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return Returns number of bytes send
|
||||
*/
|
||||
typedef uint32 (*IfxStdIf_DPipe_GetSendCount)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Returns the time stamp of the last transmit data
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return Returns the time stamp of the last transmit data
|
||||
*/
|
||||
typedef Ifx_TickTime (*IfxStdIf_DPipe_GetTxTimeStamp)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Returns the number of free bytes (free space) in the tx buffer
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return Returns the number of free bytes in the tx buffer
|
||||
*/
|
||||
typedef sint32 (*IfxStdIf_DPipe_GetWriteCount)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Returns write event object
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return Returns write event object
|
||||
*/
|
||||
typedef IfxStdIf_DPipe_WriteEvent (*IfxStdIf_DPipe_GetWriteEvent)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Indicates if the required number of bytes are available for read in the buffer
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
* \param count Pointer to the count of data (in bytes).
|
||||
* \param timeout in system timer ticks
|
||||
*
|
||||
* \return Returns TRUE if at least count bytes are available for read in the rx buffer,
|
||||
* if not the Event is armed to be set when the buffer count is bigger or equal to the requested count
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_DPipe_CanReadCount)(IfxStdIf_InterfaceDriver stdIf, Ifx_SizeT count, Ifx_TickTime timeout);
|
||||
|
||||
/** \brief Indicates if there is enough free space to write the data in the buffer
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
* \param count Pointer to the count of data (in bytes).
|
||||
* \param timeout in system timer ticks
|
||||
*
|
||||
* \return Returns TRUE if at least count bytes can be written to the tx buffer,
|
||||
* if not the Event is armed to be set when the buffer free count is bigger or equal to the requested count
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_DPipe_CanWriteCount)(IfxStdIf_InterfaceDriver stdIf, Ifx_SizeT count, Ifx_TickTime timeout);
|
||||
|
||||
/** \brief Flush the transmit buffer by transmitting all data
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
* \param timeout timeout for the flush operation
|
||||
*
|
||||
* \return Returns TRUE if the FIFO is empty
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_DPipe_FlushTx)(IfxStdIf_InterfaceDriver stdIf, Ifx_TickTime timeout);
|
||||
|
||||
/** \brief Clears the RX buffer by removing all data
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
* \return void
|
||||
*/
|
||||
typedef void (*IfxStdIf_DPipe_ClearRx)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Clears the TX buffer by removing all data
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
* \return void
|
||||
*/
|
||||
typedef void (*IfxStdIf_DPipe_ClearTx)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief handler called on reveive event
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_DPipe_OnReceive)(IfxStdIf_InterfaceDriver stdIf);
|
||||
/** \brief handler called on transmit event
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_DPipe_OnTransmit)(IfxStdIf_InterfaceDriver stdIf);
|
||||
/** \brief handler called on error event
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_DPipe_OnError)(IfxStdIf_InterfaceDriver stdIf);
|
||||
/** \brief Reset the sendCount counter
|
||||
*
|
||||
* \param stdif Pointer to the interface driver object
|
||||
*
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_DPipe_ResetSendCount)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Standard interface object
|
||||
*/
|
||||
struct IfxStdIf_DPipe_
|
||||
{
|
||||
IfxStdIf_InterfaceDriver driver; /**< \brief Pointer to the specific driver object */
|
||||
boolean txDisabled; /**< \brief If disabled is set to TRUE, the output is disabled, else enabled */
|
||||
|
||||
/* Standard interface APIs */
|
||||
IfxStdIf_DPipe_Write write; /**< \brief \see IfxStdIf_DPipe_Write */
|
||||
IfxStdIf_DPipe_Read read; /**< \brief \see IfxStdIf_DPipe_Read */
|
||||
IfxStdIf_DPipe_GetReadCount getReadCount; /**< \brief \see IfxStdIf_DPipe_GetReadCount */
|
||||
IfxStdIf_DPipe_GetReadEvent getReadEvent; /**< \brief \see IfxStdIf_DPipe_GetReadEvent */
|
||||
IfxStdIf_DPipe_GetWriteCount getWriteCount; /**< \brief \see IfxStdIf_DPipe_GetWriteCount */
|
||||
IfxStdIf_DPipe_GetWriteEvent getWriteEvent; /**< \brief \see IfxStdIf_DPipe_GetWriteEvent */
|
||||
IfxStdIf_DPipe_CanReadCount canReadCount; /**< \brief \see IfxStdIf_DPipe_CanReadCount */
|
||||
IfxStdIf_DPipe_CanWriteCount canWriteCount; /**< \brief \see IfxStdIf_DPipe_CanWriteCount */
|
||||
IfxStdIf_DPipe_FlushTx flushTx; /**< \brief \see IfxStdIf_DPipe_FlushTx */
|
||||
IfxStdIf_DPipe_ClearTx clearTx; /**< \brief \see IfxStdIf_DPipe_ClearTx */
|
||||
IfxStdIf_DPipe_ClearRx clearRx; /**< \brief \see IfxStdIf_DPipe_ClearRx */
|
||||
IfxStdIf_DPipe_OnReceive onReceive; /**< \brief \see IfxStdIf_DPipe_OnReceive */
|
||||
IfxStdIf_DPipe_OnTransmit onTransmit; /**< \brief \see IfxStdIf_DPipe_OnTransmit */
|
||||
IfxStdIf_DPipe_OnError onError; /**< \brief \see IfxStdIf_DPipe_OnError */
|
||||
|
||||
IfxStdIf_DPipe_GetSendCount getSendCount; /**< \brief \see IfxStdIf_DPipe_GetSendCount */
|
||||
IfxStdIf_DPipe_GetTxTimeStamp getTxTimeStamp; /**< \brief \see IfxStdIf_DPipe_GetTxTimeStamp */
|
||||
IfxStdIf_DPipe_ResetSendCount resetSendCount; /**< \brief \see IfxStdIf_DPipe_ResetSendCount */
|
||||
};
|
||||
/** \addtogroup library_srvsw_stdif_dpipe
|
||||
* \{ */
|
||||
/** \copydoc IfxStdIf_DPipe_Write
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_DPipe_write(IfxStdIf_DPipe *stdIf, void *data, Ifx_SizeT *count, Ifx_TickTime timeout)
|
||||
{
|
||||
return stdIf->write(stdIf->driver, data, count, timeout);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_Read
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_DPipe_read(IfxStdIf_DPipe *stdIf, void *data, Ifx_SizeT *count, Ifx_TickTime timeout)
|
||||
{
|
||||
return stdIf->read(stdIf->driver, data, count, timeout);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_GetReadCount
|
||||
*/
|
||||
IFX_INLINE sint32 IfxStdIf_DPipe_getReadCount(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
return stdIf->getReadCount(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_GetWriteCount
|
||||
*/
|
||||
IFX_INLINE sint32 IfxStdIf_DPipe_getWriteCount(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
return stdIf->getWriteCount(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_CanReadCount
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_DPipe_canReadCount(IfxStdIf_DPipe *stdIf, Ifx_SizeT count, Ifx_TickTime timeout)
|
||||
{
|
||||
return stdIf->canReadCount(stdIf->driver, count, timeout);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_CanWriteCount
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_DPipe_canWriteCount(IfxStdIf_DPipe *stdIf, Ifx_SizeT count, Ifx_TickTime timeout)
|
||||
{
|
||||
return stdIf->canWriteCount(stdIf->driver, count, timeout);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_GetReadEvent
|
||||
*/
|
||||
IFX_INLINE IfxStdIf_DPipe_ReadEvent IfxStdIf_DPipe_getReadEvent(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
return stdIf->getReadEvent(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_GetWriteEvent
|
||||
*/
|
||||
IFX_INLINE IfxStdIf_DPipe_WriteEvent IfxStdIf_DPipe_getWriteEvent(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
return stdIf->getWriteEvent(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_FlushTx
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_DPipe_flushTx(IfxStdIf_DPipe *stdIf, Ifx_TickTime timeout)
|
||||
{
|
||||
return stdIf->flushTx(stdIf->driver, timeout);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_ClearTx
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_DPipe_clearTx(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
stdIf->clearTx(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_ClearRx
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_DPipe_clearRx(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
stdIf->clearRx(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_OnReceive
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_DPipe_onReceive(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
stdIf->onReceive(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_OnTransmit
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_DPipe_onTransmit(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
stdIf->onTransmit(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_OnError
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_DPipe_onError(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
stdIf->onError(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_GetSendCount
|
||||
*/
|
||||
IFX_INLINE uint32 IfxStdIf_DPipe_getSendCount(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
return stdIf->getSendCount(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_GetTxTimeStamp
|
||||
*/
|
||||
IFX_INLINE Ifx_TickTime IfxStdIf_DPipe_getTxTimeStamp(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
return stdIf->getTxTimeStamp(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_DPipe_ResetSendCount
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_DPipe_resetSendCount(IfxStdIf_DPipe *stdIf)
|
||||
{
|
||||
stdIf->resetSendCount(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
IFX_EXTERN void IfxStdIf_DPipe_print(IfxStdIf_DPipe *stdIf, pchar format, ...);
|
||||
|
||||
/** \} */
|
||||
//----------------------------------------------------------------------------------------
|
||||
|
||||
#endif /* STDIF_DPIPE_H_ */
|
||||
@@ -0,0 +1,97 @@
|
||||
/**
|
||||
* \file IfxStdIf_Pos.c
|
||||
* \brief Standard interface: Position interface
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \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 "IfxStdIf_Pos.h"
|
||||
|
||||
void IfxStdIf_Pos_initConfig (IfxStdIf_Pos_Config * config)
|
||||
{
|
||||
config->offset = 0;
|
||||
config->reversed = FALSE;
|
||||
config->resolution = 0;
|
||||
config->periodPerRotation = 1;
|
||||
config->resolutionFactor = IfxStdIf_Pos_ResolutionFactor_oneFold;
|
||||
config->updatePeriod = 0.001;
|
||||
config->speedModeThreshold = 0;
|
||||
config->minSpeed = 0; // 0 rpm
|
||||
config->maxSpeed = 20000.0 / 60.0 * (2 * IFX_PI); // 20000 rpm
|
||||
config->speedFilterEnabled = FALSE;
|
||||
config->speedFilerCutOffFrequency = 0;
|
||||
|
||||
}
|
||||
|
||||
void IfxStdIf_Pos_printStatus(IfxStdIf_Pos *driver, IfxStdIf_DPipe *io)
|
||||
{
|
||||
IfxStdIf_Pos_Status status;
|
||||
status = IfxStdIf_Pos_getFault(driver);
|
||||
|
||||
IfxStdIf_DPipe_print(io, "DSADC RDC status:"ENDL);
|
||||
if (status.status != 0)
|
||||
{
|
||||
if (status.B.commError)
|
||||
{
|
||||
IfxStdIf_DPipe_print(io, "- Communication error"ENDL);
|
||||
}
|
||||
if (status.B.notSynchronised)
|
||||
{
|
||||
IfxStdIf_DPipe_print(io, "- Synchronization error"ENDL);
|
||||
}
|
||||
if (status.B.signalDegradation)
|
||||
{
|
||||
IfxStdIf_DPipe_print(io, "- Signal degradation error"ENDL);
|
||||
}
|
||||
if (status.B.signalLoss)
|
||||
{
|
||||
IfxStdIf_DPipe_print(io, "- Signal loss error"ENDL);
|
||||
}
|
||||
if (status.B.trackingLoss)
|
||||
{
|
||||
IfxStdIf_DPipe_print(io, "- Tracking error"ENDL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
IfxStdIf_DPipe_print(io, "- Ready"ENDL);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,583 @@
|
||||
/**
|
||||
* \file IfxStdIf_Pos.h
|
||||
* \brief Standard interface: Position interface
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \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_stdif_posif Standard interface: Position interface
|
||||
* \ingroup library_srvsw_stdif
|
||||
*
|
||||
* The standard interface position interface (IfxStdIf_Pos) abstract the hardware used for position interface feature like encoder, hall, resolver, ... It provide, after proper initialization an hardware
|
||||
* Independent way to interact with the position sensor like getting position, speed, direction, ...
|
||||
*
|
||||
* The figure below shows the standard position interface.
|
||||
*
|
||||
* \image html "stdif_PosIf.png" "Standard position interface"
|
||||
*
|
||||
* This interface defines the following features:
|
||||
* -
|
||||
*
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef IFXSTDIF_POSIF_H
|
||||
#define IFXSTDIF_POSIF_H 1
|
||||
|
||||
#include "Cpu/Std/Ifx_Types.h"
|
||||
#include "IfxStdIf.h"
|
||||
#include "IfxStdIf_DPipe.h"
|
||||
|
||||
/** \brief Output event enable / disable */
|
||||
typedef enum
|
||||
{
|
||||
IfxStdIf_Pos_MotionType_rotating, /**< \brief Rotating sensor */
|
||||
IfxStdIf_Pos_MotionType_linear /**< \brief Linear sensor */
|
||||
} IfxStdIf_Pos_MotionType;
|
||||
|
||||
/** \brief Output event enable / disable */
|
||||
typedef enum
|
||||
{
|
||||
IfxStdIf_Pos_ResolutionFactor_oneFold = 1, /**< \brief Default, no multipluication factor */
|
||||
IfxStdIf_Pos_ResolutionFactor_twoFold = 2, /**< \brief 2-fold resolution. Valid for encoder */
|
||||
IfxStdIf_Pos_ResolutionFactor_fourFold = 4 /**< \brief 4-fold resolution. Valid for encoder */
|
||||
} IfxStdIf_Pos_ResolutionFactor;
|
||||
|
||||
/** \brief Position sensor Types */
|
||||
typedef enum
|
||||
{
|
||||
IfxStdIf_Pos_SensorType_encoder,
|
||||
IfxStdIf_Pos_SensorType_hall,
|
||||
IfxStdIf_Pos_SensorType_resolver,
|
||||
IfxStdIf_Pos_SensorType_angletrk,
|
||||
IfxStdIf_Pos_SensorType_igmr,
|
||||
IfxStdIf_Pos_SensorType_virtual
|
||||
} IfxStdIf_Pos_SensorType;
|
||||
|
||||
/** \brief Position sensor direction definition */
|
||||
typedef enum
|
||||
{
|
||||
IfxStdIf_Pos_Dir_forward, /**< \brief Forward direction. For rotating position sensor, forward is clockwise rotation */
|
||||
IfxStdIf_Pos_Dir_backward, /**< \brief Backward direction. For rotating position sensor, fackward is counter-clockwise rotation */
|
||||
IfxStdIf_Pos_Dir_unknown /**< \brief Unknown direction */
|
||||
} IfxStdIf_Pos_Dir;
|
||||
|
||||
/** \brief Position sensor status definition */
|
||||
typedef union
|
||||
{
|
||||
uint32 status; /**< \brief Global status access */
|
||||
struct
|
||||
{
|
||||
uint32 notSynchronised : 1; /**< \brief Sensor is not synchronized */
|
||||
uint32 signalLoss : 1; /**< \brief Loss of signal error */
|
||||
uint32 signalDegradation : 1; /**< \brief Signal degradation warning */
|
||||
uint32 trackingLoss : 1; /**< \brief Tracking loss error */
|
||||
uint32 commError : 1; /**< \brief Communication error*/
|
||||
} B; /**< \brief Bitfielf status access */
|
||||
} IfxStdIf_Pos_Status;
|
||||
|
||||
typedef sint32 IfxStdIf_Pos_RawAngle;
|
||||
|
||||
/** \brief Forward declaration */
|
||||
typedef struct IfxStdIf_Pos_ IfxStdIf_Pos;
|
||||
|
||||
/** \brief Return the position, inclusive turns
|
||||
*
|
||||
* Return the sensor position in rad for rotating sensor inclusive turns, or in m for linear sensors.
|
||||
* For linear sensor the effect is the same as IfxStdIf_Pos_GetPosition.
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the position inclusive turns in rad
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_Pos_GetAbsolutePosition)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Handles the zero interrupt
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_OnZeroIrq)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the raw position sensor offset
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the raw position sensor offset sensor in ticks
|
||||
*/
|
||||
typedef sint32 (*IfxStdIf_Pos_GetOffset)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the position
|
||||
*
|
||||
* Return the sensor position in rad for rotating sensor or in m for linear sensors.
|
||||
* For rotating sensor, the position is always between 0 and 2*IFX_PI.
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the position in rad or m
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_Pos_GetPosition)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the direction
|
||||
*
|
||||
* Return the sensor direction.
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the direction
|
||||
*/
|
||||
typedef IfxStdIf_Pos_Dir (*IfxStdIf_Pos_GetDirection)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the sensor status
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the sensor status
|
||||
*/
|
||||
typedef IfxStdIf_Pos_Status (*IfxStdIf_Pos_GetFault)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the period per rotation setting
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the period per rotation setting
|
||||
*/
|
||||
typedef uint16 (*IfxStdIf_Pos_GetPeriodPerRotation)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the raw position in ticks
|
||||
*
|
||||
* Return the sensor raw position in ticks.
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the raw position in ticks
|
||||
*/
|
||||
typedef sint32 (*IfxStdIf_Pos_GetRawPosition)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Get the update period
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the update period in s
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_Pos_GetRefreshPeriod)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Get the resolution
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the resolution
|
||||
*/
|
||||
typedef sint32 (*IfxStdIf_Pos_GetResolution)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Get the sensor type
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the sensor type
|
||||
*/
|
||||
typedef IfxStdIf_Pos_SensorType (*IfxStdIf_Pos_GetSensorType)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the speed
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the speed in rad/s or m/s
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_Pos_GetSpeed)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return position in turn
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return position in turn
|
||||
*/
|
||||
typedef sint32 (*IfxStdIf_Pos_GetTurn)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Handles the A sensor event
|
||||
* Event A is a sensor defined event. it is optional.
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_OnEventA)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Refresh the status
|
||||
*
|
||||
* Update the stdIf state like speed, position, status, taking into account the updatePeriod
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_Update)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Reset the driver
|
||||
*
|
||||
* Clear faults, reset speed and position to 0
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_Reset)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Reset the driver fault
|
||||
*
|
||||
* Clear faults
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_ResetFaults)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Set the sensor offset
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param offset Offset in sensor ticks
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_SetOffset)(IfxStdIf_InterfaceDriver stdIf, sint32 offset);
|
||||
|
||||
/** \brief Set the sensor position (virtual sensor)
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param position Position sensor rad
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_SetPosition)(IfxStdIf_InterfaceDriver stdIf, float32 position);
|
||||
/** \brief Set the sensor position (virtual sensor)
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param position Position sensor ticks
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_SetRawPosition)(IfxStdIf_InterfaceDriver stdIf, sint32 position);
|
||||
|
||||
/** \brief Set the sensor speed (virtual sensor)
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param speed speed in rad/s
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_SetSpeed)(IfxStdIf_InterfaceDriver stdIf, float32 speed);
|
||||
|
||||
/** \brief Set the update period
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param updatePeriod Refresh period in s
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Pos_SetRefreshPeriod)(IfxStdIf_InterfaceDriver stdIf, float32 updatePeriod);
|
||||
|
||||
/** \brief Standard interface object
|
||||
*/
|
||||
struct IfxStdIf_Pos_
|
||||
{
|
||||
IfxStdIf_InterfaceDriver driver; /**< \brief Interface driver object */
|
||||
IfxStdIf_Pos_OnZeroIrq onZeroIrq; /**< \brief \see IfxStdIf_Pos_OnZeroIrq */
|
||||
IfxStdIf_Pos_GetAbsolutePosition getAbsolutePosition; /**< \brief Return the absolute position */
|
||||
IfxStdIf_Pos_GetOffset getOffset; /**< \brief \see IfxStdIf_Pos_GetOffset */
|
||||
IfxStdIf_Pos_GetPosition getPosition; /**< \brief \see IfxStdIf_Pos_GetPosition */
|
||||
IfxStdIf_Pos_GetDirection getDirection; /**< \brief \see IfxStdIf_Pos_GetDirection */
|
||||
IfxStdIf_Pos_GetFault getFault; /**< \brief \see IfxStdIf_Pos_GetFault */
|
||||
IfxStdIf_Pos_GetRawPosition getRawPosition; /**< \brief \see IfxStdIf_Pos_GetRawPosition */
|
||||
IfxStdIf_Pos_GetPeriodPerRotation getPeriodPerRotation; /**< \brief \see IfxStdIf_Pos_GetPeriodPerRotation */
|
||||
IfxStdIf_Pos_GetRefreshPeriod getRefreshPeriod; /**< \brief \see IfxStdIf_Pos_GetRefreshPeriod */
|
||||
IfxStdIf_Pos_GetResolution getResolution; /**< \brief \see IfxStdIf_Pos_GetResolution */
|
||||
IfxStdIf_Pos_GetSensorType getSensorType; /**< \brief \see IfxStdIf_Pos_GetSensorType */
|
||||
IfxStdIf_Pos_GetTurn getTurn; /**< \brief \see IfxStdIf_Pos_GetTurn */
|
||||
IfxStdIf_Pos_OnEventA onEventA; /**< \brief \see IfxStdIf_Pos_OnEventA */
|
||||
IfxStdIf_Pos_Reset reset; /**< \brief \see IfxStdIf_Pos_Reset */
|
||||
IfxStdIf_Pos_ResetFaults resetFaults; /**< \brief \see IfxStdIf_Pos_ResetFaults */
|
||||
IfxStdIf_Pos_GetSpeed getSpeed; /**< \brief \see IfxStdIf_Pos_GetSpeed */
|
||||
IfxStdIf_Pos_Update update; /**< \brief \see IfxStdIf_Pos_Update */
|
||||
IfxStdIf_Pos_SetOffset setOffset; /**< \brief \see IfxStdIf_Pos_SetOffset */
|
||||
IfxStdIf_Pos_SetPosition setPosition; /**< \brief \see IfxStdIf_Pos_SetPosition */
|
||||
IfxStdIf_Pos_SetRawPosition setRawPosition; /**< \brief \see IfxStdIf_Pos_SetRawPosition */
|
||||
IfxStdIf_Pos_SetSpeed setSpeed; /**< \brief \see IfxStdIf_Pos_SetSpeed */
|
||||
IfxStdIf_Pos_SetRefreshPeriod setRefreshPeriod; /**< \brief \see IfxStdIf_Pos_SetRefreshPeriod */
|
||||
};
|
||||
|
||||
/** \brief Position interface configuration */
|
||||
typedef struct
|
||||
{
|
||||
sint32 offset; /**< \brief Position sensor offset */
|
||||
boolean reversed; /**< \brief If true, the sensor direction is reversed */
|
||||
sint32 resolution; /**< \brief Sensor resolution. For encoder with 1024 pulse per revolution, the value should be 1024 */
|
||||
uint16 periodPerRotation; /**< \brief Number of period per rotation. Is usually 1 for encoder */
|
||||
IfxStdIf_Pos_ResolutionFactor resolutionFactor; /**< \brief Resolution multiplier for encoder interface, valid is 2, 4. */
|
||||
float32 updatePeriod; /**< \brief period in seconds, at which the application calls IfxStdIf_Pos_update() */
|
||||
float32 speedModeThreshold; /**< \brief Speed threshold used for the speed calculation mode. For encoder, above the threshold the pulse count mode is used, below the threshold, the time delta is used */
|
||||
float32 minSpeed; /**< \brief Absolute minimal allowed speed. below speed is recognized as 0rad/s */
|
||||
float32 maxSpeed; /**< \brief Absolute maximal allowed speed. Above speed is recognized as error */
|
||||
boolean speedFilterEnabled; /**< \brief Enable / disable the speed low pass filter */
|
||||
float32 speedFilerCutOffFrequency; /**< \brief Speed low pass filter cut off frequency */
|
||||
} IfxStdIf_Pos_Config;
|
||||
|
||||
/** \addtogroup library_srvsw_stdif_posif
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_OnZeroIrq
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_onZeroIrq(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
stdIf->onZeroIrq(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetAbsolutePosition
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Pos_getAbsolutePosition(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getAbsolutePosition(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetFault MCMETILLD-521
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE IfxStdIf_Pos_Status IfxStdIf_Pos_getFault(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getFault(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetOffset
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE sint32 IfxStdIf_Pos_getOffset(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getOffset(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetPosition
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Pos_getPosition(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getPosition(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetDirection
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE IfxStdIf_Pos_Dir IfxStdIf_Pos_getDirection(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getDirection(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetPeriodPerRotation
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE uint16 IfxStdIf_Pos_getPeriodPerRotation(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getPeriodPerRotation(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetRawPosition
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE sint32 IfxStdIf_Pos_getRawPosition(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getRawPosition(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetRefreshPeriod
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Pos_getRefreshPeriod(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getRefreshPeriod(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetResolution
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE sint32 IfxStdIf_Pos_getResolution(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getResolution(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetTurn
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE sint32 IfxStdIf_Pos_getTurn(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getTurn(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetSensorType
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE IfxStdIf_Pos_SensorType IfxStdIf_Pos_getSensorType(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getSensorType(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_GetSpeed
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Pos_getSpeed(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return stdIf->getSpeed(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** Check whether the sensor is faulty
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_Pos_isFault(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
return IfxStdIf_Pos_getFault(stdIf).status != 0;
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_OnEventA
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_onEventA(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
stdIf->onEventA(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_Update
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_update(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
stdIf->update(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_Reset
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_reset(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
stdIf->reset(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_ResetFaults
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_resetFaults(IfxStdIf_Pos *stdIf)
|
||||
{
|
||||
stdIf->resetFaults(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_SetOffset
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_setOffset(IfxStdIf_Pos *stdIf, sint32 offset)
|
||||
{
|
||||
stdIf->setOffset(stdIf->driver, offset);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_SetPosition
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_setPosition(IfxStdIf_Pos *stdIf, float32 position)
|
||||
{
|
||||
stdIf->setPosition(stdIf->driver, position);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_SetRawPosition
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_setRawPosition(IfxStdIf_Pos *stdIf, sint32 position)
|
||||
{
|
||||
stdIf->setRawPosition(stdIf->driver, position);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_SetSpeed
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_setSpeed(IfxStdIf_Pos *stdIf, float32 speed)
|
||||
{
|
||||
stdIf->setSpeed(stdIf->driver, speed);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Pos_SetRefreshPeriod
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Pos_setRefreshPeriod(IfxStdIf_Pos *stdIf, float32 updatePeriod)
|
||||
{
|
||||
stdIf->setRefreshPeriod(stdIf->driver, updatePeriod);
|
||||
}
|
||||
|
||||
|
||||
/** \} */
|
||||
|
||||
/** \brief Converts from rad/s to rpm
|
||||
*
|
||||
* \param speed Specifies the speed in rad/s.
|
||||
*
|
||||
* \return returns the converted speed in rpm.
|
||||
* \see IfxStdIf_Pos_rpmToRads()
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Pos_radsToRpm(float32 speed)
|
||||
{
|
||||
return (60.0 / (2.0 * IFX_PI)) * speed;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Converts from rpm to rad/s
|
||||
*
|
||||
* \param speed Specifies the speed in rpm.
|
||||
*
|
||||
* \return returns the converted speed in rad/s.
|
||||
* \see IfxStdIf_Pos_radsToRpm()
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Pos_rpmToRads(float32 speed)
|
||||
{
|
||||
return speed * ((2.0 * IFX_PI) / 60.0);
|
||||
}
|
||||
|
||||
|
||||
/** Initialize the configuration structure to default
|
||||
*
|
||||
* \param config Position interface configuration. This parameter is initialized by the function
|
||||
*
|
||||
*/
|
||||
IFX_EXTERN void IfxStdIf_Pos_initConfig(IfxStdIf_Pos_Config *config);
|
||||
|
||||
/** \brief Print the device status
|
||||
*
|
||||
* \param driver driver handle
|
||||
* \param io Interface to which the status is output
|
||||
* \return none
|
||||
*/
|
||||
IFX_EXTERN void IfxStdIf_Pos_printStatus(IfxStdIf_Pos *driver, IfxStdIf_DPipe *io);
|
||||
|
||||
|
||||
#endif /* IFXSTDIF_POSIF_H */
|
||||
@@ -0,0 +1,58 @@
|
||||
/**
|
||||
* \file IfxStdIf_PwmHl.c
|
||||
* \brief Standard interface: Multi-channels, dual-complementary PWM interface
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
|
||||
*
|
||||
* $Date: 2014-02-27 20:08:24 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 "IfxStdIf_PwmHl.h"
|
||||
|
||||
void IfxStdIf_PwmHl_initConfig(IfxStdIf_PwmHl_Config *config)
|
||||
{
|
||||
config->deadtime = 0;
|
||||
config->minPulse = 0;
|
||||
config->channelCount = 0;
|
||||
config->emergencyEnabled = FALSE;
|
||||
config->outputMode = IfxPort_OutputMode_pushPull;
|
||||
config->outputDriver = IfxPort_PadDriver_cmosAutomotiveSpeed1;
|
||||
config->ccxActiveState = Ifx_ActiveState_high;
|
||||
config->coutxActiveState = Ifx_ActiveState_high;
|
||||
}
|
||||
@@ -0,0 +1,322 @@
|
||||
/**
|
||||
* \file IfxStdIf_PwmHl.h
|
||||
* \brief Standard interface: Multi-channels, dual-complementary PWM interface
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \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.
|
||||
|
||||
*
|
||||
*
|
||||
* \defgroup library_srvsw_stdif_pwmhl Standard interface: Multi-channels, dual-complementary PWM interface
|
||||
* \ingroup library_srvsw_stdif
|
||||
*
|
||||
* The standard interface pwm high/low (PwmHl) abstract the hardware used for pwm feature. It provide, after proper initialization an hardware
|
||||
* independant way to interact with the PWM functionallity like setting duty cycles, dead time,timer functionalities, ...
|
||||
*
|
||||
* The figure below shows the standard Multi-channels, dual-complementary PWM interface.
|
||||
*
|
||||
* \image html "PwmHl-overview.png" "Standard Multi-channels, dual-complementary PWM interface"
|
||||
*
|
||||
* This PWM interface provides multiple dual-complementary PWM channels.
|
||||
* Each dual-complementary PWM channel is made of two PWM channels, a top channel CCx and a bottom channel COUTx.
|
||||
* The interface implements the \ref library_srvsw_stdif_timer.
|
||||
*
|
||||
* This interface defines the following features:
|
||||
* - Configurable duty cycle from 0% to 100%
|
||||
* - Adjustable dead-time between top and bottom channels
|
||||
* - Center aligned, left aligned, right aligned PWM
|
||||
* - Optional minimal pulse cancellation
|
||||
* - Optional emergency stop
|
||||
* - Configurable signal active state for top and bottom PWM
|
||||
* - Configurable output ports
|
||||
* - Inherit the features from library_srvsw_stdif_timer
|
||||
*
|
||||
* Example of signal generation in center aligned mode:
|
||||
*
|
||||
* \image html "PwmHl-centerAligned.png" "Standard Multi-channels, dual-complementary PWM interface - Center aligned mode"
|
||||
*/
|
||||
|
||||
#ifndef IFXSTDIF_PWMHL_H
|
||||
#define IFXSTDIF_PWMHL_H 1
|
||||
|
||||
#include "IfxStdIf.h"
|
||||
#include "IfxStdIf_Timer.h"
|
||||
|
||||
/** \brief Forward declaration */
|
||||
typedef struct IfxStdIf_PwmHl_ IfxStdIf_PwmHl;
|
||||
|
||||
/** \brief Set the dead time in s
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param deadtime deadtime in second
|
||||
* \retval TRUE In case of success
|
||||
* \retval FALSE In case of failure
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_PwmHl_SetDeadtime)(IfxStdIf_InterfaceDriver stdIf, float32 deadtime);
|
||||
|
||||
/** \brief Return the dead time in s
|
||||
*
|
||||
* It returns the last dead time values set by IfxStdIf_PwmHl_SetDeadtime() or during initialisation
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Returns the deadtime in second
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_PwmHl_GetDeadtime)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Set the minimum pulse time in s
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param minPulse minimal pulse in second
|
||||
* \retval TRUE In case of success
|
||||
* \retval FALSE In case of failure
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_PwmHl_SetMinPulse)(IfxStdIf_InterfaceDriver stdIf, float32 minPulse);
|
||||
|
||||
/** \brief Return the minimum pulse time in s
|
||||
*
|
||||
* It returns the last minimum pulse time values set by IfxStdIf_PwmHl_SetMinPulse() or during initialisation
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Returns the minimum pulse time in second
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_PwmHl_GetMinPulse)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the PWM mode
|
||||
*
|
||||
* It returns the last pwm mode set by IfxStdIf_PwmHl_SetMode() or during initialisation
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Returns the pwm mode
|
||||
*/
|
||||
typedef Ifx_Pwm_Mode (*IfxStdIf_PwmHl_GetMode)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Set the pwm mode
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param mode PWM mode
|
||||
* \retval TRUE In case of success
|
||||
* \retval FALSE In case of failure (feature not supported)
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_PwmHl_SetMode)(IfxStdIf_InterfaceDriver stdIf, Ifx_Pwm_Mode mode);
|
||||
|
||||
/** \brief Set the pwm ON time
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param tOn Pointer to an array of ON times in ticks. The array size must be equal to the number of PWM channels
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_PwmHl_SetOnTime)(IfxStdIf_InterfaceDriver stdIf, Ifx_TimerValue *tOn);
|
||||
|
||||
/** \brief Set the pwm ON time and shift value
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param tOn Pointer to an array of ON times in ticks. The array size must be equal to the number of PWM channels
|
||||
* \param shift Pointer to an array of shift values in ticks. The array size must be equal to the number of PWM channels
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_PwmHl_SetOnTimeAndShift)(IfxStdIf_InterfaceDriver stdIf, Ifx_TimerValue *tOn, Ifx_TimerValue *shift);
|
||||
|
||||
/** \brief Set the pwm pulse of all switched independently
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param tOn Pointer to an array of ON times in s. The array size must be equal to the number of PWM channels times 2. Parameters order is Phase 0 top, phase 1 top, ... phase 0 bottom, phase 1 botteom, ...
|
||||
* \param offset Pointer to an array of offset values in s. The array size must be equal to the number of PWM channels times 2. Parameters order is Phase 0 top, phase 1 top, ... phase 0 bottom, phase 1 botteom, ...
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_PwmHl_SetPulse)(IfxStdIf_InterfaceDriver stdIf, float32 *tOn, float32 *offset);
|
||||
|
||||
/** \brief Set channels which are generating PWM or in "stuck-at" state.
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param activeCh Pointer to boolean array containing values for PWM channels.
|
||||
* If FALSE, the channel will be in stuck-at state, else the channel will generate PWM.
|
||||
*
|
||||
* \param stuckSt Pointer to boolean array containing values for active channels.
|
||||
* If FALSE, the stuck-at state is passive level, else the stuck-at state is active level.
|
||||
*
|
||||
* \note The values for the parameters are arranged as follows:
|
||||
* index = 0 --> phase 0 top
|
||||
* index = 1 --> phase 0 bottom
|
||||
* index = 2 --> phase 1 top
|
||||
* index = 3 --> phase 1 bottom
|
||||
* index = 4 --> phase 2 top
|
||||
* index = 5 --> phase 2 bottom
|
||||
*/
|
||||
typedef void (*IfxStdIf_PwmHl_SetupChannels)(IfxStdIf_InterfaceDriver stdIf, boolean *activeCh, boolean *stuckSt);
|
||||
|
||||
/** \brief Standard interface object
|
||||
*/
|
||||
struct IfxStdIf_PwmHl_
|
||||
{
|
||||
IfxStdIf_InterfaceDriver driver; /**< \brief Interface driver object */
|
||||
|
||||
/* PWM related APIs*/
|
||||
IfxStdIf_PwmHl_SetDeadtime setDeadtime; /**< \brief IfxStdIf_PwmHl_SetDeadtime */
|
||||
IfxStdIf_PwmHl_GetDeadtime getDeadtime; /**< \brief IfxStdIf_PwmHl_GetDeadtime */
|
||||
IfxStdIf_PwmHl_SetMinPulse setMinPulse; /**< \brief IfxStdIf_PwmHl_SetMinPulse */
|
||||
IfxStdIf_PwmHl_GetMinPulse getMinPulse; /**< \brief IfxStdIf_PwmHl_GetMinPulse */
|
||||
IfxStdIf_PwmHl_GetMode getMode; /**< \brief IfxStdIf_PwmHl_GetMode */
|
||||
IfxStdIf_PwmHl_SetMode setMode; /**< \brief IfxStdIf_PwmHl_SetMode */
|
||||
IfxStdIf_PwmHl_SetOnTime setOnTime; /**< \brief IfxStdIf_PwmHl_SetOnTime */
|
||||
IfxStdIf_PwmHl_SetOnTimeAndShift setOnTimeAndShift; /**< \brief IfxStdIf_PwmHl_SetOnTime */
|
||||
IfxStdIf_PwmHl_SetPulse setPulse; /**< \brief IfxStdIf_PwmHl_Pulse */
|
||||
IfxStdIf_PwmHl_SetupChannels setupChannels; /**< \brief IfxStdIf_PwmHl_SetupChannels */
|
||||
|
||||
IfxStdIf_Timer timer; /**< \brief Timer related standard interface */
|
||||
};
|
||||
|
||||
/** \brief Multi-channels PWM object configuration */
|
||||
typedef struct
|
||||
{
|
||||
float32 deadtime; /**< \brief Dead time between the top and bottom channels in seconds */
|
||||
float32 minPulse; /**< \brief Min pulse allowed as active state for the top and bottom PWM in seconds */
|
||||
uint8 channelCount; /**< \brief Number of PWM channels, one channel is made of a top and bottom channel */
|
||||
boolean emergencyEnabled; /**< \brief Specifies if the emergency stop should be enabled or not */
|
||||
|
||||
IfxPort_OutputMode outputMode; /**< \brief Output mode of ccx and coutx pins */
|
||||
IfxPort_PadDriver outputDriver; /**< \brief Output pad driver of ccx and coutx pins */
|
||||
|
||||
Ifx_ActiveState ccxActiveState; /**< \brief Top PWM active state */
|
||||
Ifx_ActiveState coutxActiveState; /**< \brief Bottom PWM active state */
|
||||
} IfxStdIf_PwmHl_Config;
|
||||
|
||||
/** \addtogroup library_srvsw_stdif_pwmhl
|
||||
* \{
|
||||
*/
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_SetDeadtime
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_PwmHl_setDeadtime(IfxStdIf_PwmHl *stdIf, float32 deadtime)
|
||||
{
|
||||
return stdIf->setDeadtime(stdIf->driver, deadtime);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_GetDeadtime
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_PwmHl_getDeadtime(IfxStdIf_PwmHl *stdIf)
|
||||
{
|
||||
return stdIf->getDeadtime(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_SetMinPulse
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_PwmHl_setMinPulse(IfxStdIf_PwmHl *stdIf, float32 minPulse)
|
||||
{
|
||||
return stdIf->setMinPulse(stdIf->driver, minPulse);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_GetMinPulse
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_PwmHl_getMinPulse(IfxStdIf_PwmHl *stdIf)
|
||||
{
|
||||
return stdIf->getMinPulse(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_GetMode
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE Ifx_Pwm_Mode IfxStdIf_PwmHl_getMode(IfxStdIf_PwmHl *stdIf)
|
||||
{
|
||||
return stdIf->getMode(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_SetMode
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_PwmHl_setMode(IfxStdIf_PwmHl *stdIf, Ifx_Pwm_Mode mode)
|
||||
{
|
||||
return stdIf->setMode(stdIf->driver, mode);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_SetOnTime
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_PwmHl_setOnTime(IfxStdIf_PwmHl *stdIf, Ifx_TimerValue *tOn)
|
||||
{
|
||||
stdIf->setOnTime(stdIf->driver, tOn);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_SetOnTimeAndShift
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_PwmHl_setOnTimeAndShift(IfxStdIf_PwmHl *stdIf, Ifx_TimerValue *tOn, Ifx_TimerValue *shift)
|
||||
{
|
||||
stdIf->setOnTimeAndShift(stdIf->driver, tOn, shift);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_SetPulse
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_PwmHl_setPulse(IfxStdIf_PwmHl *stdIf, float32 *tOn, float32 *offset)
|
||||
{
|
||||
stdIf->setPulse(stdIf->driver, tOn, offset);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_PwmHl_SetupChannels
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_PwmHl_setupChannels(IfxStdIf_PwmHl *stdIf, boolean *activeCh, boolean *stuckSt)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
IFX_UNUSED_PARAMETER(activeCh);
|
||||
IFX_UNUSED_PARAMETER(stuckSt);
|
||||
}
|
||||
|
||||
/** \brief Return the timer standard interface used by the IfxStdIf_PwmHl standard interface
|
||||
* \param stdIf Standard interface pointer
|
||||
* \return Returns the pointer to the IfxStdIf_Timer object
|
||||
*/
|
||||
IFX_INLINE IfxStdIf_Timer *IfxStdIf_PwmHl_getTimer(IfxStdIf_PwmHl *stdIf)
|
||||
{
|
||||
return &stdIf->timer;
|
||||
}
|
||||
|
||||
|
||||
/** \} */
|
||||
|
||||
/** Initialize the configuration structure to default
|
||||
*
|
||||
* \param config Timer configuration. This parameter is initialised by the function
|
||||
*
|
||||
*/
|
||||
IFX_EXTERN void IfxStdIf_PwmHl_initConfig(IfxStdIf_PwmHl_Config *config);
|
||||
|
||||
#endif /* IFXSTDIF_PWMHL_H */
|
||||
@@ -0,0 +1,165 @@
|
||||
/**
|
||||
* \file IfxStdIf_Timer.c
|
||||
* \brief Standard interface: Timer
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \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.
|
||||
|
||||
*
|
||||
*/
|
||||
|
||||
#include "IfxStdIf_Timer.h"
|
||||
|
||||
void IfxStdIf_Timer_initConfig(IfxStdIf_Timer_Config *config)
|
||||
{
|
||||
config->frequency = 1000;
|
||||
config->isrPriority = 0;
|
||||
config->isrProvider = IfxSrc_Tos_cpu0;
|
||||
config->minResolution = 0;
|
||||
config->trigger.outputMode = IfxPort_OutputMode_pushPull;
|
||||
config->trigger.outputDriver = IfxPort_PadDriver_cmosAutomotiveSpeed1;
|
||||
config->trigger.risingEdgeAtPeriod = FALSE;
|
||||
config->trigger.outputEnabled = FALSE;
|
||||
config->trigger.enabled = FALSE;
|
||||
config->trigger.triggerPoint = 0;
|
||||
config->trigger.isrPriority = 0;
|
||||
config->trigger.isrProvider = IfxSrc_Tos_cpu0;
|
||||
config->countDir = IfxStdIf_Timer_CountDir_up;
|
||||
config->startOffset = 0.0;
|
||||
}
|
||||
|
||||
|
||||
static float32 IfxStdIf_Timer_nopGetFrequency(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
return 0.0;
|
||||
}
|
||||
static Ifx_TimerValue IfxStdIf_Timer_nopGetPeriod(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
return 0;
|
||||
}
|
||||
static float32 IfxStdIf_Timer_nopGetResolution(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
return 0.0;
|
||||
}
|
||||
static Ifx_TimerValue IfxStdIf_Timer_nopGetTrigger(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
return 0;
|
||||
}
|
||||
static boolean IfxStdIf_Timer_nopSetFrequency(IfxStdIf_InterfaceDriver stdIf, float32 frequency)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
IFX_UNUSED_PARAMETER(frequency);
|
||||
return FALSE;
|
||||
}
|
||||
static void IfxStdIf_Timer_nopUpdateInputFrequency(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
}
|
||||
static void IfxStdIf_Timer_nopApplyUpdate(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
}
|
||||
static void IfxStdIf_Timer_nopDisableUpdate(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
}
|
||||
static float32 IfxStdIf_Timer_nopGetInputFrequency(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
return 0.0;
|
||||
}
|
||||
static void IfxStdIf_Timer_nopRun(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
}
|
||||
static boolean IfxStdIf_Timer_nopSetPeriod(IfxStdIf_InterfaceDriver stdIf, Ifx_TimerValue period)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
IFX_UNUSED_PARAMETER(period);
|
||||
return FALSE;
|
||||
}
|
||||
static void IfxStdIf_Timer_nopSetSingleMode(IfxStdIf_InterfaceDriver stdIf, boolean enabled)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
IFX_UNUSED_PARAMETER(enabled);
|
||||
}
|
||||
static void IfxStdIf_Timer_nopSetTrigger(IfxStdIf_InterfaceDriver stdIf, Ifx_TimerValue triggerPoint)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
IFX_UNUSED_PARAMETER(triggerPoint);
|
||||
}
|
||||
static void IfxStdIf_Timer_nopStop(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
}
|
||||
static boolean IfxStdIf_Timer_nopAckTimerIrq(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
return FALSE;
|
||||
}
|
||||
static boolean IfxStdIf_Timer_nopAckTriggerIrq(IfxStdIf_InterfaceDriver stdIf)
|
||||
{
|
||||
IFX_UNUSED_PARAMETER(stdIf);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
|
||||
void IfxStdIf_Timer_initStdIf(IfxStdIf_Timer *stdIf, IfxStdIf_InterfaceDriver driver)
|
||||
{
|
||||
stdIf->driver = driver;
|
||||
stdIf->getFrequency =&IfxStdIf_Timer_nopGetFrequency ;
|
||||
stdIf->getPeriod =&IfxStdIf_Timer_nopGetPeriod ;
|
||||
stdIf->getResolution =&IfxStdIf_Timer_nopGetResolution ;
|
||||
stdIf->getTrigger =&IfxStdIf_Timer_nopGetTrigger ;
|
||||
stdIf->setFrequency =&IfxStdIf_Timer_nopSetFrequency ;
|
||||
stdIf->updateInputFrequency =&IfxStdIf_Timer_nopUpdateInputFrequency;
|
||||
stdIf->applyUpdate =&IfxStdIf_Timer_nopApplyUpdate ;
|
||||
stdIf->disableUpdate =&IfxStdIf_Timer_nopDisableUpdate ;
|
||||
stdIf->getInputFrequency =&IfxStdIf_Timer_nopGetInputFrequency ;
|
||||
stdIf->run =&IfxStdIf_Timer_nopRun ;
|
||||
stdIf->setPeriod =&IfxStdIf_Timer_nopSetPeriod ;
|
||||
stdIf->setSingleMode =&IfxStdIf_Timer_nopSetSingleMode ;
|
||||
stdIf->setTrigger =&IfxStdIf_Timer_nopSetTrigger ;
|
||||
stdIf->stop =&IfxStdIf_Timer_nopStop ;
|
||||
stdIf->ackTimerIrq =&IfxStdIf_Timer_nopAckTimerIrq ;
|
||||
stdIf->ackTriggerIrq =&IfxStdIf_Timer_nopAckTriggerIrq ;
|
||||
}
|
||||
@@ -0,0 +1,481 @@
|
||||
/**
|
||||
* \file IfxStdIf_Timer.h
|
||||
* \brief Standard interface: Timer
|
||||
* \ingroup IfxStdIf
|
||||
*
|
||||
* \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_stdif_timer Standard interface: Timer
|
||||
* \ingroup library_srvsw_stdif
|
||||
*
|
||||
* The standard interface timer (Timer) abstract the hardware used for timer feature. It provide, after proper initialization an hardware
|
||||
* independant way to interact with the timer functionallity like setting period, trigger points, ...
|
||||
*
|
||||
* The figure below shows the standard timer interface.
|
||||
*
|
||||
* \image html "Timer.png" "Standard timer interface"
|
||||
*
|
||||
* This interface defines the following features:
|
||||
* - Timer with configurable frequency
|
||||
* - Configurable counting direction
|
||||
* - Optional interrupt on timer event with configurable service request provider and priority
|
||||
* - Optional trigger signal with:
|
||||
* - Optional interrupt on trigger event with configurable service request provider and priority
|
||||
* - Configurable trigger point
|
||||
* - Configurable trigger edge
|
||||
* - trigger signal can be internal only or forwarded to a port pin
|
||||
*/
|
||||
|
||||
#ifndef IFXSTDIF_TIMER_H
|
||||
#define IFXSTDIF_TIMER_H 1
|
||||
|
||||
#include "Cpu/Std/Ifx_Types.h"
|
||||
#include "Src/Std/IfxSrc.h"
|
||||
#include "Port/Std/IfxPort.h"
|
||||
#include "IfxStdIf.h"
|
||||
/** \brief Output event enable / disable */
|
||||
typedef enum
|
||||
{
|
||||
IfxStdIf_Timer_Output_disabled, /**< \brief Timer output is set to the inactive, no change in the output */
|
||||
IfxStdIf_Timer_Output_enabled /**< \brief In case the trigger is enabled,
|
||||
* the output is set to active between time 0 to the trigger point,
|
||||
* and is set to inactive between the trigger point and the period.
|
||||
* In case the trigger is disabled and counting direction if IfxStdIf_Timer_CountDir_up, the output is toggled when the timer is reset
|
||||
* In case the trigger is disabled and counting direction if IfxStdIf_Timer_CountDir_down, the output is toggled when the timer is reloaded
|
||||
* In case the trigger is disabled and counting direction if IfxStdIf_Timer_CountDir_upAndDown, the output is toggled when the timer reach 0
|
||||
* In case the trigger is enabled the trigger is active before the trigger point and inactive after the trigger point.
|
||||
*/
|
||||
} IfxStdIf_Timer_OutputEvent;
|
||||
|
||||
/** \brief Timer increment direction */
|
||||
typedef enum
|
||||
{
|
||||
IfxStdIf_Timer_CountDir_up, /**< \brief Timer is counting up */
|
||||
IfxStdIf_Timer_CountDir_upAndDown, /**< \brief Timer is counting up and down */
|
||||
IfxStdIf_Timer_CountDir_down /**< \brief Timer is counting down */
|
||||
} IfxStdIf_Timer_CountDir;
|
||||
|
||||
/** \brief Forward declaration */
|
||||
typedef struct IfxStdIf_Timer_ IfxStdIf_Timer;
|
||||
|
||||
/** \brief Return the timer frequency in Hz
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the timer frequency in Hz
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_Timer_GetFrequency)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the timer period in ticks
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the timer period in ticks
|
||||
*/
|
||||
typedef Ifx_TimerValue (*IfxStdIf_Timer_GetPeriod)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the timer resolution in seconds
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the timer resolution in seconds
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_Timer_GetResolution)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the timer trigger point
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the timer timer point
|
||||
*/
|
||||
typedef Ifx_TimerValue (*IfxStdIf_Timer_GetTrigger)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Set the timer frequency in Hz
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param frequency Requested timer frequency in Hz
|
||||
* \retval TRUE The requested frequency could be set
|
||||
* \retval FALSE The requested frequency is out of range
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_Timer_SetFrequency)(IfxStdIf_InterfaceDriver stdIf, float32 frequency);
|
||||
|
||||
/** \brief Indicates the stdIf that the imput frequency has changed and that it should be taken in account
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Timer_UpdateInputFrequency)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Apply requested updates.
|
||||
*
|
||||
* Such requested update are calls to:
|
||||
* - IfxStdIf_Timer_setSingleMode()
|
||||
* - IfxStdIf_Timer_setTrigger()
|
||||
* - IfxStdIf_Timer_setPeriod() or IfxStdIf_Timer_setFrequency()
|
||||
* as well as PWM generation related calls such as:
|
||||
* - IfxStdIf_PwmHl_setDeadtime()
|
||||
* - IfxStdIf_PwmHl_setMode()
|
||||
* - IfxStdIf_PwmHl_setOnTime()
|
||||
* - IfxStdIf_PwmHl_setupChannels()
|
||||
*
|
||||
* It is important to note, that only one call to Timer_applyUpdate() is allowed within
|
||||
* one timer period!!!
|
||||
* In order to ensure correct update synchronisation, disableUpdate() should have been called previously.
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Timer_ApplyUpdate)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Disable updates
|
||||
*
|
||||
* The following API action will not be taken in account before applyUpdate is called:
|
||||
* - IfxStdIf_Timer_setSingleMode()
|
||||
* - IfxStdIf_Timer_setTrigger()
|
||||
* - IfxStdIf_Timer_setPeriod() or IfxStdIf_Timer_setFrequency()
|
||||
* as well as PWM generation related calls such as:
|
||||
* - IfxStdIf_PwmHl_setDeadtime()
|
||||
* - IfxStdIf_PwmHl_setMode()
|
||||
* - IfxStdIf_PwmHl_setOnTime()
|
||||
* - IfxStdIf_PwmHl_setupChannels()
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return None
|
||||
*/
|
||||
typedef void (*IfxStdIf_Timer_DisableUpdate)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the timer input frequency in Hz
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the timer input frequency in Hz
|
||||
*/
|
||||
typedef float32 (*IfxStdIf_Timer_GetInputFrequency)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Immediately start the timer.
|
||||
*
|
||||
* Please note that other mechanism may avoid the timer to tick, such as when the
|
||||
* global (input) clock to the timer block is inactive.
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_Timer_Run)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Set the timer period.
|
||||
*
|
||||
* Timer_applyUpdate() shall be invoked in order this to take effect.
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param period Period value in ticks
|
||||
* \retval TRUE The requested period could be set
|
||||
* \retval FALSE The requested period is out of range
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_Timer_SetPeriod)(IfxStdIf_InterfaceDriver stdIf, Ifx_TimerValue period);
|
||||
|
||||
/** \brief Stop timer at the end of the period
|
||||
*
|
||||
* Timer_applyUpdate() shall be invoked in order this to take effect.
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param enabled If TRUE, enable the single mode, else disable the single mode (continuous mode)
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_Timer_SetSingleMode)(IfxStdIf_InterfaceDriver stdIf, boolean enabled);
|
||||
|
||||
/** \brief Set trigger point.
|
||||
*
|
||||
* \see Timer_OutputEvent for the definition of the output level.
|
||||
* Active state is defined by Timer_Config::outputActiveState.
|
||||
*
|
||||
* Timer_applyUpdate() shall be invoked in order this to take effect.
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param triggerPoint Trigger point in ticks from the period start.
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_Timer_SetTrigger)(IfxStdIf_InterfaceDriver stdIf, Ifx_TimerValue triggerPoint);
|
||||
|
||||
/** \brief Immediately stops the timer
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return none
|
||||
*/
|
||||
typedef void (*IfxStdIf_Timer_Stop)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the timer interrupt flag and reset it
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the timer interrupt flag
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_Timer_AckTimerIrq)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Return the trigger interrupt flag and reset it
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \return Return the trigger interrupt flag
|
||||
*/
|
||||
typedef boolean (*IfxStdIf_Timer_AckTriggerIrq)(IfxStdIf_InterfaceDriver stdIf);
|
||||
|
||||
/** \brief Standard interface object
|
||||
*/
|
||||
struct IfxStdIf_Timer_
|
||||
{
|
||||
IfxStdIf_InterfaceDriver driver; /**< \brief Interface driver object */
|
||||
IfxStdIf_Timer_GetFrequency getFrequency; /**< \brief \see IfxStdIf_Timer_GetFrequency */
|
||||
IfxStdIf_Timer_GetPeriod getPeriod; /**< \brief \see IfxStdIf_Timer_GetPeriod */
|
||||
IfxStdIf_Timer_GetResolution getResolution; /**< \brief \see IfxStdIf_Timer_GetResolution */
|
||||
IfxStdIf_Timer_GetTrigger getTrigger; /**< \brief \see IfxStdIf_Timer_GetTrigger */
|
||||
IfxStdIf_Timer_SetFrequency setFrequency; /**< \brief \see IfxStdIf_Timer_SetFrequency */
|
||||
IfxStdIf_Timer_UpdateInputFrequency updateInputFrequency; /**< \brief \see IfxStdIf_Timer_UpdateInputFrequency */
|
||||
IfxStdIf_Timer_ApplyUpdate applyUpdate; /**< \brief \see IfxStdIf_Timer_ApplyUpdate */
|
||||
IfxStdIf_Timer_DisableUpdate disableUpdate; /**< \brief \see IfxStdIf_Timer_DisableUpdate */
|
||||
IfxStdIf_Timer_GetInputFrequency getInputFrequency; /**< \brief \see IfxStdIf_Timer_GetInputFrequency */
|
||||
IfxStdIf_Timer_Run run; /**< \brief \see IfxStdIf_Timer_Run */
|
||||
IfxStdIf_Timer_SetPeriod setPeriod; /**< \brief \see IfxStdIf_Timer_SetPeriod */
|
||||
IfxStdIf_Timer_SetSingleMode setSingleMode; /**< \brief \see IfxStdIf_Timer_SetSingleMode */
|
||||
IfxStdIf_Timer_SetTrigger setTrigger; /**< \brief \see IfxStdIf_Timer_SetTrigger */
|
||||
IfxStdIf_Timer_Stop stop; /**< \brief \see IfxStdIf_Timer_Stop */
|
||||
IfxStdIf_Timer_AckTimerIrq ackTimerIrq; /**< \brief \see IfxStdIf_Timer_AckTimerIrq */
|
||||
IfxStdIf_Timer_AckTriggerIrq ackTriggerIrq; /**< \brief \see IfxStdIf_Timer_AckTriggerIrq */
|
||||
};
|
||||
|
||||
/** \brief Trigger configuration */
|
||||
typedef struct
|
||||
{
|
||||
boolean enabled; /**< \brief If true, the trigger functionality is Initialised, else ignored */
|
||||
Ifx_TimerValue triggerPoint; /**< \brief Trigger point in timer ticks */
|
||||
Ifx_Priority isrPriority; /**< \brief Interrupt isrPriority of the trigger interrupt, if 0 the interrupt is disable */
|
||||
IfxSrc_Tos isrProvider; /**< \brief Interrupt service provider for the trigger interrupt */
|
||||
IfxPort_OutputMode outputMode; /**< \brief Output mode */
|
||||
IfxPort_PadDriver outputDriver; /**< \brief Output pad driver */
|
||||
boolean risingEdgeAtPeriod; /**< \brief Set the clock signal polarity, if TRUE, the rising edge is at the period, else at the trigger offset. When the timer is stopped, the output is set to high */
|
||||
boolean outputEnabled; /**< \brief If TRUE, the output pin is enabled, else disabled. In case the output is disabled, the output pin is not initialized. */
|
||||
} IfxStdIf_Timer_TrigConfig;
|
||||
|
||||
/** \brief Timer configuration */
|
||||
typedef struct
|
||||
{
|
||||
float32 frequency; /**< \brief PWM frequency in Hz. This parameter is only used to initialise the timer structure. An additional cell is required to build the timer. */
|
||||
Ifx_Priority isrPriority; /**< \brief Interrupt isrPriority of the timer interrupt, if 0 the interrupt is disable */
|
||||
IfxSrc_Tos isrProvider; /**< \brief Interrupt service provider for the timer interrupt */
|
||||
float32 minResolution; /**< \brief Minimum resolution of the timer in seconds. if 0, this parameter is ignored. If the configuration does not enable this setting a warning is given */
|
||||
IfxStdIf_Timer_TrigConfig trigger; /**< \brief Trigger configuration */
|
||||
IfxStdIf_Timer_CountDir countDir; /**< \brief Timer counting mode */
|
||||
float32 startOffset; /**< \brief FIXME make startOffset as Ifx_TimerValue. Timer initial offset in % of the period */
|
||||
} IfxStdIf_Timer_Config;
|
||||
|
||||
/** \addtogroup library_srvsw_stdif_timer
|
||||
* \{
|
||||
*/
|
||||
/** \copydoc IfxStdIf_Timer_GetFrequency
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Timer_getFrequency(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return stdIf->getFrequency(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_GetPeriod
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE Ifx_TimerValue IfxStdIf_Timer_getPeriod(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return stdIf->getPeriod(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_GetTrigger
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE Ifx_TimerValue IfxStdIf_Timer_getTrigger(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return stdIf->getTrigger(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_GetResolution
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Timer_getResolution(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return stdIf->getResolution(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_SetFrequency
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_Timer_setFrequency(IfxStdIf_Timer *stdIf, float32 frequency)
|
||||
{
|
||||
return stdIf->setFrequency(stdIf->driver, frequency);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_UpdateInputFrequency
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Timer_updateInputFrequency(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
stdIf->updateInputFrequency(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_ApplyUpdate
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Timer_applyUpdate(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
stdIf->applyUpdate(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_DisableUpdate
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Timer_disableUpdate(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
stdIf->disableUpdate(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_GetInputFrequency
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Timer_getInputFrequency(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return stdIf->getInputFrequency(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_Run
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Timer_run(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
stdIf->run(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_SetPeriod
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_Timer_setPeriod(IfxStdIf_Timer *stdIf, Ifx_TimerValue period)
|
||||
{
|
||||
return stdIf->setPeriod(stdIf->driver, period);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_SetSingleMode
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Timer_setSingleMode(IfxStdIf_Timer *stdIf, boolean enabled)
|
||||
{
|
||||
stdIf->setSingleMode(stdIf->driver, enabled);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_SetTrigger
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Timer_setTrigger(IfxStdIf_Timer *stdIf, Ifx_TimerValue triggerPoint)
|
||||
{
|
||||
stdIf->setTrigger(stdIf->driver, triggerPoint);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_Stop
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE void IfxStdIf_Timer_stop(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
stdIf->stop(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_AckTimerIrq
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_Timer_ackTimerIrq(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return stdIf->ackTimerIrq(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \copydoc IfxStdIf_Timer_AckTriggerIrq
|
||||
* \param stdIf Standard interface pointer
|
||||
*/
|
||||
IFX_INLINE boolean IfxStdIf_Timer_ackTriggerIrq(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return stdIf->ackTriggerIrq(stdIf->driver);
|
||||
}
|
||||
|
||||
|
||||
/** \brief Convert timer ticks to seconds
|
||||
* \param clockFreq Timer clock frequency
|
||||
* \param ticks time value in ticks to be converted
|
||||
* \return Return the converted time in s
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Timer_tickToS(float32 clockFreq, Ifx_TimerValue ticks)
|
||||
{
|
||||
return ticks / clockFreq;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Convert seconds to timer ticks
|
||||
* \param clockFreq Timer clock frequency
|
||||
* \param seconds time value in seconds to be converted
|
||||
* \return Return the converted time in timer ticks
|
||||
*/
|
||||
IFX_INLINE Ifx_TimerValue IfxStdIf_Timer_sToTick(float32 clockFreq, float32 seconds)
|
||||
{
|
||||
return seconds * clockFreq;
|
||||
}
|
||||
|
||||
|
||||
/** \brief Return the timer period in second
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
*/
|
||||
IFX_INLINE float32 IfxStdIf_Timer_getPeriodSecond(IfxStdIf_Timer *stdIf)
|
||||
{
|
||||
return IfxStdIf_Timer_tickToS(IfxStdIf_Timer_getInputFrequency(stdIf), stdIf->getPeriod(stdIf->driver));
|
||||
}
|
||||
|
||||
|
||||
/** \} */
|
||||
|
||||
/** Initialize the configuration structure to default
|
||||
*
|
||||
* \param config Timer configuration. This parameter is initialised by the function
|
||||
*
|
||||
*/
|
||||
IFX_EXTERN void IfxStdIf_Timer_initConfig(IfxStdIf_Timer_Config *config);
|
||||
|
||||
/** Initialize the stdIf so that all call back function default to no operation
|
||||
*
|
||||
* \param stdIf Pointer to the interface driver object
|
||||
* \param driver Interface driver object
|
||||
*
|
||||
*/
|
||||
IFX_EXTERN void IfxStdIf_Timer_initStdIf(IfxStdIf_Timer *stdIf, IfxStdIf_InterfaceDriver driver);
|
||||
|
||||
#endif /* IFXSTDIF_TIMER_H */
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 4.8 KiB |
Binary file not shown.
|
After Width: | Height: | Size: 12 KiB |
BIN
libraries/infineon_libraries/Service/CpuGeneric/StdIf/Timer.png
Normal file
BIN
libraries/infineon_libraries/Service/CpuGeneric/StdIf/Timer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 7.8 KiB |
Reference in New Issue
Block a user