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

etpu_cam.h File Reference


Detailed Description

This file contains useful macros and prototypes for CAM API.

Author:
Milan Brejl [r54529]
Version:
1.0
Date:
16-Mar-2014

Definition in file etpu_cam.h.

#include "etpu_util.h"
#include "etpu_cam_auto.h"

Go to the source code of this file.

Defines

#define FS_ETPU_CAM_LOG_FALLING   FS_ETPU_CAM_FM0_LOG_FALLING
#define FS_ETPU_CAM_LOG_RISING   FS_ETPU_CAM_FM1_LOG_RISING
#define FS_ETPU_CAM_LOG_BOTH   (FS_ETPU_CAM_FM0_LOG_FALLING + FS_ETPU_CAM_FM1_LOG_RISING)

Functions

uint32_t fs_etpu_cam_init (struct cam_instance_t *p_cam_instance, struct cam_config_t *p_cam_config)
 This function initializes eTPU channels to run CAM function.
uint32_t fs_etpu_cam_config (struct cam_instance_t *p_cam_instance, struct cam_config_t *p_cam_config)
 This function changes the CAM configuration.
uint32_t fs_etpu_cam_get_states (struct cam_instance_t *p_cam_instance, struct cam_states_t *p_cam_states)
 This function reads state parameter values of the CAM function.
uint32_t * fs_etpu_cam_copy_log (struct cam_instance_t *p_cam_instance, uint32_t *p_cam_log)
 This function copies the CAM log into another array in RAM.
uint32_t fs_etpu_cam_reset_log (struct cam_instance_t *p_cam_instance)
 This function resets the index to the CAM log so that the next detected transition is logged to the first position. Before that, the internal log_count variable is set to the number of logged transitions before the reset. If this number is 0 the channel interrupt is raised together with setting the error FS_ETPU_CAM_ERROR_ZERO_TRANS.


Define Documentation

#define FS_ETPU_CAM_LOG_BOTH   (FS_ETPU_CAM_FM0_LOG_FALLING + FS_ETPU_CAM_FM1_LOG_RISING)
 

Definition at line 35 of file etpu_cam.h.

#define FS_ETPU_CAM_LOG_FALLING   FS_ETPU_CAM_FM0_LOG_FALLING
 

CAM Mode

Definition at line 33 of file etpu_cam.h.

#define FS_ETPU_CAM_LOG_RISING   FS_ETPU_CAM_FM1_LOG_RISING
 

Definition at line 34 of file etpu_cam.h.


Function Documentation

uint32_t fs_etpu_cam_config struct cam_instance_t p_cam_instance,
struct cam_config_t p_cam_config
 

This function changes the CAM configuration.

Note:
The following actions are performed in order:
  1. Write FM bits
Parameters:
*p_cam_instance - This is a pointer to the instance structure cam_instance_t.
*p_cam_config - This is a pointer to the structure of configuration parameters cam_config_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 173 of file etpu_cam.c.

References cam_instance_t::chan_num, and cam_config_t::mode.

uint32_t* fs_etpu_cam_copy_log struct cam_instance_t p_cam_instance,
uint32_t *  p_cam_log
 

This function copies the CAM log into another array in RAM.

Note:
The following actions are performed in order:
  1. Copy out data from eTPU DATA RAM.
Parameters:
*p_cam_instance - This is a pointer to the instance structure cam_instance_t.
*p_cam_log - This is a pointer where the Cam log will be copied to. The Cam log is an array of input transitions captured. Each item is a 32-bit word which includes:
  • transition polarity (0-falling, 1-rising) in upper 8 bits
  • transition TCR2 angle in lower 24 bits. The amount of data copied in bytes is 4 * p_cam_instance->log_size.
Returns:
A pointer to a memory location just after the copied data.

Definition at line 240 of file etpu_cam.c.

References cam_instance_t::cpba_log, and cam_instance_t::log_size.

uint32_t fs_etpu_cam_get_states struct cam_instance_t p_cam_instance,
struct cam_states_t p_cam_states
 

This function reads state parameter values of the CAM function.

Note:
The following actions are performed in order:
  1. Read output parameter values from eTPU DATA RAM
  2. Clear CAM error flags in eTPU DATA RAM
Parameters:
*p_cam_instance - This is a pointer to the instance structure cam_instance_t.
*p_cam_states - This is a pointer to the structure of states cam_states_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 201 of file etpu_cam.c.

References cam_instance_t::cpba, cam_states_t::error, FS_ETPU_CAM_OFFSET_ERROR, FS_ETPU_CAM_OFFSET_LOG_COUNT, FS_ETPU_CAM_OFFSET_LOG_IDX, cam_states_t::log_count, and cam_states_t::log_idx.

uint32_t fs_etpu_cam_init struct cam_instance_t p_cam_instance,
struct cam_config_t p_cam_config
 

This function initializes eTPU channels to run CAM function.

Note:
The following actions are performed in order:
  1. Use user-defined CPBA or allocate new eTPU DATA RAM
  2. Write chan config registers and FM bits
  3. Write channel parameters
  4. Write HSR
  5. Set channel priority
Parameters:
*p_cam_instance - This is a pointer to the instance structure cam_instance_t.
*p_cam_config - This is a pointer to the structure of configuration parameters cam_config_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_MALLOC - eTPU DATA RAM memory allocation error
  • FS_ETPU_ERROR_NONE - No error
Warning:
This function does not configure the pins, only the eTPU channels.

Definition at line 89 of file etpu_cam.c.

References cam_instance_t::chan_num, cam_instance_t::cpba, cam_instance_t::cpba_log, FS_ETPU_CAM_ERROR_NO, FS_ETPU_CAM_FUNCTION_NUMBER, FS_ETPU_CAM_HSR_INIT, FS_ETPU_CAM_NUM_PARMS, FS_ETPU_CAM_OFFSET_ERROR, FS_ETPU_CAM_OFFSET_LOG, FS_ETPU_CAM_OFFSET_LOG_COUNT, FS_ETPU_CAM_OFFSET_LOG_IDX, FS_ETPU_CAM_OFFSET_LOG_SIZE, FS_ETPU_CAM_TABLE_SELECT, fs_etpu_data_ram_start, cam_instance_t::log_size, cam_config_t::mode, and cam_instance_t::priority.

uint32_t fs_etpu_cam_reset_log struct cam_instance_t p_cam_instance  ) 
 

This function resets the index to the CAM log so that the next detected transition is logged to the first position. Before that, the internal log_count variable is set to the number of logged transitions before the reset. If this number is 0 the channel interrupt is raised together with setting the error FS_ETPU_CAM_ERROR_ZERO_TRANS.

Note:
The following actions are performed in order:
  1. Check HSR is 0
  2. Write HSR
Parameters:
*p_cam_instance - This is a pointer to the instance structure cam_instance_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error.
  • FS_ETPU_ERROR_TIMING - The reset was not done because there is a HSR pending on the eTPU channel. It can be caused by a call of another API function which writes the HSR to the same channel shortly before this function call. Try to repeat the function call several microseconds later.

Definition at line 286 of file etpu_cam.c.

References cam_instance_t::chan_num, and FS_ETPU_CAM_HSR_RESET.