blob: 6f4ec9f301eaa4e74677166729b432647133f817 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
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 <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
|