summaryrefslogtreecommitdiff
path: root/timer.h
diff options
context:
space:
mode:
Diffstat (limited to 'timer.h')
-rw-r--r--timer.h92
1 files changed, 38 insertions, 54 deletions
diff --git a/timer.h b/timer.h
index 6f4ec9f..2b99de6 100644
--- a/timer.h
+++ b/timer.h
@@ -1,55 +1,39 @@
/*
- 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 <stdio.h>
-#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
-
+ * Copyright (C) 2010 Tobias Klauser <tklauser@distanz.ch>
+ * Copyright (C) 2010 chysun2000@gmail.com
+ *
+ * This file is part of nios2sim-ng.
+ *
+ * This file is subject to the terms and conditions of the GNU General Public
+ * License. See the file "COPYING" in the main directory of this archive
+ * for more details.
+ */
+
+#ifndef _TIMER_H_
+#define _TIMER_H_
+
+#include "device.h"
+
+#define TIMER_BASE 0x84842000
+#define TIMER_SIZE 48
+#define TIMER_IRQ IRQ_TIMER
+#define TIMER_REG_COUNT (TIMER_SIZE / sizeof(uint32_t))
+
+#define TIMER_STATUS_REG 0
+#define TIMER_CTRL_REG 1
+#define TIMER_PERIODL_REG 2
+#define TIMER_PERIODH_REG 3
+#define TIMER_SNAPL_REG 4
+#define TIMER_SNAPH_REG 5
+
+#define TIMER_STATUS_TO_MASK 0x01
+#define TIMER_STATUS_RUN_MASK 0x02
+
+#define TIMER_CTRL_ITO_MASK 0x01
+#define TIMER_CTRL_CONT_MASK 0x02
+#define TIMER_CTRL_START_MASK 0x04
+#define TIMER_CTRL_STOP_MASK 0x08
+
+extern struct device timer_core;
+
+#endif /* _TIMER_H_ */