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

etpu_spark.c File Reference


Detailed Description

This file contains API for using the eTPU function Spark (SPARK).

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

Definition in file etpu_spark.c.

#include "etpu_spark.h"
#include "etpu_util.h"

Go to the source code of this file.

Functions

uint32_t fs_etpu_spark_init (struct spark_instance_t *p_spark_instance, struct spark_config_t *p_spark_config)
 This function initializes eTPU channels to run SPARK function.
uint32_t fs_etpu_spark_config (struct spark_instance_t *p_spark_instance, struct spark_config_t *p_spark_config)
 This function changes the SPARK configuration.
uint32_t fs_etpu_spark_get_states (struct spark_instance_t *p_spark_instance, struct spark_states_t *p_spark_states)
 This function reads SPARK state variables, including error flags, and clears the eTPU error after reading.

Variables

uint32_t fs_etpu_data_ram_start
uint32_t fs_etpu_data_ram_ext


Function Documentation

uint32_t fs_etpu_spark_config struct spark_instance_t p_spark_instance,
struct spark_config_t p_spark_config
 

This function changes the SPARK configuration.

Note:
The following actions are performed in order:
  1. Write configuration parameter values to eTPU DATA RAM
  2. Write HSR
Warning:
The new single spark configurations (array of single spark structures) must fit into the eTPU DATA RAM already allocated. It means the spark_count can only be lower or the same as the value provided on initialization.
Parameters:
*p_spark_instance - This is a pointer to the instance structure spark_instance_t.
*p_spark_config - This is a pointer to the structure of configuration parameters spark_config_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error
  • FS_ETPU_ERROR_TIMING - The mode was not set because there is a HSR pending on the eTPU channel. It can be caused by a call of an 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 216 of file etpu_spark.c.

References spark_config_t::angle_offset_recalc, spark_instance_t::chan_num, spark_instance_t::cpba, spark_instance_t::cpba_single_spark, single_spark_config_t::dwell_time, spark_config_t::dwell_time_max, spark_config_t::dwell_time_min, single_spark_config_t::end_angle, FS_ETPU_SINGLE_SPARK_OFFSET_DWELL_TIME, FS_ETPU_SINGLE_SPARK_OFFSET_END_ANGLE, FS_ETPU_SINGLE_SPARK_OFFSET_MULTI_PULSE_COUNT, FS_ETPU_SINGLE_SPARK_STRUCT_SIZE, FS_ETPU_SPARK_HSR_UPDATE, FS_ETPU_SPARK_OFFSET_ANGLE_OFFSET_RECALC, FS_ETPU_SPARK_OFFSET_DWELL_TIME_MAX, FS_ETPU_SPARK_OFFSET_DWELL_TIME_MIN, FS_ETPU_SPARK_OFFSET_GENERATION_DISABLE, FS_ETPU_SPARK_OFFSET_MULTI_OFF_TIME, FS_ETPU_SPARK_OFFSET_MULTI_ON_TIME, FS_ETPU_SPARK_OFFSET_SPARK_COUNT, spark_config_t::generation_disable, spark_config_t::multi_off_time, spark_config_t::multi_on_time, single_spark_config_t::multi_pulse_count, spark_config_t::p_single_spark_config, and spark_config_t::spark_count.

uint32_t fs_etpu_spark_get_states struct spark_instance_t p_spark_instance,
struct spark_states_t p_spark_states
 

This function reads SPARK state variables, including error flags, and clears the eTPU error after reading.

Note:
The following actions are performed in order:
  1. Read state parameter values from eTPU DATA RAM
  2. Clear SPARK error
Parameters:
*p_spark_instance - This is a pointer to the instance structure inj_instance_t.
*p_spark_states - This is a pointer to the return structure of states inj_states_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 290 of file etpu_spark.c.

References spark_instance_t::cpba, spark_states_t::dwell_time_applied, spark_states_t::error, FS_ETPU_SPARK_OFFSET_DWELL_TIME_APPLIED, and FS_ETPU_SPARK_OFFSET_ERROR.

uint32_t fs_etpu_spark_init struct spark_instance_t p_spark_instance,
struct spark_config_t p_spark_config
 

This function initializes eTPU channels to run SPARK 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_spark_instance - This is a pointer to the instance structure spark_instance_t.
*p_spark_config - This is a pointer to the structure of configuration parameters spark_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 90 of file etpu_spark.c.

References spark_config_t::angle_offset_recalc, spark_instance_t::chan_num, spark_instance_t::cpba, spark_instance_t::cpba_single_spark, single_spark_config_t::dwell_time, spark_config_t::dwell_time_max, spark_config_t::dwell_time_min, single_spark_config_t::end_angle, fs_etpu_data_ram_start, FS_ETPU_SINGLE_SPARK_OFFSET_DWELL_TIME, FS_ETPU_SINGLE_SPARK_OFFSET_END_ANGLE, FS_ETPU_SINGLE_SPARK_OFFSET_MULTI_PULSE_COUNT, FS_ETPU_SINGLE_SPARK_STRUCT_SIZE, FS_ETPU_SPARK_FUNCTION_NUMBER, FS_ETPU_SPARK_HSR_INIT, FS_ETPU_SPARK_NUM_PARMS, FS_ETPU_SPARK_OFFSET_ANGLE_OFFSET_RECALC, FS_ETPU_SPARK_OFFSET_DWELL_TIME, FS_ETPU_SPARK_OFFSET_DWELL_TIME_APPLIED, FS_ETPU_SPARK_OFFSET_DWELL_TIME_MAX, FS_ETPU_SPARK_OFFSET_DWELL_TIME_MIN, FS_ETPU_SPARK_OFFSET_END_ANGLE, FS_ETPU_SPARK_OFFSET_ERROR, FS_ETPU_SPARK_OFFSET_GENERATION_DISABLE, FS_ETPU_SPARK_OFFSET_MULTI_OFF_TIME, FS_ETPU_SPARK_OFFSET_MULTI_ON_TIME, FS_ETPU_SPARK_OFFSET_MULTI_PULSE_COUNT, FS_ETPU_SPARK_OFFSET_MULTI_PULSE_COUNTER, FS_ETPU_SPARK_OFFSET_P_SINGLE_SPARK, FS_ETPU_SPARK_OFFSET_P_SINGLE_SPARK_FIRST, FS_ETPU_SPARK_OFFSET_PULSE_START_TIME, FS_ETPU_SPARK_OFFSET_SPARK_COUNT, FS_ETPU_SPARK_OFFSET_SPARK_COUNTER, FS_ETPU_SPARK_OFFSET_STATE, FS_ETPU_SPARK_OFFSET_TDC_ANGLE, FS_ETPU_SPARK_OFFSET_TDC_ANGLE_ACTUAL, FS_ETPU_SPARK_TABLE_SELECT, spark_config_t::generation_disable, spark_config_t::multi_off_time, spark_config_t::multi_on_time, single_spark_config_t::multi_pulse_count, spark_config_t::p_single_spark_config, spark_instance_t::polarity, spark_instance_t::priority, spark_config_t::spark_count, and spark_instance_t::tdc_angle.


Variable Documentation

uint32_t fs_etpu_data_ram_ext
 

uint32_t fs_etpu_data_ram_start
 

Referenced by fs_etpu_spark_init().