diff --git a/Demo/MB91460_Softune/91467d_FreeRTOS.prj b/Demo/MB91460_Softune/91467d_FreeRTOS.prj index 2f8885e16..e05a92c98 100644 --- a/Demo/MB91460_Softune/91467d_FreeRTOS.prj +++ b/Demo/MB91460_Softune/91467d_FreeRTOS.prj @@ -362,17 +362,19 @@ F27-7=- ..\..\Source\include\task.h F27-8=- ..\..\Source\include\list.h F27-9=- SRC\watchdog\watchdog.h F27-10=- ..\..\..\..\..\..\devtools\Softune6\LIB\911\INCLUDE\stddef.h -F28=10 c 1 SRC\utility\taskutility.c +F28=12 c 1 SRC\utility\taskutility.c F28-1=- SRC\mb91467d.h F28-2=- SRC\vectors.h F28-3=- ..\..\Source\include\FreeRTOS.h -F28-4=- ..\..\Source\include\projdefs.h -F28-5=- SRC\FreeRTOSConfig.h -F28-6=- ..\..\Source\include\portable.h -F28-7=- ..\..\Source\portable\Softune\MB91460\portmacro.h -F28-8=- ..\..\Source\include\task.h -F28-9=- ..\..\Source\include\list.h -F28-10=- ..\..\..\..\..\..\devtools\Softune6\LIB\911\INCLUDE\stddef.h +F28-4=- ..\..\..\..\..\..\devtools\Softune6\LIB\911\INCLUDE\stddef.h +F28-5=- ..\..\Source\include\projdefs.h +F28-6=- SRC\FreeRTOSConfig.h +F28-7=- ..\..\Source\include\portable.h +F28-8=- ..\..\Source\portable\Softune\MB91460\portmacro.h +F28-9=- ..\..\Source\include\task.h +F28-10=- ..\..\Source\include\list.h +F28-11=- ..\..\Source\include\semphr.h +F28-12=- ..\..\Source\include\queue.h F29=25 c 1 SRC\main.c F29-1=- SRC\mb91467d.h F29-2=- SRC\vectors.h diff --git a/Demo/MB91460_Softune/91467d_FreeRTOS.wsp b/Demo/MB91460_Softune/91467d_FreeRTOS.wsp index a9e6f6772..512ab5b47 100644 --- a/Demo/MB91460_Softune/91467d_FreeRTOS.wsp +++ b/Demo/MB91460_Softune/91467d_FreeRTOS.wsp @@ -18,6 +18,8 @@ AutoLoad=1 WSP=C:\E\Dev\FreeRTOS\WorkingCopy2\Demo\MB91460_Softune\ [EditState] -STATE-1=SRC\main.c:1 -Count=1 +STATE-1=SRC\main.c:18 +STATE-2=..\..\Source\queue.c:988 +STATE-3=..\..\Source\tasks.c:1342 +Count=3 diff --git a/Demo/MB91460_Softune/SRC/FreeRTOSConfig.h b/Demo/MB91460_Softune/SRC/FreeRTOSConfig.h index f5dfe2f5f..af11cda28 100644 --- a/Demo/MB91460_Softune/SRC/FreeRTOSConfig.h +++ b/Demo/MB91460_Softune/SRC/FreeRTOSConfig.h @@ -53,7 +53,7 @@ #define configCPU_CLOCK_HZ ( ( unsigned portLONG ) 64000000 ) /* Clock setup from start91460.asm in the demo application. */ #define configPER_CLOCK_HZ ( ( unsigned portLONG ) 16000000 ) /* Clock setup from start91460.asm in the demo application. */ #define configMAX_PRIORITIES ( ( unsigned portBASE_TYPE ) 6 ) -#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 70 ) +#define configMINIMAL_STACK_SIZE ( ( unsigned portSHORT ) 100 ) #define configTOTAL_HEAP_SIZE ( ( size_t ) ( 32768 - 4192 ) ) #define configMAX_TASK_NAME_LEN ( 20 ) #define configUSE_TRACE_FACILITY 1 diff --git a/Demo/MB91460_Softune/SRC/serial/serial.c b/Demo/MB91460_Softune/SRC/serial/serial.c index 4aaf19159..090d79935 100644 --- a/Demo/MB91460_Softune/SRC/serial/serial.c +++ b/Demo/MB91460_Softune/SRC/serial/serial.c @@ -174,7 +174,7 @@ signed portBASE_TYPE xReturn; /*If the post causes a task to wake force a context switch as the woken task may have a higher priority than the task we have interrupted. */ - portYIELDFromISR(); + portYIELD_FROM_ISR(); } } diff --git a/Demo/MB91460_Softune/SRC/utility/taskutility.c b/Demo/MB91460_Softune/SRC/utility/taskutility.c index e381aee67..b23f633f2 100644 --- a/Demo/MB91460_Softune/SRC/utility/taskutility.c +++ b/Demo/MB91460_Softune/SRC/utility/taskutility.c @@ -1,189 +1,215 @@ /* THIS SAMPLE CODE IS PROVIDED AS IS AND IS SUBJECT TO ALTERATIONS. FUJITSU */ /* MICROELECTRONICS ACCEPTS NO RESPONSIBILITY OR LIABILITY FOR ANY ERRORS OR */ /* ELIGIBILITY FOR ANY PURPOSES. */ -/* (C) Fujitsu Microelectronics Europe GmbH */ +/* (C) Fujitsu Microelectronics Europe GmbH */ /*------------------------------------------------------------------------ taskutility.C - -------------------------------------------------------------------------*/ - - -/*************************@INCLUDE_START************************/ #include "mb91467d.h" #include "vectors.h" #include "FreeRTOS.h" #include "task.h" - +#include "semphr.h" static void vUART5Task( void *pvParameters ); -/**************************@INCLUDE_END*************************/ -/*********************@GLOBAL_VARIABLES_START*******************/ -const char ASCII[] = "0123456789ABCDEF"; +const char ASCII[] = "0123456789ABCDEF"; -xTaskHandle UART_TaskHandle; +void vInitUart5( void ); -void InitUart5(void) +xSemaphoreHandle xSemaphore; + +void vInitUart5( void ) { //Initialize UART asynchronous mode - BGR05 = 1666; // 9600 Baud @ 16MHz - + BGR05 = 1666; // 9600 Baud @ 16MHz SCR05 = 0x17; // 7N2 SMR05 = 0x0d; // enable SOT3, Reset, normal mode SSR05 = 0x00; // LSB first - PFR19_D4 = 1; // enable UART PFR19_D5 = 1; // enable UART //EPFR19 = 0x00; // enable UART - SSR05_RIE = 1; } -void Putch5(char ch) /* sends a char */ +void Putch5( char ch ) /* sends a char */ { - while (SSR05_TDRE == 0); /* wait for transmit buffer empty */ - TDR05 = ch; /* put ch into buffer */ + while( SSR05_TDRE == 0 ); + + /* wait for transmit buffer empty */ + TDR05 = ch; /* put ch into buffer */ } -char Getch5(void) /* waits for and returns incomming char */ +char Getch5( void ) /* waits for and returns incomming char */ { - volatile unsigned ch; - - while(SSR05_RDRF == 0); /* wait for data received */ - if (SSR05_ORE) /* overrun error */ - { - ch = RDR05; /* reset error flags */ - return (char)(-1); - } - else - return (RDR05); /* return char */ -} + volatile unsigned ch; -void Puts5(const char *Name5) /* Puts a String to UART */ -{ - volatile portSHORT i,len; - len = strlen(Name5); - - for (i=0; i> div)&0xF); /* get hex-digit value */ - Putch5(digit + ((digit < 0xA) ? '0' : 'A' - 0xA)); - div-=4; /* next digit shift */ - } -} - -void Putdec5(unsigned long x, int digits) -{ - portSHORT i; - portCHAR buf[10],sign=1; - - if (digits < 0) { /* should be print of zero? */ - digits *= (-1); - sign =1; - } - buf[digits]='\0'; /* end sign of string */ - - for (i=digits; i>0; i--) { - buf[i-1] = ASCII[x % 10]; - x = x/10; - } - - if ( sign ) + /* wait for data received */ + if( SSR05_ORE ) /* overrun error */ { - for (i=0; buf[i]=='0'; i++) { /* no print of zero */ - if ( i> div) & 0xF ); /* get hex-digit value */ + Putch5( digit + ((digit < 0xA) ? '0' : 'A' - 0xA) ); + div -= 4; /* next digit shift */ + } +} + +void Putdec5( unsigned long x, int digits ) +{ + portSHORT i; + portCHAR buf[10], sign = 1; + + if( digits < 0 ) + { /* should be print of zero? */ + digits *= ( -1 ); + sign = 1; + } + + buf[digits] = '\0'; /* end sign of string */ + + for( i = digits; i > 0; i-- ) + { + buf[i - 1] = ASCII[x % 10]; + x = x / 10; + } + + if( sign ) + { + for( i = 0; buf[i] == '0'; i++ ) + { /* no print of zero */ + if( i < digits - 1 ) + { + buf[i] = ' '; + } + } + } + + Puts5( buf ); /* send string */ } void vUtilityStartTraceTask( unsigned portBASE_TYPE uxPriority ) { portENTER_CRITICAL(); - InitUart5(); + vInitUart5(); portENTER_CRITICAL(); - xTaskCreate( vUART5Task , ( signed portCHAR * ) "UART4", ( unsigned portSHORT ) 2048, ( void * ) NULL, uxPriority, &UART_TaskHandle ); + + vSemaphoreCreateBinary( xSemaphore ); + + if( xSemaphore != NULL ) + { + xTaskCreate( vUART5Task, (signed portCHAR *) "UART4", ( unsigned portSHORT ) 2048, ( void * ) NULL, uxPriority, NULL ); + } } static void vUART5Task( void *pvParameters ) { - portCHAR tasklist_buff[512], trace_buff[512]; - unsigned portLONG trace_len, j; - - unsigned portCHAR ch; - - Puts5("\n -------------MB91467D FreeRTOS DEMO Task List and Trace Utility----------- \n"); + portCHAR tasklist_buff[512], trace_buff[512]; + unsigned portLONG trace_len, j; - for(;;) + unsigned portCHAR ch; + + Puts5( "\n -------------MB91467D FreeRTOS DEMO Task List and Trace Utility----------- \n" ); + + for( ;; ) { - Puts5("\n\rPress any of the following keys for the corresponding functionality: "); + Puts5( "\n\rPress any of the following keys for the corresponding functionality: " ); - Puts5("\n\r1: To call vTaskList() and display current task status "); + Puts5( "\n\r1: To call vTaskList() and display current task status " ); - Puts5("\n\r2: To call vTaskStartTrace() and to display trace results once the trace ends"); + Puts5( "\n\r2: To call vTaskStartTrace() and to display trace results once the trace ends" ); - SSR05_RIE=1; + SSR05_RIE = 1; - vTaskSuspend(NULL); + /* Block on the semaphore. The UART interrupt will use the semaphore to + wake this task when required. */ + xSemaphoreTake( xSemaphore, portMAX_DELAY ); - ch=Getch5(); + ch = Getch5(); - switch ( ch ) + switch( ch ) { case '1': - vTaskList( ( signed char * ) tasklist_buff ); - Puts5("\n\rThe current task list is as follows...."); - Puts5("\n\r----------------------------------------------"); - Puts5("\n\rName State Priority Stack Number"); - Puts5("\n\r----------------------------------------------"); - Puts5(tasklist_buff); - Puts5("\r----------------------------------------------"); + vTaskList( (signed char *) tasklist_buff ); + Puts5( "\n\rThe current task list is as follows...." ); + Puts5( "\n\r----------------------------------------------" ); + Puts5( "\n\rName State Priority Stack Number" ); + Puts5( "\n\r----------------------------------------------" ); + Puts5( tasklist_buff ); + Puts5( "\r----------------------------------------------" ); break; case '2': - vTaskStartTrace(( signed char * ) trace_buff, 512); - Puts5("\n\rThe trace started!!"); - vTaskDelay( ( portTickType ) 450); + vTaskStartTrace( (signed char *) trace_buff, 512 ); + Puts5( "\n\rThe trace started!!" ); + vTaskDelay( (portTickType) 450 ); trace_len = ulTaskEndTrace(); - Puts5("\n\rThe trace ended!!"); - Puts5("\n\rThe trace is as follows...."); - Puts5("\n\r--------------------------------------------------------"); - Puts5("\n\r Tick | Task Number | Tick | Task Number |"); - Puts5("\n\r--------------------------------------------------------\n\r"); - for( j = 0 ; j < trace_len ; j++ ) + Puts5( "\n\rThe trace ended!!" ); + Puts5( "\n\rThe trace is as follows...." ); + Puts5( "\n\r--------------------------------------------------------" ); + Puts5( "\n\r Tick | Task Number | Tick | Task Number |" ); + Puts5( "\n\r--------------------------------------------------------\n\r" ); + for( j = 0; j < trace_len; j++ ) { - Puthex5(trace_buff[j],2); - if(j%4==3) Puts5(" | "); - if(j%16==15) Puts5("\n"); + Puthex5( trace_buff[j], 2 ); + if( j % 4 == 3 ) + { + Puts5( " | " ); + } + + if( j % 16 == 15 ) + { + Puts5( "\n" ); + } } - Puts5("\r--------------------------------------------------------"); + + Puts5( "\r--------------------------------------------------------" ); break; - + default: break; } - Puts5("\n"); + + Puts5( "\n" ); } } -__interrupt void UART5_RxISR ( void ) +__interrupt void UART5_RxISR( void ) { - SSR05_RIE=0; - vTaskResume( UART_TaskHandle ); + SSR05_RIE = 0; + xSemaphoreGiveFromISR( xSemaphore, pdFALSE ); } diff --git a/Demo/MB91460_Softune/SRC/vectors.c b/Demo/MB91460_Softune/SRC/vectors.c index 21fa3682a..c99e1490b 100644 --- a/Demo/MB91460_Softune/SRC/vectors.c +++ b/Demo/MB91460_Softune/SRC/vectors.c @@ -49,7 +49,7 @@ void InitIrqLevels(void) /* External Interrupt 13 */ ICR07 = 31; /* External Interrupt 14 */ /* External Interrupt 15 */ - ICR08 = 23; /* Reload Timer 0 */ + ICR08 = 30; /* Reload Timer 0 */ /* Reload Timer 1 */ ICR09 = 31; /* Reload Timer 2 */ /* Reload Timer 3 */ @@ -75,17 +75,17 @@ void InitIrqLevels(void) /* USART (LIN) 0 TX */ ICR20 = 31; /* USART (LIN) 1 RX */ /* USART (LIN) 1 TX */ - ICR21 = 21; /* USART (LIN) 2 RX */ + ICR21 = 30; /* USART (LIN) 2 RX */ /* USART (LIN) 2 TX */ ICR22 = 31; /* USART (LIN) 3 RX */ /* USART (LIN) 3 TX */ - ICR23 = 23; /* System Reserved */ + ICR23 = 30; /* System Reserved */ /* Delayed Interrupt */ ICR24 = 31; /* System Reserved */ /* System Reserved */ ICR25 = 31; /* USART (LIN, FIFO) 4 RX */ /* USART (LIN, FIFO) 4 TX */ - ICR26 = 21; /* USART (LIN, FIFO) 5 RX */ + ICR26 = 30; /* USART (LIN, FIFO) 5 RX */ /* USART (LIN, FIFO) 5 TX */ ICR27 = 31; /* USART (LIN, FIFO) 6 RX */ /* USART (LIN, FIFO) 6 TX */ diff --git a/Demo/MB91460_Softune/STANDALONE/Mondeb_57K6_com1.sup b/Demo/MB91460_Softune/STANDALONE/Mondeb_57K6_com1.sup index 79c4e50c7..9af36c8af 100644 --- a/Demo/MB91460_Softune/STANDALONE/Mondeb_57K6_com1.sup +++ b/Demo/MB91460_Softune/STANDALONE/Mondeb_57K6_com1.sup @@ -30,7 +30,7 @@ AssemblyState=0 AssemblyFGColor=0 0 255 CommandSize=132 138 958 562 CommandState=0 -Assembly Address=H'00044F1C +Assembly Address=H'00042412 Memory Address=H'0002F038 Memory Mode=H'00000003 Memory Ascii=H'00000001 @@ -132,7 +132,7 @@ WatchState=0 Source2Name=SRC\main.c Source2Size=66 69 1074 448 Source2State=0 -Source2Line=7C +Source2Line=124 Source2Mode=2 Source3Name=SRC\watchdog\watchdog.c Source3Size=44 46 998 421 @@ -148,6 +148,12 @@ Source4Size=198 207 1086 679 Source4State=0 Source4Line=913 Source4Mode=2 +Layer11=2000,SRC\vectors.c +Source5Name=SRC\vectors.c +Source5Size=22 23 859 518 +Source5State=2 +Source5Line=49 +Source5Mode=2 [Path Environment] Flag=Enable Source=