Added code to setup the timer interrupt - not tested yet.
Added the taskYIELD() implementation - so far just checked it generates an interrupt.
pull/4/head
Richard Barry 7 years ago
parent b11eb3a59c
commit 32f35e9130

@ -39,7 +39,7 @@
* file is weak to allow application writers to change the timer used to * file is weak to allow application writers to change the timer used to
* generate the tick interrupt. * generate the tick interrupt.
*/ */
void vPortSetupTimerInterrupt( void ); void vPortSetupTimerInterrupt( void ) __attribute__(( weak ));
/* /*
* Used to catch tasks that attempt to return from their implementing function. * Used to catch tasks that attempt to return from their implementing function.
@ -48,10 +48,16 @@ static void prvTaskExitError( void );
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
/* Used to program the machine timer compare register. */
static uint64_t ullNextTime = 0ULL;
static volatile uint64_t * const pullMachineTimerCompareRegister = ( volatile uint64_t * const ) 0x2004000;
/*-----------------------------------------------------------*/
void prvTaskExitError( void ) void prvTaskExitError( void )
{ {
volatile uint32_t ulx = 0; volatile uint32_t ulx = 0;
#warning prvTaskExitError not used yet.
/* A function that implements a task must not exit or attempt to return to /* A function that implements a task must not exit or attempt to return to
its caller as there is nothing to return to. If a task wants to exit it its caller as there is nothing to return to. If a task wants to exit it
should instead call vTaskDelete( NULL ). should instead call vTaskDelete( NULL ).
@ -154,6 +160,29 @@ StackType_t *pxPortInitialiseStack( StackType_t *pxTopOfStack, TaskFunction_t px
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vPortSetupTimerInterrupt( void )
{
uint32_t ulCurrentTimeHigh, ulCurrentTimeLow;
volatile uint32_t * const pulTimeHigh = ( volatile uint32_t * const ) 0x200BFF8;
volatile uint32_t * const pulTimeLow = ( volatile uint32_t * const ) 0x200BFFc;
do
{
ulCurrentTimeHigh = *pulTimeHigh;
ulCurrentTimeLow = *pulTimeLow;
} while( ulCurrentTimeHigh != *pulTimeHigh );
ullNextTime = ( uint64_t ) ulCurrentTimeHigh;
ullNextTime <<= 32ULL;
ullNextTime |= ( uint64_t ) ulCurrentTimeLow;
ullNextTime += ( configCPU_CLOCK_HZ / configTICK_RATE_HZ );
*pullMachineTimerCompareRegister = ullNextTime;
/* Enable timer interrupt */
__asm volatile( "csrs mie, %0" :: "r"(0x80) );
}
/*-----------------------------------------------------------*/
BaseType_t xPortStartScheduler( void ) BaseType_t xPortStartScheduler( void )
{ {
__asm volatile __asm volatile
@ -189,6 +218,7 @@ BaseType_t xPortStartScheduler( void )
"lw x6, 100( sp ) \r\n" /* X6 */ "lw x6, 100( sp ) \r\n" /* X6 */
"lw x5, 104( sp ) \r\n" /* X5 */ "lw x5, 104( sp ) \r\n" /* X5 */
"lw x1, 108( sp ) \r\n" /* X1 */ "lw x1, 108( sp ) \r\n" /* X1 */
"csrs mie, 8 \r\n" /* Enable soft interrupt. */
"csrs mstatus, 8 \r\n" /* Enable interrupts. */ "csrs mstatus, 8 \r\n" /* Enable interrupts. */
"ret " "ret "
); );
@ -198,8 +228,5 @@ BaseType_t xPortStartScheduler( void )
} }
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/
void vPortYield( void )
{
}

@ -70,8 +70,7 @@ not need to be guarded with a critical section. */
/* Scheduler utilities. */ /* Scheduler utilities. */
extern void vPortYield( void ); #define portYIELD() { volatile uint32_t * const ulSoftInterrupt = ( uint32_t * ) 0x2000000; *ulSoftInterrupt = 1UL; }
#define portYIELD() vPortYield()
#define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYield() #define portEND_SWITCHING_ISR( xSwitchRequired ) if( xSwitchRequired ) vPortYield()
#define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x ) #define portYIELD_FROM_ISR( x ) portEND_SWITCHING_ISR( x )
/*-----------------------------------------------------------*/ /*-----------------------------------------------------------*/

Loading…
Cancel
Save