]> git.sur5r.net Git - freertos/blobdiff - FreeRTOS/Demo/CORTEX_R4F_RZ_T_GCC_IAR_ARM/src/main.c
Simplify and improve GIC-less Cortex-R4 port.
[freertos] / FreeRTOS / Demo / CORTEX_R4F_RZ_T_GCC_IAR_ARM / src / main.c
index ea23b6d5b469ad3f635b535595a7356b589bd248..a90203650c7588f5295fbaec82de7cf99dabf90c 100644 (file)
@@ -1,4 +1,3 @@
-#if 1\r
 /*\r
     FreeRTOS V8.2.2 - Copyright (C) 2015 Real Time Engineers Ltd.\r
     All rights reserved\r
@@ -110,6 +109,11 @@ or 0 to run the more comprehensive test and demo application. */
 \r
 /*-----------------------------------------------------------*/\r
 \r
+/*\r
+ * The start up code does not include a routine to clear the BSS segment to 0\r
+ * (as would be normal before calling main()), so the BSS is cleared manually\r
+ * using the following function.\r
+ */\r
 static void prvClearBSS( void );\r
 \r
 /*\r
@@ -143,15 +147,13 @@ extern void R_Systeminit( void );
 \r
 /*-----------------------------------------------------------*/\r
 \r
-volatile uint32_t ultest = 0, ultest2 = 9999;\r
-\r
 int main( void )\r
 {\r
+       /* The start up code does not include a routine to clear the BSS segment to\r
+       0 (as would be normal before calling main()), so the BSS is cleared manually\r
+       using the following function. */\r
        prvClearBSS();\r
 \r
-       configASSERT( ultest == 0 );\r
-       configASSERT( ultest2 == 9999 );\r
-\r
        /* Configure the hardware ready to run the demo. */\r
        prvSetupHardware();\r
 \r
@@ -228,7 +230,7 @@ volatile size_t xFreeHeapSpace;
        management options.  If there is a lot of heap memory free then the\r
        configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up\r
        RAM. */\r
-//     xFreeHeapSpace = xPortGetFreeHeapSize();\r
+       xFreeHeapSpace = xPortGetFreeHeapSize();\r
 \r
        /* Remove compiler warning about xFreeHeapSpace being set but never used. */\r
        ( void ) xFreeHeapSpace;\r
@@ -247,46 +249,6 @@ void vApplicationTickHook( void )
 }\r
 /*-----------------------------------------------------------*/\r
 \r
-/* The function called by the RTOS port layer after it has managed interrupt\r
-entry. */\r
-void vApplicationIRQHandler( void )\r
-{\r
-#if 1\r
-extern void FreeRTOS_Tick_Handler( void );\r
-\r
-       /* Clear the interrupt source CMI5. */\r
-       VIC.PIC9.LONG = 0x00001000UL;\r
-\r
-       FreeRTOS_Tick_Handler();\r
-\r
-       /* Dummy write */\r
-       portDISABLE_INTERRUPTS();\r
-       // Done in the epilogue code VIC.HVA0.LONG = 0x00000000UL;\r
-\r
-#else\r
-typedef void (*ISRFunction_t)( void );\r
-ISRFunction_t pxISRFunction;\r
-volatile uint32_t * pulAIC_IVR = ( uint32_t * ) configINTERRUPT_VECTOR_ADDRESS;\r
-\r
-       /* Obtain the address of the interrupt handler from the AIR. */\r
-       pxISRFunction = ( ISRFunction_t ) *pulAIC_IVR;\r
-\r
-       /* Write back to the SAMA5's interrupt controller's IVR register in case the\r
-       CPU is in protect mode.  If the interrupt controller is not in protect mode\r
-       then this write is not necessary. */\r
-       *pulAIC_IVR = ( uint32_t ) pxISRFunction;\r
-\r
-       /* Ensure the write takes before re-enabling interrupts. */\r
-       __DSB();\r
-       __ISB();\r
-    __enable_irq();\r
-\r
-       /* Call the installed ISR. */\r
-       pxISRFunction();\r
-#endif\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
 static void prvClearBSS( void )\r
 {\r
 extern uint32_t __bss_start__[];\r
@@ -300,240 +262,3 @@ size_t xSize;
 \r
 \r
 \r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-#else\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-\r
-#include "FreeRTOS.h"\r
-#include "task.h"\r
-\r
-/***********************************************************************************************************************\r
-Includes\r
-***********************************************************************************************************************/\r
-#include "r_cg_macrodriver.h"\r
-#include "r_cg_cgc.h"\r
-#include "r_cg_icu.h"\r
-#include "r_cg_port.h"\r
-#include "r_cg_tpu.h"\r
-#include "r_cg_cmt.h"\r
-#include "r_cg_scifa.h"\r
-#include "r_cg_rspi.h"\r
-#include "r_cg_s12ad.h"\r
-/* Start user code for include. Do not edit comment generated here */\r
-#include "r_cg_mpc.h"\r
-#include "r_system.h"\r
-#include "r_reset.h"\r
-#include "lcd_pmod.h"\r
-#include "logo_data.h"\r
-#include "stdio.h"\r
-#include "siochar.h"\r
-/* End user code. Do not edit comment generated here */\r
-#include "r_cg_userdefine.h"\r
-\r
-/* Start user code for global. Do not edit comment generated here */\r
-\r
-#define LZ_ENABLE   (1)\r
-#define LZ_DISABLE  (0)\r
-\r
-/* Welcome banner - displayed on serial port at startup*/\r
-static uint8_t welcome_banner[] = "\n\n\rRSK+RZT1 \n\n\r- Tutorial - Press 'c' or SW3 for ADC Conversion\r\n\0";\r
-\r
-/* Used as a Data Transmit counter    */\r
-static uint8_t uart_buffer[] = " ADC count: x.     Value: xxxxx\r\n";\r
-\r
-/* Used as a Data Transmit counter    */\r
-static uint8_t lcd_buffer[] = " ADC = xxxx ";\r
-\r
-/* Function prototype for displaying the 2 bit binary counter using LEDs */\r
-static void led_display_count (const uint8_t count);\r
-\r
-extern void R_Systeminit(void);\r
-void R_MAIN_UserInit(void);\r
-\r
-/* Prototypes for the standard FreeRTOS callback/hook functions implemented\r
-within this file. */\r
-void vApplicationMallocFailedHook( void );\r
-void vApplicationIdleHook( void );\r
-void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName );\r
-void vApplicationTickHook( void );\r
-\r
-\r
-/* Prototype for the IRQ handler called by the generic Cortex-A5 RTOS port\r
-layer. */\r
-void vApplicationIRQHandler( void );\r
-\r
-void main(void)\r
-{\r
-uint32_t adc_count = 0;\r
-\r
-    R_Systeminit();\r
-\r
-    R_MAIN_UserInit();\r
-\r
-    /* SW3 interrupts */\r
-    R_ICU_IRQ12_Start();\r
-\r
-    /* Clear flags */\r
-    g_switch_press_flg = 0;\r
-    g_terminal_request = 0;\r
-\r
-    /* Display the welcome banner on the serial terminal */\r
-    R_SCIFA2_Serial_Send((uint8_t *)&welcome_banner, sizeof(welcome_banner));\r
-        \r
-    /* Data transmission and reception done in the infinite loop */\r
-    while (1U)\r
-    {         \r
-        /* Check for a valid request from the switch or serial terminal */\r
-        if ((g_terminal_request) || (g_switch_press_flg & SW3_PRESS_FLG))\r
-        {          \r
-            /* Update the binary count using LED2 and LED3 */\r
-            led_display_count(adc_count);\r
-\r
-            while(0u == SCIFA2.FSR.BIT.TDFE)\r
-            {\r
-                /* Wait for previous transmission to complete */\r
-            }\r
-\r
-            /* Write send data */\r
-            R_SCIFA2_Serial_Send((uint8_t *)&uart_buffer, sizeof(uart_buffer));\r
-\r
-            /* Clear TDFE */\r
-            SCIFA2.FSR.BIT.TDFE = 0U;\r
-            \r
-            if (g_terminal_request)\r
-            {\r
-                /* Clear the request */\r
-                g_terminal_request = 0U;\r
-            }\r
-                        \r
-            if (g_switch_press_flg & SW3_PRESS_FLG)\r
-            {\r
-                /* Clear the request */\r
-                g_switch_press_flg &= ((uint8_t)~SW3_PRESS_FLG);\r
-            }\r
-\r
-            adc_count++;\r
-        }\r
-    }\r
-}\r
-/***********************************************************************************************************************\r
-* Function Name: R_MAIN_UserInit\r
-* Description  : This function adds user code before implementing main function.\r
-* Arguments    : None\r
-* Return Value : None\r
-***********************************************************************************************************************/\r
-void R_MAIN_UserInit(void)\r
-{\r
-    /* Enable RSPI1 operations */\r
-    R_RSPI1_Start();\r
-       \r
-    /* Configure UART channel for communication with host PC via RL78/G1C device */\r
-    io_init_scifa2();\r
-    \r
-    /* Enable SCIFA2 operations */\r
-    R_SCIFA2_Start();\r
-}\r
-\r
-static void led_display_count (const uint8_t count)\r
-{\r
-    /* Set LEDs according to lower nibble of count parameter */\r
-    LED2 = (uint8_t) ((count & 0x01) ? LED_ON : LED_OFF);\r
-    LED3 = (uint8_t) ((count & 0x02) ? LED_ON : LED_OFF);\r
-}\r
-\r
-/*-----------------------------------------------------------*/\r
-\r
-void vApplicationMallocFailedHook( void )\r
-{\r
-       /* Called if a call to pvPortMalloc() fails because there is insufficient\r
-       free memory available in the FreeRTOS heap.  pvPortMalloc() is called\r
-       internally by FreeRTOS API functions that create tasks, queues, software\r
-       timers, and semaphores.  The size of the FreeRTOS heap is set by the\r
-       configTOTAL_HEAP_SIZE configuration constant in FreeRTOSConfig.h. */\r
-\r
-       /* Force an assert. */\r
-       configASSERT( ( volatile void * ) NULL );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )\r
-{\r
-       ( void ) pcTaskName;\r
-       ( void ) pxTask;\r
-\r
-       /* Run time stack overflow checking is performed if\r
-       configCHECK_FOR_STACK_OVERFLOW is defined to 1 or 2.  This hook\r
-       function is called if a stack overflow is detected. */\r
-\r
-       /* Force an assert. */\r
-       configASSERT( ( volatile void * ) NULL );\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vApplicationIdleHook( void )\r
-{\r
-volatile size_t xFreeHeapSpace;\r
-\r
-       /* This is just a trivial example of an idle hook.  It is called on each\r
-       cycle of the idle task.  It must *NOT* attempt to block.  In this case the\r
-       idle task just queries the amount of FreeRTOS heap that remains.  See the\r
-       memory management section on the http://www.FreeRTOS.org web site for memory\r
-       management options.  If there is a lot of heap memory free then the\r
-       configTOTAL_HEAP_SIZE value in FreeRTOSConfig.h can be reduced to free up\r
-       RAM. */\r
-       xFreeHeapSpace = xPortGetFreeHeapSize();\r
-\r
-       /* Remove compiler warning about xFreeHeapSpace being set but never used. */\r
-       ( void ) xFreeHeapSpace;\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vApplicationTickHook( void )\r
-{\r
-}\r
-/*-----------------------------------------------------------*/\r
-\r
-void vApplicationIRQHandler( void )\r
-{\r
-}\r
-\r
-\r
-#endif\r
-\r