⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 c40.c

📁 ucos在DSP40上的移植,可以用,在ucos网站上下的!
💻 C
字号:
/*
*********************************************************************************************************
*                                      TMW320C40 SUPPORT FUNCTIONS
*
*                               (c) Copyright 1999, Ran Cabell, Hampton, VA
*                                           All Rights Reserved
*
* File : C40.C
* By   : Ran Cabell
*********************************************************************************************************
*/

#include "includes.h"

/*
*********************************************************************************************************
*                                               CONSTANTS
*********************************************************************************************************
*/


/*
*********************************************************************************************************
*                                       LOCAL GLOBAL VARIABLES
*********************************************************************************************************
*/
             
/*$PAGE*/
void C40_Init( void )
{

    /* clear interrupt flags */
    load_iie( 0x0 );
    
    /* stuff added for debugging using spectrum tools */
    /* Perform IACK instruction to allow external ints */
    /* through to the C40                              */
    asm("	PUSH  AR0");
    asm("	PUSH  DP");
    asm("	LDI   030H, AR0");
    asm("	LSH   16, AR0");
    asm("	IACK  *AR0");
    asm("	POP   DP");
    asm("	POP   AR0");
    
    /* macro from prts40 */
    /* default ivtp is .vector section in linker command file */ 
    INT_DISABLE();
    set_ivtp((void*)0x2ff800); 
    set_tvtp((void*)0x2ff800);

}

/*
*********************************************************************************************************
*                                       ELAPSED TIME INITIALIZATION
*
* Description : This function initialize the elapsed time module by determining how long the START and
*               STOP functions take to execute.  In other words, this function calibrates this module
*               to account for the processing time of the START and STOP functions.
*
* Arguments   : None.
*
* Returns     : None.
*********************************************************************************************************
*/
void C40_ElapsedInit(void)
{
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                         INITIALIZE PC'S TIMER #2
*
* Description : This function initialize the PC's Timer #2 to be used to measure the time between events.
*               Timer #2 will be running when the function returns.
*
* Arguments   : None.
*
* Returns     : None.
*********************************************************************************************************
*/
void C40_ElapsedStart(void)
{
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                 STOP THE PC'S TIMER #2 AND GET ELAPSED TIME
*
* Description : This function stops the PC's Timer #2, obtains the elapsed counts from when it was
*               started and converts the elapsed counts to micro-seconds.
*
* Arguments   : None.
*
* Returns     : The number of micro-seconds since the timer was last started.
*
* Notes       : - The returned time accounts for the processing time of the START and STOP functions.
*               - 54926 represents 54926S-16 or, 0.838097 which is used to convert timer counts to
*                 micro-seconds.  The clock source for the PC's timer #2 is 1.19318 MHz (or 0.838097 uS)
*********************************************************************************************************
*/
INT16U C40_ElapsedStop(void)
{
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                      SET THE PC'S TICK FREQUENCY
*
* Description: This function is called to change the tick rate of the C40 timer. 
*
* Arguments  : freq      is the desired frequency of the ticker (in Hz)
*
* Returns    : none
*
* Notes      : 1) Assume 50MHz part
*
*********************************************************************************************************
*/
#define CLOCK_PER_SEC 25000000.

void C40_SetTickRate (INT16U freq)
{
    TIMER_REG *ucos_timer = TIMER_ADDR( 0 );

    ucos_timer->period = (unsigned long)(TIMER_CLOCK / (float)freq);
    ucos_timer->gcontrol = TIM_START;
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                      Enable a C40 Interrupt
*
* Description: This function sets the specified bit in the IIE register
*
* Arguments  : bit      is the desired bit to set high
*
* Returns    : none
*
* Notes      : none
*
*********************************************************************************************************
*/
void C40_EnableInt(INT8U bit)
{
    set_iie( bit );
}
/*$PAGE*/
/*
*********************************************************************************************************
*                                        OBTAIN INTERRUPT VECTOR
*
* Description: This function reads the pointer stored at the specified vector.
*
* Arguments  : vect  is the desired interrupt vector number, a number between 0 and 255.
*
* Returns    : none
*********************************************************************************************************
*/
void *C40_VectGet (INT8U vect)
{

}

/*
*********************************************************************************************************
*                                        INSTALL INTERRUPT VECTOR
*
* Description: This function sets an interrupt vector in the interrupt vector table.
*
* Arguments  : vect  is the desired interrupt vector number, a number between 0 and 63.
*              isr   is a pointer to a function to execute when the interrupt or exception occurs.
*
* Returns    : none
*********************************************************************************************************
*/
void C40_VectSet (INT8U vect, void (*isr)(void))
{
    install_int_vector( (ISR_FnPtr)isr, vect );
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -