From f1559214618e6dd1d7a308b3bfe75513ce8d9f30 Mon Sep 17 00:00:00 2001
From: Richard Barry <ribarry@amazon.com>
Date: Thu, 28 Apr 2011 15:13:30 +0000
Subject: [PATCH] Tidy up the IAR SmartFusion demo reading for release.

---
 .../FreeRTOSConfig.h                          |   8 -
 .../RTOSDemo_IAR.ewd                          |   2 +-
 .../RTOSDemo_IAR.ewp                          | 268 +++++++++++++++++-
 .../WebServer/httpd-cgi.c                     |   6 +-
 Demo/CORTEX_A2F200_IAR_and_Keil/main-blinky.c |  19 ++
 Demo/CORTEX_A2F200_IAR_and_Keil/main-full.c   |   5 +
 Demo/CORTEX_A2F200_IAR_and_Keil/uIP_Task.c    |  12 +-
 7 files changed, 300 insertions(+), 20 deletions(-)

diff --git a/Demo/CORTEX_A2F200_IAR_and_Keil/FreeRTOSConfig.h b/Demo/CORTEX_A2F200_IAR_and_Keil/FreeRTOSConfig.h
index 1afb6e2483..17a636d40b 100644
--- a/Demo/CORTEX_A2F200_IAR_and_Keil/FreeRTOSConfig.h
+++ b/Demo/CORTEX_A2F200_IAR_and_Keil/FreeRTOSConfig.h
@@ -58,14 +58,6 @@
 */
 
 
-/* The following #error directive is to remind users that a batch file must be
- * executed prior to this project being built.  The batch file *cannot* be
- * executed from within CCS4!  Once it has been executed, re-open or refresh
- * the CCS4 project and remove the #error line below.
- */
-//#error Ensure CreateProjectDirectoryStructure.bat has been executed before building.  See comment immediately above.
-
-
 #ifndef FREERTOS_CONFIG_H
 #define FREERTOS_CONFIG_H
 
diff --git a/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewd b/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewd
index e08d211763..ab5cf1b24d 100644
--- a/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewd
+++ b/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewd
@@ -1671,7 +1671,7 @@
     </debuggerPlugins>
   </configuration>
   <configuration>
-    <name>Full-with-optimisation</name>
+    <name>Full_with_optimisation</name>
     <toolchain>
       <name>ARM</name>
     </toolchain>
diff --git a/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewp b/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewp
index d5dbf4de7b..72f633045c 100644
--- a/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewp
+++ b/Demo/CORTEX_A2F200_IAR_and_Keil/RTOSDemo_IAR.ewp
@@ -1142,6 +1142,8 @@
           <state>$PROJ_DIR$/MicroSemi_Code/CMSIS</state>
           <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_gpio</state>
           <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_watchdog</state>
+          <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_ace</state>
+          <state>$PROJ_DIR$/MicroSemi_Code/drivers_config/mss_ace</state>
           <state>$PROJ_DIR$/WebServer</state>
           <state>$PROJ_DIR$/../Common/ethernet/FreeTCPIP/apps/httpd</state>
           <state>$PROJ_DIR$/../Common/ethernet/FreeTCPIP</state>
@@ -1733,7 +1735,7 @@
     </settings>
   </configuration>
   <configuration>
-    <name>Full-with-optimisation</name>
+    <name>Full_with_optimisation</name>
     <toolchain>
       <name>ARM</name>
     </toolchain>
@@ -1747,15 +1749,15 @@
         <debug>1</debug>
         <option>
           <name>ExePath</name>
-          <state>Full-with-optimisation\Exe</state>
+          <state>Full_with_optimisation\Exe</state>
         </option>
         <option>
           <name>ObjPath</name>
-          <state>Full-with-optimisation\Obj</state>
+          <state>Full_with_optimisation\Obj</state>
         </option>
         <option>
           <name>ListPath</name>
-          <state>Full-with-optimisation\List</state>
+          <state>Full_with_optimisation\List</state>
         </option>
         <option>
           <name>Variant</name>
@@ -2011,6 +2013,8 @@
           <state>$PROJ_DIR$/MicroSemi_Code/CMSIS</state>
           <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_gpio</state>
           <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_watchdog</state>
+          <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_ace</state>
+          <state>$PROJ_DIR$/MicroSemi_Code/drivers_config/mss_ace</state>
           <state>$PROJ_DIR$/WebServer</state>
           <state>$PROJ_DIR$/../Common/ethernet/FreeTCPIP/apps/httpd</state>
           <state>$PROJ_DIR$/../Common/ethernet/FreeTCPIP</state>
@@ -2695,6 +2699,18 @@
     </group>
     <group>
       <name>Drivers</name>
+      <file>
+        <name>$PROJ_DIR$\MicroSemi_Code\drivers_config\mss_ace\ace_config.c</name>
+        <excluded>
+          <configuration>Blinky</configuration>
+        </excluded>
+      </file>
+      <file>
+        <name>$PROJ_DIR$\MicroSemi_Code\drivers\mss_ace\ace_convert.c</name>
+        <excluded>
+          <configuration>Blinky</configuration>
+        </excluded>
+      </file>
       <file>
         <name>$PROJ_DIR$\MicroSemi_Code\drivers\mss_ethernet_mac\crc32.c</name>
         <excluded>
@@ -2707,6 +2723,248 @@
           <configuration>Blinky</configuration>
         </excluded>
       </file>
+      <file>
+        <name>$PROJ_DIR$\MicroSemi_Code\drivers\mss_ace\mss_ace.c</name>
+        <excluded>
+          <configuration>Blinky</configuration>
+        </excluded>
+        <configuration>
+          <name>Blinky</name>
+          <settings>
+            <name>ICCARM</name>
+            <data>
+              <version>26</version>
+              <wantNonLocal>0</wantNonLocal>
+              <debug>1</debug>
+              <option>
+                <name>CCDefines</name>
+                <state></state>
+              </option>
+              <option>
+                <name>CCPreprocFile</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCPreprocComments</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCPreprocLine</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCListCFile</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCListCMnemonics</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCListCMessages</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCListAssFile</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCListAssSource</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCEnableRemarks</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCDiagSuppress</name>
+                <state>Pa082</state>
+              </option>
+              <option>
+                <name>CCDiagRemark</name>
+                <state></state>
+              </option>
+              <option>
+                <name>CCDiagWarning</name>
+                <state></state>
+              </option>
+              <option>
+                <name>CCDiagError</name>
+                <state></state>
+              </option>
+              <option>
+                <name>CCObjPrefix</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>CCAllowList</name>
+                <version>1</version>
+                <state>0000000</state>
+              </option>
+              <option>
+                <name>CCDebugInfo</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IEndianMode</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IProcessor</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IExtraOptionsCheck</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>IExtraOptions</name>
+                <state></state>
+              </option>
+              <option>
+                <name>CCLangConformance</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCSignedPlainChar</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>CCRequirePrototypes</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCMultibyteSupport</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCDiagWarnAreErr</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCCompilerRuntimeInfo</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>IFpuProcessor</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>OutputFile</name>
+                <state>$FILE_BNAME$.o</state>
+              </option>
+              <option>
+                <name>CCLibConfigHeader</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>PreInclude</name>
+                <state></state>
+              </option>
+              <option>
+                <name>CompilerMisraOverride</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCIncludePath2</name>
+                <state>$PROJ_DIR$/../../Source/include</state>
+                <state>$PROJ_DIR$/../../Source/portable/IAR/ARM_CM3</state>
+                <state>$PROJ_DIR$</state>
+                <state>$PROJ_DIR$/MicroSemi_Code/CMSIS</state>
+                <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_gpio</state>
+                <state>$PROJ_DIR$/MicroSemi_Code/drivers/mss_watchdog</state>
+              </option>
+              <option>
+                <name>CCStdIncCheck</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCCodeSection</name>
+                <state>.text</state>
+              </option>
+              <option>
+                <name>IInterwork2</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>IProcessorMode2</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>CCOptLevel</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCOptStrategy</name>
+                <version>0</version>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCOptLevelSlave</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CompilerMisraRules98</name>
+                <version>0</version>
+                <state>1000111110110101101110011100111111101110011011000101110111101101100111111111111100110011111001110111001111111111111111111111111</state>
+              </option>
+              <option>
+                <name>CompilerMisraRules04</name>
+                <version>0</version>
+                <state>111101110010111111111000110111111111111111111111111110010111101111010101111111111111111111111111101111111011111001111011111011111111111111111</state>
+              </option>
+              <option>
+                <name>CCPosIndRopi</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCPosIndRwpi</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>CCPosIndNoDynInit</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>IccLang</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>IccCDialect</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IccAllowVLA</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>IccCppDialect</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IccExceptions</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IccRTTI</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IccStaticDestr</name>
+                <state>1</state>
+              </option>
+              <option>
+                <name>IccRelaxedFpPrecision</name>
+                <state>0</state>
+              </option>
+              <option>
+                <name>IccCppInlineSemantics</name>
+                <state>0</state>
+              </option>
+            </data>
+          </settings>
+        </configuration>
+      </file>
       <file>
         <name>$PROJ_DIR$\MicroSemi_Code\drivers\mss_ethernet_mac\mss_ethernet_mac.c</name>
         <excluded>
@@ -2758,7 +3016,7 @@
     <name>$PROJ_DIR$\main-blinky.c</name>
     <excluded>
       <configuration>Full</configuration>
-      <configuration>Full-with-optimisation</configuration>
+      <configuration>Full_with_optimisation</configuration>
     </excluded>
   </file>
   <file>
diff --git a/Demo/CORTEX_A2F200_IAR_and_Keil/WebServer/httpd-cgi.c b/Demo/CORTEX_A2F200_IAR_and_Keil/WebServer/httpd-cgi.c
index 38ea41fa24..ab3facf0aa 100644
--- a/Demo/CORTEX_A2F200_IAR_and_Keil/WebServer/httpd-cgi.c
+++ b/Demo/CORTEX_A2F200_IAR_and_Keil/WebServer/httpd-cgi.c
@@ -49,6 +49,7 @@
 #include "apps/httpd/httpd.h"
 #include "apps/httpd/httpd-cgi.h"
 #include "apps/httpd/httpd-fs.h"
+#include "mss_ace.h"
 
 #include <stdio.h>
 #include <string.h>
@@ -210,6 +211,8 @@ static unsigned short generate_io_state( void *arg )
 {
 	extern long lParTestGetLEDState( unsigned long ulLED );
 	( void ) arg;
+	unsigned short usRawVoltage;
+	const ace_channel_handle_t xVoltageChannel = ( ace_channel_handle_t ) 0;
 
 	/* Are the dynamically setable LEDs currently on or off? */
 	if( lParTestGetLEDState( 3 ) )
@@ -221,7 +224,8 @@ static unsigned short generate_io_state( void *arg )
 		pcStatus = "";
 	}
 
-	sprintf( uip_appdata, "<input type=\"checkbox\" name=\"LED0\" value=\"1\" %s>LED<p><p>", pcStatus );
+	usRawVoltage = ( unsigned short ) ACE_get_ppe_sample( xVoltageChannel );	
+	sprintf( uip_appdata, "<input type=\"checkbox\" name=\"LED0\" value=\"1\" %s>LED<p><p><p>Raw voltage input is %d", pcStatus, usRawVoltage );
 
 	return strlen( uip_appdata );
 }
diff --git a/Demo/CORTEX_A2F200_IAR_and_Keil/main-blinky.c b/Demo/CORTEX_A2F200_IAR_and_Keil/main-blinky.c
index af060a25c6..cd04278b2d 100644
--- a/Demo/CORTEX_A2F200_IAR_and_Keil/main-blinky.c
+++ b/Demo/CORTEX_A2F200_IAR_and_Keil/main-blinky.c
@@ -308,6 +308,8 @@ unsigned long ulReceivedValue;
 
 static void prvSetupHardware( void )
 {
+	SystemCoreClockUpdate();
+
 	/* Disable the Watch Dog Timer */
 	MSS_WD_disable( );
 
@@ -376,4 +378,21 @@ volatile size_t xFreeStackSpace;
 		reduced accordingly. */
 	}
 }
+/*-----------------------------------------------------------*/
+
+void vMainConfigureTimerForRunTimeStats( void )
+{
+	/* This function is not used by the Blinky build configuration, but needs
+	to be defined as the Blinky and Full build configurations share a
+	FreeRTOSConfig.h header file. */
+}
+/*-----------------------------------------------------------*/
+
+unsigned long ulGetRunTimeCounterValue( void )
+{
+	/* This function is not used by the Blinky build configuration, but needs
+	to be defined as the Blinky and Full build configurations share a
+	FreeRTOSConfig.h header file. */
+	return 0UL;
+}
 
diff --git a/Demo/CORTEX_A2F200_IAR_and_Keil/main-full.c b/Demo/CORTEX_A2F200_IAR_and_Keil/main-full.c
index cb7eb25aee..d412c41dab 100644
--- a/Demo/CORTEX_A2F200_IAR_and_Keil/main-full.c
+++ b/Demo/CORTEX_A2F200_IAR_and_Keil/main-full.c
@@ -148,6 +148,7 @@
 #include "mss_gpio.h"
 #include "mss_watchdog.h"
 #include "mss_timer.h"
+#include "mss_ace.h"
 #include "oled.h"
 
 /* Common demo includes. */
@@ -551,6 +552,9 @@ static void prvSetupHardware( void )
 
 	/* Configure the GPIO for the LEDs. */
 	vParTestInitialise();
+	
+	/* ACE Initialization */
+	ACE_init();
 
 	/* Setup the GPIO and the NVIC for the switch used in this simple demo. */
 	NVIC_SetPriority( GPIO8_IRQn, configLIBRARY_MAX_SYSCALL_INTERRUPT_PRIORITY );
@@ -628,6 +632,7 @@ const unsigned long ulMax32BitValue = 0xffffffffUL;
 	MSS_TIM64_start();
 }
 /*-----------------------------------------------------------*/
+
 unsigned long ulGetRunTimeCounterValue( void )
 {
 unsigned long long ullCurrentValue;
diff --git a/Demo/CORTEX_A2F200_IAR_and_Keil/uIP_Task.c b/Demo/CORTEX_A2F200_IAR_and_Keil/uIP_Task.c
index 3a6ea91e68..b3e150b7fe 100644
--- a/Demo/CORTEX_A2F200_IAR_and_Keil/uIP_Task.c
+++ b/Demo/CORTEX_A2F200_IAR_and_Keil/uIP_Task.c
@@ -159,8 +159,8 @@ clock_time_t clock_time( void )
 void vuIP_Task( void *pvParameters )
 {
 portBASE_TYPE i;
-unsigned long ulNewEvent = 0UL;
-unsigned long ulUIP_Events = 0UL;
+unsigned long ulNewEvent = 0UL, ulUIP_Events = 0UL;
+long lPacketLength;
 
 	/* Just to prevent compiler warnings about the unused parameter. */
 	( void ) pvParameters;
@@ -174,11 +174,13 @@ unsigned long ulUIP_Events = 0UL;
 	for( ;; )
 	{
 		/* Is there received data ready to be processed? */
-		uip_len = MSS_MAC_rx_packet();
+		lPacketLength = MSS_MAC_rx_packet();
 
 		/* Statements to be executed if data has been received on the Ethernet. */
-		if( ( uip_len > 0 ) && ( uip_buf != NULL ) )
+		if( ( lPacketLength > 0 ) && ( uip_buf != NULL ) )
 		{
+			uip_len = ( u16_t ) lPacketLength;
+			
 			/* Standard uIP loop taken from the uIP manual. */
 			if( xHeader->type == htons( UIP_ETHTYPE_IP ) )
 			{
@@ -356,7 +358,7 @@ void vEMACWrite( void )
 {
 const long lMaxAttempts = 10;
 long lAttempt;
-const portTickType xShortDelay = ( 10 / portTICK_RATE_MS );
+const portTickType xShortDelay = ( 5 / portTICK_RATE_MS );
 
 	/* Try to send data to the Ethernet.  Keep trying for a while if data cannot
 	be sent immediately.  Note that this will actually cause the data to be sent