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