BIAZI.ENG.BR
SZSPTP ez430-RF2480
1.0
ZigBee Sensor Network with synchronized time and time-stamped measurements.
<<
Programming
Electronics
Contact
License/Rights
>>
Main Page
Related Pages
Modules
Classes
Files
License
File List
File Members
im.c
Go to the documentation of this file.
1
/*
2
* im.c
3
*
4
* Date: 19/06/2014
5
* Author: Fernando Biazi Nascimento
6
* Copyright © 2014 Fernando Biazi Nascimento. All rights reserved.
7
*
8
* License of use and copy on file license.txt
9
*
10
*/
11
25
/*
26
* ======== Standard MSP430 includes ========
27
*/
28
#include <msp430f2274.h>
29
30
/*
31
* ======== Includes ========
32
*/
33
34
#include "
im.h
"
35
36
/*
37
* ======== Constants ========
38
*/
39
50
#define IM_DISABLE_1 0
51
62
#define IM_DISABLE_2 (0x01 || 0x02 || 0x04 || 0x08)
63
70
#define IM_DISABLE_P1 0xFF
71
78
#define IM_DISABLE_P2 0xFF
79
85
#define IM_DISABLE_ADC10 TRUE
86
92
#define IM_DISABLE_TA TRUE
93
99
#define IM_DISABLE_TB FALSE
100
101
/*
102
* ======== Macros ========
103
*/
104
105
/*
106
* ======== Types ========
107
*/
108
109
/*
110
* ======== Global Variables ========
111
*/
112
113
/*
114
* ======== Local Variables ========
115
*/
116
120
uint8_t
im_saveIE1
;
121
125
uint8_t
im_saveIE2
;
126
130
uint8_t
im_saveIEP1
;
131
135
uint8_t
im_saveIEP2
;
136
145
uint8_t
im_saveIEOthers
;
146
uint8_t im_disableCounter;
147
148
/*
149
* ======== Local Functions ========
150
*/
151
152
/*
153
* ================
154
*/
155
162
void
im_disable_interrupt
() {
163
164
__disable_interrupt();
165
166
if
(!im_disableCounter) {
167
168
if
(
IM_DISABLE_1
) {
169
im_saveIE1
= (IE1 &
IM_DISABLE_1
);
170
IE1 &= ~((uint8_t)
IM_DISABLE_1
);
171
}
172
173
if
(
IM_DISABLE_2
) {
174
im_saveIE2
= (IE2 &
IM_DISABLE_2
);
175
IE2 &= ~((uint8_t)
IM_DISABLE_2
);
176
}
177
178
if
(
IM_DISABLE_P1
) {
179
im_saveIEP1
= (P1IE &
IM_DISABLE_P1
);
180
P1IE &= ~((uint8_t)
IM_DISABLE_P1
);
181
}
182
183
if
(
IM_DISABLE_P2
) {
184
im_saveIEP2
= (P2IE &
IM_DISABLE_P2
);
185
P2IE &= ~((uint8_t)
IM_DISABLE_P2
);
186
}
187
188
im_saveIEOthers
= 0;
189
190
if
(
IM_DISABLE_ADC10
) {
191
if
(ADC10CTL0 & ADC10IE)
192
im_saveIEOthers
|= 0x01;
193
ADC10CTL0 &= ~(ADC10IE);
194
}
195
196
if
(
IM_DISABLE_TA
) {
197
if
(TACTL & TAIE)
198
im_saveIEOthers
|= 0x02;
199
TACTL &= ~(TAIE);
200
}
201
202
if
(
IM_DISABLE_TB
) {
203
if
(TBCTL & TBIE)
204
im_saveIEOthers
|= 0x04;
205
TBCTL &= ~(TBIE);
206
}
207
}
208
209
im_disableCounter++;
210
211
__enable_interrupt();
212
}
213
222
void
im_enable_interrupt
() {
223
224
__disable_interrupt();
225
226
if
(im_disableCounter) {
227
im_disableCounter--;
228
229
if
(!im_disableCounter) {
230
IE1 |=
im_saveIE1
;
231
232
IE2 |=
im_saveIE2
;
233
234
P1IE |=
im_saveIEP1
;
235
236
P2IE |=
im_saveIEP2
;
237
238
if
(
im_saveIEOthers
& 0x01) {
239
ADC10CTL0 |= ADC10IE;
240
}
241
242
if
(
im_saveIEOthers
& 0x02) {
243
TACTL |= TAIE;
244
}
245
246
if
(
im_saveIEOthers
& 0x04) {
247
TBCTL |= TBIE;
248
}
249
}
250
}
251
__enable_interrupt();
252
253
}
im_saveIE2
uint8_t im_saveIE2
Saved state of IE2.
Definition:
im.c:125
im.h
Interruption management (enable/disable) interface.
IM_DISABLE_ADC10
#define IM_DISABLE_ADC10
Interrupt on ADC10.
Definition:
im.c:85
IM_DISABLE_TB
#define IM_DISABLE_TB
Interrupt on Timer_B3.
Definition:
im.c:99
im_disable_interrupt
void im_disable_interrupt()
Disable interrupt.
Definition:
im.c:162
im_saveIEOthers
uint8_t im_saveIEOthers
Saved state of ADC10/Timer_A3/Timer_B3 IE.
Definition:
im.c:145
im_enable_interrupt
void im_enable_interrupt()
Enable interrupt.
Definition:
im.c:222
IM_DISABLE_P2
#define IM_DISABLE_P2
Interrupts Port2 that can be disabled.
Definition:
im.c:78
im_saveIEP2
uint8_t im_saveIEP2
Saved state of Port 2 IE.
Definition:
im.c:135
im_saveIE1
uint8_t im_saveIE1
Saved state of IE1.
Definition:
im.c:120
im_saveIEP1
uint8_t im_saveIEP1
Saved state of Port 1 IE.
Definition:
im.c:130
IM_DISABLE_P1
#define IM_DISABLE_P1
Interrupts Port1 that can be disabled.
Definition:
im.c:70
IM_DISABLE_2
#define IM_DISABLE_2
Interrupts 2 that can be disabled.
Definition:
im.c:62
IM_DISABLE_TA
#define IM_DISABLE_TA
Interrupt on Timer_A3.
Definition:
im.c:92
IM_DISABLE_1
#define IM_DISABLE_1
Interrupts 1 that can be disabled.
Definition:
im.c:50
Local:
Root
/
UPM
/
Master Tesis
/
SZS, PTP and Program
/
im.c