45 #ifndef _TN_ARCH_PIC24_H
46 #define _TN_ARCH_PIC24_H
54 #include "../../core/tn_common_macros.h"
55 #include "../../core/tn_cfg_dispatch.h"
72 #ifndef DOXYGEN_SHOULD_SKIP_THIS
74 #define _TN_PIC24_INTSAVE_DATA_INVALID 0xffff
77 # define _TN_PIC24_INTSAVE_CHECK() \
79 if (tn_save_status_reg == _TN_PIC24_INTSAVE_DATA_INVALID){ \
80 _TN_FATAL_ERROR(""); \
84 # define _TN_PIC24_INTSAVE_CHECK()
93 #define _TN_FFS(x) _tn_p24_ffs_asm(x)
94 int _tn_p24_ffs_asm(
int x);
103 #define _TN_FATAL_ERROR(error_msg, ...) \
104 {__asm__ volatile(".pword 0xDA4000"); __asm__ volatile ("nop");}
130 #if defined (__C30__)
131 # define TN_ARCH_STK_ATTR_BEFORE
132 # define TN_ARCH_STK_ATTR_AFTER
134 # error "Unknown compiler"
141 #define TN_MIN_STACK_SIZE (25 \
142 + _TN_EDS_STACK_ADD \
143 + _TN_STACK_OVERFLOW_SIZE_ADD \
152 # define _TN_EDS_STACK_ADD 1
154 # define _TN_EDS_STACK_ADD 0
161 #define TN_INT_WIDTH 16
183 #define TN_PRIORITIES_MAX_CNT TN_INT_WIDTH
189 #define TN_WAIT_INFINITE (TN_TickCnt)0xFFFFFFFF
194 #define TN_FILL_STACK_VAL 0xFEED
211 #define TN_INTSAVE_DATA \
212 int tn_save_status_reg = _TN_PIC24_INTSAVE_DATA_INVALID;
221 #define TN_INTSAVE_DATA_INT TN_INTSAVE_DATA
249 # define TN_INT_DIS_SAVE() tn_save_status_reg = tn_arch_sr_save_int_dis()
250 # define TN_INT_RESTORE() _TN_PIC24_INTSAVE_CHECK(); \
251 tn_arch_sr_restore(tn_save_status_reg)
260 #define TN_INT_IDIS_SAVE() TN_INT_DIS_SAVE()
269 #define TN_INT_IRESTORE() TN_INT_RESTORE()
274 #define TN_IS_INT_DISABLED() (_tn_arch_is_int_disabled())
279 #define _TN_CONTEXT_SWITCH_IPEND_IF_NEEDED() \
280 _tn_context_switch_pend_if_needed()
287 #define _TN_SIZE_BYTES_TO_UWORDS(size_in_bytes) ((size_in_bytes) >> 1)
289 #define _TN_INLINE inline
291 #define _TN_VOLATILE_WORKAROUND
309 # define _TN_SOFT_ISR_PRIORITY_CHECK() \
311 " mov #0xE0, W0 \n" \
312 " and _SR, WREG \n" \
313 " lsr W0, #5, W0 \n" \
314 " cp W0, #" _TN_STRINGIZE_MACRO(TN_P24_SYS_IPL) " \n" \
318 " .pword 0xDA4000 \n" \
324 # define _TN_SOFT_ISR_PRIORITY_CHECK()
328 #define _TN_SOFT_ISR_PROLOGUE \
338 _TN_SOFT_ISR_PRIORITY_CHECK() \
349 " mov __tn_p24_int_splim, w0; \n" \
355 " mov SPLIM, w1; \n" \
356 " mov w0, SPLIM; \n" \
358 " mov __tn_p24_int_stack_low_addr, w15; \n" \
377 #define _TN_SOFT_ISR_CALL \
383 #define _TN_SOFT_ISR_EPILOGUE \
391 " mov w1, SPLIM; \n" \
407 " mov.b w0, [w15-1]; \n" \
415 #define _tn_soft_isr_internal(_func, _psv, _shadow) \
416 void __attribute__(( \
419 _TN_SOFT_ISR_PROLOGUE \
421 _TN_SOFT_ISR_EPILOGUE \
432 #define _TN_ARCH_STACK_PT_TYPE _TN_ARCH_STACK_PT_TYPE__EMPTY
433 #define _TN_ARCH_STACK_DIR _TN_ARCH_STACK_DIR__ASC
435 #endif //-- DOXYGEN_SHOULD_SKIP_THIS
473 #define tn_p24_soft_isr(_func, _psv) _tn_soft_isr_internal(_func, _psv, )
482 #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.