📄 tpu_qom.c
字号:
/**************************************************************************/
/* FILE NAME: tpu_qom.c COPYRIGHT (c) MOTOROLA 2002 */
/* VERSION: 1.1 All Rights Reserved */
/* */
/* DESCRIPTION: This file contains the TPU QOM function. This function */
/* allow you to completely control TPU channels running the QOM function. */
/* They provide a simple interface requiring the minimum amount of */
/* configuration by the user. */
/*========================================================================*/
/* HISTORY ORIGINAL AUTHOR: Jeff Loeliger */
/* REV AUTHOR DATE DESCRIPTION OF CHANGE */
/* --- ----------- --------- --------------------- */
/* 1.0 J. Loeliger 21/Sep/02 Initial version of function. */
/* 1.1 J. Loeliger 05/Dec/02 Fixed potential problem with init. code*/
/* parameter RAM now cleared correctly. */
/**************************************************************************/
#include "tpu_qom.h"
#include "mpc500_util.h"
/*******************************************************************************
FUNCTION : tpu_qom_init
PURPOSE : To initialize a channel to run the QOM function in output mode.
INPUTS NOTES : This function has 4 parameters:
*tpu - This is a pointer to the TPU3 module to use. It is of
type TPU3_tag which is defined in m_tpu3.h
channel - This is the channel number of the primary QDEC
channel.
priority - This is the priority to assign to both channels.
This parameter should be assigned a value of:
TPU_PRIORITY_HIGH, TPU_PRIORITY_MIDDLE or
TPU_PRIORITY_LOW.
mode - This is the operating mode.
timebase - This is the timebase to reference.
pin - This is the intial pin state.
ref - This is an address refence in ref mode.
loop - This is the loop count in loop mode.
match - reference mode for first match.
events - This is the number of events.
event[] - This is the array of events.
RETURNS NOTES : none
WARNING : The channels must be stopped before it is reconfigured. The
function disables the channels but if they were currently
being serviced it would continue. The delay for assigning the
pram pointer may to enough but depends on system loading.
*******************************************************************************/
void tpu_qom_init(struct TPU3_tag *tpu, UINT8 channel, UINT8 priority,\
UINT8 mode, UINT8 timebase, UINT8 pin, UINT8 first_match, UINT8 loop, \
UINT8 ref, UINT8 events, union event_tag event[])
{
int x,p;
/* diable channel so it can be configured safely */
tpu_disable( tpu, channel);
/* select QOM function for channel */
tpu_func( tpu, channel, TPU_FUNCTION_QOM);
/* Initialize HSQ which determines operating mode */
tpu_hsq(tpu, channel, mode);
/* Configure parameter RAM */
tpu->PARM.R[channel][0] = (((UINT16)ref & 0xfe) << 8) | \
(((UINT16)first_match & 2) << 7) | \
(((channel << 4) + 2 + (events * 2)) & 0xFF) |\
timebase;
if (mode == TPU_QOM_LOOP)
tpu->PARM.R[channel][1] = ((UINT16)loop << 8);
if ((first_match & 1) == 1 )
tpu->PARM.R[channel][1] |= 1;
else
tpu->PARM.R[channel][1] &= 0xFFFE;
tpu->PARM.R[channel][1] &= 0xFF01;
/* build event offset and pin state table */
p = 2;
for(x=0 ; x<events ; x++){
tpu->PARM.R[channel][p++] = event[x].p;
if (p == 8){
p = 0;
channel++;
}
if (channel == 16)
channel = 0;
}
/* Initalize function with intial pin state */
tpu_hsr(tpu, channel, pin);
/* Enable channel by assigning a priority. */
tpu_enable(tpu, channel, priority);
}
/*********************************************************************
*
* Copyright:
* MOTOROLA, INC. All Rights Reserved.
* You are hereby granted a copyright license to use, modify, and
* distribute the SOFTWARE so long as this entire notice is
* retained without alteration in any modified and/or redistributed
* versions, and that such modified versions are clearly identified
* as such. No licenses are granted by implication, estoppel or
* otherwise under any patents or trademarks of Motorola, Inc. This
* software is provided on an "AS IS" basis and without warranty.
*
* To the maximum extent permitted by applicable law, MOTOROLA
* DISCLAIMS ALL WARRANTIES WHETHER EXPRESS OR IMPLIED, INCLUDING
* IMPLIED WARRANTIES OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR
* PURPOSE AND ANY WARRANTY AGAINST INFRINGEMENT WITH REGARD TO THE
* SOFTWARE (INCLUDING ANY MODIFIED VERSIONS THEREOF) AND ANY
* ACCOMPANYING WRITTEN MATERIALS.
*
* To the maximum extent permitted by applicable law, IN NO EVENT
* SHALL MOTOROLA BE LIABLE FOR ANY DAMAGES WHATSOEVER (INCLUDING
* WITHOUT LIMITATION, DAMAGES FOR LOSS OF BUSINESS PROFITS, BUSINESS
* INTERRUPTION, LOSS OF BUSINESS INFORMATION, OR OTHER PECUNIARY
* LOSS) ARISING OF THE USE OR INABILITY TO USE THE SOFTWARE.
*
* Motorola assumes no responsibility for the maintenance and support
* of this software
********************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -