ATmegaxxxx - clarify initial stack setup

This commit is contained in:
Phillip Stevens 2020-04-11 18:37:00 +10:00
parent 10fcd90af1
commit 62682ebe5b

View file

@ -542,6 +542,14 @@ uint16_t usAddress;
/* The start of the task code will be popped off the stack last, so place
it on first. */
usAddress = ( uint16_t ) pxCode;
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
usAddress >>= 8;
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
#if defined(__AVR_3_BYTE_PC__)
/* The AVR ATmega2560/ATmega2561 have 256KBytes of program memory and a 17-bit
* program counter. When a code address is stored on the stack, it takes 3 bytes
@ -553,24 +561,9 @@ uint16_t usAddress;
* In order to do this properly, we would need to get a full 3-byte pointer to
* pxCode. That requires a change to GCC. Not likely to happen any time soon.
*/
usAddress = ( uint16_t ) pxCode;
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
usAddress >>= 8;
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
*pxTopOfStack = 0;
pxTopOfStack--;
#else
usAddress = ( uint16_t ) pxCode;
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
usAddress >>= 8;
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
pxTopOfStack--;
#endif
/* Next simulate the stack as if after a call to portSAVE_CONTEXT().