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

etpu_util.h File Reference


Detailed Description

This file contains useful macros and prototypes for using the eTPU and eTPU2.

Author:
Milan Brejl [r54529]
Version:
3.2
Date:
21-Mar-2014

Definition in file etpu_util.h.

#include "typedefs.h"
#include "etpu_struct.h"

Go to the source code of this file.

Defines

#define FS_ETPU_ENGINE_CHANNEL(x, y)   (((x)-1)*64 + y)
 Channel number expressed by (engine, channel).
#define FS_ETPU_CHANNEL_TO_LINK(x)   ((x)+64)
 Transformation from absolute channel number to link register encoding.
#define TRUE   1
#define FALSE   0
#define FS_ETPU_PRIORITY_HIGH   0x3
#define FS_ETPU_PRIORITY_MIDDLE   0x2
#define FS_ETPU_PRIORITY_LOW   0x1
#define FS_ETPU_PRIORITY_DISABLE   0x0
#define FS_ETPU_PIN_HIGH   1
#define FS_ETPU_PIN_LOW   0
#define FS_ETPU_TCR1   0
#define FS_ETPU_TCR2   1
#define FS_ETPU_TCR1_A   0
#define FS_ETPU_TCR2_A   1
#define FS_ETPU_TCR1_B   0
#define FS_ETPU_TCR2_B   1
#define FS_ETPU_MISC_ENABLE   0x00000200
#define FS_ETPU_MISC_DISABLE   0x00000000
#define FS_ETPU_VIS_ON   0x00000040
#define FS_ETPU_VIS_OFF   0x00000000
#define FS_ETPU_GLOBAL_TIMEBASE_ENABLE   0x00000001
#define FS_ETPU_GLOBAL_TIMEBASE_DISABLE   0x00000000
#define FS_ETPU_SDM_READ_ERROR   0x40000000
#define FS_ETPU_WATCHDOG_TIMEOUT_A   0x20000000
#define FS_ETPU_WATCHDOG_TIMEOUT_B   0x10000000
#define FS_ETPU_MICROCODE_GLOBAL_EX_A   0x08000000
#define FS_ETPU_MICROCODE_GLOBAL_EX_B   0x04000000
#define FS_ETPU_ILLEGAL_INSTRUCTION_A   0x02000000
#define FS_ETPU_ILLEGAL_INSTRUCTION_B   0x01000000
#define FS_ETPU_SHARED_SUBSYS_ACC_ERR   0x00800000
#define FS_ETPU_SCM_MISC_FLAG   0x00000400
#define FS_ETPU_SCM_READ_ERROR   0x00000100
#define FS_ETPU_FILTER_CLOCK_DIV2   0x00000000
#define FS_ETPU_FILTER_CLOCK_DIV4   0x00010000
#define FS_ETPU_FILTER_CLOCK_DIV8   0x00020000
#define FS_ETPU_FILTER_CLOCK_DIV16   0x00030000
#define FS_ETPU_FILTER_CLOCK_DIV32   0x00040000
#define FS_ETPU_FILTER_CLOCK_DIV64   0x00050000
#define FS_ETPU_FILTER_CLOCK_DIV128   0x00060000
#define FS_ETPU_FILTER_CLOCK_DIV256   0x00070000
#define FS_ETPU_FCSS_DIV2   0x00000000
#define FS_ETPU_FCSS_DIV1   0x00080000
#define FS_ETPU_CHAN_FILTER_2SAMPLE   0x00000000
#define FS_ETPU_CHAN_FILTER_3SAMPLE   0x00008000
#define FS_ETPU_CHAN_FILTER_CONT   0x0000C000
#define FS_ETPU_CHAN_FILTER_BYPASS   0x00004000
#define FS_ETPU_ENGINE_ENABLE   0x00000000
#define FS_ETPU_ENGINE_DISABLE   0x40000000
#define FS_ETPU_PRIORITY_PASSING_ENABLE   0x00000000
#define FS_ETPU_PRIORITY_PASSING_DISABLE   0x00000080
#define FS_ETPU_TCRCLK_MODE_2SAMPLE   0x00000000
#define FS_ETPU_TCRCLK_MODE_INTEGRATION   0x10000000
#define FS_ETPU_TCRCLK_INPUT_DIV2CLOCK   0x00000000
#define FS_ETPU_TCRCLK_INPUT_CHANCLOCK   0x08000000
#define FS_ETPU_TCR1CTL_TCRCLK   0x00000000
#define FS_ETPU_TCR1CTL_DIV2   0x00008000
#define FS_ETPU_TCR1CS_DIV2   0x00000000
#define FS_ETPU_TCR1CS_DIV1   0x00002000
#define FS_ETPU_ANGLE_MODE_ENABLE   0x02000000
#define FS_ETPU_ANGLE_MODE_DISABLE   0x00000000
#define FS_ETPU_ANGLE_MODE_ENABLE_CH1   0x04000000
#define FS_ETPU_ANGLE_MODE_ENABLE_CH2   0x06000000
#define FS_ETPU_TCR2CTL_GATEDDIV8   0x00000000
#define FS_ETPU_TCR2CTL_RISE   0x20000000
#define FS_ETPU_TCR2CTL_FALL   0x40000000
#define FS_ETPU_TCR2CTL_RISEFALL   0x60000000
#define FS_ETPU_TCR2CTL_DIV8   0x80000000
#define FS_ETPU_TCR1_PRESCALER(x)   (((x)-1) & 0xFF)
#define FS_ETPU_TCR2_PRESCALER(x)   ((((x)-1) & 0x3F)<<16)
#define FS_ETPU_TCR1_STAC_ENABLE   0x80000000
#define FS_ETPU_TCR1_STAC_DISABLE   0x00000000
#define FS_ETPU_TCR1_STAC_CLIENT   0x00000000
#define FS_ETPU_TCR1_STAC_SERVER   0x40000000
#define FS_ETPU_TCR1_STAC_SRVSLOT(x)   (((x) & 0xF)<<16)
#define FS_ETPU_TCR2_STAC_ENABLE   0x00008000
#define FS_ETPU_TCR2_STAC_DISABLE   0x00000000
#define FS_ETPU_TCR2_STAC_CLIENT   0x00000000
#define FS_ETPU_TCR2_STAC_SERVER   0x00004000
#define FS_ETPU_TCR2_STAC_SRVSLOT(x)   ((x) & 0xF)
#define FS_ETPU_WDM_DISABLED   0x00000000
#define FS_ETPU_WDM_THREAD_LEN   0x80000000
#define FS_ETPU_WDM_BUSY_LEN   0xC0000000
#define FS_ETPU_WDTR_WDCNT(x)   ((x) & 0xFFFF)
#define FS_ETPU_INTERRUPT_ENABLE   0x80000000
#define FS_ETPU_INTERRUPT_DISABLE   0x00000000
#define FS_ETPU_DMA_ENABLE   0x40000000
#define FS_ETPU_DMA_DISABLE   0x00000000
#define FS_ETPU_ENTRY_TABLE_STANDARD   0x00000000
#define FS_ETPU_ENTRY_TABLE_ALTERNATE   0x01000000
#define FS_ETPU_ENTRY_TABLE_PIN_INPUT   0x00000000
#define FS_ETPU_ENTRY_TABLE_PIN_OUTPUT   0x02000000
#define FS_ETPU_OUTPUT_DISABLE_OFF   0x00000000
#define FS_ETPU_OUTPUT_DISABLE_LOW   0x0000C000
#define FS_ETPU_OUTPUT_DISABLE_HIGH   0x00008000
#define FS_ETPU_ERROR_NONE   0
#define FS_ETPU_ERROR_MALLOC   1
#define FS_ETPU_ERROR_FREQ   2
#define FS_ETPU_ERROR_VALUE   3
#define FS_ETPU_ERROR_CODESIZE   4
#define FS_ETPU_ERROR_VIS_BIT_NOT_SET   5
#define FS_ETPU_ERROR_ADDRESS   6
#define FS_ETPU_ERROR_TIMING   7

Typedefs

typedef uint32_t ufract24_t
typedef int32_t fract24_t
typedef uint32_t uint24_t
typedef int32_t int24_t

Functions

uint32_t fs_etpu_init (struct etpu_config_t p_etpu_config, uint32_t *code, uint32_t code_size, uint32_t *globals, uint32_t globals_size)
 This function initializes the eTPU module.
uint32_t fs_etpu2_init (struct etpu_config_t p_etpu_config, uint32_t engine_mem_size)
 This function initializes the eTPU2-only setting of an eTPU2 module.
uint32_t * fs_etpu_chan_init (uint8_t channel, uint8_t function, uint8_t mode, uint8_t hsr, uint8_t num_param, uint32_t config, uint32_t *func_frame)
 This function initializes an eTPU channel.
uint32_t * fs_etpu_malloc (uint16_t num_bytes)
 This function allocates DATA RAM (parameter RAM) for a channel.
uint32_t * fs_etpu_malloc2 (uint8_t channel, uint16_t num_bytes)
 This function allocates DATA RAM for a channel if it has not been allocated before.
void fs_timer_start (void)
 This function starts the timebases.
uint32_t fs_etpu_get_global_exceptions (void)
 This function returns the global exception flags.
void fs_etpu_clear_global_exceptions (void)
 This function clears all eTPU global exceptions.
uint32_t fs_etpu_get_global_error (void)
 This function reads the Global Error value from eTPU DATA RAM, which is used by Freescale eTPU functions to reports unhandled events.
void fs_etpu_set_interrupt_mask_a (uint32_t mask)
 This function enables or disables channel interrupt for each engine A channel according to the given mask.
void fs_etpu_set_interrupt_mask_b (uint32_t mask)
 This function enables or disables channel interrupt for each engine B channel according to the given mask.
void fs_etpu_set_dma_mask_a (uint32_t mask)
 This function enables or disables channel DMA request for each engine A channel according to the given mask.
void fs_etpu_set_dma_mask_b (uint32_t mask)
 This function enables or disables channel DMA request for each engine B channel according to the given mask.
void fs_etpu_set_output_disable_mask_a (uint32_t mask, uint32_t polarity)
 This function enables or disables the channel "output disable" feature for each engine A channel according to the given mask and polarity.
void fs_etpu_set_output_disable_mask_b (uint32_t mask, uint32_t polarity)
 This function enables or disables the channel "output disable" feature for each engine B channel according to the given mask and polarity.
uint8_t fs_etpu_get_hsr (uint8_t channel)
 This function returns the current value of the Host Service Request (HSR) register of the specified eTPU channel.
void fs_etpu_set_hsr (uint8_t channel, uint8_t hsr)
 This function sets the Host Service Request (HSR) register of the specified eTPU channel.
void fs_etpu_enable (uint8_t channel, uint8_t priority)
 This function enables or changes the priority of an eTPU channel.
void fs_etpu_disable (uint8_t channel)
 This function disables an eTPU channel.
void fs_etpu_interrupt_enable (uint8_t channel)
 This function enables an eTPU channel to generate interrupts.
void fs_etpu_interrupt_disable (uint8_t channel)
 This function disables an eTPU channel from generating interrupts.
uint8_t fs_etpu_get_chan_interrupt_flag (uint8_t channel)
 This function returns the current value of the Channel Interrupt Status bit of the specified eTPU channel.
void fs_etpu_clear_chan_interrupt_flag (uint8_t channel)
 This function clears the channel interrupt flag.
uint8_t fs_etpu_get_chan_interrupt_overflow_flag (uint8_t channel)
void fs_etpu_clear_chan_interrupt_overflow_flag (uint8_t channel)
 This function clears the channel interrupt oveflow flag.
void fs_etpu_dma_enable (uint8_t channel)
 This function enables an eTPU channel to request DMA service.
void fs_etpu_dma_disable (uint8_t channel)
 This function disables an eTPU channel from generating DMA requests.
uint8_t fs_etpu_get_chan_dma_flag (uint8_t channel)
 This function returns the current value of the Data Transfer Request Status bit of the specified eTPU channel.
void fs_etpu_clear_chan_dma_flag (uint8_t channel)
 This function clears the channel data transfer request flag.
uint8_t fs_etpu_get_chan_dma_overflow_flag (uint8_t channel)
void fs_etpu_clear_chan_dma_overflow_flag (uint8_t channel)
uint32_t * fs_etpu_data_ram (uint8_t channel)
 This function returns a pointer to the start of the data RAM for the specified channel.
uint32_t fs_etpu_get_chan_local_32 (uint8_t channel, uint32_t offset)
 This function reads a 32-bit parameter from an eTPU channel..
uint24_t fs_etpu_get_chan_local_24 (uint8_t channel, uint32_t offset)
 This function reads a unsigned 24-bit parameter from an eTPU channel.
int24_t fs_etpu_get_chan_local_24s (uint8_t channel, uint32_t offset)
 This function reads a signed 24-bit parameter from an eTPU channel.
uint16_t fs_etpu_get_chan_local_16 (uint8_t channel, uint32_t offset)
 This function reads a 16-bit parameter from an eTPU channel.
uint8_t fs_etpu_get_chan_local_8 (uint8_t channel, uint32_t offset)
 This function reads an 8-bit parameter from an eTPU channel.
void fs_etpu_set_chan_local_32 (uint8_t channel, uint32_t offset, uint32_t value)
 This function sets a 32-bit parameter for an eTPU channel.
void fs_etpu_set_chan_local_24 (uint8_t channel, uint32_t offset, uint24_t value)
 This function sets a 24-bit parameter for an eTPU channel.
void fs_etpu_set_chan_local_16 (uint8_t channel, uint32_t offset, uint16_t value)
 This function sets a 16-bit parameter for an eTPU channel.
void fs_etpu_set_chan_local_8 (uint8_t channel, uint32_t offset, uint8_t value)
 This function sets an 8-bit parameter for an eTPU channel.
uint32_t fs_etpu_get_global_32 (uint32_t offset)
 This function reads a 32-bit global variable.
int24_t fs_etpu_get_global_24s (uint32_t offset)
 This function reads a signed 24-bit global variable.
uint24_t fs_etpu_get_global_24 (uint32_t offset)
 This function reads an unsigned 24-bit global variable.
uint16_t fs_etpu_get_global_16 (uint32_t offset)
 This function reads a 16-bit global variable.
uint8_t fs_etpu_get_global_8 (uint32_t offset)
 This function reads an 8-bit global variable.
void fs_etpu_set_global_32 (uint32_t offset, uint32_t value)
 This function writes to a 32-bit global variable.
void fs_etpu_set_global_24 (uint32_t offset, uint24_t value)
 This function writes to a 24-bit global variable.
void fs_etpu_set_global_16 (uint32_t offset, uint16_t value)
 This function writes to a 16-bit global variable.
void fs_etpu_set_global_8 (uint32_t offset, uint8_t value)
 This function writes to an 8-bit global variable.
uint32_t fs_etpu_coherent_read_24 (uint8_t channel, uint32_t offset1, uint32_t offset2, int32_t *value1, int32_t *value2)
 This function coherently reads two 24-bit variables from the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).
uint32_t fs_etpu_coherent_read_32 (uint8_t channel, uint32_t offset1, uint32_t offset2, uint32_t *value1, uint32_t *value2)
 This function coherently reads two 32-bit variables from the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).
uint32_t fs_etpu_coherent_write_24 (uint8_t channel, uint32_t offset1, uint32_t offset2, int32_t value1, int32_t value2)
 This function coherently writes two 24-bit variables into the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).
uint32_t fs_etpu_coherent_write_32 (uint8_t channel, uint32_t offset1, uint32_t offset2, uint32_t value1, uint32_t value2)
 This function coherently writes two 32-bit variables into the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).
uint24_t fs_etpu_get_idle_cnt_a (void)
 This function returns the current value of engine A Idle Count Register.
uint24_t fs_etpu_get_idle_cnt_b (void)
 This function returns the current value of engine B Idle Count Register.
void fs_etpu_clear_idle_cnt_a (void)
 This function clears the engine A Idle Count Register.
void fs_etpu_clear_idle_cnt_b (void)
 This function clears the engine B Idle Count Register.
uint32_t * fs_memcpy32 (uint32_t *dest, uint32_t *source, uint32_t size)
 This function is similar to the standard C memset() function however it sets 32-bit words rather than bytes.
void fs_memset32 (uint32_t *start, uint32_t value, int32_t size)
 This function is similar to the standard C memcpy() function however it copies 32-bit words rather than bytes.

Variables

uint32_t * fs_free_param
 Pointer to the first free parameter in eTPU DATA RAM.
eTPU_structeTPU
 Access to eTPU registers' structure.


Define Documentation

#define FALSE   0
 

Definition at line 50 of file etpu_util.h.

Referenced by fs_etpu_dma_disable(), and fs_etpu_interrupt_disable().

#define FS_ETPU_ANGLE_MODE_DISABLE   0x00000000
 

Definition at line 360 of file etpu_util.h.

#define FS_ETPU_ANGLE_MODE_ENABLE   0x02000000
 

Definition at line 359 of file etpu_util.h.

#define FS_ETPU_ANGLE_MODE_ENABLE_CH1   0x04000000
 

Definition at line 361 of file etpu_util.h.

#define FS_ETPU_ANGLE_MODE_ENABLE_CH2   0x06000000
 

Definition at line 362 of file etpu_util.h.

#define FS_ETPU_CHAN_FILTER_2SAMPLE   0x00000000
 

Definition at line 336 of file etpu_util.h.

#define FS_ETPU_CHAN_FILTER_3SAMPLE   0x00008000
 

Definition at line 337 of file etpu_util.h.

#define FS_ETPU_CHAN_FILTER_BYPASS   0x00004000
 

Definition at line 339 of file etpu_util.h.

#define FS_ETPU_CHAN_FILTER_CONT   0x0000C000
 

Definition at line 338 of file etpu_util.h.

#define FS_ETPU_CHANNEL_TO_LINK  )     ((x)+64)
 

Transformation from absolute channel number to link register encoding.

Definition at line 43 of file etpu_util.h.

#define FS_ETPU_DMA_DISABLE   0x00000000
 

Definition at line 402 of file etpu_util.h.

#define FS_ETPU_DMA_ENABLE   0x40000000
 

Definition at line 401 of file etpu_util.h.

#define FS_ETPU_ENGINE_CHANNEL x,
 )     (((x)-1)*64 + y)
 

Channel number expressed by (engine, channel).

Note:
All channel numbers for both eTPUs are absolute. eTPU_A has channels 0-31 and eTPU_B has channels 64-95.

Definition at line 38 of file etpu_util.h.

#define FS_ETPU_ENGINE_DISABLE   0x40000000
 

Definition at line 342 of file etpu_util.h.

#define FS_ETPU_ENGINE_ENABLE   0x00000000
 

Definition at line 341 of file etpu_util.h.

#define FS_ETPU_ENTRY_TABLE_ALTERNATE   0x01000000
 

Definition at line 405 of file etpu_util.h.

#define FS_ETPU_ENTRY_TABLE_PIN_INPUT   0x00000000
 

Definition at line 407 of file etpu_util.h.

#define FS_ETPU_ENTRY_TABLE_PIN_OUTPUT   0x02000000
 

Definition at line 408 of file etpu_util.h.

#define FS_ETPU_ENTRY_TABLE_STANDARD   0x00000000
 

Definition at line 404 of file etpu_util.h.

#define FS_ETPU_ERROR_ADDRESS   6
 

Definition at line 421 of file etpu_util.h.

Referenced by fs_etpu_coherent_read_24(), fs_etpu_coherent_read_32(), fs_etpu_coherent_write_24(), and fs_etpu_coherent_write_32().

#define FS_ETPU_ERROR_CODESIZE   4
 

Definition at line 419 of file etpu_util.h.

Referenced by fs_etpu_init().

#define FS_ETPU_ERROR_FREQ   2
 

Definition at line 417 of file etpu_util.h.

#define FS_ETPU_ERROR_MALLOC   1
 

Definition at line 416 of file etpu_util.h.

Referenced by fs_etpu2_init(), fs_etpu_chan_init(), fs_etpu_coherent_read_24(), fs_etpu_coherent_read_32(), fs_etpu_coherent_write_24(), and fs_etpu_coherent_write_32().

#define FS_ETPU_ERROR_NONE   0
 

Definition at line 415 of file etpu_util.h.

#define FS_ETPU_ERROR_TIMING   7
 

Definition at line 422 of file etpu_util.h.

#define FS_ETPU_ERROR_VALUE   3
 

Definition at line 418 of file etpu_util.h.

#define FS_ETPU_ERROR_VIS_BIT_NOT_SET   5
 

Definition at line 420 of file etpu_util.h.

Referenced by fs_etpu_init().

#define FS_ETPU_FCSS_DIV1   0x00080000
 

Definition at line 334 of file etpu_util.h.

#define FS_ETPU_FCSS_DIV2   0x00000000
 

Definition at line 333 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV128   0x00060000
 

Definition at line 330 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV16   0x00030000
 

Definition at line 327 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV2   0x00000000
 

Definition at line 324 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV256   0x00070000
 

Definition at line 331 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV32   0x00040000
 

Definition at line 328 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV4   0x00010000
 

Definition at line 325 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV64   0x00050000
 

Definition at line 329 of file etpu_util.h.

#define FS_ETPU_FILTER_CLOCK_DIV8   0x00020000
 

Definition at line 326 of file etpu_util.h.

#define FS_ETPU_GLOBAL_TIMEBASE_DISABLE   0x00000000
 

Definition at line 310 of file etpu_util.h.

#define FS_ETPU_GLOBAL_TIMEBASE_ENABLE   0x00000001
 

Definition at line 309 of file etpu_util.h.

#define FS_ETPU_ILLEGAL_INSTRUCTION_A   0x02000000
 

Definition at line 317 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_ILLEGAL_INSTRUCTION_B   0x01000000
 

Definition at line 318 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_INTERRUPT_DISABLE   0x00000000
 

Definition at line 399 of file etpu_util.h.

#define FS_ETPU_INTERRUPT_ENABLE   0x80000000
 

Definition at line 398 of file etpu_util.h.

#define FS_ETPU_MICROCODE_GLOBAL_EX_A   0x08000000
 

Definition at line 315 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_MICROCODE_GLOBAL_EX_B   0x04000000
 

Definition at line 316 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_MISC_DISABLE   0x00000000
 

Definition at line 304 of file etpu_util.h.

#define FS_ETPU_MISC_ENABLE   0x00000200
 

Definition at line 303 of file etpu_util.h.

#define FS_ETPU_OUTPUT_DISABLE_HIGH   0x00008000
 

Definition at line 412 of file etpu_util.h.

#define FS_ETPU_OUTPUT_DISABLE_LOW   0x0000C000
 

Definition at line 411 of file etpu_util.h.

#define FS_ETPU_OUTPUT_DISABLE_OFF   0x00000000
 

Definition at line 410 of file etpu_util.h.

#define FS_ETPU_PIN_HIGH   1
 

Definition at line 291 of file etpu_util.h.

#define FS_ETPU_PIN_LOW   0
 

Definition at line 292 of file etpu_util.h.

#define FS_ETPU_PRIORITY_DISABLE   0x0
 

Definition at line 289 of file etpu_util.h.

Referenced by fs_etpu_disable().

#define FS_ETPU_PRIORITY_HIGH   0x3
 

Definition at line 286 of file etpu_util.h.

#define FS_ETPU_PRIORITY_LOW   0x1
 

Definition at line 288 of file etpu_util.h.

#define FS_ETPU_PRIORITY_MIDDLE   0x2
 

Definition at line 287 of file etpu_util.h.

#define FS_ETPU_PRIORITY_PASSING_DISABLE   0x00000080
 

Definition at line 345 of file etpu_util.h.

#define FS_ETPU_PRIORITY_PASSING_ENABLE   0x00000000
 

Definition at line 344 of file etpu_util.h.

#define FS_ETPU_SCM_MISC_FLAG   0x00000400
 

Definition at line 320 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_SCM_READ_ERROR   0x00000100
 

Definition at line 321 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_SDM_READ_ERROR   0x40000000
 

Definition at line 312 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_SHARED_SUBSYS_ACC_ERR   0x00800000
 

Definition at line 319 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_TCR1   0
 

Definition at line 295 of file etpu_util.h.

#define FS_ETPU_TCR1_A   0
 

Definition at line 297 of file etpu_util.h.

#define FS_ETPU_TCR1_B   0
 

Definition at line 299 of file etpu_util.h.

#define FS_ETPU_TCR1_PRESCALER  )     (((x)-1) & 0xFF)
 

Definition at line 370 of file etpu_util.h.

#define FS_ETPU_TCR1_STAC_CLIENT   0x00000000
 

Definition at line 377 of file etpu_util.h.

#define FS_ETPU_TCR1_STAC_DISABLE   0x00000000
 

Definition at line 375 of file etpu_util.h.

#define FS_ETPU_TCR1_STAC_ENABLE   0x80000000
 

Definition at line 374 of file etpu_util.h.

#define FS_ETPU_TCR1_STAC_SERVER   0x40000000
 

Definition at line 378 of file etpu_util.h.

#define FS_ETPU_TCR1_STAC_SRVSLOT  )     (((x) & 0xF)<<16)
 

Definition at line 380 of file etpu_util.h.

#define FS_ETPU_TCR1CS_DIV1   0x00002000
 

Definition at line 357 of file etpu_util.h.

#define FS_ETPU_TCR1CS_DIV2   0x00000000
 

Definition at line 356 of file etpu_util.h.

#define FS_ETPU_TCR1CTL_DIV2   0x00008000
 

Definition at line 354 of file etpu_util.h.

#define FS_ETPU_TCR1CTL_TCRCLK   0x00000000
 

Definition at line 353 of file etpu_util.h.

#define FS_ETPU_TCR2   1
 

Definition at line 296 of file etpu_util.h.

#define FS_ETPU_TCR2_A   1
 

Definition at line 298 of file etpu_util.h.

#define FS_ETPU_TCR2_B   1
 

Definition at line 300 of file etpu_util.h.

#define FS_ETPU_TCR2_PRESCALER  )     ((((x)-1) & 0x3F)<<16)
 

Definition at line 371 of file etpu_util.h.

#define FS_ETPU_TCR2_STAC_CLIENT   0x00000000
 

Definition at line 385 of file etpu_util.h.

#define FS_ETPU_TCR2_STAC_DISABLE   0x00000000
 

Definition at line 383 of file etpu_util.h.

#define FS_ETPU_TCR2_STAC_ENABLE   0x00008000
 

Definition at line 382 of file etpu_util.h.

#define FS_ETPU_TCR2_STAC_SERVER   0x00004000
 

Definition at line 386 of file etpu_util.h.

#define FS_ETPU_TCR2_STAC_SRVSLOT  )     ((x) & 0xF)
 

Definition at line 388 of file etpu_util.h.

#define FS_ETPU_TCR2CTL_DIV8   0x80000000
 

Definition at line 368 of file etpu_util.h.

#define FS_ETPU_TCR2CTL_FALL   0x40000000
 

Definition at line 366 of file etpu_util.h.

#define FS_ETPU_TCR2CTL_GATEDDIV8   0x00000000
 

Definition at line 364 of file etpu_util.h.

#define FS_ETPU_TCR2CTL_RISE   0x20000000
 

Definition at line 365 of file etpu_util.h.

#define FS_ETPU_TCR2CTL_RISEFALL   0x60000000
 

Definition at line 367 of file etpu_util.h.

#define FS_ETPU_TCRCLK_INPUT_CHANCLOCK   0x08000000
 

Definition at line 351 of file etpu_util.h.

#define FS_ETPU_TCRCLK_INPUT_DIV2CLOCK   0x00000000
 

Definition at line 350 of file etpu_util.h.

#define FS_ETPU_TCRCLK_MODE_2SAMPLE   0x00000000
 

Definition at line 348 of file etpu_util.h.

#define FS_ETPU_TCRCLK_MODE_INTEGRATION   0x10000000
 

Definition at line 349 of file etpu_util.h.

#define FS_ETPU_VIS_OFF   0x00000000
 

Definition at line 307 of file etpu_util.h.

#define FS_ETPU_VIS_ON   0x00000040
 

Definition at line 306 of file etpu_util.h.

#define FS_ETPU_WATCHDOG_TIMEOUT_A   0x20000000
 

Definition at line 313 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_WATCHDOG_TIMEOUT_B   0x10000000
 

Definition at line 314 of file etpu_util.h.

Referenced by fs_etpu_get_global_exceptions().

#define FS_ETPU_WDM_BUSY_LEN   0xC0000000
 

Definition at line 393 of file etpu_util.h.

#define FS_ETPU_WDM_DISABLED   0x00000000
 

Definition at line 391 of file etpu_util.h.

#define FS_ETPU_WDM_THREAD_LEN   0x80000000
 

Definition at line 392 of file etpu_util.h.

#define FS_ETPU_WDTR_WDCNT  )     ((x) & 0xFFFF)
 

Definition at line 395 of file etpu_util.h.

#define TRUE   1
 

Definition at line 46 of file etpu_util.h.

Referenced by fs_etpu_dma_enable(), fs_etpu_interrupt_enable(), and fs_timer_start().


Typedef Documentation

typedef int32_t fract24_t
 

Definition at line 66 of file etpu_util.h.

typedef int32_t int24_t
 

Definition at line 69 of file etpu_util.h.

typedef uint32_t ufract24_t
 

Definition at line 65 of file etpu_util.h.

typedef uint32_t uint24_t
 

Definition at line 68 of file etpu_util.h.


Function Documentation

uint32_t fs_etpu2_init struct etpu_config_t  p_etpu_config,
uint32_t  engine_mem_size
 

This function initializes the eTPU2-only setting of an eTPU2 module.

Note:
For eTPU2, this function should be called after fs_etpu_init(...). The following actions are performed in order:
  1. Initialize Watchdog Timer
  2. Allocate engine-relative data memory for each engine
Parameters:
p_etpu_config - This is the structure used to initialize the eTPU2 watchdog timer on both engines.
engine_mem_size - This is the size of the engine relative data in bytes.
Returns:
Zero or an error code. Error code that can be returned is:
  • FS_ETPU_ERROR_MALLOC - When the available free eTPU DATA RAM is not big enough for the engine-relative data.
Warning:
This function is applicable to eTPU2 only.

Definition at line 193 of file etpu_util.c.

References eTPU_struct::ECR_A, eTPU_struct::ECR_B, eTPU, fs_etpu_data_ram_end, FS_ETPU_ERROR_MALLOC, fs_free_param, fs_memset32(), etpu_config_t::wdtr_a, eTPU_struct::WDTR_A, etpu_config_t::wdtr_b, and eTPU_struct::WDTR_B.

uint32_t* fs_etpu_chan_init uint8_t  channel,
uint8_t  function,
uint8_t  mode,
uint8_t  hsr,
uint8_t  num_param,
uint32_t  config,
uint32_t *  func_frame
 

This function initializes an eTPU channel.

Parameters:
channel - The eTPU channel number
functions - The eTPU function number
mode - The eTPU function mode (FM bits)
hsr - The eTPU function initialization Host Service Request
num_param - The number of 32-bit eTPU function parameters
config - The eTPU function configuration register settings, e.g.
*func_frame - The base address of the allocated eTPU channel DATA RAM. If assigned by 0, the DATA RAM of num_param size is allocated.
Returns:
A pointer to the start of the eTPU DATA RAM allocated for the channel or an error code. Error code that can be returned is:

Definition at line 258 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, fs_etpu_data_ram_start, FS_ETPU_ERROR_MALLOC, and fs_etpu_malloc().

void fs_etpu_clear_chan_dma_flag uint8_t  channel  ) 
 

This function clears the channel data transfer request flag.

Parameters:
channel - The eTPU channel number

Definition at line 1124 of file etpu_util.c.

References eTPU_struct::CDTRSR_A, eTPU_struct::CDTRSR_B, and eTPU.

void fs_etpu_clear_chan_dma_overflow_flag uint8_t  channel  ) 
 

void fs_etpu_clear_chan_interrupt_flag uint8_t  channel  ) 
 

This function clears the channel interrupt flag.

Parameters:
channel - The eTPU channel number

Definition at line 1052 of file etpu_util.c.

References eTPU_struct::CISR_A, eTPU_struct::CISR_B, and eTPU.

void fs_etpu_clear_chan_interrupt_overflow_flag uint8_t  channel  ) 
 

This function clears the channel interrupt oveflow flag.

Parameters:
channel - The eTPU channel number

Definition at line 1088 of file etpu_util.c.

References eTPU_struct::CIOSR_A, eTPU_struct::CIOSR_B, and eTPU.

void fs_etpu_clear_global_exceptions void   ) 
 

This function clears all eTPU global exceptions.

Definition at line 1214 of file etpu_util.c.

References eTPU, and eTPU_struct::MCR.

void fs_etpu_clear_idle_cnt_a void   ) 
 

This function clears the engine A Idle Count Register.

Warning:
This function is applicable to eTPU2 only.

Definition at line 1288 of file etpu_util.c.

References eTPU, and eTPU_struct::IDLE_A.

void fs_etpu_clear_idle_cnt_b void   ) 
 

This function clears the engine B Idle Count Register.

Warning:
This function is applicable to eTPU2 only.

Definition at line 1300 of file etpu_util.c.

References eTPU, and eTPU_struct::IDLE_B.

uint32_t fs_etpu_coherent_read_24 uint8_t  channel,
uint32_t  offset1,
uint32_t  offset2,
int32_t *  value1,
int32_t *  value2
 

This function coherently reads two 24-bit variables from the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).

Parameters:
channel - The eTPU channel number
offset1 - The offset to the first 24-bit variable to be read
offset2 - The offset to the second 24-bit variable to be read
*value1 - A pointer to where the first variable value will be stored
*value2 - A pointer to where the second variable value will be stored
Returns:
Zero or an error code. Error codes that can be returned are:

Definition at line 1323 of file etpu_util.c.

References eTPU_struct::CDCR, eTPU_struct::CHAN, eTPU, fs_etpu_data_ram_end, fs_etpu_data_ram_start, FS_ETPU_ERROR_ADDRESS, FS_ETPU_ERROR_MALLOC, and fs_free_param.

uint32_t fs_etpu_coherent_read_32 uint8_t  channel,
uint32_t  offset1,
uint32_t  offset2,
uint32_t *  value1,
uint32_t *  value2
 

This function coherently reads two 32-bit variables from the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).

Parameters:
channel - The eTPU channel number
offset1 - The offset to the first 32-bit variable to be read
offset2 - The offset to the second 32-bit variable to be read
*value1 - A pointer to where the first variable value will be stored
*value2 - A pointer to where the second variable value will be stored
Returns:
Zero or an error code. Error codes that can be returned are:

Definition at line 1395 of file etpu_util.c.

References eTPU_struct::CDCR, eTPU_struct::CHAN, eTPU, fs_etpu_data_ram_end, fs_etpu_data_ram_start, FS_ETPU_ERROR_ADDRESS, FS_ETPU_ERROR_MALLOC, and fs_free_param.

uint32_t fs_etpu_coherent_write_24 uint8_t  channel,
uint32_t  offset1,
uint32_t  offset2,
int32_t  value1,
int32_t  value2
 

This function coherently writes two 24-bit variables into the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).

Parameters:
channel - The eTPU channel number
offset1 - The offset to the first 24-bit variable to be written
offset2 - The offset to the second 24-bit variable to be written
value1 - The first variable value
value2 - The second variable value
Returns:
Zero or an error code. Error codes that can be returned are:

Definition at line 1467 of file etpu_util.c.

References eTPU_struct::CDCR, eTPU_struct::CHAN, eTPU, fs_etpu_data_ram_end, fs_etpu_data_ram_start, FS_ETPU_ERROR_ADDRESS, FS_ETPU_ERROR_MALLOC, and fs_free_param.

uint32_t fs_etpu_coherent_write_32 uint8_t  channel,
uint32_t  offset1,
uint32_t  offset2,
uint32_t  value1,
uint32_t  value2
 

This function coherently writes two 32-bit variables into the eTPU DATA RAM, using the Coherent Dual-Parameter Controller (CDC).

Parameters:
channel - The eTPU channel number
offset1 - The offset to the first 32-bit variable to be written
offset2 - The offset to the second 32-bit variable to be written
value1 - The first variable value
value2 - The second variable value
Returns:
Zero or an error code. Error codes that can be returned are:

Definition at line 1540 of file etpu_util.c.

References eTPU_struct::CDCR, eTPU_struct::CHAN, eTPU, fs_etpu_data_ram_end, fs_etpu_data_ram_start, FS_ETPU_ERROR_ADDRESS, FS_ETPU_ERROR_MALLOC, and fs_free_param.

uint32_t* fs_etpu_data_ram uint8_t  channel  ) 
 

This function returns a pointer to the start of the data RAM for the specified channel.

Parameters:
channel - The eTPU channel number
Returns:
A pointer to the start of the eTPU DATA RAM allocated for the channel
Warning:
This function does no error checking. If the channel has not been initialized then an undefined value will be returned (normally 0).

Definition at line 292 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

Referenced by fs_etpu_malloc2().

void fs_etpu_disable uint8_t  channel  ) 
 

This function disables an eTPU channel.

Parameters:
channel - The eTPU channel number
Warning:
If the channel is currently being serviced then the service will complete.

Definition at line 363 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and FS_ETPU_PRIORITY_DISABLE.

void fs_etpu_dma_disable uint8_t  channel  ) 
 

This function disables an eTPU channel from generating DMA requests.

Parameters:
channel - The eTPU channel number
Warning:
When DMA requests are disabled the eTPU DMA request status bits are still set and can be used to poll the DMA request status.

Definition at line 428 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and FALSE.

void fs_etpu_dma_enable uint8_t  channel  ) 
 

This function enables an eTPU channel to request DMA service.

Parameters:
channel - The eTPU channel number
Warning:
In a given device not all of the DMA requests may be connected to DMA channels.

Definition at line 412 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and TRUE.

void fs_etpu_enable uint8_t  channel,
uint8_t  priority
 

This function enables or changes the priority of an eTPU channel.

Parameters:
channel - The eTPU channel number
priority - The priority to be assigned to the channel. This should be assigned a value of

Definition at line 346 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

uint8_t fs_etpu_get_chan_dma_flag uint8_t  channel  ) 
 

This function returns the current value of the Data Transfer Request Status bit of the specified eTPU channel.

Parameters:
channel - The eTPU channel number
Returns:
Value of DTRS bit of the specified channel SCR register.

Definition at line 1111 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

uint8_t fs_etpu_get_chan_dma_overflow_flag uint8_t  channel  ) 
 

uint8_t fs_etpu_get_chan_interrupt_flag uint8_t  channel  ) 
 

This function returns the current value of the Channel Interrupt Status bit of the specified eTPU channel.

Parameters:
channel - The eTPU channel number
Returns:
Value of CIS bit of the specified channel SCR register.

Definition at line 1039 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

uint8_t fs_etpu_get_chan_interrupt_overflow_flag uint8_t  channel  ) 
 

uint16_t fs_etpu_get_chan_local_16 uint8_t  channel,
uint32_t  offset
 

This function reads a 16-bit parameter from an eTPU channel.

Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This must be a 16-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The 16-bit value of the parameter.

Definition at line 667 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

uint24_t fs_etpu_get_chan_local_24 uint8_t  channel,
uint32_t  offset
 

This function reads a unsigned 24-bit parameter from an eTPU channel.

Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This must be a 24-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The unsigned 24-bit value of the parameter.

Definition at line 649 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

int24_t fs_etpu_get_chan_local_24s uint8_t  channel,
uint32_t  offset
 

This function reads a signed 24-bit parameter from an eTPU channel.

Note:
This function uses the sign extended area of the DATA RAM.
Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This must be a 24-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The signed 24-bit value of the parameter.

Definition at line 631 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_ext.

uint32_t fs_etpu_get_chan_local_32 uint8_t  channel,
uint32_t  offset
 

This function reads a 32-bit parameter from an eTPU channel..

Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This must be a 32-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The 32-bit value of the parameter.

Definition at line 611 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

uint8_t fs_etpu_get_chan_local_8 uint8_t  channel,
uint32_t  offset
 

This function reads an 8-bit parameter from an eTPU channel.

Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This value is normally provided by the eTPU compiler.
Returns:
The 8-bit value of the parameter.

Definition at line 685 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

uint16_t fs_etpu_get_global_16 uint32_t  offset  ) 
 

This function reads a 16-bit global variable.

Parameters:
offset - The byte offset to the variable. This must be a 16-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The 16-bit value of the variable.

Definition at line 818 of file etpu_util.c.

References fs_etpu_data_ram_start.

uint24_t fs_etpu_get_global_24 uint32_t  offset  ) 
 

This function reads an unsigned 24-bit global variable.

Parameters:
offset - The byte offset to the variable. This must be a 24-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The unsigned 24-bit value of the variable.

Definition at line 802 of file etpu_util.c.

References fs_etpu_data_ram_start.

int24_t fs_etpu_get_global_24s uint32_t  offset  ) 
 

This function reads a signed 24-bit global variable.

Note:
This function uses the sign extended area of the DATA RAM.
Parameters:
offset - The byte offset to the variable. This must be a 24-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The signed 24-bit value of the variable.

Definition at line 786 of file etpu_util.c.

References fs_etpu_data_ram_ext.

uint32_t fs_etpu_get_global_32 uint32_t  offset  ) 
 

This function reads a 32-bit global variable.

Parameters:
offset - The byte offset to the variable. This must be a 32-bit aligned value. This value is normally provided by the eTPU compiler.
Returns:
The 32-bit value of the variable.

Definition at line 768 of file etpu_util.c.

References fs_etpu_data_ram_start.

uint8_t fs_etpu_get_global_8 uint32_t  offset  ) 
 

This function reads an 8-bit global variable.

Parameters:
offset - The byte offset to the variable. This value is normally provided by the eTPU compiler.
Returns:
The 8-bit value of the variable.

Definition at line 834 of file etpu_util.c.

References fs_etpu_data_ram_start.

uint32_t fs_etpu_get_global_error void   ) 
 

This function reads the Global Error value from eTPU DATA RAM, which is used by Freescale eTPU functions to reports unhandled events.

Returns:
The 32-bit value of the Global Error is returned. The Global Error value includes 2 fields. Under FS_ETPU_GLOBAL_ERROR_CHANNEL_MASK there is the channel number of the channel where the unhandled event occurred. Under FS_ETPU_GLOBAL_ERROR_EVENT_MASK there is the event condition which may include one or more the following bits:
  • FS_ETPU_GLOBAL_ERROR_EVENT_LSR
  • FS_ETPU_GLOBAL_ERROR_EVENT_MRLA
  • FS_ETPU_GLOBAL_ERROR_EVENT_MRLB
  • FS_ETPU_GLOBAL_ERROR_EVENT_TDLA
  • FS_ETPU_GLOBAL_ERROR_EVENT_TDLB
  • FS_ETPU_GLOBAL_ERROR_EVENT_PSS
  • and for eTPU2 only also
  • FS_ETPU_GLOBAL_ERROR_EVENT_FLAG0
  • FS_ETPU_GLOBAL_ERROR_EVENT_FLAG1

Definition at line 1242 of file etpu_util.c.

References fs_etpu_data_ram_start.

uint32_t fs_etpu_get_global_exceptions void   ) 
 

This function returns the global exception flags.

Note:
This function can be used after eTPU global exception interrupt. This function enables to decode the source of the global exception.
Parameters:
channel - The eTPU channel number
Returns:
The returned value can include the following exception bits:

Definition at line 1195 of file etpu_util.c.

References eTPU, FS_ETPU_ILLEGAL_INSTRUCTION_A, FS_ETPU_ILLEGAL_INSTRUCTION_B, FS_ETPU_MICROCODE_GLOBAL_EX_A, FS_ETPU_MICROCODE_GLOBAL_EX_B, FS_ETPU_SCM_MISC_FLAG, FS_ETPU_SCM_READ_ERROR, FS_ETPU_SDM_READ_ERROR, FS_ETPU_SHARED_SUBSYS_ACC_ERR, FS_ETPU_WATCHDOG_TIMEOUT_A, FS_ETPU_WATCHDOG_TIMEOUT_B, and eTPU_struct::MCR.

uint8_t fs_etpu_get_hsr uint8_t  channel  ) 
 

This function returns the current value of the Host Service Request (HSR) register of the specified eTPU channel.

Parameters:
channel - The eTPU channel number
Returns:
The value of HSR register

Definition at line 328 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

uint24_t fs_etpu_get_idle_cnt_a void   ) 
 

This function returns the current value of engine A Idle Count Register.

Returns:
The 32-bit number of the idle microinstruction cycles is returned.
Warning:
This function is applicable to eTPU2 only.

Definition at line 1261 of file etpu_util.c.

References eTPU, and eTPU_struct::IDLE_A.

uint24_t fs_etpu_get_idle_cnt_b void   ) 
 

This function returns the current value of engine B Idle Count Register.

Returns:
The 32-bit number of the idle microinstruction cycles is returned.
Warning:
This function is applicable to eTPU2 only.

Definition at line 1276 of file etpu_util.c.

References eTPU, and eTPU_struct::IDLE_B.

uint32_t fs_etpu_init struct etpu_config_t  p_etpu_config,
uint32_t *  code,
uint32_t  code_size,
uint32_t *  globals,
uint32_t  globals_size
 

This function initializes the eTPU module.

Note:
The following actions are performed in order:
  1. Load eTPU code into code RAM
  2. Initialize global registers:
    • Module Control Register
    • MISC value
    • Engine Control Registers
    • TCR pre-scalers
  3. Copy initial values of global variables to data RAM
Parameters:
p_etpu_config - This is the structure used to initialize the eTPU
*code - This is a pointer to an image of the eTPU code.
code_size - This is the size of the eTPU code in bytes.
*globals - This is a pointer to the global eTPU data that needs to be initialized.
globals_size - This is the size of the global data in bytes.
Returns:
Zero or an error code. Error codes that can be returned are:
Warning:
This function does not configure the pins, only the eTPU.

Definition at line 106 of file etpu_util.c.

References etpu_config_t::ecr_a, eTPU_struct::ECR_A, etpu_config_t::ecr_b, eTPU_struct::ECR_B, eTPU, fs_etpu_code_start, fs_etpu_data_ram_start, FS_ETPU_ERROR_CODESIZE, FS_ETPU_ERROR_VIS_BIT_NOT_SET, fs_free_param, fs_memcpy32(), fs_memset32(), etpu_config_t::mcr, eTPU_struct::MCR, etpu_config_t::misc, eTPU_struct::MISCCMPR, eTPU_struct::REDCR_A, eTPU_struct::REDCR_B, etpu_config_t::stacr_a, etpu_config_t::stacr_b, etpu_config_t::tbcr_a, eTPU_struct::TBCR_A, etpu_config_t::tbcr_b, and eTPU_struct::TBCR_B.

void fs_etpu_interrupt_disable uint8_t  channel  ) 
 

This function disables an eTPU channel from generating interrupts.

Parameters:
channel - The eTPU channel number
Warning:
When interrupts are disabled the eTPU interrupt status bits are still set and can be used to poll the interrupt status.

Definition at line 396 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and FALSE.

void fs_etpu_interrupt_enable uint8_t  channel  ) 
 

This function enables an eTPU channel to generate interrupts.

Parameters:
channel - The eTPU channel number
Warning:
This enables the eTPU to send interrupts to an interrupt controller. Additional configuration may be required for the CPU to receive the interrupts.

Definition at line 380 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and TRUE.

uint32_t* fs_etpu_malloc uint16_t  num_bytes  ) 
 

This function allocates DATA RAM (parameter RAM) for a channel.

Parameters:
num_bytes - this is the number of bytes that is required to allocate in DATA RAM.
Returns:
A pointer to allocated DATA RAM. If the requested amount of memory is larger than the available amount of memory then 0 is returned.
Warning:
This function is non-reentrant and uses the fs_free_param global. The granularity of eTPU DATA RAM allocation for channel parameters is 8 bytes. The requested size is enlarged to a multiple of 8 bytes.

Definition at line 464 of file etpu_util.c.

References fs_etpu_data_ram_end, and fs_free_param.

Referenced by fs_etpu_chan_init().

uint32_t* fs_etpu_malloc2 uint8_t  channel,
uint16_t  num_bytes
 

This function allocates DATA RAM for a channel if it has not been allocated before.

Note:
This function is similar to fs_etpu_malloc. The difference is that this function first checks to see if the CPBA is not zero. If it is not zero then it assumes the channel has already been initialized and does not allocate more data RAM to the channel.
Parameters:
channel - The eTPU channel number
num_bytes - this is the number of bytes that is required to allocate in DATA RAM.
Returns:
A pointer to allocated DATA RAM. If the requested amount of memory is larger than the available amount of memory then 0 is returned.
Warning:
The granularity of eTPU DATA RAM allocation for channel parameters is 8 bytes. The requested size is enlarged to a multiple of 8 bytes.

Definition at line 499 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, fs_etpu_data_ram(), fs_etpu_data_ram_end, and fs_free_param.

void fs_etpu_set_chan_local_16 uint8_t  channel,
uint32_t  offset,
uint16_t  value
 

This function sets a 16-bit parameter for an eTPU channel.

Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This must be a 16-bit aligned value. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 573 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

void fs_etpu_set_chan_local_24 uint8_t  channel,
uint32_t  offset,
uint24_t  value
 

This function sets a 24-bit parameter for an eTPU channel.

Note:
This function uses the sign extended location of the data memory to write only 24 bits to the data memory. This 24 bit write is an atomic operation and does not effect the upper 8 bits of the 32 bit value associated with the 24 bits
Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This must be a 24-bit aligned value. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 555 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_ext.

void fs_etpu_set_chan_local_32 uint8_t  channel,
uint32_t  offset,
uint32_t  value
 

This function sets a 32-bit parameter for an eTPU channel.

Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This must be a 32-bit aligned value. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 532 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

void fs_etpu_set_chan_local_8 uint8_t  channel,
uint32_t  offset,
uint8_t  value
 

This function sets an 8-bit parameter for an eTPU channel.

Parameters:
channel - The eTPU channel number
offset - The byte offset to the parameter. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 591 of file etpu_util.c.

References eTPU_struct::CHAN, eTPU, and fs_etpu_data_ram_start.

void fs_etpu_set_dma_mask_a uint32_t  mask  ) 
 

This function enables or disables channel DMA request for each engine A channel according to the given mask.

Parameters:
mask - The DMA enable mask. A value of:
  • 0x00000001 enables DMA requests on channel 0 only,
  • 0x80000000 enables DMA requests on channel 31 only

Definition at line 949 of file etpu_util.c.

References eTPU_struct::CDTRER_A, and eTPU.

void fs_etpu_set_dma_mask_b uint32_t  mask  ) 
 

This function enables or disables channel DMA request for each engine B channel according to the given mask.

Parameters:
mask - The DMA enable mask. A value of:
  • 0x00000001 enables DMA requests on channel 64 only,
  • 0x80000000 enables DMA requests on channel 95 only

Definition at line 965 of file etpu_util.c.

References eTPU_struct::CDTRER_B, and eTPU.

void fs_etpu_set_global_16 uint32_t  offset,
uint16_t  value
 

This function writes to a 16-bit global variable.

Parameters:
offset - The byte offset to the variable. This must be a 16-bit aligned value. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 734 of file etpu_util.c.

References fs_etpu_data_ram_start.

void fs_etpu_set_global_24 uint32_t  offset,
uint24_t  value
 

This function writes to a 24-bit global variable.

Parameters:
offset - The byte offset to the variable. This must be a 24-bit aligned value. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 718 of file etpu_util.c.

References fs_etpu_data_ram_ext.

void fs_etpu_set_global_32 uint32_t  offset,
uint32_t  value
 

This function writes to a 32-bit global variable.

Parameters:
offset - The byte offset to the variable. This must be a 32-bit aligned value. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 702 of file etpu_util.c.

References fs_etpu_data_ram_start.

void fs_etpu_set_global_8 uint32_t  offset,
uint8_t  value
 

This function writes to an 8-bit global variable.

Parameters:
offset - The byte offset to the variable. This value is normally provided by the eTPU compiler.
value - The value to write to the parameter

Definition at line 750 of file etpu_util.c.

References fs_etpu_data_ram_start.

void fs_etpu_set_hsr uint8_t  channel,
uint8_t  hsr
 

This function sets the Host Service Request (HSR) register of the specified eTPU channel.

Parameters:
channel - The eTPU channel number
hsr - The HSR value to send to the channel
Warning:
The application should check that the HSR field is 0 before calling this routine. If the HSR field is not 0 then the 2 values will be ORed together.

Definition at line 311 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

void fs_etpu_set_interrupt_mask_a uint32_t  mask  ) 
 

This function enables or disables channel interrupt for each engine A channel according to the given mask.

Parameters:
mask - The interrupt enable mask. A value of:
  • 0x00000001 enables interrupt on channel 0 only,
  • 0x80000000 enables interrupt on channel 31 only

Definition at line 917 of file etpu_util.c.

References eTPU_struct::CIER_A, and eTPU.

void fs_etpu_set_interrupt_mask_b uint32_t  mask  ) 
 

This function enables or disables channel interrupt for each engine B channel according to the given mask.

Parameters:
mask - The interrupt enable mask. A value of:
  • 0x00000001 enables interrupt on channel 64 only,
  • 0x80000000 enables interrupt on channel 95 only

Definition at line 933 of file etpu_util.c.

References eTPU_struct::CIER_B, and eTPU.

void fs_etpu_set_output_disable_mask_a uint32_t  mask,
uint32_t  polarity
 

This function enables or disables the channel "output disable" feature for each engine A channel according to the given mask and polarity.

Parameters:
mask - The "output disable" enable mask. A value of:
  • 0x00000001 enables the "output disable" feature on channel 0 only,
  • 0x80000000 enables the "output disable" feature on channel 31 only
polarity - The "output disable" polarity mask. A value of:
  • 0x00000001 sets the high polarity of disabled output on channel 0 and low polarity of disabled output on all other channels

Definition at line 985 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

void fs_etpu_set_output_disable_mask_b uint32_t  mask,
uint32_t  polarity
 

This function enables or disables the channel "output disable" feature for each engine B channel according to the given mask and polarity.

Parameters:
mask - The "output disable" enable mask. A value of:
  • 0x00000001 enables the "output disable" feature on channel 64 only,
  • 0x80000000 enables the "output disable" feature on channel 95 only
polarity - The "output disable" polarity mask. A value of:
  • 0x00000001 sets the high polarity of disabled output on channel 64 and low polarity of disabled output on all other channels

Definition at line 1014 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

uint32_t* fs_memcpy32 uint32_t *  dest,
uint32_t *  source,
uint32_t  size
 

This function is similar to the standard C memset() function however it sets 32-bit words rather than bytes.

Parameters:
*dest - The pointer to the destination location
*source - The pointer to the source location
size - The size of the data to copy in bytes
Returns:
A pointer to the end of the copied data.
Warning:
The *dest and *source pointers should be aligned to a 32-bit address. If they are not it may cause memory exceptions. Moving data to the eTPU code memory that is not 32-bit aligned is undefined. The size should be a multiple of 4. If it is not it is rounded down.

Definition at line 858 of file etpu_util.c.

Referenced by fs_etpu_init().

void fs_memset32 uint32_t *  start,
uint32_t  value,
int32_t  size
 

This function is similar to the standard C memcpy() function however it copies 32-bit words rather than bytes.

Parameters:
*start - The pointer to the start location
*value - The value to write to memory
size - The size of the data to set in bytes
Warning:
The *start pointers should be aligned to a 32-bit address. If it is not it may cause memory exceptions. Writing data to the eTPU code memory that is not 32-bit aligned is undefined. The size should be a multiple of 4. If it is not it is rounded down.

Definition at line 892 of file etpu_util.c.

Referenced by fs_etpu2_init(), and fs_etpu_init().

void fs_timer_start void   ) 
 

This function starts the timebases.

Note:
This functions synchronously starts the timebases of all timer modules on a device.
Parameters:
channel - The eTPU channel number

Definition at line 444 of file etpu_util.c.

References eTPU, eTPU_struct::MCR, and TRUE.


Variable Documentation

struct eTPU_struct* eTPU
 

Access to eTPU registers' structure.

Referenced by fs_etpu2_init(), fs_etpu_chan_init(), fs_etpu_clear_chan_dma_flag(), fs_etpu_clear_chan_dma_oveflow_flag(), fs_etpu_clear_chan_interrupt_flag(), fs_etpu_clear_chan_interrupt_overflow_flag(), fs_etpu_clear_global_exceptions(), fs_etpu_clear_idle_cnt_a(), fs_etpu_clear_idle_cnt_b(), fs_etpu_coherent_read_24(), fs_etpu_coherent_read_32(), fs_etpu_coherent_write_24(), fs_etpu_coherent_write_32(), fs_etpu_data_ram(), fs_etpu_disable(), fs_etpu_dma_disable(), fs_etpu_dma_enable(), fs_etpu_enable(), fs_etpu_get_chan_dma_flag(), fs_etpu_get_chan_dma_oveflow_flag(), fs_etpu_get_chan_interrupt_flag(), fs_etpu_get_chan_interrupt_oveflow_flag(), fs_etpu_get_chan_local_16(), fs_etpu_get_chan_local_24(), fs_etpu_get_chan_local_24s(), fs_etpu_get_chan_local_32(), fs_etpu_get_chan_local_8(), fs_etpu_get_global_exceptions(), fs_etpu_get_hsr(), fs_etpu_get_idle_cnt_a(), fs_etpu_get_idle_cnt_b(), fs_etpu_init(), fs_etpu_interrupt_disable(), fs_etpu_interrupt_enable(), fs_etpu_malloc2(), fs_etpu_set_chan_local_16(), fs_etpu_set_chan_local_24(), fs_etpu_set_chan_local_32(), fs_etpu_set_chan_local_8(), fs_etpu_set_dma_mask_a(), fs_etpu_set_dma_mask_b(), fs_etpu_set_hsr(), fs_etpu_set_interrupt_mask_a(), fs_etpu_set_interrupt_mask_b(), fs_etpu_set_output_disable_mask_a(), fs_etpu_set_output_disable_mask_b(), and fs_timer_start().

uint32_t* fs_free_param
 

Pointer to the first free parameter in eTPU DATA RAM.

Referenced by fs_etpu2_init(), fs_etpu_coherent_read_24(), fs_etpu_coherent_read_32(), fs_etpu_coherent_write_24(), fs_etpu_coherent_write_32(), fs_etpu_init(), fs_etpu_malloc(), and fs_etpu_malloc2().