From 65cf833ddf6cd54c9b98f17d22b2923cb45c8666 Mon Sep 17 00:00:00 2001 From: rtel Date: Mon, 10 Dec 2018 05:28:05 +0000 Subject: [PATCH] Backup checkin of MiFive demo running in ReNode emulator. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2601 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- .../.cproject | 396 ++++++++++++------ .../.settings/language.settings.xml | 34 +- .../FreeRTOSConfig.h | 14 +- .../Packages/.repos.xml | 8 + .../RTOSDemo Debug Hardware.launch | 62 +++ .../RTOSDemo Debug Renode.launch | 62 +++ ...mo-start-renode-emulator-and-attach.launch | 14 + .../blinky_demo/main_blinky.c | 206 +++++++++ .../full_demo/main_full.c | 58 ++- .../RISC-V_IGLOO2_Creative_SoftConsole/main.c | 10 +- 10 files changed, 696 insertions(+), 168 deletions(-) create mode 100644 FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/Packages/.repos.xml create mode 100644 FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Hardware.launch create mode 100644 FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Renode.launch create mode 100644 FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo-start-renode-emulator-and-attach.launch create mode 100644 FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/blinky_demo/main_blinky.c diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.cproject b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.cproject index 921b03ba1..f14a66062 100644 --- a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.cproject +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.cproject @@ -1,130 +1,272 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.settings/language.settings.xml b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.settings/language.settings.xml index 64e732cd8..e5699ca2b 100644 --- a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.settings/language.settings.xml +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/.settings/language.settings.xml @@ -1,14 +1,26 @@ - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/FreeRTOSConfig.h b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/FreeRTOSConfig.h index d4520e4f5..133d535a0 100644 --- a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/FreeRTOSConfig.h @@ -88,13 +88,14 @@ #define configCLINT_BASE_ADDRESS PRCI_BASE #define configUSE_PREEMPTION 1 -#define configUSE_IDLE_HOOK 0 +#define configUSE_IDLE_HOOK 1 #define configUSE_TICK_HOOK 1 -#define configCPU_CLOCK_HZ ( ( unsigned long ) ( SYS_CLK_FREQ / 100 ) ) /*_RB_ Seems to be a factor of 100 between machine timer frequency and CPU frequency. */ +#define configCPU_CLOCK_HZ ( ( unsigned long ) ( SYS_CLK_FREQ ) ) +//#define configCPU_CLOCK_HZ ( ( unsigned long ) ( SYS_CLK_FREQ / 100 ) ) /*_RB_ Seems to be a factor of 100 between machine timer frequency and CPU frequency. */ #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES ( 5 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 140 ) /* Can be as low as 60 but some of the demo tasks that use tis constant require it to be higher. */ -#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 100 * 1024 ) ) +#define configMINIMAL_STACK_SIZE ( ( unsigned short ) 256 ) /* Can be as low as 60 but some of the demo tasks that use tis constant require it to be higher. */ +#define configTOTAL_HEAP_SIZE ( ( size_t ) ( 256 * 1024 ) ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 0 #define configUSE_16_BIT_TICKS 0 @@ -115,8 +116,8 @@ /* Software timer definitions. */ #define configUSE_TIMERS 1 #define configTIMER_TASK_PRIORITY ( configMAX_PRIORITIES - 1 ) -#define configTIMER_QUEUE_LENGTH 7 -#define configTIMER_TASK_STACK_DEPTH ( 120 ) +#define configTIMER_QUEUE_LENGTH 4 +#define configTIMER_TASK_STACK_DEPTH ( configMINIMAL_STACK_SIZE ) /* Task priorities. Allow these to be overridden. */ #ifndef uartPRIMARY_PRIORITY @@ -139,4 +140,5 @@ to exclude the API function. */ header file. */ #define configASSERT( x ) if( ( x ) == 0 ) { taskDISABLE_INTERRUPTS(); __asm volatile( "ebreak" ); for( ;; ); } +#define configUSE_PORT_OPTIMISED_TASK_SELECTION 0 #endif /* FREERTOS_CONFIG_H */ diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/Packages/.repos.xml b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/Packages/.repos.xml new file mode 100644 index 000000000..76dbb8968 --- /dev/null +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/Packages/.repos.xml @@ -0,0 +1,8 @@ + + + + CMSIS Pack + Keil + http://www.keil.com/pack/index.pidx + + diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Hardware.launch b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Hardware.launch new file mode 100644 index 000000000..3669d25a7 --- /dev/null +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Hardware.launch @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Renode.launch b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Renode.launch new file mode 100644 index 000000000..78d09056f --- /dev/null +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo Debug Renode.launch @@ -0,0 +1,62 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo-start-renode-emulator-and-attach.launch b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo-start-renode-emulator-and-attach.launch new file mode 100644 index 000000000..383dbed17 --- /dev/null +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/RTOSDemo-start-renode-emulator-and-attach.launch @@ -0,0 +1,14 @@ + + + + + + + + + + + + + + diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/blinky_demo/main_blinky.c b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/blinky_demo/main_blinky.c new file mode 100644 index 000000000..7688ed8c7 --- /dev/null +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/blinky_demo/main_blinky.c @@ -0,0 +1,206 @@ +/* + * FreeRTOS Kernel V10.1.1 + * Copyright (C) 2018 Amazon.com, Inc. or its affiliates. All Rights Reserved. + * + * Permission is hereby granted, free of charge, to any person obtaining a copy of + * this software and associated documentation files (the "Software"), to deal in + * the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of + * the Software, and to permit persons to whom the Software is furnished to do so, + * subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS + * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR + * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER + * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + * + * http://www.FreeRTOS.org + * http://aws.amazon.com/freertos + * + * 1 tab == 4 spaces! + */ + +/****************************************************************************** + * NOTE 1: This project provides two demo applications. A simple blinky + * style project, and a more comprehensive test and demo application. The + * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting in main.c is used to select + * between the two. See the notes on using mainCREATE_SIMPLE_BLINKY_DEMO_ONLY + * in main.c. This file implements the simply blinky style version. + * + * NOTE 2: This file only contains the source code that is specific to the + * basic demo. Generic functions, such FreeRTOS hook functions, and functions + * required to configure the hardware are defined in main.c. + ****************************************************************************** + * + * main_blinky() creates one queue, and two tasks. It then starts the + * scheduler. + * + * The Queue Send Task: + * The queue send task is implemented by the prvQueueSendTask() function in + * this file. prvQueueSendTask() sits in a loop that causes it to repeatedly + * block for 1000 milliseconds, before sending the value 100 to the queue that + * was created within main_blinky(). Once the value is sent, the task loops + * back around to block for another 1000 milliseconds...and so on. + * + * The Queue Receive Task: + * The queue receive task is implemented by the prvQueueReceiveTask() function + * in this file. prvQueueReceiveTask() sits in a loop where it repeatedly + * blocks on attempts to read data from the queue that was created within + * main_blinky(). When data is received, the task checks the value of the + * data, and if the value equals the expected 100, writes 'Blink' to the UART + * (the UART is used in place of the LED to allow easy execution in QEMU). The + * 'block time' parameter passed to the queue receive function specifies that + * the task should be held in the Blocked state indefinitely to wait for data to + * be available on the queue. The queue receive task will only leave the + * Blocked state when the queue send task writes to the queue. As the queue + * send task writes to the queue every 1000 milliseconds, the queue receive + * task leaves the Blocked state every 1000 milliseconds, and therefore toggles + * the LED every 200 milliseconds. + */ + +/* Standard includes. */ +#include +#include +#include + +/* Kernel includes. */ +#include "FreeRTOS.h" +#include "task.h" +#include "queue.h" + +/* Priorities used by the tasks. */ +#define mainQUEUE_RECEIVE_TASK_PRIORITY ( tskIDLE_PRIORITY + 2 ) +#define mainQUEUE_SEND_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 ) + +/* The rate at which data is sent to the queue. The 200ms value is converted +to ticks using the pdMS_TO_TICKS() macro. */ +#define mainQUEUE_SEND_FREQUENCY_MS pdMS_TO_TICKS( 1000 ) + +/* The maximum number items the queue can hold. The priority of the receiving +task is above the priority of the sending task, so the receiving task will +preempt the sending task and remove the queue items each time the sending task +writes to the queue. Therefore the queue will never have more than one item in +it at any time, and even with a queue length of 1, the sending task will never +find the queue full. */ +#define mainQUEUE_LENGTH ( 1 ) + +/*-----------------------------------------------------------*/ + +/* + * Called by main when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1 in + * main.c. + */ +void main_blinky( void ); + +/* + * The tasks as described in the comments at the top of this file. + */ +static void prvQueueReceiveTask( void *pvParameters ); +static void prvQueueSendTask( void *pvParameters ); + +/*-----------------------------------------------------------*/ + +/* The queue used by both tasks. */ +static QueueHandle_t xQueue = NULL; + +/*-----------------------------------------------------------*/ + +void main_blinky( void ) +{ + /* Create the queue. */ + xQueue = xQueueCreate( mainQUEUE_LENGTH, sizeof( uint32_t ) ); + + if( xQueue != NULL ) + { + /* Start the two tasks as described in the comments at the top of this + file. */ + xTaskCreate( prvQueueReceiveTask, /* The function that implements the task. */ + "Rx", /* The text name assigned to the task - for debug only as it is not used by the kernel. */ + configMINIMAL_STACK_SIZE * 2U, /* The size of the stack to allocate to the task. */ + NULL, /* The parameter passed to the task - not used in this case. */ + mainQUEUE_RECEIVE_TASK_PRIORITY, /* The priority assigned to the task. */ + NULL ); /* The task handle is not required, so NULL is passed. */ + + xTaskCreate( prvQueueSendTask, "TX", configMINIMAL_STACK_SIZE * 2U, NULL, mainQUEUE_SEND_TASK_PRIORITY, NULL ); + + /* Start the tasks and timer running. */ + vTaskStartScheduler(); + } + + /* If all is well, the scheduler will now be running, and the following + line will never be reached. If the following line does execute, then + there was insufficient FreeRTOS heap memory available for the Idle and/or + timer tasks to be created. See the memory management section on the + FreeRTOS web site for more details on the FreeRTOS heap + http://www.freertos.org/a00111.html. */ + for( ;; ); +} +/*-----------------------------------------------------------*/ + +static void prvQueueSendTask( void *pvParameters ) +{ +TickType_t xNextWakeTime; +const unsigned long ulValueToSend = 100UL; +BaseType_t xReturned; + + /* Remove compiler warning about unused parameter. */ + ( void ) pvParameters; + + /* Initialise xNextWakeTime - this only needs to be done once. */ + xNextWakeTime = xTaskGetTickCount(); + + for( ;; ) + { + /* Place this task in the blocked state until it is time to run again. */ + vTaskDelayUntil( &xNextWakeTime, mainQUEUE_SEND_FREQUENCY_MS ); + + /* Send to the queue - causing the queue receive task to unblock and + toggle the LED. 0 is used as the block time so the sending operation + will not block - it shouldn't need to block as the queue should always + be empty at this point in the code. */ + xReturned = xQueueSend( xQueue, &ulValueToSend, 0U ); + configASSERT( xReturned == pdPASS ); + } +} +/*-----------------------------------------------------------*/ + +static void prvQueueReceiveTask( void *pvParameters ) +{ +unsigned long ulReceivedValue; +const unsigned long ulExpectedValue = 100UL; +const char * const pcPassMessage = "Blink\r\n"; +const char * const pcFailMessage = "Unexpected value received\r\n"; +extern void vSendString( const char * const pcString ); +extern void vToggleLED( void ); + + /* Remove compiler warning about unused parameter. */ + ( void ) pvParameters; + + for( ;; ) + { + /* Wait until something arrives in the queue - this task will block + indefinitely provided INCLUDE_vTaskSuspend is set to 1 in + FreeRTOSConfig.h. */ + xQueueReceive( xQueue, &ulReceivedValue, portMAX_DELAY ); + + /* To get here something must have been received from the queue, but + is it the expected value? If it is, toggle the LED. */ + if( ulReceivedValue == ulExpectedValue ) + { + vSendString( pcPassMessage ); + vToggleLED(); + ulReceivedValue = 0U; + } + else + { + vSendString( pcFailMessage ); + } + } +} +/*-----------------------------------------------------------*/ + diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/full_demo/main_full.c b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/full_demo/main_full.c index 8bbad7c19..655d6ff15 100644 --- a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/full_demo/main_full.c +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/full_demo/main_full.c @@ -101,7 +101,7 @@ comments at the top of this file. */ #define mainCHECK_TASK_STACK_SIZE_WORDS 100 /* Size of the stacks to allocated for the register check tasks. */ -#define mainREG_TEST_STACK_SIZE_WORDS 60 +#define mainREG_TEST_STACK_SIZE_WORDS 70 /*-----------------------------------------------------------*/ @@ -150,22 +150,22 @@ void main_full( void ) kernel port. */ vStartDynamicPriorityTasks(); vCreateBlockTimeTasks(); -// vStartGenericQueueTasks( tskIDLE_PRIORITY ); -// vStartRecursiveMutexTasks(); -// vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); -// vStartEventGroupTasks(); -// vStartTaskNotifyTask(); + vStartGenericQueueTasks( tskIDLE_PRIORITY ); + vStartRecursiveMutexTasks(); + vStartTimerDemoTask( mainTIMER_TEST_PERIOD ); + vStartEventGroupTasks(); + vStartTaskNotifyTask(); /* Create the register check tasks, as described at the top of this file. Use xTaskCreateStatic() to create a task using only statically allocated memory. */ -// xTaskCreate( prvRegTestTaskEntry1, /* The function that implements the task. */ -// "Reg1", /* The name of the task. */ -// mainREG_TEST_STACK_SIZE_WORDS, /* Size of stack to allocate for the task - in words not bytes!. */ -// mainREG_TEST_TASK_1_PARAMETER, /* Parameter passed into the task. */ -// tskIDLE_PRIORITY, /* Priority of the task. */ -// NULL ); /* Can be used to pass out a handle to the created task. */ -// xTaskCreate( prvRegTestTaskEntry2, "Reg2", mainREG_TEST_STACK_SIZE_WORDS, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL ); + xTaskCreate( prvRegTestTaskEntry1, /* The function that implements the task. */ + "Reg1", /* The name of the task. */ + mainREG_TEST_STACK_SIZE_WORDS, /* Size of stack to allocate for the task - in words not bytes!. */ + mainREG_TEST_TASK_1_PARAMETER, /* Parameter passed into the task. */ + tskIDLE_PRIORITY, /* Priority of the task. */ + NULL ); /* Can be used to pass out a handle to the created task. */ + xTaskCreate( prvRegTestTaskEntry2, "Reg2", mainREG_TEST_STACK_SIZE_WORDS, mainREG_TEST_TASK_2_PARAMETER, tskIDLE_PRIORITY, NULL ); /* Create the task that performs the 'check' functionality, as described at the top of this file. */ @@ -183,7 +183,7 @@ void main_full( void ) for( ;; ); } /*-----------------------------------------------------------*/ - +//int count = 0; static void prvCheckTask( void *pvParameters ) { TickType_t xDelayPeriod = mainNO_ERROR_CHECK_TASK_PERIOD; @@ -209,9 +209,20 @@ extern void vToggleLED( void ); doing gives visual feedback of the system status. */ for( ;; ) { +// if( ++count == 5 ) {taskENTER_CRITICAL();for(;;);} /* Delay until it is time to execute again. */ vTaskDelayUntil( &xLastExecutionTime, xDelayPeriod ); +// taskENTER_CRITICAL(); +// for( int i = 0; i < 100; i++ ) +// { +// for( int j = 0; j < 1000; j++ ) taskYIELD(); +// taskEXIT_CRITICAL(); +// vTaskDelay( 1 ); +// taskENTER_CRITICAL(); +// } +// taskEXIT_CRITICAL(); + /* Check all the demo tasks (other than the flash tasks) to ensure that they are all still running, and that none have detected an error. */ if( xAreDynamicPriorityTasksStillRunning() != pdTRUE ) @@ -226,40 +237,40 @@ extern void vToggleLED( void ); if ( xAreGenericQueueTasksStillRunning() != pdTRUE ) { -// pcStatusMessage = "ERROR: Generic queue demo/tests.\r\n"; + pcStatusMessage = "ERROR: Generic queue demo/tests.\r\n"; } if ( xAreRecursiveMutexTasksStillRunning() != pdTRUE ) { -// pcStatusMessage = "ERROR: Recursive mutex demo/tests.\r\n"; + pcStatusMessage = "ERROR: Recursive mutex demo/tests.\r\n"; } if( xAreTimerDemoTasksStillRunning( ( TickType_t ) xDelayPeriod ) != pdPASS ) { -// pcStatusMessage = "ERROR: Timer demo/tests.\r\n"; + pcStatusMessage = "ERROR: Timer demo/tests.\r\n"; } if( xAreEventGroupTasksStillRunning() != pdPASS ) { -// pcStatusMessage = "ERROR: Event group demo/tests.\r\n"; + pcStatusMessage = "ERROR: Event group demo/tests.\r\n"; } if( xAreTaskNotificationTasksStillRunning() != pdPASS ) { -// pcStatusMessage = "ERROR: Task notification demo/tests.\r\n"; + pcStatusMessage = "ERROR: Task notification demo/tests.\r\n"; } /* Check that the register test 1 task is still running. */ if( ulLastRegTest1Value == ulRegTest1LoopCounter ) { -// pcStatusMessage = "ERROR: Register test 1.\r\n"; + pcStatusMessage = "ERROR: Register test 1.\r\n"; } ulLastRegTest1Value = ulRegTest1LoopCounter; /* Check that the register test 2 task is still running. */ if( ulLastRegTest2Value == ulRegTest2LoopCounter ) { -// pcStatusMessage = "ERROR: Register test 2.\r\n"; + pcStatusMessage = "ERROR: Register test 2.\r\n"; } ulLastRegTest2Value = ulRegTest2LoopCounter; @@ -317,6 +328,7 @@ void vFullDemoTickHook( void ) { /* Called from vApplicationTickHook() when the project is configured to build the full demo. */ -// vTimerPeriodicISRTests(); -// vPeriodicEventGroupsProcessing(); + vTimerPeriodicISRTests(); + vPeriodicEventGroupsProcessing(); + xNotifyTaskFromISR(); } diff --git a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/main.c b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/main.c index be526c213..96834b822 100644 --- a/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/main.c +++ b/FreeRTOS/Demo/RISC-V_IGLOO2_Creative_SoftConsole/main.c @@ -87,7 +87,7 @@ static gpio_instance_t g_gpio_out; int main( void ) { - prvSetupHardware(); +// prvSetupHardware(); /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top of this file. */ @@ -144,6 +144,11 @@ void vApplicationMallocFailedHook( void ) } /*-----------------------------------------------------------*/ +volatile uint64_t mtimer = 0, mcompare = 0; +volatile uint32_t mstatus; +static volatile uint64_t * const pulCompareLow = ( volatile uint64_t * const ) ( configCLINT_BASE_ADDRESS + 0x4000 ); +static volatile uint64_t * const pulTimeLow = ( volatile uint64_t * const ) ( configCLINT_BASE_ADDRESS + 0xBFF8 ); + void vApplicationIdleHook( void ) { /* vApplicationIdleHook() will only be called if configUSE_IDLE_HOOK is set @@ -155,6 +160,9 @@ void vApplicationIdleHook( void ) important that vApplicationIdleHook() is permitted to return to its calling function, because it is the responsibility of the idle task to clean up memory allocated by the kernel to any task that has since been deleted. */ + mstatus = read_csr( mstatus ); + mtimer = *pulTimeLow; + mcompare = *pulCompareLow; } /*-----------------------------------------------------------*/ -- 2.39.2