OpenCores
URL https://opencores.org/ocsvn/neorv32/neorv32/trunk

Subversion Repositories neorv32

[/] [neorv32/] [trunk/] [sw/] [example/] [demo_freeRTOS/] [main.c] - Diff between revs 22 and 36

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 22 Rev 36
Line 23... Line 23...
 * http://aws.amazon.com/freertos
 * http://aws.amazon.com/freertos
 *
 *
 * 1 tab == 4 spaces!
 * 1 tab == 4 spaces!
 */
 */
 
 
 
/******************************************************************************
 
 * 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 (defined in this file) is used to
 
 * select between the two.  The simply blinky demo is implemented and described
 
 * in main_blinky.c.  The more comprehensive test and demo application is
 
 * implemented and described in main_full.c.
 
 *
 
 * This file implements the code that is not demo specific, including the
 
 * hardware setup and standard FreeRTOS hook functions.
 
 *
 
 * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
 
 * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
 
 * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
 
 *
 
 */
 
 
/*
/*
 * Modified for the NEORV32 processor by Stephan Nolting.
 * Modified for the NEORV32 processor by Stephan Nolting.
 */
 */
 
 
#ifdef RUN_FREERTOS_DEMO
#ifdef RUN_FREERTOS_DEMO
 
 
 
#include <stdint.h>
 
 
/* FreeRTOS kernel includes. */
/* FreeRTOS kernel includes. */
#include <FreeRTOS.h>
#include <FreeRTOS.h>
 
#include <semphr.h>
 
#include <queue.h>
#include <task.h>
#include <task.h>
 
 
/* NEORV32 includes. */
/* NEORV32 includes. */
#include <neorv32.h>
#include <neorv32.h>
 
 
 
/* misc */
 
//#include "driver_wrapper/uart_serial.h"
 
 
 
/* 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. */
 
#define mainCREATE_SIMPLE_BLINKY_DEMO_ONLY      1
 
 
 
/* UART hardware constants. */
#define BAUD_RATE 19200
#define BAUD_RATE 19200
 
 
 
/*-----------------------------------------------------------*/
 
 
/******************************************************************************
/*
 * This project provides two demo applications.  A simple blinky style project,
 * main_blinky() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 1.
 * and a more comprehensive test and demo application.  The
 * main_full() is used when mainCREATE_SIMPLE_BLINKY_DEMO_ONLY is set to 0.
 * mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting (defined in this file) is used to
 
 * select between the two.  The simply blinky demo is implemented and described
 
 * in main_blinky.c.  The more comprehensive test and demo application is
 
 * implemented and described in main_full.c.
 
 *
 
 * This file implements the code that is not demo specific, including the
 
 * hardware setup and standard FreeRTOS hook functions.
 
 *
 
 * ENSURE TO READ THE DOCUMENTATION PAGE FOR THIS PORT AND DEMO APPLICATION ON
 
 * THE http://www.FreeRTOS.org WEB SITE FOR FULL INFORMATION ON USING THIS DEMO
 
 * APPLICATION, AND ITS ASSOCIATE FreeRTOS ARCHITECTURE PORT!
 
 *
 
 */
 */
 
#if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1
extern void main_blinky( void );
extern void main_blinky( void );
 
#else
 
        extern void main_full( void );
 
#endif /* #if mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 */
 
 
extern void freertos_risc_v_trap_handler( void );
extern void freertos_risc_v_trap_handler( void );
 
 
/* Prototypes for the standard FreeRTOS callback/hook functions implemented
/*
within this file.  See https://www.freertos.org/a00016.html */
 * Prototypes for the standard FreeRTOS callback/hook functions implemented
 
 * within this file.  See https://www.freertos.org/a00016.html
 
 */
void vApplicationMallocFailedHook( void );
void vApplicationMallocFailedHook( void );
void vApplicationIdleHook( void );
void vApplicationIdleHook( void );
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );
void vApplicationTickHook( void );
void vApplicationTickHook( void );
 
 
/* Prepare hardware to run the demo. */
/* Prepare hardware to run the demo. */
static void prvSetupHardware( void );
static void prvSetupHardware( void );
 
 
/* Send a message to the UART initialised in prvSetupHardware. */
/* System */
void vSendString( const char * const pcString );
void vToggleLED( void );
 
void vSendString( const char * pcString );
 
 
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
 
 
int main( void )
int main( void )
{
{
        prvSetupHardware();
        prvSetupHardware();
 
 
  neorv32_uart_printf("FreeRTOS %s\n", tskKERNEL_VERSION_NUMBER);
  /* say hi */
 
  neorv32_uart_printf("FreeRTOS %s on NEORV32 Demo\n\n", tskKERNEL_VERSION_NUMBER);
 
 
 
        /* The mainCREATE_SIMPLE_BLINKY_DEMO_ONLY setting is described at the top
 
        of this file. */
 
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY == 1 )
        main_blinky();
        main_blinky();
 
#else
 
  main_full();
 
#endif
}
}
 
 
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
 
 
static void prvSetupHardware( void )
static void prvSetupHardware( void )
{
{
  // configure trap handler entry point
  // configure trap handler entry point
  neorv32_cpu_csr_write(CSR_MTVEC, (uint32_t)&freertos_risc_v_trap_handler);
  neorv32_cpu_csr_write(CSR_MTVEC, (uint32_t)&freertos_risc_v_trap_handler);
 
 
 
  // clear GPIO.out port
 
  neorv32_gpio_port_set(0);
 
 
  // configure UART for default baud rate, no rx interrupt, no tx interrupt
  // configure UART for default baud rate, no rx interrupt, no tx interrupt
  neorv32_uart_setup(BAUD_RATE, 0, 0);
  neorv32_uart_setup(BAUD_RATE, 0, 0);
}
}
 
 
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
Line 105... Line 138...
        neorv32_gpio_pin_toggle(0);
        neorv32_gpio_pin_toggle(0);
}
}
 
 
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
 
 
void vSendString( const char * const pcString )
void vSendString( const char * pcString )
{
{
        neorv32_uart_print( (char *)pcString );
        neorv32_uart_print( ( const char * ) pcString );
}
}
 
 
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
 
 
void vApplicationMallocFailedHook( void )
void vApplicationMallocFailedHook( void )
Line 125... Line 158...
        heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
        heap available to pvPortMalloc() is defined by configTOTAL_HEAP_SIZE in
        FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
        FreeRTOSConfig.h, and the xPortGetFreeHeapSize() API function can be used
        to query the size of free heap space that remains (although it does not
        to query the size of free heap space that remains (although it does not
        provide information on how the remaining heap might be fragmented). */
        provide information on how the remaining heap might be fragmented). */
        taskDISABLE_INTERRUPTS();
        taskDISABLE_INTERRUPTS();
  neorv32_uart_print("FreeRTOS_FAULT: vApplicationMallocFailedHook\n");
  neorv32_uart_print("FreeRTOS_FAULT: vApplicationMallocFailedHook (solution: increase 'configTOTAL_HEAP_SIZE' in FreeRTOSConfig.h)\n");
        __asm volatile( "ebreak" );
        __asm volatile( "ebreak" );
        for( ;; );
        for( ;; );
}
}
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
 
 
Line 165... Line 198...
 
 
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
 
 
void vApplicationTickHook( void )
void vApplicationTickHook( void )
{
{
 
  /* The tests in the full demo expect some interaction with interrupts. */
 
#if( mainCREATE_SIMPLE_BLINKY_DEMO_ONLY != 1 )
 
  {
 
  extern void vFullDemoTickHook( void );
 
  vFullDemoTickHook();
 
  }
 
#endif
}
}
 
 
/*-----------------------------------------------------------*/
/*-----------------------------------------------------------*/
 
 
/* This handler is responsible for handling all interrupts. Only the machine timer interrupt is handled by the kernel. */
/* This handler is responsible for handling all interrupts. Only the machine timer interrupt is handled by the kernel. */

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.