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

etpu_cam.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_cam.h
00010 *
00011 * @author  Milan Brejl [r54529]
00012 *
00013 * @version 1.0
00014 *
00015 * @date    16-Mar-2014
00016 *
00017 * @brief   This file contains useful macros and prototypes for CAM API.
00018 *
00019 *******************************************************************************/
00020 #ifndef _ETPU_CAM_H_
00021 #define _ETPU_CAM_H_
00022 
00023 /*******************************************************************************
00024 * Includes
00025 *******************************************************************************/
00026 #include "etpu_util.h"        /* 24-bit types */
00027 #include "etpu_cam_auto.h"    /* auto generated header file */
00028 
00029 /*******************************************************************************
00030 * Definitions
00031 *******************************************************************************/
00032 /** CAM Mode */
00033 #define FS_ETPU_CAM_LOG_FALLING   FS_ETPU_CAM_FM0_LOG_FALLING
00034 #define FS_ETPU_CAM_LOG_RISING    FS_ETPU_CAM_FM1_LOG_RISING
00035 #define FS_ETPU_CAM_LOG_BOTH     (FS_ETPU_CAM_FM0_LOG_FALLING + FS_ETPU_CAM_FM1_LOG_RISING)
00036 
00037 /*******************************************************************************
00038 * Type Definitions
00039 *******************************************************************************/
00040 /** A structure to represent an instance of CAM.
00041  *  It includes static CAM initialization items. */
00042 struct cam_instance_t
00043 {
00044   const uint8_t  chan_num;  /**< Channel number of the CAM channel. */
00045   const uint8_t  priority;  /**< Channel priority for the CAM channel. */
00046   const uint8_t  log_size;  /**< CAM log array size as a number of logged
00047                                  items. */
00048         uint32_t *cpba;     /**< Channel parameter base address.
00049     Set cpba = 0 to use automatic allocation of eTPU DATA RAM for CAM channel
00050     parameters using the eTPU utility function fs_etpu_malloc (recommanded),
00051     or assign the cpba manually by an address where the CAM channel parameter
00052     space will start from, e.g. 0xC3FC8100. */
00053         uint32_t *cpba_log; /**< Pointer to the CAM log buffer in eTPU DATA RAM.
00054     Set cpba_log = 0 to use automatic allocation of eTPU DATA RAM for the CAM
00055     buffer using the eTPU utility function fs_etpu_malloc (recommanded), or
00056     assign the cpba_log manually by an address where the CAM buffer will start.*/
00057 };
00058 
00059 /** A structure to represent a configuration of CAM.
00060  *  It includes CAM configuration items which can be changed in
00061  *  run-time. */
00062 struct cam_config_t
00063 {
00064         uint8_t  mode;      /**< CAM mode.
00065     It defines which type of transitions are logged. It can be one of:
00066     - @ref FS_ETPU_CAM_LOG_FALLING
00067     - @ref FS_ETPU_CAM_LOG_RISING
00068     - @ref FS_ETPU_CAM_LOG_BOTH */
00069 };
00070 
00071 /** A structure to represent internal states of CAM. */
00072 struct cam_states_t
00073 {
00074         uint8_t error;      /**< This is the error status of CAM. It includes
00075     the following error flags:
00076     - @ref FS_ETPU_CAM_ERROR_ZERO_TRANS
00077     - @ref FS_ETPU_CAM_ERROR_LOG_OVERFLOW
00078     The eTPU sets the error flags, the CPU clears them after reading. */
00079         uint8_t log_count; /**< This is a count of transitions logged during
00080     the last completed engine cycle. */
00081         uint8_t log_idx; /**< This is an index of the first free position
00082     in the log buffer, starting at 0. log_idx is copied to log_count before
00083     resetting. */
00084 };
00085 
00086 /*******************************************************************************
00087 * Function prototypes
00088 *******************************************************************************/
00089 /* Initialize */
00090 uint32_t fs_etpu_cam_init(
00091   struct cam_instance_t *p_cam_instance,
00092   struct cam_config_t   *p_cam_config);
00093 
00094 /* Change configuration */
00095 uint32_t fs_etpu_cam_config(
00096   struct cam_instance_t *p_cam_instance,
00097   struct cam_config_t   *p_cam_config);
00098 
00099 /* Get states */
00100 uint32_t fs_etpu_cam_get_states(
00101   struct cam_instance_t *p_cam_instance,
00102   struct cam_states_t   *p_cam_states);
00103 
00104 /* Copy log */
00105 uint32_t *fs_etpu_cam_copy_log(
00106   struct cam_instance_t *p_cam_instance,
00107                uint32_t *p_cam_log);
00108 
00109 /* Reset log */
00110 uint32_t fs_etpu_cam_reset_log(
00111   struct cam_instance_t *p_cam_instance);
00112 
00113 
00114 #endif /* _ETPU_CAM_H_ */
00115 /*******************************************************************************
00116  *
00117  * Copyright:
00118  *  Freescale Semiconductor, INC. All Rights Reserved.
00119  *  You are hereby granted a copyright license to use, modify, and
00120  *  distribute the SOFTWARE so long as this entire notice is
00121  *  retained without alteration in any modified and/or redistributed
00122  *  versions, and that such modified versions are clearly identified
00123  *  as such. No licenses are granted by implication, estoppel or
00124  *  otherwise under any patents or trademarks of Freescale
00125  *  Semiconductor, Inc. This software is provided on an "AS IS"
00126  *  basis and without warranty.
00127  *
00128  *  To the maximum extent permitted by applicable law, Freescale
00129  *  Semiconductor DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED,
00130  *  INCLUDING IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A
00131  *  PARTICULAR PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH
00132  *  REGARD TO THE SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF)
00133  *  AND ANY ACCOMPANYING WRITTEN MATERIALS.
00134  *
00135  *  To the maximum extent permitted by applicable law, IN NO EVENT
00136  *  SHALL Freescale Semiconductor BE LIABLE FOR ANY DAMAGES WHATSOEVER
00137  *  (INCLUDING WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS,
00138  *  BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER
00139  *  PECUNIARY LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
00140  *
00141  *  Freescale Semiconductor assumes no responsibility for the
00142  *  maintenance and support of this software
00143  ******************************************************************************/
00144 /*******************************************************************************
00145  *
00146  * REVISION HISTORY:
00147  *
00148  * FILE OWNER: Milan Brejl [r54529]
00149  *
00150  * Revision 1.0  2014/03/16  r54529
00151  * Minor comment and formating improvements.
00152  * Ready for eTPU Engine Control Library release 1.0.
00153  *
00154  * Revision 0.2  2014/01/23  r54529
00155  * fs_etpu_cam_reset_log() added.
00156  *
00157  * Revision 0.1  2012/06/13  r54529
00158  * Initial version of file.
00159  ******************************************************************************/