From: rtel Date: Fri, 11 Oct 2019 02:59:13 +0000 (+0000) Subject: RIS-V_RV32_SiFive_HiFive1_GCC project now running the blinky demo - still a work... X-Git-Tag: V10.3.0~87 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=24d8d2669677d4a45f5196729b28f96ac92d5b19;p=freertos RIS-V_RV32_SiFive_HiFive1_GCC project now running the blinky demo - still a work in progress. git-svn-id: https://svn.code.sf.net/p/freertos/code/trunk@2736 1d2547de-c912-0410-9cb9-b8ca96c0e9e2 --- diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/.cproject b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/.cproject index 2d226af01..f7e341555 100644 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/.cproject +++ b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/.cproject @@ -51,7 +51,7 @@ - diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/FreeRTOSConfig.h b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/FreeRTOSConfig.h index 2f7b0e015..d27c2557b 100644 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/FreeRTOSConfig.h +++ b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/FreeRTOSConfig.h @@ -71,16 +71,6 @@ #ifndef FREERTOS_CONFIG_H #define FREERTOS_CONFIG_H -/* - * For some reason the standard demo timer demo/test tasks fail when executing - * in QEMU, although they pass on other RISC-V platforms. This requires - * further investigation, but for now, defining _WINDOWS_ has the effect of - * using the wider timer test thresholds that are normally only used when the - * tests are used with the FreeRTOS Windows port (which is not deterministic - * and therefore requires wider margins). - */ -#define _WINDOWS_ - /*----------------------------------------------------------- * Application specific definitions. * @@ -97,11 +87,11 @@ #define configUSE_PREEMPTION 1 #define configUSE_IDLE_HOOK 0 #define configUSE_TICK_HOOK 1 -#define configCPU_CLOCK_HZ ( 10000000 ) /*QEMU*/ +#define configCPU_CLOCK_HZ ( 32768 ) /*QEMU*/ #define configTICK_RATE_HZ ( ( TickType_t ) 1000 ) #define configMAX_PRIORITIES ( 7 ) #define configMINIMAL_STACK_SIZE ( ( unsigned short ) 70 ) -#define configTOTAL_HEAP_SIZE ( ( size_t ) 14100 ) +#define configTOTAL_HEAP_SIZE ( ( size_t ) 10000 ) #define configMAX_TASK_NAME_LEN ( 16 ) #define configUSE_TRACE_FACILITY 0 #define configUSE_16_BIT_TICKS 0 diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/blinky_demo/main_blinky.c b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/blinky_demo/main_blinky.c new file mode 100644 index 000000000..1e5cf0a9c --- /dev/null +++ b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/blinky_demo/main_blinky.c @@ -0,0 +1,205 @@ +/* + * FreeRTOS Kernel V10.2.1 + * Copyright (C) 2019 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 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 ) + { + write( STDOUT_FILENO, pcPassMessage, strlen( pcPassMessage ) ); + vToggleLED(); + ulReceivedValue = 0U; + } + else + { + write( STDOUT_FILENO, pcFailMessage, strlen( pcFailMessage ) ); + } + } +} +/*-----------------------------------------------------------*/ + diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/bsp/metal.default.lds b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/bsp/metal.default.lds index a28307841..1d45a9266 100644 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/bsp/metal.default.lds +++ b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/bsp/metal.default.lds @@ -211,13 +211,14 @@ SECTIONS PROVIDE( end = . ); PROVIDE( metal_segment_bss_target_end = . ); - .stack : { - PROVIDE(metal_segment_stack_begin = .); - . = __stack_size; - PROVIDE( _sp = . ); + . = ALIGN(16); + metal_segment_stack_begin = .; + . += __stack_size; + _sp = .; PROVIDE(metal_segment_stack_end = .); + __freertos_irq_stack_top = .; } >ram AT>ram :ram diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/main.c b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/main.c index 41d4100d7..6013912ee 100644 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/main.c +++ b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/main.c @@ -1,3 +1,4 @@ +#if 1 /* * FreeRTOS Kernel V10.2.1 * Copyright (C) 2019 Amazon.com, Inc. or its affiliates. All Rights Reserved. @@ -29,6 +30,12 @@ #include #include +/* Freedom metal driver includes. */ +#include +#include +#include + + /****************************************************************************** * This project provides two demo applications. A simple blinky style project, * and a more comprehensive test and demo application. The @@ -49,6 +56,8 @@ #warning Also test in QEMU and add instructions above. +/* Index to first HART (there is only one). */ +#define mainHART_0 0 /* Set mainCREATE_SIMPLE_BLINKY_DEMO_ONLY to one to run the simple blinky demo, or 0 to run the more comprehensive test and demo application. */ @@ -71,16 +80,18 @@ void vApplicationIdleHook( void ); void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ); void vApplicationTickHook( void ); -/*-----------------------------------------------------------*/ +/* Setup the hardware to run this demo. */ +static void prvSetupHardware( void ); -void main_blinky( void ) -{ -#warning Not implemented yet. - for( ;; ); -} +/* Used by the Freedom Metal drivers. */ +static struct metal_led *pxLED = NULL; + +/*-----------------------------------------------------------*/ int main( void ) { + prvSetupHardware(); + /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top of this file. */ #if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 ) @@ -95,6 +106,26 @@ int main( void ) } /*-----------------------------------------------------------*/ +static void prvSetupHardware( void ) +{ +struct metal_cpu *pxCPU; +struct metal_interrupt *pxInterruptController; + + /* Initialise the red LED. */ + pxLED = metal_led_get_rgb( "LD0", "red" ); + configASSERT( pxLED ); + metal_led_enable( pxLED ); + metal_led_off( pxLED ); + + /* Initialise the interrupt controller. */ + pxCPU = metal_cpu_get( mainHART_0 ); + configASSERT( pxCPU ); + pxInterruptController = metal_cpu_interrupt_controller( pxCPU ); + configASSERT( pxInterruptController ); + metal_interrupt_init( pxInterruptController ); +} +/*-----------------------------------------------------------*/ + void vApplicationMallocFailedHook( void ) { /* vApplicationMallocFailedHook() will only be called if @@ -153,11 +184,120 @@ void vApplicationTickHook( void ) void vAssertCalled( void ) { -volatile uint32_t ulSetTo1ToExitFunction = 0; - taskDISABLE_INTERRUPTS(); - while( ulSetTo1ToExitFunction != 1 ) - { - __asm volatile( "NOP" ); - } + for( ;; ); } +/*-----------------------------------------------------------*/ + +void handle_trap( void ) +{ +#warning Not implemented. + + configASSERT( metal_cpu_get( mainHART_0 ) == 0x00 ); +} +/*-----------------------------------------------------------*/ + +void vToggleLED( void ) +{ + metal_led_toggle( pxLED ); +} + + + + +#else + +static void prvSetupTimerInterrupt( void ) +{ + int rc, up_cnt, dn_cnt; + + // Setup Timer and its interrupt so we can toggle LEDs on 1s cadence + tmr_intr = metal_cpu_timer_interrupt_controller(pxCPU); + if (tmr_intr == NULL) { + printf("TIMER interrupt controller is null.\n"); + return 4; + } + metal_interrupt_init(tmr_intr); + tmr_id = metal_cpu_timer_get_interrupt_id(pxCPU); + rc = metal_interrupt_register_handler(tmr_intr, tmr_id, timer_isr, pxCPU); + if (rc < 0) { + printf("TIMER interrupt handler registration failed\n"); + return (rc * -1); + } + + // Lastly CPU interrupt + if (metal_interrupt_enable(pxInterruptController, 0) == -1) { + printf("CPU interrupt enable failed\n"); + return 6; + } + + // Red -> Green -> Blue, repeat + while (1) { + + // Turn on RED + wait_for_timer(pxLED); + + // Turn on Green + wait_for_timer(led0_green); + + // Turn on Blue + wait_for_timer(led0_blue); + } + + // return + return 0; +} +/*-----------------------------------------------------------*/ + + +#include +#include +#include +#include +#include + +#define RTC_FREQ 32768 + +struct metal_cpu *pxCPU; +struct metal_interrupt *pxInterruptController, *tmr_intr; +int tmr_id; +volatile uint32_t timer_isr_flag; + + +void timer_isr (int id, void *data) { + + // Disable Timer interrupt + metal_interrupt_disable(tmr_intr, tmr_id); + + // Flag showing we hit timer isr + timer_isr_flag = 1; +} + +void wait_for_timer(struct metal_led *which_led) { + + // clear global timer isr flag + timer_isr_flag = 0; + + // Turn on desired LED + metal_led_on(which_led); + + // Set timer + metal_cpu_set_mtimecmp(pxCPU, metal_cpu_get_mtime(pxCPU) + RTC_FREQ); + + // Enable Timer interrupt + metal_interrupt_enable(tmr_intr, tmr_id); + + // wait till timer triggers and isr is hit + while (timer_isr_flag == 0){}; + + timer_isr_flag = 0; + + // Turn off this LED + metal_led_off(which_led); +} + + + +#endif + + diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE deleted file mode 100644 index 201a5c0fd..000000000 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE +++ /dev/null @@ -1,3 +0,0 @@ -This source repository is release under Apache2 and MIT licenses. - -See LICENSE.Apache2 and LICENSE.MIT for details. diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE.Apache2 b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE.Apache2 deleted file mode 100644 index d64569567..000000000 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE.Apache2 +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE.MIT b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE.MIT deleted file mode 100644 index 3a7e422b6..000000000 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/LICENSE.MIT +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License - -Copyright (c) 2019 SiFive, Inc. - -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. diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/README.md b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/README.md deleted file mode 100644 index 795e821b3..000000000 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/README.md +++ /dev/null @@ -1,2 +0,0 @@ -# sifive-welcome -A simple welcome example which prints SiFive banner and uses board LEDs diff --git a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/sifive-welcome.c b/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/sifive-welcome.c deleted file mode 100644 index c0e71172d..000000000 --- a/FreeRTOS/Demo/RISC-V_RV32_SiFive_HiFive1_GCC/src/sifive-welcome.c +++ /dev/null @@ -1,158 +0,0 @@ -/* Copyright 2019 SiFive, Inc */ -/* SPDX-License-Identifier: Apache-2.0 */ - -#include -#include -#include -#include -#include - -#define RTC_FREQ 32768 - -struct metal_cpu *cpu0; -struct metal_interrupt *cpu_intr, *tmr_intr; -int tmr_id; -volatile uint32_t timer_isr_flag; - -void display_banner (void) { - - printf("\n"); - printf("\n"); - printf(" SIFIVE, INC.\n"); - printf("\n"); - printf(" 5555555555555555555555555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555555555555555555555\n"); - printf(" 5555 555555555555555555555555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555 5555\n"); - printf(" 5555555555555555555555555555 55555\n"); - printf(" 55555 555555555 55555\n"); - printf(" 55555 55555 55555\n"); - printf(" 55555 5 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 55555 55555\n"); - printf(" 555555555\n"); - printf(" 55555\n"); - printf(" 5\n"); - printf("\n"); - - printf("\n"); - printf(" Welcome to SiFive!\n"); - -} - -void timer_isr (int id, void *data) { - - // Disable Timer interrupt - metal_interrupt_disable(tmr_intr, tmr_id); - - // Flag showing we hit timer isr - timer_isr_flag = 1; -} - -void wait_for_timer(struct metal_led *which_led) { - - // clear global timer isr flag - timer_isr_flag = 0; - - // Turn on desired LED - metal_led_on(which_led); - - // Set timer - metal_cpu_set_mtimecmp(cpu0, metal_cpu_get_mtime(cpu0) + RTC_FREQ); - - // Enable Timer interrupt - metal_interrupt_enable(tmr_intr, tmr_id); - - // wait till timer triggers and isr is hit - while (timer_isr_flag == 0){}; - - timer_isr_flag = 0; - - // Turn off this LED - metal_led_off(which_led); -} - -int original_main (void) -{ - int rc, up_cnt, dn_cnt; - struct metal_led *led0_red, *led0_green, *led0_blue; - - // This demo will toggle LEDs colors so we define them here - led0_red = metal_led_get_rgb("LD0", "red"); - led0_green = metal_led_get_rgb("LD0", "green"); - led0_blue = metal_led_get_rgb("LD0", "blue"); - if ((led0_red == NULL) || (led0_green == NULL) || (led0_blue == NULL)) { - printf("At least one of LEDs is null.\n"); - return 1; - } - - // Enable each LED - metal_led_enable(led0_red); - metal_led_enable(led0_green); - metal_led_enable(led0_blue); - - // All Off - metal_led_off(led0_red); - metal_led_off(led0_green); - metal_led_off(led0_blue); - - // Lets get the CPU and and its interrupt - cpu0 = metal_cpu_get(0); - if (cpu0 == NULL) { - printf("CPU null.\n"); - return 2; - } - cpu_intr = metal_cpu_interrupt_controller(cpu0); - if (cpu_intr == NULL) { - printf("CPU interrupt controller is null.\n"); - return 3; - } - metal_interrupt_init(cpu_intr); - - // display welcome banner - display_banner(); - - // Setup Timer and its interrupt so we can toggle LEDs on 1s cadence - tmr_intr = metal_cpu_timer_interrupt_controller(cpu0); - if (tmr_intr == NULL) { - printf("TIMER interrupt controller is null.\n"); - return 4; - } - metal_interrupt_init(tmr_intr); - tmr_id = metal_cpu_timer_get_interrupt_id(cpu0); - rc = metal_interrupt_register_handler(tmr_intr, tmr_id, timer_isr, cpu0); - if (rc < 0) { - printf("TIMER interrupt handler registration failed\n"); - return (rc * -1); - } - - // Lastly CPU interrupt - if (metal_interrupt_enable(cpu_intr, 0) == -1) { - printf("CPU interrupt enable failed\n"); - return 6; - } - - // Red -> Green -> Blue, repeat - while (1) { - - // Turn on RED - wait_for_timer(led0_red); - - // Turn on Green - wait_for_timer(led0_green); - - // Turn on Blue - wait_for_timer(led0_blue); - } - - // return - return 0; -}