From 1b5ab277a84f95e8fd54c313d512074e34af63ef Mon Sep 17 00:00:00 2001 From: Fabio Utzig Date: Sat, 16 Apr 2016 03:16:18 +0000 Subject: [AVR] Fixed AVR port issues git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@9281 35acf78f-673a-0410-8e92-d51de3d6d3f4 --- os/common/ports/AVR/chcore.h | 36 +++++++++++++++++------------------- 1 file changed, 17 insertions(+), 19 deletions(-) (limited to 'os/common/ports') diff --git a/os/common/ports/AVR/chcore.h b/os/common/ports/AVR/chcore.h index 823b38d8c..8bbd89582 100644 --- a/os/common/ports/AVR/chcore.h +++ b/os/common/ports/AVR/chcore.h @@ -30,6 +30,11 @@ #ifndef CHCORE_H #define CHCORE_H +#include +#include + +extern bool __avr_in_isr; + /*===========================================================================*/ /* Module constants. */ /*===========================================================================*/ @@ -130,12 +135,6 @@ #define PORT_USE_ALT_TIMER FALSE #endif -/** - * @brief Activate for devices with extended code addressing. - */ -#if !defined(PORT_AVR_3BYTES_PC) || defined(__DOXYGEN__) -#define PORT_AVR_3BYTES_PC FALSE -#endif /** * @brief Enables a "wait for interrupt" instruction in the idle loop. */ @@ -185,7 +184,7 @@ struct port_extctx { uint8_t sr; uint8_t r1; uint8_t r0; -#if PORT_AVR_3BYTES_PC +#if defined(__AVR_3_BYTE_PC__) uint8_t pcx; #endif uint16_t pc; @@ -220,7 +219,7 @@ struct port_intctx { uint8_t r4; uint8_t r3; uint8_t r2; -#if PORT_AVR_3BYTES_PC +#if defined(__AVR_3_BYTE_PC__) uint8_t pcx; #endif uint8_t pcl; @@ -247,31 +246,30 @@ struct port_context { * @details This code usually setup the context switching frame represented * by an @p port_intctx structure. */ -#if PORT_AVR_3BYTES_PC || defined(__DOXYGEN__) +#if defined(__AVR_3_BYTE_PC__) || defined(__DOXYGEN__) #define PORT_SETUP_CONTEXT(tp, wbase, wtop, pf, arg) { \ tp->ctx.sp = (struct port_intctx *)((uint8_t *)(wtop) - \ sizeof(struct port_intctx)); \ tp->ctx.sp->r2 = (uint8_t)(pf); \ - tp->ctx.sp->r3 = (uint8_t)((pf) >> 8); \ + tp->ctx.sp->r3 = (uint8_t)((uint16_t)(pf) >> 8); \ tp->ctx.sp->r4 = (uint8_t)(arg); \ - tp->ctx.sp->r5 = (uint8_t)((arg) >> 8); \ + tp->ctx.sp->r5 = (uint8_t)((uint16_t)(arg) >> 8); \ tp->ctx.sp->pcx = (uint8_t)0; \ - tp->ctx.sp->pcl = (uint8_t)_port_thread_start >> 8; \ + tp->ctx.sp->pcl = (uint16_t)_port_thread_start >> 8; \ tp->ctx.sp->pch = (uint8_t)_port_thread_start; \ } -#else /* !PORT_AVR_3BYTES_PC */ +#else /* !__AVR_3_BYTE_PC__ */ #define PORT_SETUP_CONTEXT(tp, wbase, wtop, pf, arg) { \ tp->ctx.sp = (struct port_intctx *)((uint8_t *)(wtop) - \ sizeof(struct port_intctx)); \ tp->ctx.sp->r2 = (uint8_t)(pf); \ - tp->ctx.sp->r3 = (uint8_t)((pf) >> 8); \ + tp->ctx.sp->r3 = (uint8_t)((uint16_t)(pf) >> 8); \ tp->ctx.sp->r4 = (uint8_t)(arg); \ - tp->ctx.sp->r5 = (uint8_t)((arg) >> 8); \ - tp->ctx.sp->pcl = (uint8_t)_port_thread_start >> 8; \ + tp->ctx.sp->r5 = (uint8_t)((uint16_t)(arg) >> 8); \ + tp->ctx.sp->pcl = (uint16_t)_port_thread_start >> 8; \ tp->ctx.sp->pch = (uint8_t)_port_thread_start; \ } -} -#endif /* !PORT_AVR_3BYTES_PC */ +#endif /* !__AVR_3_BYTE_PC__ */ /** * @brief Computes the thread working area global size. @@ -321,7 +319,7 @@ struct port_context { * enabled to invoke system APIs. */ #define PORT_IRQ_EPILOGUE() { \ - __avr_in_isr == false; \ + __avr_in_isr = false; \ _dbg_check_lock(); \ if (chSchIsPreemptionRequired()) \ chSchDoReschedule(); \ -- cgit v1.2.3