mirror of
https://github.com/FreeRTOS/FreeRTOS-Kernel.git
synced 2025-09-12 09:07:46 -04:00
ATmegaxxxx - add megaAVR 0-Series support
This commit is contained in:
parent
d381f654fb
commit
db234a6cc1
2 changed files with 23 additions and 74 deletions
|
@ -27,6 +27,8 @@
|
||||||
|
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
#include <avr/io.h>
|
||||||
#include <avr/interrupt.h>
|
#include <avr/interrupt.h>
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
|
@ -524,17 +526,6 @@ static void prvSetupTimerInterrupt( void );
|
||||||
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
|
StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t pxCode, void *pvParameters )
|
||||||
{
|
{
|
||||||
uint16_t usAddress;
|
uint16_t usAddress;
|
||||||
|
|
||||||
/* Place a few bytes of known values on the bottom of the stack.
|
|
||||||
This is just useful for debugging. */
|
|
||||||
|
|
||||||
*pxTopOfStack = 0x11;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x22;
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = 0x33;
|
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
/* Simulate how the stack would look after a call to vPortYield() generated by
|
/* Simulate how the stack would look after a call to vPortYield() generated by
|
||||||
the compiler. */
|
the compiler. */
|
||||||
|
|
||||||
|
@ -590,51 +581,9 @@ uint16_t usAddress;
|
||||||
|
|
||||||
/* Now the remaining registers. The compiler expects R1 to be 0. */
|
/* Now the remaining registers. The compiler expects R1 to be 0. */
|
||||||
*pxTopOfStack = ( StackType_t ) 0x00; /* R1 */
|
*pxTopOfStack = ( StackType_t ) 0x00; /* R1 */
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x02; /* R2 */
|
/* Leave R2 - R23 untouched */
|
||||||
pxTopOfStack--;
|
pxTopOfStack -= 23;
|
||||||
*pxTopOfStack = ( StackType_t ) 0x03; /* R3 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x04; /* R4 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x05; /* R5 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x06; /* R6 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x07; /* R7 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x08; /* R8 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x09; /* R9 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x10; /* R10 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x11; /* R11 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x12; /* R12 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x13; /* R13 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x14; /* R14 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x15; /* R15 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x16; /* R16 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x17; /* R17 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x18; /* R18 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x19; /* R19 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x20; /* R20 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x21; /* R21 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x22; /* R22 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x23; /* R23 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
/* Place the parameter on the stack in the expected location. */
|
/* Place the parameter on the stack in the expected location. */
|
||||||
usAddress = ( uint16_t ) pvParameters;
|
usAddress = ( uint16_t ) pvParameters;
|
||||||
|
@ -643,20 +592,9 @@ uint16_t usAddress;
|
||||||
|
|
||||||
usAddress >>= 8;
|
usAddress >>= 8;
|
||||||
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
|
*pxTopOfStack = ( StackType_t ) ( usAddress & ( uint16_t ) 0x00ff );
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x26; /* R26 X */
|
/* Leave register R26 - R31 untouched */
|
||||||
pxTopOfStack--;
|
pxTopOfStack -= 7;
|
||||||
*pxTopOfStack = ( StackType_t ) 0x27; /* R27 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x28; /* R28 Y */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x29; /* R29 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x30; /* R30 Z */
|
|
||||||
pxTopOfStack--;
|
|
||||||
*pxTopOfStack = ( StackType_t ) 0x031; /* R31 */
|
|
||||||
pxTopOfStack--;
|
|
||||||
|
|
||||||
return pxTopOfStack;
|
return pxTopOfStack;
|
||||||
}
|
}
|
||||||
|
@ -709,6 +647,21 @@ void vPortYield( void )
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Manual context switch callable from ISRs. The first thing we do is save
|
||||||
|
* the registers so we can use a naked attribute.
|
||||||
|
*/
|
||||||
|
void vPortYieldFromISR(void) __attribute__ ( ( hot, flatten, naked ) );
|
||||||
|
void vPortYieldFromISR(void)
|
||||||
|
{
|
||||||
|
portSAVE_CONTEXT();
|
||||||
|
vTaskSwitchContext();
|
||||||
|
portRESTORE_CONTEXT();
|
||||||
|
|
||||||
|
__asm__ __volatile__ ( "reti" );
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Context switch function used by the tick. This must be identical to
|
* Context switch function used by the tick. This must be identical to
|
||||||
* vPortYield() from the call to vTaskSwitchContext() onwards. The only
|
* vPortYield() from the call to vTaskSwitchContext() onwards. The only
|
||||||
|
@ -725,7 +678,7 @@ void vPortYieldFromTick( void )
|
||||||
}
|
}
|
||||||
portRESTORE_CONTEXT();
|
portRESTORE_CONTEXT();
|
||||||
|
|
||||||
__asm__ __volatile__ ( "ret" );
|
__asm__ __volatile__ ( "reti" );
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------*/
|
/*-----------------------------------------------------------*/
|
||||||
|
|
||||||
|
@ -776,7 +729,6 @@ uint8_t ucLowByte;
|
||||||
ucLowByte = portTIMSK;
|
ucLowByte = portTIMSK;
|
||||||
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
|
ucLowByte |= portCOMPARE_MATCH_A_INTERRUPT_ENABLE;
|
||||||
portTIMSK = ucLowByte;
|
portTIMSK = ucLowByte;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -799,7 +751,6 @@ uint8_t ucLowByte;
|
||||||
ISR(portSCHEDULER_ISR)
|
ISR(portSCHEDULER_ISR)
|
||||||
{
|
{
|
||||||
vPortYieldFromTick();
|
vPortYieldFromTick();
|
||||||
__asm__ __volatile__ ( "reti" );
|
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
|
||||||
|
|
|
@ -45,7 +45,6 @@ extern "C" {
|
||||||
#include <avr/wdt.h>
|
#include <avr/wdt.h>
|
||||||
|
|
||||||
/* Type definitions. */
|
/* Type definitions. */
|
||||||
|
|
||||||
#define portCHAR char
|
#define portCHAR char
|
||||||
#define portFLOAT float
|
#define portFLOAT float
|
||||||
#define portDOUBLE double
|
#define portDOUBLE double
|
||||||
|
@ -152,4 +151,3 @@ extern void vPortYield( void ) __attribute__ ( ( naked ) );
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* PORTMACRO_H */
|
#endif /* PORTMACRO_H */
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue