📄 tick_service.c
字号:
/*****************************************************************************
*
* Module : tick_service.c
* Description : Header File
* Platform : Evaluator7T
* History :
*
* 2000-03-25 Andrew N. Sloss
* - implemented a tick service
*
*****************************************************************************/
/*****************************************************************************
* IMPORT
*****************************************************************************/
#include "../headers/macros.h"
#include "../../headers/api_types.h"
/*****************************************************************************
* MACRO'S
*****************************************************************************/
/* none ... */
/*****************************************************************************
* GLOBAL
*****************************************************************************/
UINT countdown;
/*****************************************************************************
* EXTERN's
*****************************************************************************/
/* none... */
/*****************************************************************************
* GLOBALS
*****************************************************************************/
/* none... */
/*****************************************************************************
* ROUTINES
*****************************************************************************/
/* -- eventTickInit -----------------------------------------------------------
*
* Description : Initialises the counter timer in milliseconds
*
* Parameters : UINT msec - sets periodic timer in milliseconds
* Return : none...
* Notes : none...
*
*/
void eventTickInit (UINT msec)
{
/* ----------------------------------------------------------------------
*
* Initalize the Tick hardware on the Samsung part.
*
* ----------------------------------------------------------------------
*/
*TMOD = 0;
*INTPND = 0x00000000; // Clear pending interrupts .............
/* ----------------------------------------------------------------------
*
* Set the countdown value depending on msec.
*
* ----------------------------------------------------------------------
*/
switch (msec)
{
case 2: /* fast ... */
countdown = 0x000ffff0;
break;
default: /* slow ... */
countdown = 0x00effff0;
break;
}
}
/* -- eventTickService --------------------------------------------------------
*
* Description : interrupt service routine for timer0 interrupt.
*
* Parameters : none...
* Return : none...
* Notes :
*
* timer interrupt everytime the counter reaches 0. To reset
* the timer TDATA0 has to have a new initialization value.
* Finally the last act is to unmask the timer interrupt on
* the Samsung KS3250C100.
*
*/
#define tIOPDATA (volatile unsigned int *)(SYSCFG + 0x5008)
#define LEDBANK *tIOPDATA
#define LED_4_ON LEDBANK |= 0x00000010
#define LED_4_OFF LEDBANK = LEDBANK &~ 0x00000010
unsigned int xLED = 0;
void eventTickService(void)
{
/* -- reset timer interrupt... */
*INTPND = 1<<10;
*TDATA0 = countdown;
if (xLED==0)
{
LED_4_ON;
xLED=1;
}
else
{
LED_4_OFF;
xLED=0;
}
/* -- unmask the interrupt source.... */
*(volatile unsigned int*)INTMSK &= ~((1<<INT_GLOBAL)|(1<<10)|(1<<0));
}
/* -- eventTickStart ----------------------------------------------------------
*
* Description : switches on the periodic tick event
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
void eventTickStart(void)
{
*TDATA0 = countdown; /* load Counter Timer ... */
*TMOD |= 0x1; /* enable interval interrupt ... */
/* -- unmask the interrupt source.. */
*(volatile unsigned int*)INTMSK &= ~((1 << INT_GLOBAL) | (1<<10) | (1<<0));
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -