-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstm8_interrupt_vector.c
114 lines (105 loc) · 3.14 KB
/
stm8_interrupt_vector.c
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
/* BASIC INTERRUPT VECTOR TABLE FOR STM8 devices
* Copyright (c) 2007 STMicroelectronics
*/
#include "stm8s.h"
#include "iostm8s103.h"
extern void UART_Resieved(void);
extern void Timer1_overflow(void);
extern void timer1_capture1(void);
extern void timer1_capture2(void);
extern void timer1_trigger(void);
extern void timer2_overflow (void);
extern void timer2_compare3(void);
extern void timer4_overflow(void);
extern void tim4_start(uint16_t cycles);
extern void portc_event(void);
extern void portd_event(void);
extern uint8_t buttons_status;
typedef void @far (*interrupt_handler_t)(void);
struct interrupt_vector {
unsigned char interrupt_instruction;
interrupt_handler_t interrupt_handler;
};
@far @interrupt void NonHandledInterrupt (void)
{
/* in order to detect unexpected events during development,
it is recommended to set a breakpoint on the following instruction
*/
return;
}
extern void _stext(); /* startup routine */
@far @interrupt void timer2_compare_handler (void)
{
timer2_compare3();
}
@far @interrupt void UART_Resieved_Handler (void)
{
//temp = UART1_DR;
UART_Resieved();
return;
}
@far @interrupt void timer2_overflow_handler (void)
{
timer2_overflow();
return;
}
@far @interrupt void timer1_capture1_handler (void)
{
timer1_capture1();
return;
}
@far @interrupt void timer1_trigger_handler (void)
{
timer1_trigger();
return;
}
@far @interrupt void portd_int (void)
{
EXTI_CR1 = (EXTI_CR1 & 0x3f) | (~EXTI_CR1 & 0xcf);
portd_event();
return;
}
@far @interrupt void portc_int (void)
{
EXTI_CR1 = (EXTI_CR1 & 0xcf) | (~EXTI_CR1 & 0x3f);
portc_event();
return;
}
@far @interrupt void tim4_overflow_handler (void)
{
timer4_overflow();
}
struct interrupt_vector const _vectab[] = {
{0x82, (interrupt_handler_t)_stext}, /* reset */
{0x82, NonHandledInterrupt}, /* trap */
{0x82, NonHandledInterrupt}, /* irq0 */
{0x82, NonHandledInterrupt}, /* irq1 */
{0x82, NonHandledInterrupt}, /* irq2 */
{0x82, NonHandledInterrupt}, /* irq3 */
{0x82, NonHandledInterrupt}, /* irq4 */
{0x82, portc_int}, /* irq5 */
{0x82, portd_int}, /* irq6 */
{0x82, NonHandledInterrupt}, /* irq7 */
{0x82, NonHandledInterrupt}, /* irq8 */
{0x82, NonHandledInterrupt}, /* irq9 */
{0x82, NonHandledInterrupt}, /* irq10 */
{0x82, timer1_trigger_handler}, /* irq11 */
{0x82, timer1_capture1_handler}, /* irq12 */
{0x82, timer2_overflow_handler}, /* irq13 */
{0x82, timer2_compare_handler}, /* irq14 */
{0x82, NonHandledInterrupt}, /* irq15 */
{0x82, NonHandledInterrupt}, /* irq16 */
{0x82, NonHandledInterrupt}, /* irq17 */
{0x82, UART_Resieved_Handler}, /* irq18 */
{0x82, NonHandledInterrupt}, /* irq19 */
{0x82, NonHandledInterrupt}, /* irq20 */
{0x82, NonHandledInterrupt}, /* irq21 */
{0x82, NonHandledInterrupt}, /* irq22 */
{0x82, tim4_overflow_handler}, /* irq23 */
{0x82, NonHandledInterrupt}, /* irq24 */
{0x82, NonHandledInterrupt}, /* irq25 */
{0x82, NonHandledInterrupt}, /* irq26 */
{0x82, NonHandledInterrupt}, /* irq27 */
{0x82, NonHandledInterrupt}, /* irq28 */
{0x82, NonHandledInterrupt}, /* irq29 */
};