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()
79 #define _TN_FFS(x) _tn_p24_ffs_asm(x)
80 int _tn_p24_ffs_asm(
int x);
89 #define _TN_FATAL_ERROR(error_msg, ...) \
90 {__asm__ volatile(".pword 0xDA4000"); __asm__ volatile ("nop");}
116 #if defined (__C30__)
117 # define TN_ARCH_STK_ATTR_BEFORE
118 # define TN_ARCH_STK_ATTR_AFTER
120 # error "Unknown compiler"
127 #define TN_MIN_STACK_SIZE (25 \
128 + _TN_EDS_STACK_ADD \
129 + _TN_STACK_OVERFLOW_SIZE_ADD \
138 # define _TN_EDS_STACK_ADD 1
140 # define _TN_EDS_STACK_ADD 0
147 #define TN_INT_WIDTH 16
169 #define TN_PRIORITIES_MAX_CNT TN_INT_WIDTH
175 #define TN_WAIT_INFINITE (TN_TickCnt)0xFFFFFFFF
180 #define TN_FILL_STACK_VAL 0xFEED
197 #define TN_INTSAVE_DATA \
198 int tn_save_status_reg = _TN_PIC24_INTSAVE_DATA_INVALID;
207 #define TN_INTSAVE_DATA_INT TN_INTSAVE_DATA
235 # define TN_INT_DIS_SAVE() tn_save_status_reg = tn_arch_sr_save_int_dis()
236 # define TN_INT_RESTORE() _TN_PIC24_INTSAVE_CHECK(); \
237 tn_arch_sr_restore(tn_save_status_reg)
246 #define TN_INT_IDIS_SAVE() TN_INT_DIS_SAVE()
255 #define TN_INT_IRESTORE() TN_INT_RESTORE()
260 #define TN_IS_INT_DISABLED() (_tn_arch_is_int_disabled())
265 #define _TN_CONTEXT_SWITCH_IPEND_IF_NEEDED() \
266 _tn_context_switch_pend_if_needed()
273 #define _TN_SIZE_BYTES_TO_UWORDS(size_in_bytes) ((size_in_bytes) >> 1)
275 #define _TN_INLINE inline
277 #define _TN_VOLATILE_WORKAROUND
295 # define _TN_SOFT_ISR_PRIORITY_CHECK() \
297 " mov #0xE0, W0 \n" \
298 " and _SR, WREG \n" \
299 " lsr W0, #5, W0 \n" \
300 " cp W0, #" TN_P24_SYS_IPL_STR " \n" \
304 " .pword 0xDA4000 \n" \
310 # define _TN_SOFT_ISR_PRIORITY_CHECK()
314 #define _TN_SOFT_ISR_PROLOGUE \
324 _TN_SOFT_ISR_PRIORITY_CHECK() \
335 " mov __tn_p24_int_splim, w0; \n" \
341 " mov SPLIM, w1; \n" \
342 " mov w0, SPLIM; \n" \
344 " mov __tn_p24_int_stack_low_addr, w15; \n" \
363 #define _TN_SOFT_ISR_CALL \
369 #define _TN_SOFT_ISR_EPILOGUE \
377 " mov w1, SPLIM; \n" \
393 " mov.b w0, [w15-1]; \n" \
401 #define _tn_soft_isr_internal(_func, _psv, _shadow) \
402 void __attribute__(( \
405 _TN_SOFT_ISR_PROLOGUE \
407 _TN_SOFT_ISR_EPILOGUE \
418 #endif //-- DOXYGEN_SHOULD_SKIP_THIS
456 #define tn_p24_soft_isr(_func, _psv) _tn_soft_isr_internal(_func, _psv, )
465 #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.