📄 timer.c
字号:
/*******************************************************************************
*
* ARM Strategic Support Group
*
*******************************************************************************/
/*******************************************************************************
*
* Module : timer.c
* Description : Setups 77790 IRQ registers and serives the IRQ's (timer)
* Status : complete
* Platform : AEB-1
* History : 980416 ASloss
*
* - added button interrupt service
* - added header information
*
* Notes : Refer to the Sharp 77790 documentation
*
*******************************************************************************/
/*******************************************************************************
* IMPORT
*******************************************************************************/
#include "led.h"
#include "button.h"
#include "macros.h"
/*******************************************************************************
* MACRO'S
*******************************************************************************/
// -- countdown ...
#define COUNTDOWN 0x00effff0
/*****************************************************************************
* EXTERN's
*****************************************************************************/
// none...
/*****************************************************************************
* GLOBALS
*****************************************************************************/
static int led_pulse = 0;
/*****************************************************************************
* 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 : 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.
*
*/
void timer_irq (void)
{
// -- reset timer interrupt.........
*INTPND = 1<<10;
*TDATA0 = COUNTDOWN;
// -- toggle the LED D4 to show timer interrupt...
if ( led_pulse )
{ LED_4_ON; led_pulse = 0; }
else
{ LED_4_OFF; led_pulse = 1; }
// -- unmask the interrupt source....
*(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; // load Counter Timer ..............
*TMOD |= 0x1; // enable interval interrupt .......
// -- unmask the interrupt source....
*(volatile int*)INTMSK &= ~((1 << INT_GLOBAL) | (1<<10) | (1<<0));
}
/*******************************************************************************
* END OF irq.c
*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -