CSL 3.x

来源:互联网 发布:帽子品牌推荐 知乎 编辑:程序博客网 时间:2024/05/20 07:52

为适应新的DSP平台(C64x+,C67x+和OMAP器件),TI使用了CSL 3.X的结构,早期的器件依然用CSL 2.X来支持.

目前需要CSL 3.X支持的具体器件是,C6445,C672X和OMAP5912.新版本在轻便性,层次性,效率,空间,易用方面做了一些改善.

 

 Timer Example Using CSL 2.x
#include <csl.h>
#include <csl_timer.h>
/* −−−−−−−−−−−−−−−−−−−−−−−−−−− CSL 2.x Example −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− */
:
:
TIMER_Handle myhTim ; /* Handle is pointer to timer object */
TIMER_Config timCfg = { /* Initialize Config structure */
TIMER _TCR_RMK ( /* Timer Control Register */
TIMER_TCR_IDLEEN_DEFAULT,
TIMER_TCR_FUNC_OF(0),
:
:
TIMER_TCR_DATOUT_0),
0x4000u, /* Period */
0x0010 /* Prescalar */
};
TIMER_Config readCfg; /* Un-initialized, to be used with getConfig API */
:
:
void main()
{
int newPreScalar; /* Local variable */
CSL_init(); /* Initialize CSL */
/* Open timer0, initialize the registers to power-on reset values */
myTim = TIMER_open (TIMER_DEV0, TIMER_OPEN_RESET);
/* Use initialized structure to configure the timer */
TIMER_config (myTim, &timCfg);
:
TIMER_start (myhTim); /* Start the timer */
:
TIMER_stop (myhTim); /* Stop the timer */
:
TIMER_getConfig (myTim, &readCfg); /* Read the prescalar value */
newPreScalar = readCfg.prsc * 2; /* Double the prescalar */
/* Update the register */
TIMER_RSETH (myhTim, PRSC, newPreScalar);
:
TIMER_start (myhTim); /* Start the timer again */
:
:
TIMER_close (myhTim); /* Close the timer, after the usage is over */
}

 

 

Timer Example Using CSL 3.x
#include <csl_timer.h>
/* −−−−−−−−−−−−−−−−−−−−−−−−−−− CSL 3.x Example −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− */
:
:
CSL_Status st = CSL_SOK; /* Status code returned by ‘open’ */
CSL_TimerObj hTimerObj; /* TIMER object defined in user data space */
CSL_TimerHandle hTimer; /* Handle will point to TIMER object on
successful ‘open’ */
CSL_TimerHwSetup myTimSetup = { /* Initialize HwSetup structure */
0xFFFF; /* Load value – counting starts from here */
CSL_TIMER_PRESCALE_CLKBY4, /* Prescalar */
CSL_TIMER_LOADMODE_RELOAD, /* Reload mode */
CSL_TIMER_EMUMODE_RUNFREE, /* Emulation halt setting */
CSL_TIMER_EXTCLOCK_ENABLE /* External clock setting */
};
:
:
void main()
{
int preScalar; /* Local variable */
CSL_sysInit(); /* CSL system initialization */
CSL_timerInit(); /* Timer module initialization */
/* Open timer0 */
hTimer = CSL_timerOpen (&hTimerObj, CSL_TIMER_0, CSL_EXCLUSIVE,
NULL, &st);
/* Configure timer using initialized HwSetup structure */
CSL_timerHwSetup (hTimer, &myTimSetup);
:
/* Start timer */
CSL_timerHwControl (hTimer, CSL_TIMER_CMD_START, NULL);
:
/* Stop timer */
CSL_timerHwControl (hTimer, CSL_TIMER_CMD_STOP, NULL);
:
/* Read current prescalar value */
CSL_timerHwStatus (hTimer, CSL_TIMER_QUERY_PRESCALE, &preScalar);
preScalar = preScalar * 2; /* Double the prescalar */
/* Configure timer with new prescalar */
CSL_timerHwControl (hTimer, CSL_TIMER_CMD_SETPRESCALE,
(int *) &preScalar);
:
/* Start timer again */
CSL_timerHwControl (hTimer, CSL_TIMER_CMD_START, NULL);
:
:
/* Close the timer after the usage is over */
CSL_timerClose (hTimer);