-
Notifications
You must be signed in to change notification settings - Fork 0
/
mcal_interrupt_manager.c
196 lines (185 loc) · 6.65 KB
/
mcal_interrupt_manager.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
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
/*
* File : mcal_interrupt_manager.c
* Author : Mohamed Ahmed Abdel Wahab
* LinkedIn : https://www.linkedin.com/in/mohamed-abdel-wahab-162413253/
* Github : https://github.com/moabdelwahab6611
* Created on June 2, 2023, 9:36 PM
*/
/**************************Includes-Section*****************************/
#include "mcal_interrupt_manager.h"
/***********************************************************************/
/********************Data Types Declarations-Section********************/
static volatile uint8 RB4_Flag = 1;
static volatile uint8 RB5_Flag = 1;
static volatile uint8 RB6_Flag = 1;
static volatile uint8 RB7_Flag = 1;
/***********************************************************************/
/*****************Software Interfaces Functions-Section*****************/
#if INTERRUPT_PRIORITY_LEVELS_ENABLE==INTERRUPT_FEATURE_ENABLE
void __interrupt() InterruptManagerHigh(void)
{
if((INTERRUPT_ENABLE == INTCON3bits.INT2IE) && (INTERRUPT_OCCUR == INTCON3bits.INT2IF))
{
INT2_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.INT0IE) && (INTERRUPT_OCCUR == INTCONbits.INT0IF))
{
INT0_ISR();
}
else{/*****Nothing*****/}
}
void __interrupt(low_priority) InterruptManagerLow(void)
{
if((INTERRUPT_ENABLE == INTCON3bits.INT1E) && (INTERRUPT_OCCUR == INTCON3bits.INT1F))
{
INT1_ISR();
}
else{/*****Nothing*****/}
}
#else
void __interrupt() InterruptManager(void)
{
/****************INTx external on change interrupt start****************/
if((INTERRUPT_ENABLE == INTCONbits.INT0IE) && (INTERRUPT_OCCUR == INTCONbits.INT0IF))
{
INT0_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCON3bits.INT1E) && (INTERRUPT_OCCUR == INTCON3bits.INT1F))
{
INT1_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCON3bits.INT2IE) && (INTERRUPT_OCCUR == INTCON3bits.INT2IF))
{
INT2_ISR();
}
else{/*****Nothing*****/}
/***********************************************************************/
/****************PortB external on change interrupt start***************/
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB4 == GPIO_HIGH) && (RB4_Flag == 1))
{
RB4_Flag = 0;
RB4_ISR(0);
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB4 == GPIO_LOW) && (RB4_Flag == 0))
{
RB4_Flag = 1;
RB4_ISR(1);
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB5 == GPIO_HIGH) && (RB5_Flag == 1))
{
RB5_Flag = 0;
RB5_ISR(0);
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB5 == GPIO_LOW) && (RB5_Flag == 0))
{
RB5_Flag = 1;
RB5_ISR(1);
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB6 == GPIO_HIGH) && (RB6_Flag == 1))
{
RB6_Flag = 0;
RB6_ISR(0);
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB6 == GPIO_LOW) && (RB6_Flag == 0))
{
RB6_Flag = 1;
RB6_ISR(1);
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB7 == GPIO_HIGH) && (RB7_Flag == 1))
{
RB7_Flag = 0;
RB7_ISR(0);
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == INTCONbits.RBIE) && (INTERRUPT_OCCUR == INTCONbits.RBIF) &&
(PORTBbits.RB7 == GPIO_LOW) && (RB7_Flag == 0))
{
RB7_Flag = 1;
RB7_ISR(1);
}
else{/*****Nothing*****/}
/***********************************************************************/
/************************ADC modules interrupt**************************/
if((INTERRUPT_ENABLE == PIE1bits.ADIE) && (INTERRUPT_OCCUR == PIR1bits.ADIF))
{
ADC_ISR();
}
else{/*****Nothing*****/}
/***********************************************************************/
/**********************Timers modules interrupt*************************/
if((INTERRUPT_ENABLE == INTCONbits.TMR0IE) && (INTERRUPT_OCCUR == INTCONbits.TMR0IF))
{
TMR0_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == PIE1bits.TMR1IE) && (INTERRUPT_OCCUR == PIR1bits.TMR1IF))
{
TMR1_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == PIE1bits.TMR2IE) && (INTERRUPT_OCCUR == PIR1bits.TMR2IF))
{
TMR2_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == PIE2bits.TMR3IE) && (INTERRUPT_OCCUR == PIR2bits.TMR3IF))
{
TMR3_ISR();
}
else{/*****Nothing*****/}
/***********************************************************************/
/***********************USART module interrupt**************************/
if((INTERRUPT_ENABLE == PIE1bits.TXIE) && (INTERRUPT_OCCUR == PIR1bits.TXIF))
{
USART_TX_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == PIE1bits.RCIE) && (INTERRUPT_OCCUR == PIR1bits.RCIF))
{
USART_RX_ISR();
}
else{/*****Nothing*****/}
/***********************************************************************/
/**********************MSSP I2C module interrupt************************/
if((INTERRUPT_ENABLE == PIE1bits.SSPIE) && (INTERRUPT_OCCUR == PIR1bits.SSPIF))
{
MSSP_I2C_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == PIE2bits.BCLIE) && (INTERRUPT_OCCUR == PIR2bits.BCLIF))
{
MSSP_I2C_BC_ISR();
}
else{/*****Nothing*****/}
/***********************************************************************/
/*******************CCP1 and CCP2 modules interrupt*********************/
if((INTERRUPT_ENABLE == PIE1bits.CCP1IE) && (INTERRUPT_OCCUR == PIR1bits.CCP1IF))
{
CCP1_ISR();
}
else{/*****Nothing*****/}
if((INTERRUPT_ENABLE == PIE2bits.CCP2IE) && (INTERRUPT_OCCUR == PIR2bits.CCP2IF))
{
CCP2_ISR();
}
else{/*****Nothing*****/}
/***********************************************************************/
}
#endif
/***********************************************************************/