45 #ifndef _TN_ARCH_PIC24_H
46 #define _TN_ARCH_PIC24_H
48 #include "../../core/tn_cfg_dispatch.h"
58 #ifndef DOXYGEN_SHOULD_SKIP_THIS
60 #define _TN_PIC24_INTSAVE_DATA_INVALID 0xffff
63 # define _TN_PIC24_INTSAVE_CHECK() \
65 if (tn_save_status_reg == _TN_PIC24_INTSAVE_DATA_INVALID){ \
66 _TN_FATAL_ERROR(""); \
70 # define _TN_PIC24_INTSAVE_CHECK()
88 #define _TN_FATAL_ERROR(error_msg, ...) \
89 {__asm__ volatile(".pword 0xDA4000"); __asm__ volatile ("nop");}
115 #if defined (__C30__)
116 # define TN_ARCH_STK_ATTR_BEFORE
117 # define TN_ARCH_STK_ATTR_AFTER
119 # error "Unknown compiler"
126 #define TN_MIN_STACK_SIZE (25 + _TN_EDS_STACK_ADD)
134 # define _TN_EDS_STACK_ADD 1
136 # define _TN_EDS_STACK_ADD 0
143 #define TN_INT_WIDTH 16
165 #define TN_PRIORITIES_MAX_CNT TN_INT_WIDTH
171 #define TN_WAIT_INFINITE (TN_Timeout)0xFFFFFFFF
176 #define TN_FILL_STACK_VAL 0xFEED
193 #define TN_INTSAVE_DATA \
194 int tn_save_status_reg = _TN_PIC24_INTSAVE_DATA_INVALID;
203 #define TN_INTSAVE_DATA_INT TN_INTSAVE_DATA
231 # define TN_INT_DIS_SAVE() tn_save_status_reg = tn_arch_sr_save_int_dis()
232 # define TN_INT_RESTORE() _TN_PIC24_INTSAVE_CHECK(); \
233 tn_arch_sr_restore(tn_save_status_reg)
242 #define TN_INT_IDIS_SAVE() TN_INT_DIS_SAVE()
251 #define TN_INT_IRESTORE() TN_INT_RESTORE()
256 #define TN_IS_INT_DISABLED() (_tn_arch_is_int_disabled())
261 #define _TN_CONTEXT_SWITCH_IPEND_IF_NEEDED() \
262 _tn_context_switch_pend_if_needed()
269 #define _TN_SIZE_BYTES_TO_UWORDS(size_in_bytes) ((size_in_bytes) >> 1)
289 # define _TN_SOFT_ISR_PRIORITY_CHECK() \
291 " mov #0xE0, W0 \n" \
292 " and _SR, WREG \n" \
293 " lsr W0, #5, W0 \n" \
294 " cp W0, #" TN_P24_SYS_IPL_STR " \n" \
298 " .pword 0xDA4000 \n" \
304 # define _TN_SOFT_ISR_PRIORITY_CHECK()
308 #define _TN_SOFT_ISR_PROLOGUE \
318 _TN_SOFT_ISR_PRIORITY_CHECK() \
329 " mov __tn_p24_int_splim, w0; \n" \
335 " mov SPLIM, w1; \n" \
336 " mov w0, SPLIM; \n" \
338 " mov __tn_p24_int_stack_low_addr, w15; \n" \
357 #define _TN_SOFT_ISR_CALL \
363 #define _TN_SOFT_ISR_EPILOGUE \
371 " mov w1, SPLIM; \n" \
387 " mov.b w0, [w15-1]; \n" \
395 #define _tn_soft_isr_internal(_func, _psv, _shadow) \
396 void __attribute__(( \
399 _TN_SOFT_ISR_PROLOGUE \
401 _TN_SOFT_ISR_EPILOGUE \
412 #endif //-- DOXYGEN_SHOULD_SKIP_THIS
450 #define tn_p24_soft_isr(_func, _psv) _tn_soft_isr_internal(_func, _psv, )
459 #endif // _TN_ARCH_PIC24_H
unsigned int TN_UIntPtr
Unsigned integer type that is able to store pointers.
Atomic bit-field access macros for PIC24/dsPIC.
unsigned int TN_UWord
Unsigned integer type whose size is equal to the size of CPU register.