File: intvects.h

package info (click to toggle)
simulavr 0.1.2.2-6.1
  • links: PTS
  • area: main
  • in suites: lenny, squeeze
  • size: 2,756 kB
  • ctags: 3,179
  • sloc: ansic: 19,987; sh: 3,623; python: 3,528; makefile: 406; asm: 308; yacc: 145; lex: 48
file content (153 lines) | stat: -rw-r--r-- 6,133 bytes parent folder | download | duplicates (4)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
/*
 * $Id: intvects.h,v 1.7 2003/12/01 07:35:53 troth Exp $
 *
 ****************************************************************************
 *
 * simulavr - A simulator for the Atmel AVR family of microcontrollers.
 * Copyright (C) 2001, 2002, 2003  Theodore A. Roth
 *
 * 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., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 ****************************************************************************
 */

#ifndef SIM_INTVECTS_H
#define SIM_INTVECTS_H

enum _sleep_modes
{
    SLEEP_MODE_IDLE,
    SLEEP_MODE_ADC_REDUX,
    SLEEP_MODE_PWR_DOWN,
    SLEEP_MODE_PWR_SAVE,
    SLEEP_MODE_reserved1,
    SLEEP_MODE_reserved2,
    SLEEP_MODE_STANDBY,
    SLEEP_MODE_EXT_STANDBY
};

/* The reset address is always 0x00. */

#define IRQ_RESET_ADDR 0x00

/* NOTE: When an interrupt occurs, we just place a pointer to IntVect into the
   pending vector list (sorted by addr). */

typedef struct _IrqCtrlBit IrqCtrlBit;

struct _IrqCtrlBit
{
    uint16_t addr;              /* Address of the IO Register which controlls
                                   wether the interrupt is enabled or not. */
    uint8_t mask;               /* Mask denoting which bit (or bits) in the
                                   register to consider. */
};

#define NO_BIT { 0, 0 }

typedef struct _IntVect IntVect;

struct _IntVect
{
    char *name;                 /* The name of the interrupt. */
    int addr;                   /* Where to vector to when interrupt occurs. */
    uint32_t can_wake;          /* If the interrupt occurs while in sleep
                                   mode, can it wake the processor? Each bit
                                   represents a different sleep mode which the
                                   processor might be in. */

    /* For an interrupt to be serviced, both enable and flag bits must be
       set. The exception is if the interrupt flag doesn't exist, in which
       case, the flag mask is set to zero and having only the enable bit set
       is sufficient to have the interrupt be sreviced. */

    IrqCtrlBit enable;          /* This bit, if set, marks the interrupt as
                                   enabled. */
    IrqCtrlBit flag;            /* This bit, if set, marks the interrupt as
                                   flagged pending. */
};

/* Macro to calculate the field index into the structure instead of maintaining
   an index enumeration. */

#include <stddef.h>
#define irq_vect_table_index(vect) \
	(offsetof(IntVectTable, vect) / sizeof (IntVect))

/* No device will have all of these vectors, but must define a structure which
   has a slot for each interrupt. If the device doesn't support the
   interrrupt, a NULL vector will be held in the slot. */

typedef struct _IntVectTable IntVectTable;
struct _IntVectTable
{
    IntVect RESET;              /* external reset, power-on reset and watchdog
                                   reset */

    IntVect INT0;               /* external interrupt request 0 */
    IntVect INT1;               /* external interrupt request 1 */
    IntVect INT2;               /* external interrupt request 2 */
    IntVect INT3;               /* external interrupt request 3 */
    IntVect INT4;               /* external interrupt request 4 */
    IntVect INT5;               /* external interrupt request 5 */
    IntVect INT6;               /* external interrupt request 6 */
    IntVect INT7;               /* external interrupt request 7 */

    IntVect TIMER0_COMP;        /* timer/counter 0 compare match */
    IntVect TIMER0_OVF;         /* timer/counter 0 overflow */

    IntVect TIMER1_CAPT;        /* timer/counter 1 capture event */
    IntVect TIMER1_COMPA;       /* timer/counter 1 compare match A */
    IntVect TIMER1_COMPB;       /* timer/counter 1 compare match B */
    IntVect TIMER1_COMPC;       /* timer/counter 1 compare match C */
    IntVect TIMER1_OVF;         /* timer/counter 1 overflow */

    IntVect TIMER2_COMP;        /* timer/counter 2 compare match */
    IntVect TIMER2_OVF;         /* timer/counter 2 overflow */

    IntVect TIMER3_CAPT;        /* timer/counter 3 capture event */
    IntVect TIMER3_COMPA;       /* timer/counter 3 compare match A */
    IntVect TIMER3_COMPB;       /* timer/counter 3 compare match B */
    IntVect TIMER3_COMPC;       /* timer/counter 3 compare match C */
    IntVect TIMER3_OVF;         /* timer/counter 3 overflow */

    IntVect SPI_STC;            /* serial transfer complete */
    IntVect TWI;                /* Two-wire Serial Interface */

    IntVect UART_RX;            /* uart Rx complete */
    IntVect UART_UDRE;          /* uart data register empty */
    IntVect UART_TX;            /* uart Tx complete */

    IntVect USART0_RX;          /* usart0 Rx complete */
    IntVect USART0_UDRE;        /* usart0 data register empty */
    IntVect USART0_TX;          /* usart0 Tx complete */

    IntVect USART1_RX;          /* usart1 Rx complete */
    IntVect USART1_UDRE;        /* usart1 data register empty */
    IntVect USART1_TX;          /* usart1 Tx complete */

    IntVect ADC;                /* ADC conversion complete */
    IntVect ANA_COMP;           /* analog comparator */

    IntVect EE_READY;           /* EEPROM Ready */
    IntVect SPM_READY;          /* Store Program Memeory Ready */

    IntVect USB_HW;             /* USB Hardware  */
};

/* Global list of vector tables defined in intvects.c */
extern IntVectTable *global_vtable_list[];

#endif /* SIM_INTVECTS_H */