Freescale Semiconductor Inc.
Main Page | Data Structures | File List | Data Fields | Globals

etpu_knock.h

Go to the documentation of this file.
00001 /*******************************************************************************
00002 *
00003 * Freescale Semiconductor Inc.
00004 * (c) Copyright 2004-2014 Freescale Semiconductor, Inc.
00005 * ALL RIGHTS RESERVED.
00006 *
00007 ****************************************************************************//*!
00008 *
00009 * @file    etpu_knock.h
00010 *
00011 * @author  Milan Brejl [r54529]
00012 *
00013 * @version 1.0
00014 *
00015 * @date    17-Mar-2014
00016 *
00017 * @brief   This file contains useful macros and prototypes for KNOCK API.
00018 *
00019 *******************************************************************************/
00020 #ifndef _ETPU_KNOCK_H_
00021 #define _ETPU_KNOCK_H_
00022 
00023 /*******************************************************************************
00024 * Includes
00025 *******************************************************************************/
00026 #include "etpu_util.h"        /* 24-bit types */
00027 #include "etpu_knock_auto.h"    /* auto generated header file */
00028 
00029 /*******************************************************************************
00030 * Definitions
00031 *******************************************************************************/
00032 
00033 /*******************************************************************************
00034 * Type Definitions
00035 *******************************************************************************/
00036 /** A structure to represent an instance of KNOCK.
00037  *  It includes static KNOCK initialization items. */
00038 struct knock_instance_t
00039 {
00040   const uint8_t  chan_num;  /**< Channel number of the KNOCK channel. */
00041   const uint8_t  priority;  /**< Channel priority for the KNOCK channel. */
00042   const uint8_t  polarity;  /**< KNOCK polarity. It can one any of:
00043     - @ref FS_ETPU_KNOCK_FM0_ACTIVE_HIGH - active output signal state is high
00044     - @ref FS_ETPU_KNOCK_FM0_ACTIVE_LOW - active output signal state is low */
00045   const uint24_t  tdc_angle; /**< The cylinder Top Dead Center as a number
00046     of TCR2 angle ticks relative to zero engine angle, in a range corresponding
00047     to 0-720 degrees. */
00048         uint32_t *cpba;     /**< Channel parameter base address.
00049     Set cpba = 0 to use automatic allocation of eTPU DATA RAM for KNOCK channel
00050     parameters using the eTPU utility function fs_etpu_malloc (recommanded),
00051     or assign the cpba manually by an address where the KNOCK channel parameter
00052     space will start from, e.g. 0xC3FC8100. */
00053         uint32_t *cpba_windows; /**< Base address of the knock windows array in
00054     eTPU DATA RAM. Set cpba_windows = 0 to use automatic allocation of the
00055     eTPU DATA RAM space corresponding to the window_count value,
00056     using the eTPU utility function fs_etpu_malloc (recommanded),
00057     or assign the cpba_windows manually by an address, e.g. 0xC3FC8100. */
00058 };
00059 
00060 
00061 /** A structure to represent a configuration of KNOCK.
00062  *  It includes KNOCK configuration items which can be changed in run-time. */
00063 struct knock_config_t
00064 {
00065   uint8_t  mode;  /**< KNOCK mode. It can one of:
00066     - @ref FS_ETPU_KNOCK_FM1_MODE_GATE
00067     - @ref FS_ETPU_KNOCK_FM1_MODE_TRIGGER */
00068   uint8_t  window_count;  /**< The count of knock windows. */
00069   struct knock_window_config_t *p_knock_window_config; /**< Pointer to the first
00070     item of an array of the knockection configuration structures. */
00071    int24_t trigger_period;  /**< The trigger signal (50% duty-cycle PWM) period
00072     as a number of TCR1 ticks. */
00073   uint8_t  irq_dma_options;  /**< Enables to generate channel interrupt and/or
00074     DMA requests at selectable moments.
00075     It can be assigned none, one, or more values from:
00076     - @ref FS_ETPU_KNOCK_IRQ_AT_WINDOW_START
00077     - @ref FS_ETPU_KNOCK_IRQ_AT_WINDOW_END
00078     - @ref FS_ETPU_KNOCK_IRQ_AT_EVERY_TRIGGER
00079     - @ref FS_ETPU_KNOCK_DMA_AT_WINDOW_START
00080     - @ref FS_ETPU_KNOCK_DMA_AT_WINDOW_END
00081     - @ref FS_ETPU_KNOCK_DMA_AT_EVERY_TRIGGER */
00082 };
00083 
00084 
00085 /** A structure to represent a single knock window configuration. */
00086 struct knock_window_config_t
00087 {
00088    int24_t angle_start;  /**< The tdc_angle-relative window start angle as a
00089     number of TCR2 ticks. Positive values precede the TDC, negative go after. */
00090    int24_t angle_width;  /**< The window width as a number of TCR2 ticks. */
00091 };
00092 
00093 
00094 /*******************************************************************************
00095 * Function prototypes
00096 *******************************************************************************/
00097 /* Initialize */
00098 uint32_t fs_etpu_knock_init(
00099   struct knock_instance_t   *p_knock_instance,
00100   struct knock_config_t     *p_knock_config);
00101 
00102 /* Change configuration */
00103 uint32_t fs_etpu_knock_config(
00104   struct knock_instance_t *p_knock_instance,
00105   struct knock_config_t   *p_knock_config);
00106 
00107 #endif /* _ETPU_KNOCK_H_ */
00108 /*******************************************************************************
00109  *
00110  * Copyright:
00111  *  Freescale Semiconductor, INC. All Rights Reserved.
00112  *  You are hereby granted a copyright license to use, modify, and
00113  *  distribute the SOFTWARE so long as this entire notice is
00114  *  retained without alteration in any modified and/or redistributed
00115  *  versions, and that such modified versions are clearly identified
00116  *  as such. No licenses are granted by implication, estoppel or
00117  *  otherwise under any patents or trademarks of Freescale
00118  *  Semiconductor, Inc. This software is provided on an "AS IS"
00119  *  basis and without warranty.
00120  *
00121  *  To the maximum extent permitted by applicable law, Freescale
00122  *  Semiconductor DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
00123  *  INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
00124  *  PARTICULAR PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH
00125  *  REGARD TO THE SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
00126  *  AND ANY ACCOMPANYING WRITTEN MATERIALS.
00127  *
00128  *  To the maximum extent permitted by applicable law, IN NO EVENT
00129  *  SHALL Freescale Semiconductor BE LIABLE FOR ANY DAMAGES WHATSOEVER
00130  *  (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
00131  *  BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
00132  *  PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
00133  *
00134  *  Freescale Semiconductor assumes no responsibility for the
00135  *  maintenance and support of this software
00136  ******************************************************************************/
00137 /*******************************************************************************
00138  *
00139  * REVISION HISTORY:
00140  *
00141  * FILE OWNER: Milan Brejl [r54529]
00142  *
00143  * Revision 1.0  2014/03/17  r54529
00144  * Minor comment and formating improvements.
00145  * Ready for eTPU Engine Control Library release 1.0.
00146  *
00147  * Revision 0.1  2013/09/09  r54529
00148  * Initial version of file.
00149  ******************************************************************************/