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

etpu_crank.h File Reference


Detailed Description

This file contains useful macros and prototypes for CRANK API.

Author:
Milan Brejl [r54529]
Version:
1.1
Date:
29-Jun-2015

Definition in file etpu_crank.h.

#include "etpu_util.h"
#include "etpu_crank_auto.h"

Go to the source code of this file.

Functions

uint32_t fs_etpu_crank_init (struct crank_instance_t *p_crank_instance, struct crank_config_t *p_crank_config)
 This function initializes eTPU channels to run CRANK function.
uint32_t fs_etpu_crank_config (struct crank_instance_t *p_crank_instance, struct crank_config_t *p_crank_config)
 This function changes the CRANK configuration.
uint32_t fs_etpu_crank_get_states (struct crank_instance_t *p_crank_instance, struct crank_states_t *p_crank_states)
 This function reads state parameter values of the CRANK function.
uint32_t fs_etpu_crank_set_sync (struct crank_instance_t *p_crank_instance, uint24_t tcr2_adjustment)
 This function adjusts the TCR2 angle counter and asks the eTPU to set the global engine position status to FULL_SYNC.
uint24_t * fs_etpu_crank_copy_tooth_period_log (struct crank_instance_t *p_crank_instance, uint24_t *p_tooth_period_log)
 This function copies the CRANK tooth_period_log into another array in RAM.
uint32_t fs_etpu_crank_get_angle_reseting (void)
 This function returns the engine angle as a number of TCR2 ticks in a range 0 to (tcr2_ticks_per_tooth*teeth_per_cycle - 1), corresponding to 0-720 degrees.


Function Documentation

uint32_t fs_etpu_crank_config struct crank_instance_t p_crank_instance,
struct crank_config_t p_crank_config
 

This function changes the CRANK configuration.

Note:
The following actions are performed in order:
  1. Write configuration parameter values to eTPU DATA RAM
Parameters:
*p_crank_instance - This is a pointer to the instance structure crank_instance_t.
*p_crank_config - This is a pointer to the structure of configuration parameters crank_config_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 268 of file etpu_crank.c.

References crank_config_t::blank_teeth, crank_config_t::blank_time, crank_instance_t::cpba, crank_config_t::first_tooth_timeout, FS_ETPU_CRANK_OFFSET_BLANK_TEETH, FS_ETPU_CRANK_OFFSET_BLANK_TIME, FS_ETPU_CRANK_OFFSET_FIRST_TOOTH_TIMEOUT, FS_ETPU_CRANK_OFFSET_GAP_RATIO, FS_ETPU_CRANK_OFFSET_TEETH_PER_SYNC, FS_ETPU_CRANK_OFFSET_WIN_RATIO_ACROSS_GAP, FS_ETPU_CRANK_OFFSET_WIN_RATIO_AFTER_GAP, FS_ETPU_CRANK_OFFSET_WIN_RATIO_AFTER_TIMEOUT, FS_ETPU_CRANK_OFFSET_WIN_RATIO_NORMAL, crank_config_t::gap_ratio, crank_config_t::teeth_per_sync, crank_config_t::win_ratio_across_gap, crank_config_t::win_ratio_after_gap, crank_config_t::win_ratio_after_timeout, and crank_config_t::win_ratio_normal.

uint24_t* fs_etpu_crank_copy_tooth_period_log struct crank_instance_t p_crank_instance,
uint24_t *  p_tooth_period_log
 

This function copies the CRANK tooth_period_log into another array in RAM.

Parameters:
*p_crank_instance - This is a pointer to the instance structure crank_instance_t.
*p_tooth_period_log - This is a pointer where the CRANK tooth_period_log will be copied to. The amount of data copied in bytes is 4 * p_crank_instance->teeth_per_cycle.
Returns:
A pointer to a memory location just after the copied data.

Definition at line 390 of file etpu_crank.c.

References crank_instance_t::cpba_tooth_period_log, and crank_instance_t::teeth_per_cycle.

uint32_t fs_etpu_crank_get_angle_reseting void   ) 
 

This function returns the engine angle as a number of TCR2 ticks in a range 0 to (tcr2_ticks_per_tooth*teeth_per_cycle - 1), corresponding to 0-720 degrees.

Returns:
A number of TCR2 ticks which determines the actual engine angle. The value 0 corresponds to the first tooth after gap. A maximum number is (tcr2_ticks_per_tooth*teeth_per_cycle - 1).

Definition at line 423 of file etpu_crank.c.

References FS_ETPU_OFFSET_ENG_CYCLE_TCR2_START, and FS_ETPU_OFFSET_ENG_CYCLE_TCR2_TICKS.

uint32_t fs_etpu_crank_get_states struct crank_instance_t p_crank_instance,
struct crank_states_t p_crank_states
 

This function reads state parameter values of the CRANK function.

Note:
The following actions are performed in order:
  1. Read parameter values from eTPU DATA RAM
  2. Clear Crank error
Parameters:
*p_crank_instance - This is a pointer to the instance structure crank_instance_t.
*p_crank_states - This is a pointer to the structure of states crank_states_t which is updated.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 312 of file etpu_crank.c.

References crank_instance_t::cpba, crank_states_t::eng_pos_state, crank_states_t::error, FS_ETPU_CRANK_OFFSET_ERROR, FS_ETPU_CRANK_OFFSET_LAST_TOOTH_PERIOD, FS_ETPU_CRANK_OFFSET_STATE, FS_ETPU_CRANK_OFFSET_TOOTH_COUNTER_CYCLE, FS_ETPU_CRANK_OFFSET_TOOTH_COUNTER_GAP, fs_etpu_data_ram_start, FS_ETPU_OFFSET_ENG_POS_STATE, crank_states_t::last_tooth_period, crank_states_t::state, crank_states_t::tooth_counter_cycle, and crank_states_t::tooth_counter_gap.

uint32_t fs_etpu_crank_init struct crank_instance_t p_crank_instance,
struct crank_config_t p_crank_config
 

This function initializes eTPU channels to run CRANK 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 and global parameters
  4. Write HSR
  5. Set channel priority
Parameters:
*p_crank_instance - This is a pointer to the instance structure crank_instance_t.
*p_crank_config - This is a pointer to the structure of configuration parameters crank_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 147 of file etpu_crank.c.

References crank_config_t::blank_teeth, crank_config_t::blank_time, crank_instance_t::chan_num, crank_instance_t::cpba, crank_instance_t::cpba_tooth_period_log, crank_config_t::first_tooth_timeout, FS_ETPU_CRANK_ERR_NO_ERROR, FS_ETPU_CRANK_FM1_TOOTH_PERIODS_LOG_ON, FS_ETPU_CRANK_FUNCTION_NUMBER, FS_ETPU_CRANK_HSR_INIT, FS_ETPU_CRANK_NUM_PARMS, FS_ETPU_CRANK_OFFSET_BLANK_TEETH, FS_ETPU_CRANK_OFFSET_BLANK_TIME, FS_ETPU_CRANK_OFFSET_ERROR, FS_ETPU_CRANK_OFFSET_FIRST_TOOTH_TIMEOUT, FS_ETPU_CRANK_OFFSET_GAP_RATIO, FS_ETPU_CRANK_OFFSET_LAST_TOOTH_PERIOD, FS_ETPU_CRANK_OFFSET_LAST_TOOTH_TCR1_TIME, FS_ETPU_CRANK_OFFSET_LINK_1, FS_ETPU_CRANK_OFFSET_LINK_2, FS_ETPU_CRANK_OFFSET_LINK_3, FS_ETPU_CRANK_OFFSET_LINK_4, FS_ETPU_CRANK_OFFSET_LINK_CAM, FS_ETPU_CRANK_OFFSET_MISSCNT_MASK, FS_ETPU_CRANK_OFFSET_STATE, FS_ETPU_CRANK_OFFSET_TCR2_ADJUSTMENT, FS_ETPU_CRANK_OFFSET_TCR2_TICKS_PER_ADD_TOOTH, FS_ETPU_CRANK_OFFSET_TCR2_TICKS_PER_TOOTH, FS_ETPU_CRANK_OFFSET_TEETH_IN_GAP, FS_ETPU_CRANK_OFFSET_TEETH_PER_CYCLE, FS_ETPU_CRANK_OFFSET_TEETH_PER_SYNC, FS_ETPU_CRANK_OFFSET_TEETH_TILL_GAP, FS_ETPU_CRANK_OFFSET_TOOTH_COUNTER_CYCLE, FS_ETPU_CRANK_OFFSET_TOOTH_COUNTER_GAP, FS_ETPU_CRANK_OFFSET_TOOTH_PERIOD_LOG, FS_ETPU_CRANK_OFFSET_WIN_RATIO_ACROSS_GAP, FS_ETPU_CRANK_OFFSET_WIN_RATIO_AFTER_GAP, FS_ETPU_CRANK_OFFSET_WIN_RATIO_AFTER_TIMEOUT, FS_ETPU_CRANK_OFFSET_WIN_RATIO_NORMAL, FS_ETPU_CRANK_SEEK, FS_ETPU_CRANK_TABLE_SELECT, fs_etpu_data_ram_start, FS_ETPU_ENG_POS_SEEK, FS_ETPU_OFFSET_ENG_CYCLE_TCR2_START, FS_ETPU_OFFSET_ENG_CYCLE_TCR2_TICKS, FS_ETPU_OFFSET_ENG_POS_STATE, crank_config_t::gap_ratio, crank_instance_t::link_1, crank_instance_t::link_2, crank_instance_t::link_3, crank_instance_t::link_4, crank_instance_t::link_cam, crank_instance_t::log_tooth_periods, crank_instance_t::polarity, crank_instance_t::priority, crank_instance_t::tcr2_ticks_per_add_tooth, crank_instance_t::tcr2_ticks_per_tooth, crank_instance_t::teeth_in_gap, crank_instance_t::teeth_per_cycle, crank_config_t::teeth_per_sync, crank_instance_t::teeth_till_gap, crank_config_t::win_ratio_across_gap, crank_config_t::win_ratio_after_gap, crank_config_t::win_ratio_after_timeout, and crank_config_t::win_ratio_normal.

uint32_t fs_etpu_crank_set_sync struct crank_instance_t p_crank_instance,
uint24_t  tcr2_adjustment
 

This function adjusts the TCR2 angle counter and asks the eTPU to set the global engine position status to FULL_SYNC.

Note:
The following actions are performed in order:
  1. Write channel parameter tcr2_adjustment
  2. Write HSR FS_ETPU_CRANK_HSR_SET_SYNC
Parameters:
*p_crank_instance - This is a pointer to the instance structure crank_instance_t.
tcr2_adjustment - This is the TCR2 angle value corresponding to the fisrt tooth after the gap at which the recognized Cam log ends.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 355 of file etpu_crank.c.

References crank_instance_t::chan_num, crank_instance_t::cpba, FS_ETPU_CRANK_HSR_SET_SYNC, and FS_ETPU_CRANK_OFFSET_TCR2_ADJUSTMENT.