From 32f507ce5f66dd9c89a45854688f46bde33c5e3d Mon Sep 17 00:00:00 2001 From: Tobias Klauser Date: Wed, 10 Nov 2010 09:20:50 +0100 Subject: Initial import of nios2sim (http://nios2sim.googlecode.com/svn/trunk/ r16) --- timer.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 timer.h (limited to 'timer.h') diff --git a/timer.h b/timer.h new file mode 100644 index 0000000..6f4ec9f --- /dev/null +++ b/timer.h @@ -0,0 +1,55 @@ +/* + Nios-sim - one simple NIOSII simulator only for personal interest and fun. + Copyright (C) 2010 chysun2000@gmail.com + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. +*/ + +#ifndef __TIMER_H__ +#define __TIMER_H__ + +#include +#include "public.h" +#include "niosii.h" +#include "io_device.h" + +#define TIMER_REG_CNT (6) +#define TIMER_BASE_ADDR (0x80681020) + +#define CTRL_ITO_MASK (0x01) +#define CTRL_CONT_MASK (0x02) +#define CTRL_START_MASK (0x04) +#define CTRL_STOP_MASK (0x08) + +#define STATUS_TO_MASK (0x01) +#define TIM_IRQ_MASK (1 << 3) +struct timer_hw{ + struct io_reg io_regs[TIMER_REG_CNT]; + uint32_t set_period; + uint32_t curr_count; + +}; + +/* the index */ +#define TIM_REG_STATUS (0) +#define TIM_REG_CTRL (1) +#define TIM_REG_PERIODL (2) +#define TIM_REG_PERIODH (3) +#define TIM_REG_SNAPL (4) +#define TIM_REG_SNAPH (5) + +extern struct io_device timer_core; +#endif + -- cgit v1.2.3-54-g00ecf