File tree 3 files changed +32
-21
lines changed
hardware/zpuino/zpu20/cores/zpuino
3 files changed +32
-21
lines changed Original file line number Diff line number Diff line change 5
5
6
6
static __attribute__((always_inline )) inline void sei ()
7
7
{
8
- INTRCTL = 1 ;
8
+ INTRCTL = 1 ;
9
9
}
10
10
11
11
static __attribute__((always_inline )) inline void cli ()
12
12
{
13
- INTRCTL = 0 ;
14
-
13
+ INTRCTL = 0 ;
15
14
}
15
+
16
+ extern void attachInterrupt (unsigned int , void (* )(void ), int mode = 0 );
17
+ extern void detachInterrupt (unsigned int );
18
+ extern int attachInterrupt (unsigned int line , void (* function )(void * ), void * arg );
19
+
20
+
16
21
#endif
Original file line number Diff line number Diff line change 5
5
6
6
#define ZPUINO_MAX_INTERRUPTS 16
7
7
8
- typedef void (*interrupt_type_t )(void );
8
+ struct interrupt_type_t {
9
+ void (*func)(void *);
10
+ void *arg;
11
+ };
9
12
10
13
static interrupt_type_t itable[ZPUINO_MAX_INTERRUPTS]={0 };
11
14
15
+ int attachInterrupt (unsigned int line, void (*function)(void *), void *arg)
16
+ {
17
+ if (line>=ZPUINO_MAX_INTERRUPTS)
18
+ return -1 ;
19
+ // cli();
20
+ itable[line].func = function;
21
+ itable[line].arg = arg;
22
+ // sei();
23
+ return 0 ;
24
+ }
25
+
12
26
void attachInterrupt (unsigned int line, void (*function)(void ), int mode)
13
27
{
14
- if (line>=ZPUINO_MAX_INTERRUPTS)
15
- return ;
16
- // cli();
17
- itable[line] = function;
18
- // sei();
28
+ attachInterrupt (line, (void (*)(void *))function, NULL );
19
29
}
30
+
20
31
void detachInterrupt (unsigned int line)
21
32
{
22
- // cli();
23
- if (line>=ZPUINO_MAX_INTERRUPTS)
24
- return ;
25
- itable[line] = 0 ;
26
- // sei();
33
+ if (line>=ZPUINO_MAX_INTERRUPTS)
34
+ return ;
35
+ itable[line].func = 0 ;
27
36
}
28
37
29
38
void _zpu_interrupt (unsigned int line)
30
39
{
31
- if (line>=ZPUINO_MAX_INTERRUPTS)
32
- return ;
33
- if (itable[line])
34
- itable[line]( );
40
+ if (line>=ZPUINO_MAX_INTERRUPTS)
41
+ return ;
42
+ if (itable[line]. func )
43
+ itable[line]. func (itable[line]. arg );
35
44
}
Original file line number Diff line number Diff line change 10
10
#define _BV (x ) (1<<(x))
11
11
#endif
12
12
13
- extern void attachInterrupt (unsigned int , void (* )(void ), int mode = 0 );
14
- extern void detachInterrupt (unsigned int );
15
-
16
13
typedef volatile unsigned int * register_t ;
17
14
18
15
extern void itoa (int value , char * dest , int base );
You can’t perform that action at this time.
0 commit comments