📄 timer32_a9.h
字号:
/*
===============================================================================
TEXAS INSTRUMENTS INCORPORATED PROPRIETARY INFORMATION
Property of Texas Instruments
For Unrestricted Internal Use Only
Unauthorized reproduction and/or distribution is strictly prohibited.
This product is protected under copyright law and trade secret law
as an unpublished work.
Created 1999, (C) Copyright 1999 Texas Instruments. All rights reserved.
Filename : timer32_a9.h
Description : Header file for the 32-Khz OS Timer
Project : Perseus
Author : Sebastien Sabatier
MACROS PROVIDED :
timer32_set_CR
timer32_set_TVR
FUNCTIONS PROVIDED :
TIMER32_ReadCr
TIMER32_ReadTvr
TIMER32_ReadTcr
===============================================================================
*/
#ifndef _TIMER32__HH
#define _TIMER32__HH
#include "result.h"
#include "test.h"
#include "mapping.h"
// Timer Control Register
//========================
#define TIMER_CTRL_REG_OFFSET 0x008
#define TIMER32_CTRL_REG (TIMER32_BASE_ADDR + TIMER_CTRL_REG_OFFSET)
#define TIMER32_CTRL_ADDR TIMER32_CTRL_REG
#define CTRL_TSS_POS 0x0
#define CTRL_TSS_NUMB 0x1
#define CTRL_TSS_RES_VAL 0x0
#define CTRL_TRB_POS 0x1
#define CTRL_TRB_NUMB 0x1
#define CTRL_TRB_RES_VAL 0x0
#define CTRL_ITENA_POS 0x2
#define CTRL_ITENA_NUMB 0x1
#define CTRL_ITENA_RES_VAL 0x0
#define CTRL_ARL_POS 0x3
#define CTRL_ARL_NUMB 0x1
#define CTRL_ARL_RES_VAL 0x1
// Tick Counter Register
//=======================
#define TICK_COUNTER_REG_OFFSET 0x004
#define TIMER32_TCR_REG (TIMER32_BASE_ADDR + TICK_COUNTER_REG_OFFSET)
#define TIMER32_TCR_ADDR TIMER32_TCR_REG
#define TIMER32_TCR_REG_RES_VAL 0x00FFFFFF
#define TIMER32_TCR_POS 0x0
#define TIMER32_TCR_NUMB 0x18
#define TIMER32_TCR_RES_VAL 0x00FFFFFF
// Tick Value Register
//=====================
#define TICK_VALUE_REG_OFFSET 0x000
#define TIMER32_TVR_REG (TIMER32_BASE_ADDR + TICK_VALUE_REG_OFFSET)
#define TIMER32_TVR_ADDR TIMER32_TVR_REG
#define TIMER32_TVR_REG_RES_VAL 0x00FFFFFF
#define TIMER32_TVR_POS 0x0
#define TIMER32_TVR_NUMB 0x18
#define TIMER32_TVR_RES_VAL 0x00FFFFFF
typedef enum { STOP_TIMER = 0, START_TIMER = 1 } tss_t;
typedef enum { NO_RELOAD_TIMER = 0, RELOAD_TIMER = 1 } trb_t;
typedef enum { IT_DISABLED = 0, IT_ENABLED = 1 } it_ena_t;
typedef enum { ONE_SHOT_MODE = 0, AUTO_RESTART_MODE = 1 } arl_t;
/*
-----------------------------------------------------------------------------
NAME : timer32_set_CR -
DESCRIPTION : Set the Timer Control Register -
SYNOPSYS : void timer32_set_CR (tss_t tss, -
trb_t trb, -
it_ena_t it_ena, -
arl_t arl) -
PARAMETERS : See 32-Khz OS Timer Specification -
RETURN VALUE: None. -
LIMITATIONS : Supervisor mode -
-----------------------------------------------------------------------------
*/
#define timer32_set_CR(tss, trb, it_ena, arl) \
{ \
*(REGISTER_UWORD16*)TIMER32_CTRL_ADDR = \
( tss | (trb << 1) | (it_ena << 2) | (arl << 3)); \
}
/*
-----------------------------------------------------------------------------
NAME : START_TIMER -
DESCRIPTION : Start the count down -
SYNOPSYS : void START_TIMER () -
PARAMETERS : -
RETURN VALUE: -
LIMITATIONS : -
-----------------------------------------------------------------------------
*/
#define START_TIMER() \
{ \
*(REGISTER_UWORD16*)TIMER32_CTRL_ADDR |=START_TIMER; \
\
}
/*
-----------------------------------------------------------------------------
NAME : LOAD_TIMER -
DESCRIPTION : Load the counter with the value in TVR register -
SYNOPSYS : void LOAD_TIMER () -
PARAMETERS : -
RETURN VALUE: -
LIMITATIONS : -
-----------------------------------------------------------------------------
*/
#define LOAD_TIMER() \
{ \
*(REGISTER_UWORD16*)TIMER32_CTRL_ADDR |= (RELOAD_TIMER<<CTRL_TRB_POS); \
\
}
/*
-----------------------------------------------------------------------------
NAME : timer32_set_TVR_helen -
DESCRIPTION : Set the Tick Value Register -
SYNOPSYS : void timer32_set_TVR (UWORD32 tick_value_reg) -
PARAMETERS : See 32-Khz OS Timer Specification -
RETURN VALUE: None. -
LIMITATIONS : Supervisor mode & only used for helen1 -
-----------------------------------------------------------------------------
*/
#define timer32_set32bits_TVR(tick_value_reg) \
{ \
*(REGISTER_UWORD32*)TIMER32_TVR_ADDR = ( tick_value_reg ); \
}
/*
-----------------------------------------------------------------------------
NAME : timer32_set_TVR -
DESCRIPTION : Set the Tick Value Register -
SYNOPSYS : void timer32_set_TVR (UWORD16 tick_value_reg) -
PARAMETERS : See 32-Khz OS Timer Specification -
RETURN VALUE: None. -
LIMITATIONS : Supervisor mode -
-----------------------------------------------------------------------------
*/
#define timer32_set_TVR(tick_value_reg) \
{ \
*(REGISTER_UWORD16*)TIMER32_TVR_ADDR = ( tick_value_reg ); \
}
void TIMER32_TestResetValue(void);
/*
-----------------------------------------------------------------------------
NAME : TIMER32_ReadCr -
DESCRIPTION : Read the Timer Control Register -
PARAMETERS : None. -
RETURN VALUE: Read value. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
UWORD16 TIMER32_ReadCr (void);
/*
-----------------------------------------------------------------------------
NAME : TIMER32_ReadTvr -
DESCRIPTION : Read the Tick Vakue Register -
PARAMETERS : None. -
RETURN VALUE: Read value. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
UWORD32 TIMER32_ReadTvr (void);
/*
-----------------------------------------------------------------------------
NAME : TIMER32_ReadTcr -
DESCRIPTION : Read the Tick Counter Register -
PARAMETERS : None. -
RETURN VALUE: Read value. -
LIMITATIONS : None. -
-----------------------------------------------------------------------------
*/
UWORD32 TIMER32_ReadTcr (void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -