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

etpu_util.c File Reference


Detailed Description

This file contains useful functions for using the eTPU and eTPU2.

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

Definition in file etpu_util.c.

#include "etpu_util.h"

Go to the source code of this file.

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_data_ram (uint8_t channel)
 This function returns a pointer to the start of the data RAM for the specified 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.
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_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.
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.
void fs_timer_start (void)
 This function starts the timebases.
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_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_chan_local_32 (uint8_t channel, uint32_t offset)
 This function reads a 32-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.
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.
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_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_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.
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.
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_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_oveflow_flag (uint8_t channel)
 This function returns the current value of the Channel Interrupt Overflow Status bit of the specified eTPU channel.
void fs_etpu_clear_chan_interrupt_overflow_flag (uint8_t channel)
 This function clears the channel interrupt oveflow flag.
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_oveflow_flag (uint8_t channel)
 This function returns the current value of the Data Transfer Request Oveflow Status bit of the specified eTPU channel.
void fs_etpu_clear_chan_dma_oveflow_flag (uint8_t channel)
 This function clears the channel data transfer request oveflow flag.
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.
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_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).

Variables

uint32_t fs_etpu_code_start
uint32_t fs_etpu_data_ram_start
uint32_t fs_etpu_data_ram_end
uint32_t fs_etpu_data_ram_ext


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_struct::WDTR_A, etpu_config_t::wdtr_a, eTPU_struct::WDTR_B, and etpu_config_t::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_oveflow_flag uint8_t  channel  ) 
 

This function clears the channel data transfer request oveflow flag.

Parameters:
channel - The eTPU channel number

Definition at line 1160 of file etpu_util.c.

References eTPU_struct::CDTROSR_A, eTPU_struct::CDTROSR_B, and eTPU.

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_oveflow_flag uint8_t  channel  ) 
 

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

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

Definition at line 1147 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

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_oveflow_flag uint8_t  channel  ) 
 

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

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

Definition at line 1075 of file etpu_util.c.

References eTPU_struct::CHAN, and eTPU.

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_struct::ECR_A, etpu_config_t::ecr_a, eTPU_struct::ECR_B, etpu_config_t::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_struct::MCR, etpu_config_t::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_struct::TBCR_A, etpu_config_t::tbcr_a, eTPU_struct::TBCR_B, and etpu_config_t::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

uint32_t fs_etpu_code_start
 

Referenced by fs_etpu_init().

uint32_t fs_etpu_data_ram_end
 

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_malloc(), and fs_etpu_malloc2().

uint32_t fs_etpu_data_ram_ext
 

Referenced by fs_etpu_get_chan_local_24s(), fs_etpu_get_global_24s(), fs_etpu_set_chan_local_24(), and fs_etpu_set_global_24().

uint32_t fs_etpu_data_ram_start
 

Referenced by fs_etpu_chan_init(), 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_get_chan_local_16(), fs_etpu_get_chan_local_24(), fs_etpu_get_chan_local_32(), fs_etpu_get_chan_local_8(), fs_etpu_get_global_16(), fs_etpu_get_global_24(), fs_etpu_get_global_32(), fs_etpu_get_global_8(), fs_etpu_get_global_error(), fs_etpu_init(), fs_etpu_set_chan_local_16(), fs_etpu_set_chan_local_32(), fs_etpu_set_chan_local_8(), fs_etpu_set_global_16(), fs_etpu_set_global_32(), and fs_etpu_set_global_8().