Added FreeRTOS_debug_printf

This commit is contained in:
Alexei 2023-02-06 00:22:53 +07:00
parent d79ae7abf4
commit 7e1fa80cc5
13 changed files with 826 additions and 819 deletions

View File

@ -189,6 +189,9 @@ const BaseType_t xBacklog = 20;
listen for incoming connections. */
xBindAddress.sin_port = tcpechoPORT_NUMBER;
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port );
#if (ipconfigUSE_DHCP == 0)
xBindAddress.sin_addr = FreeRTOS_htonl(xNetworkAddressing.ulDefaultIPAddress);
#endif
FreeRTOS_bind( xListeningSocket, &xBindAddress, sizeof( xBindAddress ) );
FreeRTOS_listen( xListeningSocket, xBacklog );
@ -196,7 +199,7 @@ const BaseType_t xBacklog = 20;
{
/* Wait for a client to connect. */
xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient, &xSize );
configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
//configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
/* Spawn a task to handle the connection. */
xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY, NULL );

View File

@ -352,7 +352,7 @@
if( prvSendDHCPDiscover() == pdPASS )
{
FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", EP_DHCPData.xDHCPTxPeriod ) );
FreeRTOS_debug_printf( ( "vDHCPProcess: timeout %lu ticks\n", (UBaseType_t)EP_DHCPData.xDHCPTxPeriod ) );
}
else
{
@ -369,7 +369,7 @@
}
else
{
FreeRTOS_debug_printf( ( "vDHCPProcess: giving up %lu > %lu ticks\n", EP_DHCPData.xDHCPTxPeriod, ipconfigMAXIMUM_DISCOVER_TX_PERIOD ) );
FreeRTOS_debug_printf( ( "vDHCPProcess: giving up %lu > %lu ticks\n", (UBaseType_t)EP_DHCPData.xDHCPTxPeriod, (UBaseType_t)ipconfigMAXIMUM_DISCOVER_TX_PERIOD ) );
#if ( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 )
{
@ -665,7 +665,7 @@
/* Create the DHCP socket if it has not already been created. */
prvCreateDHCPSocket();
FreeRTOS_debug_printf( ( "prvInitialiseDHCP: start after %lu ticks\n", dhcpINITIAL_TIMER_PERIOD ) );
FreeRTOS_debug_printf( ( "prvInitialiseDHCP: start after %lu ticks\n", (UBaseType_t)dhcpINITIAL_TIMER_PERIOD ) );
vDHCPTimerReload( dhcpINITIAL_TIMER_PERIOD );
}
else

View File

@ -233,8 +233,8 @@
else
{
FreeRTOS_printf( ( "prvPrepareLookup: name is too long ( %lu > %lu )\n",
( uint32_t ) xLength,
( uint32_t ) ipconfigDNS_CACHE_NAME_LENGTH ) );
(UBaseType_t) xLength,
(UBaseType_t) ipconfigDNS_CACHE_NAME_LENGTH ) );
}
}
@ -256,7 +256,7 @@
if( ulIPAddress != 0U )
{
FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, ulIPAddress ) );
FreeRTOS_debug_printf( ( "FreeRTOS_gethostbyname: found '%s' in cache: %lxip\n", pcHostName, (UBaseType_t)ulIPAddress ) );
}
else
{

View File

@ -53,6 +53,7 @@
#include "NetworkInterface.h"
#include "NetworkBufferManagement.h"
#include "FreeRTOS_DNS.h"
#include "portable.h"
/* Used to ensure the structure packing is having the desired effect. The
* 'volatile' is used to prevent compiler warnings about comparing a constant with
@ -670,7 +671,7 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer,
{
#if ( ipconfigHAS_DEBUG_PRINTF != 0 )
{
FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: len invalid: %lu\n", pcType, ulLength ) );
FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: len invalid: %lu\n", pcType, (UBaseType_t)ulLength ) );
}
#endif /* ipconfigHAS_DEBUG_PRINTF != 0 */
@ -758,8 +759,8 @@ uint16_t usGenerateProtocolChecksum( uint8_t * pucEthernetBuffer,
FreeRTOS_debug_printf( ( "usGenerateProtocolChecksum[%s]: ID %04X: from %lxip to %lxip bad crc: %04X\n",
pcType,
FreeRTOS_ntohs( pxIPPacket->xIPHeader.usIdentification ),
FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ),
FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulDestinationIPAddress ),
(UBaseType_t)FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulSourceIPAddress ),
(UBaseType_t)FreeRTOS_ntohl( pxIPPacket->xIPHeader.ulDestinationIPAddress ),
FreeRTOS_ntohs( usChecksumFound ) ) );
}
else
@ -1016,7 +1017,7 @@ uint16_t usGenerateChecksum( uint16_t usSum,
void vPrintResourceStats( void )
{
UBaseType_t uxCurrentBufferCount;
size_t uxMinSize;
size_t uxMinSize = 0;
/* When setting up and testing a project with FreeRTOS+TCP, it is
* can be helpful to monitor a few resources: the number of network
@ -1034,8 +1035,9 @@ uint16_t usGenerateChecksum( uint16_t usSum,
uxGetNumberOfFreeNetworkBuffers(),
uxCurrentBufferCount ) );
}
#ifndef DEBUG
uxMinSize = xPortGetMinimumEverFreeHeapSize();
#endif
if( uxMinLastSize == 0U )
{
@ -1050,7 +1052,7 @@ uint16_t usGenerateChecksum( uint16_t usSum,
else if( ( uxMinLastSize * ipMONITOR_PERCENTAGE_90 ) > ( uxMinSize * ipMONITOR_PERCENTAGE_100 ) )
{
uxMinLastSize = uxMinSize;
FreeRTOS_printf( ( "Heap: current %lu lowest %lu\n", xPortGetFreeHeapSize(), uxMinSize ) );
FreeRTOS_printf( ( "Heap: current %lu lowest %lu\n", (UBaseType_t)xPortGetFreeHeapSize(), (UBaseType_t)uxMinSize ) );
}
else
{

View File

@ -60,7 +60,6 @@
#include "FreeRTOS_TCP_State_Handling.h"
#include "FreeRTOS_TCP_Utils.h"
/* Just make sure the contents doesn't get compiled if TCP is not enabled. */
#if ipconfigUSE_TCP == 1
@ -191,7 +190,7 @@
{
if( ( xTCPWindowLoggingLevel > 1 ) && ipconfigTCP_MAY_LOG_PORT( pxSocket->usLocalPort ) )
{
FreeRTOS_debug_printf( ( "Send[%u->%u] del ACK %u SEQ %u (len %u)\n",
FreeRTOS_debug_printf( ("Send[%u->%u] del ACK %u SEQ %u (len %u)\n",
pxSocket->usLocalPort,
pxSocket->u.xTCP.usRemotePort,
( unsigned ) ( pxSocket->u.xTCP.xTCPWindow.rx.ulCurrentSequenceNumber - pxSocket->u.xTCP.xTCPWindow.rx.ulFirstSequenceNumber ),
@ -316,7 +315,7 @@
{
/* A socket was in the connecting phase but something
* went wrong and it should be closed. */
FreeRTOS_debug_printf( ( "Move from %s to %s\n",
FreeRTOS_debug_printf( ("Move from %s to %s\n",
FreeRTOS_GetTCPStateName( xPreviousState ),
FreeRTOS_GetTCPStateName( eTCPState ) ) );
@ -472,7 +471,7 @@
{
case eSYN_FIRST: /* 3 (server) Just created, must ACK the SYN request */
case eSYN_RECEIVED: /* 4 (server) waiting for a confirming connection request */
FreeRTOS_debug_printf( ( "Restoring a reuse socket port %u\n", pxSocket->usLocalPort ) );
FreeRTOS_debug_printf( ("Restoring a reuse socket port %u\n", pxSocket->usLocalPort ) );
/* Go back into listening mode. Set the TCP status to 'eCLOSED',
* otherwise FreeRTOS_listen() will refuse the action. */
@ -557,10 +556,10 @@
ulDelayMs = 500U;
}
FreeRTOS_debug_printf( ( "Connect[%xip:%u]: next timeout %u: %u ms\n",
FreeRTOS_debug_printf( ("Connect[%xip:%u]: next timeout %u: %u ms\n",
( unsigned ) pxSocket->u.xTCP.ulRemoteIP, pxSocket->u.xTCP.usRemotePort,
pxSocket->u.xTCP.ucRepCount, ( unsigned ) ulDelayMs ) );
pxSocket->u.xTCP.usTimeout = ( uint16_t ) ipMS_TO_MIN_TICKS( ulDelayMs );
pxSocket->u.xTCP.ucRepCount, ( unsigned ) ulDelayMs );
pxSocket->u.xTCP.usTimeout = ( uint16_t ) ipMS_TO_MIN_TICKS( ulDelayMs ) );
}
else if( pxSocket->u.xTCP.usTimeout == 0U )
{
@ -668,7 +667,7 @@
* non-active states: eCLOSED, eCLOSE_WAIT, eFIN_WAIT_2, eCLOSING, or
* eTIME_WAIT. */
FreeRTOS_debug_printf( ( "TCP: No active socket on port %d (%xip:%d)\n", usLocalPort, ( unsigned ) ulRemoteIP, usRemotePort ) );
FreeRTOS_debug_printf( ("TCP: No active socket on port %d (%xip:%d)\n", usLocalPort, ( unsigned ) ulRemoteIP, usRemotePort ) );
/* Send a RST to all packets that can not be handled. As a result
* the other party will get a ECONN error. There are two exceptions:
@ -731,7 +730,7 @@
* flag. */
if( ( ucTCPFlags & tcpTCP_FLAG_RST ) != 0U )
{
FreeRTOS_debug_printf( ( "TCP: RST received from %xip:%u for %u\n", ( unsigned ) ulRemoteIP, usRemotePort, usLocalPort ) );
FreeRTOS_debug_printf( ("TCP: RST received from %xip:%u for %u\n", ( unsigned ) ulRemoteIP, usRemotePort, usLocalPort ) );
/* Implement https://tools.ietf.org/html/rfc5961#section-3.2. */
if( pxSocket->u.xTCP.eTCPState == eCONNECT_SYN )
@ -771,7 +770,7 @@
else if( ( ( ucTCPFlags & tcpTCP_FLAG_CTRL ) == tcpTCP_FLAG_SYN ) && ( pxSocket->u.xTCP.eTCPState >= eESTABLISHED ) )
{
/* SYN flag while this socket is already connected. */
FreeRTOS_debug_printf( ( "TCP: SYN unexpected from %xip:%u\n", ( unsigned ) ulRemoteIP, usRemotePort ) );
FreeRTOS_debug_printf( ("TCP: SYN unexpected from %xip:%u\n", ( unsigned ) ulRemoteIP, usRemotePort ) );
/* The packet cannot be handled. */
xResult = pdFAIL;
@ -900,7 +899,7 @@
if( ( pxFound->ucProtocol == ( uint8_t ) FREERTOS_IPPROTO_TCP ) && ( pxFound->u.xTCP.bits.bPassAccept != pdFALSE_UNSIGNED ) )
{
pxSocket->u.xTCP.pxPeerSocket = pxFound;
FreeRTOS_debug_printf( ( "xTCPCheckNewClient[0]: client on port %u\n", pxSocket->usLocalPort ) );
FreeRTOS_debug_printf( ("xTCPCheckNewClient[0]: client on port %u\n", pxSocket->usLocalPort ) );
xResult = pdTRUE;
break;
}

View File

@ -33,14 +33,21 @@
#ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H
#include <stdarg.h>
/* Empty configuration file to check the build with default configuration. */
/* It is not sensible for this macro to have a default value as it is hardware
* dependent. */
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
#define ipconfigUSE_NETWORK_EVENT_HOOK 1
#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 4
#define ipconfigUSE_NETWORK_EVENT_HOOK 1
#define ipconfigUSE_DHCP 1
#define ipconfigUSE_DHCP_HOOK 1
#define ipconfigUSE_DNS_CACHE 1
#ifdef DEBUG
#define ipconfigHAS_DEBUG_PRINTF 1
#define ipconfigHAS_PRINTF 1
#define FreeRTOS_debug_printf( X ) printf X//, ##__VA_ARGS__
#define FreeRTOS_printf( X ) printf X
#endif
#endif

View File

@ -65,6 +65,7 @@ BaseType_t prvTCPHandleState( FreeRTOS_Socket_t * pxSocket,
FreeRTOS_Socket_t * prvHandleListen( FreeRTOS_Socket_t * pxSocket,
NetworkBufferDescriptor_t * pxNetworkBuffer );
const char * FreeRTOS_GetTCPStateName( UBaseType_t ulState );
/* *INDENT-OFF* */
#ifdef __cplusplus
} /* extern "C" */

View File

@ -253,7 +253,7 @@ BaseType_t xPhyDiscover( EthernetPhy_t * pxPhyObject )
if( pxPhyObject->xPortCount > 0 )
{
FreeRTOS_printf( ( "PHY ID %lX\n", pxPhyObject->ulPhyIDs[ 0 ] ) );
FreeRTOS_printf( ( "PHY ID %lX\n", (UBaseType_t)pxPhyObject->ulPhyIDs[ 0 ] ) );
}
return pxPhyObject->xPortCount;
@ -308,7 +308,7 @@ static uint32_t xPhyReset( EthernetPhy_t * pxPhyObject,
if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE )
{
FreeRTOS_printf( ( "xPhyReset: phyBMCR_RESET timed out ( done 0x%02lX )\n", ulDoneMask ) );
FreeRTOS_printf( ( "xPhyReset: phyBMCR_RESET timed out ( done 0x%02lX )\n", (UBaseType_t)ulDoneMask ) );
break;
}
@ -487,7 +487,7 @@ BaseType_t xPhyConfigure( EthernetPhy_t * pxPhyObject,
pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_19_PHYCR, ulPhyControl );
}
FreeRTOS_printf( ( "+TCP: advertise: %04lX config %04lX\n", ulAdvertise, ulConfig ) );
FreeRTOS_printf( ( "+TCP: advertise: %04lX config %04lX\n", (UBaseType_t)ulAdvertise, (UBaseType_t)ulConfig ) );
}
/* Keep these values for later use. */
@ -597,7 +597,7 @@ BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t * pxPhyObject,
if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE )
{
FreeRTOS_printf( ( "xPhyStartAutoNegotiation: phyBMSR_AN_COMPLETE timed out ( done 0x%02lX )\n", ulDoneMask ) );
FreeRTOS_printf( ( "xPhyStartAutoNegotiation: phyBMSR_AN_COMPLETE timed out ( done 0x%02lX )\n", (UBaseType_t)ulDoneMask ) );
break;
}
@ -727,7 +727,7 @@ BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t * pxPhyObject,
}
FreeRTOS_printf( ( "Autonego ready: %08lx: %s duplex %u mbit %s status\n",
ulRegValue,
(UBaseType_t)ulRegValue,
( ulRegValue & phyPHYSTS_DUPLEX_STATUS ) ? "full" : "half",
( ulRegValue & phyPHYSTS_SPEED_STATUS ) ? 10 : 100,
( ( ulPHYLinkStatus |= phyBMSR_LINK_STATUS ) != 0 ) ? "high" : "low" ) );
@ -775,7 +775,7 @@ BaseType_t xPhyCheckLinkStatus( EthernetPhy_t * pxPhyObject,
if( ( pxPhyObject->ulLinkStatusMask & ulBitMask ) == 0UL )
{
pxPhyObject->ulLinkStatusMask |= ulBitMask;
FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", pxPhyObject->ulLinkStatusMask ) );
FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", (UBaseType_t)pxPhyObject->ulLinkStatusMask ) );
xNeedCheck = pdTRUE;
}
}
@ -802,7 +802,7 @@ BaseType_t xPhyCheckLinkStatus( EthernetPhy_t * pxPhyObject,
pxPhyObject->ulLinkStatusMask &= ~( ulBitMask );
}
FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", pxPhyObject->ulLinkStatusMask ) );
FreeRTOS_printf( ( "xPhyCheckLinkStatus: PHY LS now %02lX\n", (UBaseType_t)pxPhyObject->ulLinkStatusMask ) );
xNeedCheck = pdTRUE;
}
}

View File

@ -208,7 +208,7 @@ void vAssertCalled(const char* pcFile,
* results in the wired network being used, while setting
* configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
* used. */
#define configNETWORK_INTERFACE_TO_USE ( 0L )
#define configNETWORK_INTERFACE_TO_USE ( 2L )
/* The address of an echo server that will be used by the two demo echo client
* tasks:
@ -216,7 +216,7 @@ void vAssertCalled(const char* pcFile,
* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html. */
#define configECHO_SERVER_ADDR0 192
#define configECHO_SERVER_ADDR1 168
#define configECHO_SERVER_ADDR2 0
#define configECHO_SERVER_ADDR2 1
#define configECHO_SERVER_ADDR3 2
#define configTCP_ECHO_CLIENT_PORT 7
@ -236,15 +236,15 @@ void vAssertCalled(const char* pcFile,
* ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */
#define configIP_ADDR0 192
#define configIP_ADDR1 168
#define configIP_ADDR2 0
#define configIP_ADDR3 1
#define configIP_ADDR2 1
#define configIP_ADDR3 2
/* 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 0
#define configGATEWAY_ADDR3 1
#define configGATEWAY_ADDR2 1
#define configGATEWAY_ADDR3 2
/* 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

View File

@ -153,40 +153,7 @@
<Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))</Name>
</SetRegEntry>
</TargetDriverDllRegistry>
<Breakpoint>
<Bp>
<Number>0</Number>
<Type>0</Type>
<LineNumber>391</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\FreeRTOS\source\FreeRTOS_IP.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
<Bp>
<Number>1</Number>
<Type>0</Type>
<LineNumber>406</LineNumber>
<EnabledFlag>1</EnabledFlag>
<Address>0</Address>
<ByteObject>0</ByteObject>
<HtxType>0</HtxType>
<ManyObjects>0</ManyObjects>
<SizeOfObject>0</SizeOfObject>
<BreakByAccess>0</BreakByAccess>
<BreakIfRCount>0</BreakIfRCount>
<Filename>.\FreeRTOS\source\FreeRTOS_IP.c</Filename>
<ExecCommand></ExecCommand>
<Expression></Expression>
</Bp>
</Breakpoint>
<Breakpoint/>
<WatchWindow1>
<Ww>
<count>0</count>
@ -208,12 +175,17 @@
<WinNumber>1</WinNumber>
<ItemText>PHY</ItemText>
</Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>frame</ItemText>
</Ww>
</WatchWindow1>
<MemoryWindow1>
<Mm>
<WinNumber>1</WinNumber>
<SubType>0</SubType>
<ItemText>0x40028014</ItemText>
<ItemText>pxNetworkBuffer</ItemText>
<AccSizeX>0</AccSizeX>
</Mm>
</MemoryWindow1>
@ -234,7 +206,7 @@
</Mm>
</MemoryWindow3>
<ScvdPack>
<Filename>C:\Users\User\AppData\Local\Arm\Packs\ARM\CMSIS-FreeRTOS\10.5.1\CMSIS\RTOS2\FreeRTOS\FreeRTOS.scvd</Filename>
<Filename>E:\Arm\Packs\ARM\CMSIS-FreeRTOS\10.5.1\CMSIS\RTOS2\FreeRTOS\FreeRTOS.scvd</Filename>
<Type>ARM.CMSIS-FreeRTOS.10.5.1</Type>
<SubType>1</SubType>
</ScvdPack>
@ -285,7 +257,7 @@
<Group>
<GroupName>Source Group 1</GroupName>
<tvExp>1</tvExp>
<tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -353,7 +325,7 @@
<Group>
<GroupName>FreeRTOS</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>0</RteFlg>
@ -373,7 +345,7 @@
<GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber>
<FileType>1</FileType>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2>
<PathWithFileName>.\FreeRTOS\source\FreeRTOS_IP.c</PathWithFileName>
@ -665,7 +637,7 @@
<Group>
<GroupName>::Compiler</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>
@ -681,7 +653,7 @@
<Group>
<GroupName>::RTOS</GroupName>
<tvExp>0</tvExp>
<tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel>
<RteFlg>1</RteFlg>

View File

@ -317,23 +317,23 @@
<interw>1</interw>
<Optim>1</Optim>
<oTime>0</oTime>
<SplitLS>1</SplitLS>
<OneElfS>1</OneElfS>
<SplitLS>0</SplitLS>
<OneElfS>0</OneElfS>
<Strict>0</Strict>
<EnumInt>0</EnumInt>
<PlainCh>0</PlainCh>
<Ropi>0</Ropi>
<Rwpi>0</Rwpi>
<wLevel>3</wLevel>
<wLevel>4</wLevel>
<uThumb>0</uThumb>
<uSurpInc>0</uSurpInc>
<uC99>1</uC99>
<uGnu>1</uGnu>
<useXO>0</useXO>
<v6Lang>5</v6Lang>
<v6LangP>5</v6LangP>
<vShortEn>1</vShortEn>
<vShortWch>1</vShortWch>
<v6LangP>6</v6LangP>
<vShortEn>0</vShortEn>
<vShortWch>0</vShortWch>
<v6Lto>0</v6Lto>
<v6WtE>0</v6WtE>
<v6Rtti>0</v6Rtti>

52
main.c
View File

@ -3,6 +3,8 @@
#include "gd32f107c_eval.h"
#include "gd32f10x_gpio.h"
#include "stdio.h"
/* System application includes. */
#include "FreeRTOSIPConfig.h"
@ -200,13 +202,7 @@ static void vInitMCU(void)
gpio_bit_set(LED5_TICK_PORT, LED5_TICK);
/*Enable PLL2 to generate 50MHz clocks */
if (ERROR == xInitPLL2())
{
#ifdef DEBUG
printf("PLL2 initialization failed\n");
__ASM("BKPT #0\n");
#endif
}
if (ERROR == xInitPLL2()) FreeRTOS_debug_printf(("PLL2 initialization failed\n"));
/* Put PLL2 clocks into CKOUT0(PA1) as ref clock for ethernet phy */
rcu_ckout0_config(RCU_CKOUT0SRC_CKPLL2);
@ -242,7 +238,7 @@ void vTaskHelloWorld( void *pvParameters)
ButtonState = !gpio_input_bit_get(GPIOB, BUTTON_USER);
if (ButtonState)
{
printf("Hello world\n");
FreeRTOS_debug_printf(("Key pressed\n"));
fflush( stdout );
vTaskDelay(TASK_HELLO_WORLD_DELAY);
}
@ -270,21 +266,23 @@ void vTaskToggleLed( void *pvParameters)
}
}
static void prvMiscInitialisation( void )
{
// time_t xTimeNow;
unsigned long xTimeNow;
uint32_t ulRandomNumbers[ 4 ];
/* Seed the random number generator. */
// time( &xTimeNow );
FreeRTOS_debug_printf( ( "Seed for randomiser: %lu\r\n", xTimeNow ) );
FreeRTOS_debug_printf( ("Seed for randomiser: %lu\r\n", xTimeNow ) );
FreeRTOS_debug_printf( ("Seed for randomiser\n") );
// prvSRand( ( uint32_t ) xTimeNow );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 1 ] );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 2 ] );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 3 ] );
FreeRTOS_debug_printf( ( "Random numbers: %08X %08X %08X %08X\r\n",
FreeRTOS_debug_printf( ("Random numbers: %08X %08X %08X %08X\r\n",
ulRandomNumbers[ 0 ],
ulRandomNumbers[ 1 ],
ulRandomNumbers[ 2 ],
@ -300,11 +298,35 @@ int main(void)
xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
xTaskCreate( vTaskHelloWorld, "HelloWorld", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
// vStartSimpleTCPServerTasks( configMINIMAL_STACK_SIZE*2, tskIDLE_PRIORITY+1 );
enet_enable();
vTaskStartScheduler();
while(1);
}
/**
* @brief xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, uint32_t ulIPAddress )
*/
eDHCPCallbackAnswer_t xApplicationDHCPHook( eDHCPCallbackPhase_t eDHCPPhase, uint32_t ulIPAddress )
{
eDHCPCallbackAnswer_t xResult = eDHCPUseDefaults;
switch (eDHCPPhase)
{
case eDHCPPhasePreDiscover:
FreeRTOS_debug_printf((" Driver is about to send a DHCP discovery.\n"));
xResult = eDHCPContinue;
break;
case eDHCPPhasePreRequest:
FreeRTOS_debug_printf((" Driver is about to request DHCP an IP address.\n"));
xResult = eDHCPContinue;
break;
default:
FreeRTOS_debug_printf((" Stop DHCP requests.\n"));
xResult = eDHCPStopNoChanges;
break;
};
return xResult;
};
/**
* @brief vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
*/
@ -563,8 +585,8 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
*/
void vApplicationMallocFailedHook( void )
{
FreeRTOS_debug_printf(("Malloc Failed Hook\n"));
#if defined (DEBUG)
printf("Malloc Failed Hook\n");
__ASM("BKPT #0\n");
#endif
NVIC_SystemReset();
@ -602,7 +624,7 @@ void vApplicationIdleHook( void )
uint32_t currentTick = xTaskGetTickCount();
if(currentTick > idleHookCounter + delta)
{
printf("Idle Hook %d\n", idleHookCounter);//__ASM("BKPT #0\n");
FreeRTOS_debug_printf(("Idle Hook %d\n", idleHookCounter));//__ASM("BKPT #0\n");
}
idleHookCounter = currentTick;
#endif
@ -613,8 +635,8 @@ void vApplicationIdleHook( void )
*/
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{
FreeRTOS_debug_printf(("Stack Overflow Hook\n"));
#if defined (DEBUG)
printf("Stack Overflow Hook\n");
__ASM("BKPT #0\n");
#endif
NVIC_SystemReset();