Netcruzer Library API
V2.03
All
Data Structures
Files
Functions
Variables
Typedefs
Enumerations
Macros
Groups
Pages
nz_interrupt.h
Go to the documentation of this file.
1
46
#ifndef NZ_INTERRUPT_H
47
#define NZ_INTERRUPT_H
48
50
// "Interrupts" - documentation module
52
104
#include "
nz_ioPorts.h
"
105
106
#define USE_AND_OR //To enable AND_OR mask setting for ports.h
107
108
#if (defined(__PIC24F__)) && defined(__C30__) // Microchip C30 compiler
109
#include <ports.h>
110
#elif defined(__dsPIC33F__) && defined(__C30__) // Microchip C30 compiler
111
#elif defined(__PIC32MX__) // Microchip C32 compiler
112
#include <peripheral/ports.h>
113
#else
114
#error Unknown processor or compiler. See Compiler.h
115
#endif
116
118
#if defined( __C30__ )
119
// Setting the priority of External or CN interrupt
120
#define CHANGE_INT_ON INT_ENABLE
121
#define CHANGE_INT_OFF INT_DISABLE
122
123
// Change Interrupt Priority Values
124
#define CHANGE_INT_PRI_7 INT_PRI_7
125
#define CHANGE_INT_PRI_6 INT_PRI_6
126
#define CHANGE_INT_PRI_5 INT_PRI_5
127
#define CHANGE_INT_PRI_4 INT_PRI_4
128
#define CHANGE_INT_PRI_3 INT_PRI_3
129
#define CHANGE_INT_PRI_2 INT_PRI_2
130
#define CHANGE_INT_PRI_1 INT_PRI_1
131
#define CHANGE_INT_PRI_0 INT_PRI_0
132
#elif defined( __PIC32MX__ )
133
#else
134
#error "Compiler not defined"
135
#endif
136
137
139
#if defined( __C30__ )
140
#define NZ_INT_DIS_PUSH() \
141
asm volatile ("push SR \n disi #3 \n mov #0xE0, W0 \n ior SR" \
142
:
/* no outputs */
\
143
:
/* no inputs */
\
144
: "w0")
145
146
//Seems like SR can only be changed with DISICNT is NOT = 0! Use disi to set DISICNT to non 0 value.
147
#define NZ_INT_EN_POP() \
148
/* Allow 2 instructions for push and pop! Compiler does not always use PUSH and POP! */
\
149
asm volatile ("disi #2 \n pop %0" \
150
: "+r" (SR)
/* Outputs */
\
151
:
/* no inputs */
)
152
153
//NOTE! With disi #4 causes errors! With disi #5 is OK!
154
//Seems like SR can only be changed with DISICNT is NOT = 0! Use disi to set DISICNT to non 0 value.
155
#define NZ_INT_DIS_SAVE(save_to) \
156
asm volatile ("disi #5 \n mov SR, W0 \n mov W0, %0 \n mov #0xE0, W0 \n ior SR" \
157
: "=g" (save_to)
/* Outputs */
\
158
:
/* no inputs */
\
159
: "w0")
160
161
//Seems like SR can only be changed with DISICNT is NOT = 0! Use disi to set DISICNT to non 0 value.
162
#define NZ_INT_EN_SAVE(save_to) \
163
asm volatile ("disi #3 \n mov %1, W0 \n mov W0, %0" \
164
: "+r" (SR)
/* Outputs */
\
165
: "g" (save_to)
/* Inputs */
\
166
: "w0")
167
169
#if !defined(NZ_INT_DISABLE_FIBERS)
170
#define NZ_INT_DISABLE_FIBERS() NZOS_INT_KERNEL_DISABLE()
171
#endif
172
174
#if !defined(NZ_INT_ENABLE_FIBERS)
175
#define NZ_INT_ENABLE_FIBERS() NZOS_INT_KERNEL_ENABLE()
176
#endif
177
184
#if !defined(NZ_INT_DISABLE_P07)
185
#define NZ_INT_DISABLE_P07() __builtin_disi(0x3FFF) // Disable interrupts, excluding level 7
186
#endif
187
189
#if !defined(NZ_INT_ENABLE_P07)
190
#define NZ_INT_ENABLE_P07() __builtin_disi(0) // Enable interrupts
191
#endif
192
194
#if !defined(NZ_BUILTIN_DISI)
195
#define NZ_BUILTIN_DISI(val) __builtin_disi(val) // Disable interrupts
196
#endif
197
202
#if !defined(NZ_SET_AND_SAVE_CPU_IPL)
203
#define NZ_SET_AND_SAVE_CPU_IPL(ipl,lvl) SET_AND_SAVE_CPU_IPL(ipl,lvl)
204
#endif
205
207
#if !defined(NZ_RESTORE_CPU_IPL)
208
#define NZ_RESTORE_CPU_IPL(ipl) RESTORE_CPU_IPL(ipl)
209
#endif
210
#elif defined( __PIC32MX__ )
211
212
// TODO for PIC32MX - implement these macros!! Just here so it compiles.
213
#define NZ_INT_DIS_PUSH()
214
#define NZ_INT_EN_POP()
215
217
#if !defined(NZ_INT_DISABLE_FIBERS)
218
#define NZ_INT_DISABLE_FIBERS() //DUMMY!!! Complete for PIC32MX!!!!!!!
219
#endif
220
222
#if !defined(NZ_INT_ENABLE_FIBERS)
223
#define NZ_INT_ENABLE_FIBERS() //DUMMY!!! Complete for PIC32MX!!!!!!!
224
#endif
225
227
#if !defined(NZ_INT_DISABLE_FIBERS)
228
#define NZ_INT_DISABLE_FIBERS() NZOS_INT_KERNEL_DISABLE()
229
#endif
230
231
#if !defined(NZ_INT_ENABLE_FIBERS)
232
#define NZ_INT_ENABLE_FIBERS() NZOS_INT_KERNEL_ENABLE()
233
#endif
234
236
#if !defined(NZ_BUILTIN_DISI)
237
// TODO for PIC32MX - implement these macros!! Just here so it compiles.
238
#define NZ_BUILTIN_DISI(val)
239
#endif
240
244
#if !defined(NZ_SET_AND_SAVE_CPU_IPL)
245
#define NZ_SET_AND_SAVE_CPU_IPL(ipl,lvl)
246
#endif
247
248
#if !defined(NZ_RESTORE_CPU_IPL)
249
#define NZ_RESTORE_CPU_IPL(ipl)
250
#endif
251
#else
252
#error "Compiler not defined"
253
#endif
254
255
280
#if defined(__C30__)
281
#define intOnChangeConfig(conf) ConfigIntCN(conf)
282
#elif defined(__C32__)
283
// TODO for PIC32MX - Port to PIC32MX, seems like there might be a "in on change" for each port. See ConfigIntCNA in ports.h
284
//#define intOnChangeConfig(conf) ConfigIntCN(conf)
285
#define intOnChangeConfig(conf) ConfigIntCNA(conf) //JUST FOR TESTING!!!! This only configured PORT A!!!!!!!!!!!!!!!
286
#else
287
#error "intOnChangeConfig() not defined for this compiler!"
288
#endif
289
290
302
#if defined(__C30__)
303
#define intOnChangeEnablePort(portID) portSetBitadr(portGetCNIE(portID))
304
#elif defined(__C32__)
305
#define intOnChangeEnablePort(portID) portSetBitadr(portGetCNIE(portID))
306
#else
307
#error "intOnChangeEnablePort() not defined for this compiler!"
308
#endif
309
310
311
323
#if defined(__C30__)
324
#define intOnChangeDisablePort(portID) portClearBitadr(portGetCNIE(portID))
325
#elif defined(__C32__)
326
#define intOnChangeDisablePort(portID) portClearBitadr(portGetCNIE(portID))
327
#else
328
#error "intOnChangeDisablePort() not defined for this compiler!"
329
#endif
330
331
337
#if defined(__C30__)
338
#define intOnChangeClearIF() InputChange_Clear_Intr_Status_Bit
339
#elif defined(__C32__)
340
#define intOnChangeClearIF()
341
#else
342
#error "Processor or Compiler not supported!"
343
#endif
344
345
346
#endif //NZ_INTERRUPT_H
347
netcruzer
lib
nz_interrupt.h
Generated on Tue Dec 9 2014 15:08:19 for Netcruzer Library API by
1.8.4