diff --git a/DemoTasks/SimpleTCPEchoServer.c b/DemoTasks/SimpleTCPEchoServer.c
index 7094c83..7c5f427 100644
--- a/DemoTasks/SimpleTCPEchoServer.c
+++ b/DemoTasks/SimpleTCPEchoServer.c
@@ -136,7 +136,7 @@ static void prvServerConnectionInstance( void *pvParameters );
/* Stores the stack size passed into vStartSimpleTCPServerTasks() so it can be
reused when the server listening task creates tasks to handle connections. */
static uint16_t usUsedStackSize = 0;
-
+static TaskHandle_t prvServerConnectionInstance_Handle = NULL;
/*-----------------------------------------------------------*/
void vStartSimpleTCPServerTasks( uint16_t usStackSize, UBaseType_t uxPriority )
@@ -157,7 +157,7 @@ Socket_t xListeningSocket, xConnectedSocket;
socklen_t xSize = sizeof( xClient );
static const TickType_t xReceiveTimeOut = portMAX_DELAY;
const BaseType_t xBacklog = 20;
-TaskHandle_t prvServerConnectionInstance_Handle = NULL;
+
#if( ipconfigUSE_TCP_WIN == 1 )
WinProperties_t xWinProps;
@@ -197,15 +197,24 @@ TaskHandle_t prvServerConnectionInstance_Handle = NULL;
FreeRTOS_listen( xListeningSocket, xBacklog );
for( ;; )
- {
+ {
/* Wait for a client to connect. */
xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient, &xSize );
- configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
- /* Spawn a task to handle the connection. */
- if (prvServerConnectionInstance_Handle)
- vTaskDelete( prvServerConnectionInstance_Handle );
- xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY + 1, &prvServerConnectionInstance_Handle );
+ configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
+ FreeRTOS_debug_printf(("Heap size TCP 0 = %d\n", xPortGetFreeHeapSize()));
+ /* Delete previous suspended EchoServer task if it was created. */
+ if (prvServerConnectionInstance_Handle && eSuspended == eTaskGetState( prvServerConnectionInstance_Handle) )
+ {
+ /* Pause for a short while to ensure the network is not too
+ * congested. */
+ vTaskDelay( 150 );
+ vTaskDelete( prvServerConnectionInstance_Handle );
+ }
+ FreeRTOS_debug_printf(("Heap size TCP 1 = %d\n", xPortGetFreeHeapSize()));
+
+ /* Spawn a task to handle the connection. */
+ xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY + 1, &prvServerConnectionInstance_Handle );
}
}
/*-----------------------------------------------------------*/
@@ -220,11 +229,7 @@ TickType_t xTimeOnShutdown;
uint8_t *pucRxBuffer;
xConnectedSocket = ( Socket_t ) pvParameters;
- HeapStats_t pxHeapStats;
- vPortGetHeapStats( &pxHeapStats );
- FreeRTOS_debug_printf(("xAvailableHeapSpaceInBytes1 = %d\n", pxHeapStats.xAvailableHeapSpaceInBytes));
- FreeRTOS_debug_printf(("xNumberOfSuccessfulAllocations1 = %d\n", pxHeapStats.xNumberOfSuccessfulAllocations));
- FreeRTOS_debug_printf(("xNumberOfSuccessfulFrees1 = %d\n", pxHeapStats.xNumberOfSuccessfulFrees));
+
/* Attempt to create the buffer used to receive the string to be echoed
back. This could be avoided using a zero copy interface that just returned
the same buffer. */
@@ -287,15 +292,10 @@ uint8_t *pucRxBuffer;
/* Finished with the socket, buffer, the task. */
vPortFree( pucRxBuffer );
- FreeRTOS_closesocket( xConnectedSocket );
-#ifdef DEBUG_TASK_DELETE
- vPortGetHeapStats( &pxHeapStats );
- FreeRTOS_debug_printf(("xAvailableHeapSpaceInBytes2 = %d\n", pxHeapStats.xAvailableHeapSpaceInBytes));
- FreeRTOS_debug_printf(("xNumberOfSuccessfulAllocations2 = %d\n", pxHeapStats.xNumberOfSuccessfulAllocations));
- FreeRTOS_debug_printf(("xNumberOfSuccessfulFrees2 = %d\n", pxHeapStats.xNumberOfSuccessfulFrees));
- //FreeRTOS_debug_printf(("Heap size after TCP = %d\n", xPortGetFreeHeapSize()));
- vTaskDelete( NULL );
-#endif
+ BaseType_t xReturned = FreeRTOS_closesocket( xConnectedSocket );
+ configASSERT( xReturned > FREERTOS_SOCKET_ERROR );
+
+ vTaskSuspend(NULL);
}
/*-----------------------------------------------------------*/
diff --git a/DemoTasks/SimpleUDPClientAndServer.c b/DemoTasks/SimpleUDPClientAndServer.c
index 392444e..dcd87e4 100644
--- a/DemoTasks/SimpleUDPClientAndServer.c
+++ b/DemoTasks/SimpleUDPClientAndServer.c
@@ -79,11 +79,11 @@ void vStartSimpleUDPClientServerTasks( uint16_t usStackSize, uint32_t ulPort, UB
/* Create the client and server tasks that do not use the zero copy
interface. */
xTaskCreate( prvSimpleClientTask, "SimpCpyClnt", usStackSize, ( void * ) ulPort, uxPriority, NULL );
- xTaskCreate( prvSimpleServerTask, "SimpCpySrv", usStackSize, ( void * ) ulPort, uxPriority + 1, NULL );
+ xTaskCreate( prvSimpleServerTask, "SimpCpySrv", usStackSize, ( void * ) ( ulPort + 1 ), uxPriority, NULL );
/* Create the client and server tasks that do use the zero copy interface. */
- xTaskCreate( prvSimpleZeroCopyUDPClientTask, "SimpZCpyClnt", usStackSize, ( void * ) ( ulPort + 1 ), uxPriority, NULL );
- xTaskCreate( prvSimpleZeroCopyServerTask, "SimpZCpySrv", usStackSize, ( void * ) ( ulPort + 1 ), uxPriority + 1, NULL );
+ xTaskCreate( prvSimpleZeroCopyUDPClientTask, "SimpZCpyClnt", usStackSize, ( void * ) ( ulPort + 2 ), uxPriority, NULL );
+ xTaskCreate( prvSimpleZeroCopyServerTask, "SimpZCpySrv", usStackSize, ( void * ) ( ulPort + 3 ), uxPriority, NULL );
}
/*-----------------------------------------------------------*/
@@ -127,7 +127,7 @@ const TickType_t x150ms = 150UL / portTICK_PERIOD_MS;
do
{
/* Create the string that is sent to the server. */
- printf( ( char * ) cString, "Server received (not zero copy): Message number %lu\r\n", ulCount );
+ sprintf( ( char * ) cString, "Server received (not zero copy): Message number %ul\r\n", ulCount );
/* Send the string to the socket. ulFlags is set to 0, so the zero
copy option is not selected. That means the data from cString[] is
@@ -190,6 +190,7 @@ Socket_t xListeningSocket;
/* Error check. */
configASSERT( lBytes == ( BaseType_t ) strlen( ( const char * ) cReceivedString ) );
+ FreeRTOS_debug_printf( ("Received string: %s, on port %d\r\n", cReceivedString, xBindAddress.sin_port ) );
}
}
/*-----------------------------------------------------------*/
@@ -255,7 +256,7 @@ const size_t xStringLength = strlen( pcStringToSend ) + 15;
end. Note that the string is being written directly into the buffer
obtained from the IP stack above. */
memset( ( void * ) pucUDPPayloadBuffer, 0x00, xStringLength );
- printf( ( char * ) pucUDPPayloadBuffer, "%s%lu\r\n", pcStringToSend, ulCount );
+ sprintf( ( char * ) pucUDPPayloadBuffer, "%s%ul\r\n", pcStringToSend, ulCount );
/* Pass the buffer into the send function. ulFlags has the
FREERTOS_ZERO_COPY bit set so the IP stack will take control of the
@@ -343,7 +344,7 @@ Socket_t xListeningSocket;
the NULL terminator is also transmitted. */
configASSERT( lBytes == ( ( BaseType_t ) strlen( ( const char * ) pucUDPPayloadBuffer ) + 1 ) );
}
-
+ FreeRTOS_debug_printf( ("Received string: %s, with ZERO_COPY on port %d\r\n", pucUDPPayloadBuffer, xBindAddress.sin_port ) );
if( lBytes >= 0 )
{
/* The buffer *must* be freed once it is no longer needed. */
diff --git a/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c b/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c
index 0985091..e15ecf3 100644
--- a/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c
+++ b/FreeRTOS/source/portable/NetworkInterface/board_family/NetworkInterface.c
@@ -78,13 +78,9 @@
#include "Driver_ETH_MAC.h"
#include "Driver_ETH_PHY.h"
#include "gd32f10x_enet.h"
-//#include "RTE_Components.h"
+
//#ifdef RTE_Drivers_PHY_DP83848C /* Driver PHY DP83848C */
-//#endif
-//#ifdef DEBUG
-//#define BKPT __asm volatile("BKPT #0\n") ;
-//#endif
static void receiveHandlerTask( void *pvParameters );
static TaskHandle_t receiveHandler = NULL;
@@ -98,6 +94,8 @@ static ARM_ETH_MAC_CAPABILITIES capabilities;
extern ARM_DRIVER_ETH_PHY ARM_Driver_ETH_PHY_(0);
#define Driver_ETH_PHY0 ARM_Driver_ETH_PHY_(0)
+extern TaskHandle_t vTaskHelloWorld_Handle, vTaskToggleLed_Handle;
+
/**
\fn void ENET_IRQHandler(void)
\brief Ethernet IRQ Handler
@@ -110,6 +108,25 @@ void ENET_IRQHandler(void)
enet_interrupt_flag_clear(ENET_DMA_INT_FLAG_RS_CLR);
vTaskNotifyGiveFromISR(receiveHandler, &pxHigherPriorityTaskWoken );
}
+#ifdef DEBUG_RBU_IRQ
+ if (SET == enet_interrupt_flag_get(ENET_DMA_INT_FLAG_RBU))
+ {
+ enet_interrupt_flag_clear(ENET_DMA_INT_FLAG_RBU_CLR);
+ vTaskNotifyGiveIndexedFromISR(vTaskToggleLed_Handle, 0, &pxHigherPriorityTaskWoken );
+ }
+#elif defined (DEBUG_TBU_IRQ)
+ if (SET == enet_interrupt_flag_get(ENET_DMA_INT_FLAG_TBU))
+ {
+ enet_interrupt_flag_clear(ENET_DMA_INT_FLAG_TBU_CLR);
+ vTaskNotifyGiveFromISR(vTaskHelloWorld_Handle, &pxHigherPriorityTaskWoken );
+ }
+#elif defined (DEBUG_RBU_IRQ)
+ if (SET == enet_interrupt_flag_get(ENET_DMA_INT_FLAG_ET))
+ {
+ enet_interrupt_flag_clear(ENET_DMA_INT_FLAG_ET_CLR);
+ vTaskNotifyGiveIndexedFromISR(vTaskHelloWorld_Handle, 1, &pxHigherPriorityTaskWoken );
+ }
+#endif
if( pxHigherPriorityTaskWoken == pdTRUE)
{
taskYIELD();
@@ -171,11 +188,47 @@ int32_t ARM_ETH_MAC_Initialize (ARM_ETH_MAC_SignalEvent_t cb_event)
xResult = ARM_DRIVER_OK;
enet_interrupt_enable( ENET_DMA_INT_RIE );
-/* enet_interrupt_enable( ENET_DMA_INT_TIE );
+#ifdef DEBUG_TI_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_TIE );
+#elif defined DEBUG_TBU_IRQ
enet_interrupt_enable( ENET_DMA_INT_TBUIE );
- enet_interrupt_enable( ENET_DMA_INT_ERIE );*/
+#elif defined DEBUG_ER_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_ERIE );
+#endif
+
enet_interrupt_enable( ENET_DMA_INT_NIE );
+#ifdef DEBUG_TJT_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_TJTIE );
+#elif defined DEBUG_TPS_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_TPSIE );
+#elif defined DEBUG_TU_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_TUIE );
+#elif defined DEBUG_RBU_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_RBUIE );
+#elif defined DEBUG_RPS_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_RPSIE );
+#elif defined DEBUG_RO_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_ROIE );
+#elif defined DEBUG_RWT_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_RWTIE );
+#elif defined DEBUG_ET_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_ETIE );
+#elif defined DEBUG_FBE_IRQ
+ enet_interrupt_enable( ENET_DMA_INT_FBEIE );
+#endif
+#if defined ( DEBUG_TJT_IRQ ) || \
+ defined ( DEBUG_TPS_IRQ ) || \
+ defined ( DEBUG_TU_IRQ ) || \
+ defined ( DEBUG_RBU_IRQ ) || \
+ defined ( DEBUG_RPS_IRQ ) || \
+ defined ( DEBUG_RO_IRQ ) || \
+ defined ( DEBUG_RWT_IRQ ) || \
+ defined ( DEBUG_ET_IRQ ) || \
+ defined ( DEBUG_FBE_IRQ )
+ enet_interrupt_enable( ENET_DMA_INT_AIE );
+#endif
+
return xResult;
}
@@ -358,16 +411,18 @@ int32_t ARM_ETH_MAC_GetTxFrameTime (ARM_ETH_MAC_TIME *time)
\return \ref execution_status
*/
int32_t ARM_ETH_MAC_Control (uint32_t control, uint32_t arg)
-{
- FreeRTOS_debug_printf(("ARM_ETH_MAC_Control\n"));
-
+{
if((control >= 0) & (arg >= 0))
{
if(SUCCESS == enet_phy_write_read(ENET_PHY_WRITE, PHY_ADDRESS, control, (uint16_t*)&arg))
return ARM_DRIVER_OK;
else
+ {
+ FreeRTOS_debug_printf(("ARM_ETH_MAC_Control_ERROR\n"));
return ARM_DRIVER_ERROR;
+ }
}else
+ FreeRTOS_debug_printf(("ARM_ETH_MAC_Control_ERROR_PARAMETER\n"));
return ARM_DRIVER_ERROR_PARAMETER;
}
diff --git a/RTE/RTOS/FreeRTOSConfig.h b/RTE/RTOS/FreeRTOSConfig.h
index 3bf5fe1..5f073fc 100644
--- a/RTE/RTOS/FreeRTOSConfig.h
+++ b/RTE/RTOS/FreeRTOSConfig.h
@@ -50,7 +50,7 @@ extern uint32_t SystemCoreClock;
/* Constants that describe the hardware and memory usage. */
#define configCPU_CLOCK_HZ (SystemCoreClock)
#define configTICK_RATE_HZ ((TickType_t)1000)
-#define configTOTAL_HEAP_SIZE ((size_t)5*8192)
+#define configTOTAL_HEAP_SIZE ((size_t)40*1024)
#define configMINIMAL_STACK_SIZE ((uint16_t)256)
#define configSUPPORT_DYNAMIC_ALLOCATION 1
#define configSUPPORT_STATIC_ALLOCATION 0
@@ -99,6 +99,7 @@ extern uint32_t SystemCoreClock;
#define configENABLE_TRUSTZONE 1
#define configMINIMAL_SECURE_STACK_SIZE ((uint32_t)1024)
#define configRUN_FREERTOS_SECURE_ONLY 0
+#define configTASK_NOTIFICATION_ARRAY_ENTRIES 2
/* Cortex-M specific definitions. */
#ifdef __NVIC_PRIO_BITS
@@ -237,14 +238,14 @@ void vAssertCalled(const char* pcFile,
#define configIP_ADDR0 192
#define configIP_ADDR1 168
#define configIP_ADDR2 1
-#define configIP_ADDR3 2
+#define configIP_ADDR3 3
/* Default gateway IP address configuration. Used in ipconfigUSE_DHCP is set to
* 0, or ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */
#define configGATEWAY_ADDR0 192
#define configGATEWAY_ADDR1 168
#define configGATEWAY_ADDR2 1
-#define configGATEWAY_ADDR3 2
+#define configGATEWAY_ADDR3 1
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and
* 208.67.220.220. Used in ipconfigUSE_DHCP is set to 0, or ipconfigUSE_DHCP is
diff --git a/RTE/_Target_1/RTE_Components.h b/RTE/_Target_1/RTE_Components.h
index 5e69c64..92c52af 100644
--- a/RTE/_Target_1/RTE_Components.h
+++ b/RTE/_Target_1/RTE_Components.h
@@ -24,6 +24,8 @@
#define RTE_RTOS_FreeRTOS_EVENTGROUPS /* RTOS FreeRTOS Event Groups */
/* ARM.FreeRTOS::RTOS:Heap:Heap_4:10.5.1 */
#define RTE_RTOS_FreeRTOS_HEAP_4 /* RTOS FreeRTOS Heap 4 */
+/* GigaDevice::Device:GD32F10x_StdPeripherals:BKP:2.0.2 */
+#define RTE_DEVICE_STDPERIPHERALS_BKP
/* GigaDevice::Device:GD32F10x_StdPeripherals:DMA:2.0.2 */
#define RTE_DEVICE_STDPERIPHERALS_DMA
/* GigaDevice::Device:GD32F10x_StdPeripherals:ENET:2.0.2 */
diff --git a/Test_project_for_GD32107C-EVAL.uvoptx b/Test_project_for_GD32107C-EVAL.uvoptx
index 8fc12bd..db93541 100644
--- a/Test_project_for_GD32107C-EVAL.uvoptx
+++ b/Test_project_for_GD32107C-EVAL.uvoptx
@@ -125,7 +125,7 @@
0
DLGTARM
- (1010=-1,-1,-1,-1,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)
+ (1010=83,112,533,669,0)(1007=-1,-1,-1,-1,0)(1008=-1,-1,-1,-1,0)(1009=-1,-1,-1,-1,0)
0
@@ -153,56 +153,7 @@
UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))
-
-
- 0
- 0
- 206
- 1
- 134220272
- 0
- 0
- 0
- 0
- 0
- 1
- .\DemoTasks\SimpleTCPEchoServer.c
-
- \\Test_project_for_GD32107C_EVAL\DemoTasks/SimpleTCPEchoServer.c\206
-
-
- 1
- 0
- 511
- 1
- 134230238
- 0
- 0
- 0
- 0
- 0
- 1
- .\FreeRTOS\source\FreeRTOS_DHCP.c
-
- \\Test_project_for_GD32107C_EVAL\FreeRTOS/source/FreeRTOS_DHCP.c\511
-
-
- 2
- 0
- 6
- 1
- 0
- 0
- 0
- 0
- 0
- 0
- 0
- .\main.c
-
-
-
-
+
0
@@ -274,6 +225,11 @@
1
pxSocket
+
+ 14
+ 1
+ prvServerConnectionInstance_Handle
+
@@ -415,18 +371,6 @@
0
0
-
- 1
- 6
- 1
- 0
- 0
- 0
- .\printf-stdarg.c
- printf-stdarg.c
- 0
- 0
-
@@ -437,7 +381,7 @@
0
2
- 7
+ 6
1
0
0
@@ -449,7 +393,7 @@
2
- 8
+ 7
1
0
0
@@ -461,7 +405,7 @@
2
- 9
+ 8
1
0
0
@@ -473,7 +417,7 @@
2
- 10
+ 9
1
0
0
@@ -485,7 +429,7 @@
2
- 11
+ 10
1
0
0
@@ -497,7 +441,7 @@
2
- 12
+ 11
1
0
0
@@ -509,7 +453,7 @@
2
- 13
+ 12
1
0
0
@@ -521,7 +465,7 @@
2
- 14
+ 13
1
0
0
@@ -533,7 +477,7 @@
2
- 15
+ 14
1
0
0
@@ -545,7 +489,7 @@
2
- 16
+ 15
1
0
0
@@ -557,7 +501,7 @@
2
- 17
+ 16
1
0
0
@@ -569,7 +513,7 @@
2
- 18
+ 17
1
0
0
@@ -581,7 +525,7 @@
2
- 19
+ 18
1
0
0
@@ -593,7 +537,7 @@
2
- 20
+ 19
1
0
0
@@ -605,7 +549,7 @@
2
- 21
+ 20
1
0
0
@@ -617,7 +561,7 @@
2
- 22
+ 21
1
0
0
@@ -629,7 +573,7 @@
2
- 23
+ 22
1
0
0
@@ -641,7 +585,7 @@
2
- 24
+ 23
1
0
0
@@ -653,7 +597,7 @@
2
- 25
+ 24
1
0
0
@@ -665,7 +609,7 @@
2
- 26
+ 25
1
0
0
@@ -677,7 +621,7 @@
2
- 27
+ 26
1
0
0
@@ -689,7 +633,7 @@
2
- 28
+ 27
1
0
0
@@ -701,7 +645,7 @@
2
- 29
+ 28
1
0
0
@@ -713,7 +657,7 @@
2
- 30
+ 29
1
0
0
@@ -759,7 +703,7 @@
::RTOS
- 1
+ 0
0
0
1
diff --git a/Test_project_for_GD32107C-EVAL.uvprojx b/Test_project_for_GD32107C-EVAL.uvprojx
index 1a32180..c3893d0 100644
--- a/Test_project_for_GD32107C-EVAL.uvprojx
+++ b/Test_project_for_GD32107C-EVAL.uvprojx
@@ -339,7 +339,7 @@
0
-D DEBUG -Wno-pragma-pack -Wno-macro-redefined
- DEBUG_TASK_DELETE
+
.\FreeRTOS\source\portable\NetworkInterface\include;.\FreeRTOS\source\include;.\FreeRTOS\source\portable\Compiler\Keil;.\DemoTasks\include;..\GigaDevice_test
@@ -410,11 +410,6 @@
1
.\PHY\PHY_DP83848C.c
-
- printf-stdarg.c
- 1
- .\printf-stdarg.c
-
@@ -820,6 +815,12 @@
+
+
+
+
+
+
@@ -908,6 +909,14 @@
+
+ RTE\Device\GD32F107VC\gd32f10x_bkp.c
+
+
+
+
+
+
RTE\Device\GD32F107VC\gd32f10x_dbg.c
diff --git a/main.c b/main.c
index 6ad43e6..0d762c2 100644
--- a/main.c
+++ b/main.c
@@ -1,5 +1,7 @@
#include "FreeRTOS.h"
#include "task.h"
+#include "queue.h"
+#include "semphr.h"
#include "gd32f107c_eval.h"
#include "gd32f10x_gpio.h"
#include "stdio.h"
@@ -26,6 +28,9 @@
#define TASK_HELLO_WORLD_DELAY 500
#define TASK_TOGGLE_LED_DELAY 125
+#define OSC32_PORT GPIOC
+#define OSC32_IN GPIO_PIN_14
+#define OSC32_OUT GPIO_PIN_15
/*
* RMII interface port & pin definitions
*/
@@ -57,12 +62,12 @@
#define TEST_RUNNER_TASK_STACK_SIZE 512
-#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 0
+#define mainCREATE_SIMPLE_UDP_CLIENT_SERVER_TASKS 1
#define mainCREATE_TCP_ECHO_TASKS_SINGLE 0
-#define mainCREATE_TCP_ECHO_SERVER_TASK 1
+#define mainCREATE_TCP_ECHO_SERVER_TASK 0
/* Simple UDP client and server task parameters. */
-#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY )
+#define mainSIMPLE_UDP_CLIENT_SERVER_TASK_PRIORITY ( tskIDLE_PRIORITY + 1 )
#define mainSIMPLE_UDP_CLIENT_SERVER_PORT ( 5005UL )
/* Echo client task parameters - used for both TCP and UDP echo clients. */
@@ -78,15 +83,12 @@
//#define mainDEVICE_NICK_NAME "windows_demo"
#ifdef DEBUG
- #define BKPT_DEBUG()\
- __BKPT(); \
-// NVIC_SystemReset(); \
-// while(TRUE){}; \
-
+ #define BKPT_DEBUG() __BKPT();
#else
#define BKPT_DEBUG()
#endif
+TaskHandle_t vTaskHelloWorld_Handle, vTaskToggleLed_Handle;
/* Default MAC address configuration. The demo creates a virtual network
* connection that uses this MAC address by accessing the raw Ethernet data
* to and from a real network connection on the host PC. See the
@@ -199,19 +201,32 @@ static void vInitMCU(void)
rcu_periph_clock_enable(RCU_AF);
rcu_periph_clock_enable(RCU_ENET);
rcu_periph_clock_enable(RCU_ENETTX);
- rcu_periph_clock_enable(RCU_ENETRX);
+ rcu_periph_clock_enable(RCU_ENETRX);
+ rcu_periph_clock_enable(RCU_BKPI);
+ rcu_periph_clock_enable(RCU_PMU);
rcu_periph_clock_enable(RCU_RTC);
/* Configure RTC */
-#ifdef RTC_ENABLE
- rcu_rtc_clock_config(RCU_RTCSRC_LXTAL);
- rtc_configuration_mode_enter();
- rtc_lwoff_wait();
- rtc_counter_set(0xA5A5A5A5);
- //rtc_lwoff_wait();
- rtc_configuration_mode_exit();
-#endif
+ gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_IN);
+ gpio_init(OSC32_PORT, GPIO_MODE_AF_PP, GPIO_OSPEED_2MHZ, OSC32_OUT);
+
+ if (FALSE == rtc_counter_get() & FALSE == rtc_flag_get(RTC_CTL_OVIF))
+ {
+ pmu_backup_write_enable();
+
+ rcu_rtc_clock_config(RCU_RTCSRC_LXTAL);
+ while (RESET == (RCU_BDCTL & RCU_BDCTL_LXTALSTB)) {}
+
+ rtc_lwoff_wait();
+ rtc_counter_set(0xA5A5);
+ rtc_lwoff_wait();
+ rtc_prescaler_set(0);
+ rtc_lwoff_wait();
+ }
+ else if (TRUE == rtc_flag_get(RTC_CTL_OVIF))
+ rtc_flag_clear(RTC_CTL_OVIF);
+
/* Configure GPIO Alternate UART function */
gd_eval_com_init(EVAL_COM1);
@@ -248,9 +263,9 @@ static void vInitMCU(void)
/* Enable Ethernet MAC */
enet_descriptors_chain_init(ENET_DMA_TX);
- enet_descriptors_chain_init(ENET_DMA_RX);
- //enet_desc_receive_complete_bit_enable(dma_current_rxdesc);
+ enet_descriptors_chain_init(ENET_DMA_RX); //enet_desc_receive_complete_bit_enable(dma_current_rxdesc);
enet_enable();
+ //nvic_irq_enable(ENET_IRQn, ipconfigMAC_INTERRUPT_PRIORITY, 0xFF);
__disable_irq();
NVIC_ClearPendingIRQ(ENET_IRQn);
NVIC_SetPriority(ENET_IRQn, ipconfigMAC_INTERRUPT_PRIORITY);
@@ -266,14 +281,19 @@ void vTaskHelloWorld( void *pvParameters)
{
char ButtonState = 0;
for( ;; )
- {
+ {
+#ifdef DEBUG_ET_IRQ
+ ulTaskNotifyTakeIndexed(1, pdFALSE, portMAX_DELAY );
+ FreeRTOS_debug_printf(("ENET_DMA_INT_FLAG_ET\n"));
+#else
ButtonState = !gpio_input_bit_get(GPIOB, BUTTON_USER);
if (ButtonState)
{
FreeRTOS_debug_printf(("Key pressed\n"));
fflush( stdout );
vTaskDelay(TASK_HELLO_WORLD_DELAY);
- }
+ }
+#endif
}
}
/**! \brief vTaskToggleLed procedure
@@ -285,6 +305,10 @@ void vTaskToggleLed( void *pvParameters)
char toggle = 1;
for( ;; )
{
+#ifdef DEBUG_RBU_IRQ
+ ulTaskNotifyTakeIndexed(0, pdFALSE, portMAX_DELAY );
+ FreeRTOS_debug_printf(("ENET_DMA_INT_FLAG_RBU\n"));
+#else
if (toggle)
{
gpio_bit_reset(LED2_USER_PORT, LED2_USER);
@@ -294,7 +318,8 @@ void vTaskToggleLed( void *pvParameters)
gpio_bit_set(LED2_USER_PORT, LED2_USER);
}
toggle = !toggle;
- vTaskDelay(TASK_TOGGLE_LED_DELAY);
+ vTaskDelay(TASK_TOGGLE_LED_DELAY);
+#endif
}
}
@@ -309,7 +334,7 @@ static void prvMiscInitialisation( void )
/* Seed the random number generator. */
xTimeNow = rtc_counter_get();
- FreeRTOS_debug_printf( ("Seed for randomiser: %lu\r\n", xTimeNow ) );
+ FreeRTOS_debug_printf( ("Seed for randomiser: %d\r\n", (unsigned)xTimeNow ) );
prvSRand( ( uint32_t ) xTimeNow );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] );
@@ -327,8 +352,8 @@ int main(void)
{
vInitMCU();
prvMiscInitialisation();
- xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
- xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
+ xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, &vTaskToggleLed_Handle);
+ xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, &vTaskHelloWorld_Handle);
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
vTaskStartScheduler();
@@ -425,8 +450,7 @@ static void prvSRand( UBaseType_t ulSeed )
}
UBaseType_t uxRand( void )
-{
- static UBaseType_t ulNextRand;
+{
const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;
/* Utility function to generate a pseudo random number. */