Main Page | Modules | Data Structures | File List | Data Fields | Globals

tpu.h File Reference

Low-level TPU functions. More...

#include <68332/types.h>

Go to the source code of this file.

Data Structures

struct  _TPUObject
struct  _TPUChannel

Defines

#define PRAM_ADDRESS(c, p)   ( (((c) << 4) & 0xF0) | ((p) & 0x0F) )
#define set_channel_master(channel, master)   (channel->master = master)
#define channel_shares_tpu(channelA, channelB)   (channelA->TPUHardware == channelB->TPUHardware)

Typedefs

typedef _TPUObject TPUObject
typedef _TPUObjectTPUObjectP
typedef _TPUChannel TPUChannel
typedef _TPUChannelTPUChannelP

Enumerations

enum  tpu_errno_t {
  TPU_ERROR_NONE = 0, TPU_NUMBER_OUT_OF_RANGE, TPU_CHANNEL_IN_USE, TPU_CHANNEL_OUT_OF_RANGE,
  TPU_ARGUMENT_OUT_OF_RANGE
}
enum  tpu_channel_t {
  TPU_CHANNEL0 = 0, TPU_CHANNEL1, TPU_CHANNEL2, TPU_CHANNEL3,
  TPU_CHANNEL4, TPU_CHANNEL5, TPU_CHANNEL6, TPU_CHANNEL7,
  TPU_CHANNEL8, TPU_CHANNEL9, TPU_CHANNEL10, TPU_CHANNEL11,
  TPU_CHANNEL12, TPU_CHANNEL13, TPU_CHANNEL14, TPU_CHANNEL15
}
enum  tpu_prio_t { TPU_PRIO_NONE = 0, TPU_PRIO_LOW = 1, TPU_PRIO_MEDIUM = 2, TPU_PRIO_HIGH = 3 }
enum  tpu_pram_word_t {
  TPU_PRAM_SLOT0 = 0x0, TPU_PRAM_SLOT1 = 0x1, TPU_PRAM_SLOT2 = 0x2, TPU_PRAM_SLOT3 = 0x3,
  TPU_PRAM_SLOT4 = 0x4, TPU_PRAM_SLOT5 = 0x5, TPU_PRAM_SLOT6 = 0x6, TPU_PRAM_SLOT7 = 0x7
}
enum  tpu_pram_byte_t {
  TPU_PRAM_SLOT0L = 0x0, TPU_PRAM_SLOT0H = 0x1, TPU_PRAM_SLOT1L = 0x2, TPU_PRAM_SLOT1H = 0x3,
  TPU_PRAM_SLOT2L = 0x4, TPU_PRAM_SLOT2H = 0x5, TPU_PRAM_SLOT3L = 0x6, TPU_PRAM_SLOT3H = 0x7,
  TPU_PRAM_SLOT4L = 0x8, TPU_PRAM_SLOT4H = 0x9, TPU_PRAM_SLOT5L = 0xA, TPU_PRAM_SLOT5H = 0xB,
  TPU_PRAM_SLOT6L = 0xC, TPU_PRAM_SLOT6H = 0xD, TPU_PRAM_SLOT7L = 0xE, TPU_PRAM_SLOT7H = 0xF
}
enum  tpu_func_t {
  TPU_FUNC_UNINITIALIZED = 0, TPU_FUNC_QOMDO, TPU_FUNC_QOMPWM, TPU_FUNC_QOMPULSE,
  TPU_FUNC_FQD_A, TPU_FUNC_FQD_B, TPU_FUNC_FQDDI, TPU_FUNC_MCPWM_MASTER,
  TPU_FUNC_MCPWM_SLAVE, TPU_FUNC_PTA_0, TPU_FUNC_PTA_1, TPU_FUNC_PTA_2,
  TPU_FUNC_PTA_3
}

Functions

int tpu_init (uint16 tpu_num)
int tpu_init_extended (uint16 tpu_num, uint16 tcr1p, uint16 tcr2p, uint16 psck)
uint32 tpu_get_tcr1_freq (uint16 tpu_num)
uint32 tpu_get_tcr2_freq (uint16 tpu_num)
int tpu_init_interrupts (uint16 tpu_num, uint16 iarb, uint16 cirl, uint16 cibv)
TPUChanneltpu_request_channel (uint16 tpu_num, uint16 channel_num)
int tpu_release_channel (uint16 tpu_num, uint16 channel_num)
int tpu_set_CIER (TPUChannel *handle, uint16 value)
int tpu_get_CISR (TPUChannel *handle)
int tpu_clear_CISR (TPUChannel *handle)
int tpu_set_CFSR (TPUChannel *handle, uint16 function_code)
int tpu_get_CFSR (TPUChannel *handle)
int tpu_set_HSQR (TPUChannel *handle, uint16 value)
int tpu_get_HSQR (TPUChannel *handle)
int tpu_set_HSRR (TPUChannel *handle, uint16 value)
int tpu_get_HSRR (TPUChannel *handle)
int tpu_set_CPR (TPUChannel *handle, uint16 value)
int tpu_get_CPR (TPUChannel *handle)
int tpu_write_parameter_word (TPUChannel *handle, tpu_pram_word_t entry, uint16 value)
int tpu_write_parameter_byte (TPUChannel *handle, tpu_pram_byte_t entry, uint8 value)
int tpu_read_parameter_word (TPUChannel *handle, tpu_pram_word_t entry, uint16 *value)
int tpu_read_parameter_byte (TPUChannel *handle, tpu_pram_byte_t entry, uint8 *value)
void tpu_perror (TPUChannel *handle)


Detailed Description

This file contains the global function prototypes and data structures for the lowlevel TPU support in libtpu.

To use the functions defined in this file, include <68332/tpu.h> and link libtpu.a.


Define Documentation

#define PRAM_ADDRESS c,
 )     ( (((c) << 4) & 0xF0) | ((p) & 0x0F) )
 

Generate a pram address to be used as a pointer.

This macro returns an address that can be used in the pram to refrence the pram of another channel. its used for things like high_time_ptr in the mcpwm function.

Parameters:
c The channel.
p The pram entry you want the addres of.

#define set_channel_master channel,
master   )     (channel->master = master)
 

Set the master channel for a particular channel

#define channel_shares_tpu channelA,
channelB   )     (channelA->TPUHardware == channelB->TPUHardware)
 

Check to see if two channels share the same TPU


Typedef Documentation

typedef struct _TPUObject TPUObject
 

Alias for struct _TPUObject, representing a TPU object

typedef struct _TPUObject* TPUObjectP
 

Alias for a pointer to struct _TPUObject

typedef struct _TPUChannel TPUChannel
 

Alias for struct _TPUChannel, representing a TPU channel

typedef struct _TPUChannel* TPUChannelP
 

Alias for a pointer to struct _TPUChannel


Enumeration Type Documentation

enum tpu_errno_t
 

TPU error codes.

Enumeration values:
TPU_ERROR_NONE 
TPU_NUMBER_OUT_OF_RANGE 
TPU_CHANNEL_IN_USE 
TPU_CHANNEL_OUT_OF_RANGE 
TPU_ARGUMENT_OUT_OF_RANGE 

enum tpu_channel_t
 

TPU Channel numbers

Enumeration values:
TPU_CHANNEL0 
TPU_CHANNEL1 
TPU_CHANNEL2 
TPU_CHANNEL3 
TPU_CHANNEL4 
TPU_CHANNEL5 
TPU_CHANNEL6 
TPU_CHANNEL7 
TPU_CHANNEL8 
TPU_CHANNEL9 
TPU_CHANNEL10 
TPU_CHANNEL11 
TPU_CHANNEL12 
TPU_CHANNEL13 
TPU_CHANNEL14 
TPU_CHANNEL15 

enum tpu_prio_t
 

TPU Priority numbers.

Enumeration values:
TPU_PRIO_NONE 
TPU_PRIO_LOW 
TPU_PRIO_MEDIUM 
TPU_PRIO_HIGH 

enum tpu_pram_word_t
 

TPU Word pram slots.

Enumeration values:
TPU_PRAM_SLOT0 
TPU_PRAM_SLOT1 
TPU_PRAM_SLOT2 
TPU_PRAM_SLOT3 
TPU_PRAM_SLOT4 
TPU_PRAM_SLOT5 
TPU_PRAM_SLOT6 
TPU_PRAM_SLOT7 

enum tpu_pram_byte_t
 

TPU Byte pram slots.

Enumeration values:
TPU_PRAM_SLOT0L 
TPU_PRAM_SLOT0H 
TPU_PRAM_SLOT1L 
TPU_PRAM_SLOT1H 
TPU_PRAM_SLOT2L 
TPU_PRAM_SLOT2H 
TPU_PRAM_SLOT3L 
TPU_PRAM_SLOT3H 
TPU_PRAM_SLOT4L 
TPU_PRAM_SLOT4H 
TPU_PRAM_SLOT5L 
TPU_PRAM_SLOT5H 
TPU_PRAM_SLOT6L 
TPU_PRAM_SLOT6H 
TPU_PRAM_SLOT7L 
TPU_PRAM_SLOT7H 

enum tpu_func_t
 

TPU function that the channel is currently initialized for.

Enumeration values:
TPU_FUNC_UNINITIALIZED 
TPU_FUNC_QOMDO 
TPU_FUNC_QOMPWM 
TPU_FUNC_QOMPULSE 
TPU_FUNC_FQD_A 
TPU_FUNC_FQD_B 
TPU_FUNC_FQDDI 
TPU_FUNC_MCPWM_MASTER 
TPU_FUNC_MCPWM_SLAVE 
TPU_FUNC_PTA_0 
TPU_FUNC_PTA_1 
TPU_FUNC_PTA_2 
TPU_FUNC_PTA_3 


Function Documentation

int tpu_init uint16  tpu_num  ) 
 

Initialize a TPU object.

This sets up the TPU with default settings for the prescalers.

Parameters:
tpu_num Indicates which TPU to initialize; starts at 0.
Returns:
0 = success, -1 = failure.

int tpu_init_extended uint16  tpu_num,
uint16  tcr1p,
uint16  tcr2p,
uint16  psck
 

Initialize a TPU object.

This lets you set up every aspect of the TPU, except EMU Mode.

Parameters:
tpu_num Indicates which TPU to initialize; starts at 0.
tcr1p The TCR1 Prescaler settings, see pg 2-2 in the TPU RM.
tcr2p The TCR2 Prescaler settings, see pg 2-4 in the TPU RM.
psck The TPU prescaler clock setting, see pg 2-5 in the TPU RM.
Returns:
0 = success, -1 = failure.

uint32 tpu_get_tcr1_freq uint16  tpu_num  ) 
 

Returns the TCR1 frequency that the TPU is using.

Parameters:
tpu_num Indicates which TPU to retrieve the TCR1 frequency from; starts at 0.
Returns:
Frequency in Hz, 0 = failure.

uint32 tpu_get_tcr2_freq uint16  tpu_num  ) 
 

Returns the TCR2 frequency that the TPU is using.

Parameters:
tpu_num Indicates which TPU to retrieve the TCR2 frequency from; starts at 0.
Returns:
Frequency in Hz, 0 = failure.

int tpu_init_interrupts uint16  tpu_num,
uint16  iarb,
uint16  cirl,
uint16  cibv
 

Initialize TPU interrupts.

Parameters:
tpu_num Indicates which TPU to initialize; starts at 0.
iarb The interrupt arbitration level for this module (0-0xF).
cirl The interrupt request level for all channels in the TPU.
cibv The interrupt base vector of the TPU. This is the high nybble.
Returns:
0 = success, -1 = failure.

TPUChannel* tpu_request_channel uint16  tpu_num,
uint16  channel_num
 

Request a TPU channel.

This function lets you reserve a TPU channel for use by your function.

Parameters:
tpu_num Indicates which TPU to operate on; starts at 0.
channel_num The channel you wish to reserve.
Returns:
TPUChannel handle.

int tpu_release_channel uint16  tpu_num,
uint16  channel_num
 

Release a TPU channel.

The function lets you notify the TPU that you are no longer using a channel.

Parameters:
tpu_num Indicates which TPU to operate on; starts at 0.
channel_num The channel you wish to release.
Returns:
0 = success, -1 = failure.

int tpu_set_CIER TPUChannel handle,
uint16  value
 

Write the CIER for a particular channel.

This function allows you to enable or disable interrupts on a per channel basis.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
value The value you wish to write. (1 enable/0 disable).
Returns:
0 = success, -1 = failure.

int tpu_get_CISR TPUChannel handle  ) 
 

Read the CISR for a particular channel.

This function allows you to get the interrupt status of a channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
Returns:
The CISR value for this channel, or -1 on error.

int tpu_clear_CISR TPUChannel handle  ) 
 

Clear the CISR for a particular channel.

This function allows you to clear the interrupt status of a channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
Returns:
0 = success, -1 = failure.

int tpu_set_CFSR TPUChannel handle,
uint16  function_code
 

Write the CFSR for a particular channel.

This function is used to set the CFSR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
function_code The function number you wish to set.
Returns:
0 = success, -1 = failure.

int tpu_get_CFSR TPUChannel handle  ) 
 

Read the CFSR for a particular channel.

This function is used to get the CFSR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
Returns:
The function code for this channel, or -1 on error.

int tpu_set_HSQR TPUChannel handle,
uint16  value
 

Write the HSQR for a particular channel.

This function is used to set the HSQR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
value The host sequence number you wish to set.
Returns:
0 = success, -1 = failure.

int tpu_get_HSQR TPUChannel handle  ) 
 

Read the HSQR for a particular channel.

This function is used to get the HSQR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
Returns:
The host sequence number for this channel, or -1 on error.

int tpu_set_HSRR TPUChannel handle,
uint16  value
 

Write the HSRR for a particular channel.

This function is used to set the HSRR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
value The host request you wish to send.
Returns:
0 = success, -1 = failure.

int tpu_get_HSRR TPUChannel handle  ) 
 

Read the HSRR for a particular channel.

This function is used to get the HSRR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
Returns:
The host request number for this channel, or -1 on error.

int tpu_set_CPR TPUChannel handle,
uint16  value
 

Write the CPR for a particular channel.

This function is used to set the CPR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
value The priority you wish to set.
Returns:
0 = success, -1 = failure.

int tpu_get_CPR TPUChannel handle  ) 
 

Read the CPR for a particular channel.

This function is used to set the CPR for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
Returns:
The channel priority for this channel, -1 on error.

int tpu_write_parameter_word TPUChannel handle,
tpu_pram_word_t  entry,
uint16  value
 

Write the parameter ram (as word) for a particular channel.

This function is used to write a parameter ram entry for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
entry The parameter ram entry you are modifying. (0-E)
value The value you wish to write.
Returns:
0 = success, -1 = failure.

int tpu_write_parameter_byte TPUChannel handle,
tpu_pram_byte_t  entry,
uint8  value
 

Write the parameter ram (as byte) for a particular channel.

This function is used to write a parameter ram entry for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
entry The parameter ram entry you are modifying. (0-F)
value The value you wish to write.
Returns:
0 = success, -1 = failure.

int tpu_read_parameter_word TPUChannel handle,
tpu_pram_word_t  entry,
uint16 value
 

Read the parameter ram (as word) for a particular channel.

This function is used to read a parameter ram entry for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
entry The parameter ram entry you are modifying. (0-E)
value Pointer to where you wish to store the value read.
Returns:
0 = success, -1 = failure.

int tpu_read_parameter_byte TPUChannel handle,
tpu_pram_byte_t  entry,
uint8 value
 

Read the parameter ram (as byte) for a particular channel.

This function is used to read a parameter ram entry for a particular channel.

Parameters:
handle A pointer to the TPUChannel that you are operating on.
entry The parameter ram entry you are modifying (0-7).
value Pointer to where you wish to store the value read.
Returns:
0 = success, -1 = failure.

void tpu_perror TPUChannel handle  ) 
 

Print the error that last occured on the TPU.

This function is used to print the error that last occured as a result of calling one of the TPU functions. This function only prints things when DEBUG is defined.

Parameters:
handle The TPUObject you are operating on.


Generated on Wed Sep 6 03:02:22 2006 for MotoRobots by doxygen 1.3.6