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

etpu_as.h File Reference


Detailed Description

This file contains useful macros and prototypes for AS API.

Author:
Milan Brejl [r54529]
Version:
1.0
Date:
17-May-2012

Definition in file etpu_as.h.

#include "etpu_util.h"
#include "etpu_as_auto.h"
#include "etpu_pwmm.h"

Go to the source code of this file.

Defines

#define FS_ETPU_AS_MODE_MASTER   FS_ETPU_AS_HSR_INIT_MODE_PERIODIC
#define FS_ETPU_AS_MODE_PWMM_SLAVE   FS_ETPU_AS_HSR_INIT_MODE_SYNC

Functions

uint32_t fs_etpu_as_init (struct as_instance_t *p_as_instance, struct pwmm_instance_t *p_pwmm_instance, struct as_config_t *p_as_config)
 This function initializes eTPU channels to run AS function.
uint32_t fs_etpu_as_config (struct as_instance_t *p_as_instance, struct as_config_t *p_as_config)
 This function changes the AS configuration.
uint32_t fs_etpu_as_get_outputs (struct as_instance_t *p_as_instance, struct as_outputs_t *p_as_outputs)
 This function reads output values of the AS function.
uint32_t fs_etpu_as_measure_dc_offsets (struct as_instance_t *p_as_instance, struct as_config_t *p_as_config, uint8_t signal_mask)
 This function uses the signal output values to set the signal dc-offsets. It is presummed the current physical signal value corresponds to what a zero value is.


Define Documentation

#define FS_ETPU_AS_MODE_MASTER   FS_ETPU_AS_HSR_INIT_MODE_PERIODIC
 

AS Mode

Definition at line 34 of file etpu_as.h.

#define FS_ETPU_AS_MODE_PWMM_SLAVE   FS_ETPU_AS_HSR_INIT_MODE_SYNC
 

Definition at line 35 of file etpu_as.h.


Function Documentation

uint32_t fs_etpu_as_config struct as_instance_t p_as_instance,
struct as_config_t p_as_config
 

This function changes the AS configuration.

Note:
The following actions are performed in order:
  1. Write configuration parameter values to eTPU DATA RAM
  2. Write AS channel FM bits
Parameters:
*p_as_instance - This is a pointer to the instance structure as_instance_t.
*p_as_config - This is a pointer to the structure of configuration parameters as_config_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 213 of file etpu_as.c.

References as_config_t::cfifo_update, as_instance_t::chan_num, as_instance_t::cpba, as_instance_t::cpba_signals, as_signal_config_t::dc_offset, as_signal_config_t::forget_factor, FS_ETPU_AS_OFFSET_DC_OFFSET, FS_ETPU_AS_OFFSET_FORGET_FACTOR, FS_ETPU_AS_OFFSET_GAIN, FS_ETPU_AS_OFFSET_LINK_CHANS_CENTER_END, FS_ETPU_AS_OFFSET_LINK_CHANS_CENTER_START, FS_ETPU_AS_OFFSET_LINK_CHANS_FRAME_END, FS_ETPU_AS_OFFSET_LINK_CHANS_FRAME_START, FS_ETPU_AS_OFFSET_OPTIONS_CFIFO, FS_ETPU_AS_OFFSET_OPTIONS_IRQ, FS_ETPU_AS_OFFSET_OPTIONS_LINK, FS_ETPU_AS_OFFSET_OPTIONS_PHASE_CURRENTS, FS_ETPU_AS_OFFSET_PERIOD, FS_ETPU_AS_OFFSET_PULSE_ADJUSTMENT_CENTER, FS_ETPU_AS_OFFSET_PULSE_ADJUSTMENT_FRAME, FS_ETPU_AS_OFFSET_PULSE_WIDTH, FS_ETPU_AS_OFFSET_SIGNAL_MASK_CENTER, FS_ETPU_AS_OFFSET_SIGNAL_MASK_FRAME, FS_ETPU_AS_SIGNAL_STRUCT_SIZE, as_signal_config_t::gain, as_config_t::irq_dma_options, as_config_t::link_chans_center_end, as_config_t::link_chans_center_start, as_config_t::link_chans_frame_end, as_config_t::link_chans_frame_start, as_config_t::link_options, as_config_t::period, as_config_t::phase_current_processing, as_config_t::pulse_adjustment_center, as_config_t::pulse_adjustment_frame, as_config_t::pulse_selection, as_config_t::pulse_width, as_config_t::signal_config, as_instance_t::signal_count, as_config_t::signal_mask_center, and as_config_t::signal_mask_frame.

uint32_t fs_etpu_as_get_outputs struct as_instance_t p_as_instance,
struct as_outputs_t p_as_outputs
 

This function reads output values of the AS function.

Note:
The following actions are performed in order:
  1. Read output parameter values from eTPU DATA RAM
Parameters:
*p_as_instance - This is a pointer to the instance structure as_instance_t.
*p_as_outputs - This is a pointer to the structure of states as_outputs_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 281 of file etpu_as.c.

References as_instance_t::cpba_signals, FS_ETPU_AS_OFFSET_VALUE, FS_ETPU_AS_SIGNAL_STRUCT_SIZE, as_instance_t::signal_count, and as_outputs_t::signal_value.

uint32_t fs_etpu_as_init struct as_instance_t p_as_instance,
struct pwmm_instance_t *  p_pwmm_instance,
struct as_config_t p_as_config
 

This function initializes eTPU channels to run AS 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
Warning:
The PWMM channel eTPU DATA RAM allocation must be done before the AS channel initialization (using fs_etpu_as_init). On AS initialization, pointers to PWMM parameters are created. This is required only when mode is FS_ETPU_AS_MODE_PWMM_SLAVE, FS_ETPU_AS_PHASE_CURRENTS_ON is set or any of AS_CFIFO_FRAME/CENTER_PULSE_START/END is set.
Parameters:
*p_as_instance - This is a pointer to the instance structure as_instance_t.
*p_pwmm_instance - This is a pointer to the instance structure pwmm_instance_t. It is used in case there is any interaction between AS and PWMM eTPU functions - if running AS in synchronized more or if reading PWMM sector for phase current processing.
*p_as_config - This is a pointer to the structure of configuration parameters as_config_t.
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error
  • FS_ETPU_ERROR_CODESIZE - When the code is too big for the available memory
  • FS_ETPU_ERROR_VIS_BIT_NOT_SET - When the SCM Visibility cannot be set and SCM cannot be written.
Warning:
This function does not configure the pins, only the eTPU channels.

Definition at line 78 of file etpu_as.c.

References as_config_t::cfifo_update, as_instance_t::chan_num, as_config_t::cmd_ia_adc_0, as_config_t::cmd_ia_adc_1, as_config_t::cmd_ib_adc_0, as_config_t::cmd_ib_adc_1, as_config_t::cmd_ic_adc_0, as_instance_t::cpba, as_instance_t::cpba_signals, as_signal_config_t::dc_offset, as_signal_config_t::forget_factor, FS_ETPU_AS_FUNCTION_NUMBER, FS_ETPU_AS_NUM_PARMS, FS_ETPU_AS_OFFSET_CENTER_TIME, FS_ETPU_AS_OFFSET_CMD_IA_ADC0, FS_ETPU_AS_OFFSET_CMD_IA_ADC1, FS_ETPU_AS_OFFSET_CMD_IB_ADC0, FS_ETPU_AS_OFFSET_CMD_IB_ADC1, FS_ETPU_AS_OFFSET_CMD_IC_ADC0, FS_ETPU_AS_OFFSET_CMD_IC_ADC1, FS_ETPU_AS_OFFSET_COMMAND_QUEUE, FS_ETPU_AS_OFFSET_DC_OFFSET, FS_ETPU_AS_OFFSET_FORGET_FACTOR, FS_ETPU_AS_OFFSET_FRAME_TIME, FS_ETPU_AS_OFFSET_GAIN, FS_ETPU_AS_OFFSET_LINK_CHANS_CENTER_END, FS_ETPU_AS_OFFSET_LINK_CHANS_CENTER_START, FS_ETPU_AS_OFFSET_LINK_CHANS_FRAME_END, FS_ETPU_AS_OFFSET_LINK_CHANS_FRAME_START, FS_ETPU_AS_OFFSET_OPTIONS_CFIFO, FS_ETPU_AS_OFFSET_OPTIONS_IRQ, FS_ETPU_AS_OFFSET_OPTIONS_LINK, FS_ETPU_AS_OFFSET_OPTIONS_PHASE_CURRENTS, FS_ETPU_AS_OFFSET_OPTIONS_POLARITY, FS_ETPU_AS_OFFSET_PERIOD, FS_ETPU_AS_OFFSET_PHASE_CURRENT_A_IDX, FS_ETPU_AS_OFFSET_PHASE_CURRENT_B_IDX, FS_ETPU_AS_OFFSET_PHASE_CURRENT_C_IDX, FS_ETPU_AS_OFFSET_PULSE_ADJUSTMENT_CENTER, FS_ETPU_AS_OFFSET_PULSE_ADJUSTMENT_FRAME, FS_ETPU_AS_OFFSET_PULSE_WIDTH, FS_ETPU_AS_OFFSET_PWMM_CENTER_TIME, FS_ETPU_AS_OFFSET_PWMM_FRAME_TIME, FS_ETPU_AS_OFFSET_PWMM_SECTOR, FS_ETPU_AS_OFFSET_QUEUE_OFFSET, FS_ETPU_AS_OFFSET_RESULT_QUEUE, FS_ETPU_AS_OFFSET_SECTOR, FS_ETPU_AS_OFFSET_SIGNAL, FS_ETPU_AS_OFFSET_SIGNAL_COUNT, FS_ETPU_AS_OFFSET_SIGNAL_MASK_CENTER, FS_ETPU_AS_OFFSET_SIGNAL_MASK_DC_OFFSET, FS_ETPU_AS_OFFSET_SIGNAL_MASK_FRAME, FS_ETPU_AS_OFFSET_START_OFFSET, FS_ETPU_AS_OFFSET_VALUE, FS_ETPU_AS_SIGNAL_STRUCT_SIZE, FS_ETPU_AS_TABLE_SELECT, fs_etpu_data_ram_start, as_signal_config_t::gain, as_config_t::irq_dma_options, as_config_t::link_chans_center_end, as_config_t::link_chans_center_start, as_config_t::link_chans_frame_end, as_config_t::link_chans_frame_start, as_config_t::link_options, as_instance_t::mode, as_config_t::p_cfifo, as_config_t::p_result_queue, as_config_t::period, as_config_t::phase_current_idx_a, as_config_t::phase_current_idx_b, as_config_t::phase_current_idx_c, as_config_t::phase_current_processing, as_instance_t::polarity, as_instance_t::priority, as_config_t::pulse_adjustment_center, as_config_t::pulse_adjustment_frame, as_config_t::pulse_selection, as_config_t::pulse_width, as_signal_config_t::queue_offset, as_config_t::signal_config, as_instance_t::signal_count, as_config_t::signal_mask_center, as_config_t::signal_mask_frame, and as_config_t::start_offset.

uint32_t fs_etpu_as_measure_dc_offsets struct as_instance_t p_as_instance,
struct as_config_t p_as_config,
uint8_t  signal_mask
 

This function uses the signal output values to set the signal dc-offsets. It is presummed the current physical signal value corresponds to what a zero value is.

Note:
The following actions are performed in order:
  1. Read output parameter values from eTPU DATA RAM
Parameters:
*p_as_instance - This is a pointer to the instance structure as_instance_t.
*p_as_config - This is a pointer to the structure of outputs as_config_t. The signal dc_offsets are updated in this structure.
signal_mask - this mask defines which signal dc_offsets are measured. Bit 0 (0x01) corresponds to signal[0].
Returns:
Error codes that can be returned are:
  • FS_ETPU_ERROR_NONE - No error

Definition at line 324 of file etpu_as.c.

References as_instance_t::cpba_signals, as_signal_config_t::dc_offset, FS_ETPU_AS_OFFSET_DC_OFFSET, FS_ETPU_AS_OFFSET_VALUE, FS_ETPU_AS_SIGNAL_STRUCT_SIZE, as_config_t::signal_config, and as_instance_t::signal_count.