📄 timer.c
字号:
/*******************************************************************************
*
* ARM Strategic Support Group
*
*******************************************************************************/
/*******************************************************************************
*
* Module : timer.c
* Description : Setup for Samsung KS32C50100 IRQ registers and serives the
* IRQ's (timer)
* Tool Chain : ARM Developer Suite v1.0
* Platform : Evaluator7T
* History :
*
* 980416 ASloss
* - added button interrupt service
* - added header information
*
* 2000-04-04 Andrew N. Sloss
* - ported to the Evaluator7T
*
* Notes : Refer to the Samsung KS32C50100 User Manual
*
*******************************************************************************/
/*******************************************************************************
* IMPORT
*******************************************************************************/
#include "led.h"
#include "button.h"
#include "macros.h"
#include "traffic.h"
#include "segment.h"
/*******************************************************************************
* MACRO'S
*******************************************************************************/
#define COUNTDOWN 0x02effff0;
/*****************************************************************************
* EXTERN's
*****************************************************************************/
// none...
/*****************************************************************************
* STATICS
*****************************************************************************/
// none...
/*****************************************************************************
* ROUTINES
*****************************************************************************/
/* -- timer_init ----------------------------------------------------------
*
* Description : Initialises the counter timer and sets the timer divisor.
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
void timer_init (void)
{
*TMOD = 0;
*INTPND = 0x00000000; // Clear pending interrupts .............
}
/* -- timer_irq ------------------------------------------------------------
*
* Description : handles the aux timer interrupt.
*
* Parameters : none...
* Return : none...
* Notes : Other interrupt sources are handled by angel. See
* irq_ven.s
*
*
*/
void timer_irq (void)
{
// *TMOD = 0;
*INTPND = 1 << 10;
*TDATA0 = COUNTDOWN; // reset interrupt
// -- toggle the LED D4 to show timer interrupt...
traffic_sequence ();
// -- re-enable interrupts ...
// *TMOD = 1;
*(volatile int*)INTMSK &= ~((1 << INT_GLOBAL) | (1 <<10) | (1<<0));
}
/* -- timer_start -----------------------------------------------------------
*
* Description : switches the timer on
*
* Parameters : none...
* Return : none...
* Notes : none...
*
*/
void timer_start (void)
{
*TDATA0 = COUNTDOWN; // reload CT .......................
*TMOD |= 0x1; // enable interval interrupt ...................
*(volatile int*)INTMSK &= ~((1 << INT_GLOBAL) | (1 <<10) | (1<<0));
/* Set counter gate to true ............................................. */
}
/*******************************************************************************
* END OF timer.c
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -