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. */ listen for incoming connections. */
xBindAddress.sin_port = tcpechoPORT_NUMBER; xBindAddress.sin_port = tcpechoPORT_NUMBER;
xBindAddress.sin_port = FreeRTOS_htons( xBindAddress.sin_port ); 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_bind( xListeningSocket, &xBindAddress, sizeof( xBindAddress ) );
FreeRTOS_listen( xListeningSocket, xBacklog ); FreeRTOS_listen( xListeningSocket, xBacklog );
@ -196,7 +199,7 @@ const BaseType_t xBacklog = 20;
{ {
/* Wait for a client to connect. */ /* Wait for a client to connect. */
xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient, &xSize ); xConnectedSocket = FreeRTOS_accept( xListeningSocket, &xClient, &xSize );
configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET ); //configASSERT( xConnectedSocket != FREERTOS_INVALID_SOCKET );
/* Spawn a task to handle the connection. */ /* Spawn a task to handle the connection. */
xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY, NULL ); xTaskCreate( prvServerConnectionInstance, "EchoServer", usUsedStackSize, ( void * ) xConnectedSocket, tskIDLE_PRIORITY, NULL );

View File

@ -352,7 +352,7 @@
if( prvSendDHCPDiscover() == pdPASS ) 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 else
{ {
@ -369,7 +369,7 @@
} }
else 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 ) #if ( ipconfigDHCP_FALL_BACK_AUTO_IP != 0 )
{ {
@ -665,7 +665,7 @@
/* Create the DHCP socket if it has not already been created. */ /* Create the DHCP socket if it has not already been created. */
prvCreateDHCPSocket(); 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 ); vDHCPTimerReload( dhcpINITIAL_TIMER_PERIOD );
} }
else else

View File

@ -233,8 +233,8 @@
else else
{ {
FreeRTOS_printf( ( "prvPrepareLookup: name is too long ( %lu > %lu )\n", FreeRTOS_printf( ( "prvPrepareLookup: name is too long ( %lu > %lu )\n",
( uint32_t ) xLength, (UBaseType_t) xLength,
( uint32_t ) ipconfigDNS_CACHE_NAME_LENGTH ) ); (UBaseType_t) ipconfigDNS_CACHE_NAME_LENGTH ) );
} }
} }
@ -256,7 +256,7 @@
if( ulIPAddress != 0U ) 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 else
{ {

View File

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

View File

@ -60,7 +60,6 @@
#include "FreeRTOS_TCP_State_Handling.h" #include "FreeRTOS_TCP_State_Handling.h"
#include "FreeRTOS_TCP_Utils.h" #include "FreeRTOS_TCP_Utils.h"
/* Just make sure the contents doesn't get compiled if TCP is not enabled. */ /* Just make sure the contents doesn't get compiled if TCP is not enabled. */
#if ipconfigUSE_TCP == 1 #if ipconfigUSE_TCP == 1
@ -559,8 +558,8 @@
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, ( unsigned ) pxSocket->u.xTCP.ulRemoteIP, pxSocket->u.xTCP.usRemotePort,
pxSocket->u.xTCP.ucRepCount, ( unsigned ) ulDelayMs ) ); pxSocket->u.xTCP.ucRepCount, ( unsigned ) ulDelayMs );
pxSocket->u.xTCP.usTimeout = ( uint16_t ) ipMS_TO_MIN_TICKS( ulDelayMs ); pxSocket->u.xTCP.usTimeout = ( uint16_t ) ipMS_TO_MIN_TICKS( ulDelayMs ) );
} }
else if( pxSocket->u.xTCP.usTimeout == 0U ) else if( pxSocket->u.xTCP.usTimeout == 0U )
{ {

View File

@ -33,14 +33,21 @@
#ifndef FREERTOS_IP_CONFIG_H #ifndef FREERTOS_IP_CONFIG_H
#define FREERTOS_IP_CONFIG_H #define FREERTOS_IP_CONFIG_H
#include <stdarg.h>
/* Empty configuration file to check the build with default configuration. */ /* 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 /* It is not sensible for this macro to have a default value as it is hardware
* dependent. */ * dependent. */
#define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN #define ipconfigBYTE_ORDER pdFREERTOS_LITTLE_ENDIAN
#define ipconfigUSE_NETWORK_EVENT_HOOK 1
#define ipconfigNUM_NETWORK_BUFFER_DESCRIPTORS 4 #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 #endif

View File

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

View File

@ -253,7 +253,7 @@ BaseType_t xPhyDiscover( EthernetPhy_t * pxPhyObject )
if( pxPhyObject->xPortCount > 0 ) 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; return pxPhyObject->xPortCount;
@ -308,7 +308,7 @@ static uint32_t xPhyReset( EthernetPhy_t * pxPhyObject,
if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE ) 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; break;
} }
@ -487,7 +487,7 @@ BaseType_t xPhyConfigure( EthernetPhy_t * pxPhyObject,
pxPhyObject->fnPhyWrite( xPhyAddress, phyREG_19_PHYCR, ulPhyControl ); 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. */ /* Keep these values for later use. */
@ -597,7 +597,7 @@ BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t * pxPhyObject,
if( xTaskCheckForTimeOut( &xTimer, &xRemainingTime ) != pdFALSE ) 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; break;
} }
@ -727,7 +727,7 @@ BaseType_t xPhyStartAutoNegotiation( EthernetPhy_t * pxPhyObject,
} }
FreeRTOS_printf( ( "Autonego ready: %08lx: %s duplex %u mbit %s status\n", FreeRTOS_printf( ( "Autonego ready: %08lx: %s duplex %u mbit %s status\n",
ulRegValue, (UBaseType_t)ulRegValue,
( ulRegValue & phyPHYSTS_DUPLEX_STATUS ) ? "full" : "half", ( ulRegValue & phyPHYSTS_DUPLEX_STATUS ) ? "full" : "half",
( ulRegValue & phyPHYSTS_SPEED_STATUS ) ? 10 : 100, ( ulRegValue & phyPHYSTS_SPEED_STATUS ) ? 10 : 100,
( ( ulPHYLinkStatus |= phyBMSR_LINK_STATUS ) != 0 ) ? "high" : "low" ) ); ( ( ulPHYLinkStatus |= phyBMSR_LINK_STATUS ) != 0 ) ? "high" : "low" ) );
@ -775,7 +775,7 @@ BaseType_t xPhyCheckLinkStatus( EthernetPhy_t * pxPhyObject,
if( ( pxPhyObject->ulLinkStatusMask & ulBitMask ) == 0UL ) if( ( pxPhyObject->ulLinkStatusMask & ulBitMask ) == 0UL )
{ {
pxPhyObject->ulLinkStatusMask |= ulBitMask; 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; xNeedCheck = pdTRUE;
} }
} }
@ -802,7 +802,7 @@ BaseType_t xPhyCheckLinkStatus( EthernetPhy_t * pxPhyObject,
pxPhyObject->ulLinkStatusMask &= ~( ulBitMask ); 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; xNeedCheck = pdTRUE;
} }
} }

View File

@ -208,7 +208,7 @@ void vAssertCalled(const char* pcFile,
* results in the wired network being used, while setting * results in the wired network being used, while setting
* configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being * configNETWORK_INTERFACE_TO_USE to 2 results in the wireless network being
* used. */ * 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 /* The address of an echo server that will be used by the two demo echo client
* tasks: * tasks:
@ -216,7 +216,7 @@ void vAssertCalled(const char* pcFile,
* https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html. */ * https://www.FreeRTOS.org/FreeRTOS-Plus/FreeRTOS_Plus_TCP/UDP_Echo_Clients.html. */
#define configECHO_SERVER_ADDR0 192 #define configECHO_SERVER_ADDR0 192
#define configECHO_SERVER_ADDR1 168 #define configECHO_SERVER_ADDR1 168
#define configECHO_SERVER_ADDR2 0 #define configECHO_SERVER_ADDR2 1
#define configECHO_SERVER_ADDR3 2 #define configECHO_SERVER_ADDR3 2
#define configTCP_ECHO_CLIENT_PORT 7 #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. */ * ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */
#define configIP_ADDR0 192 #define configIP_ADDR0 192
#define configIP_ADDR1 168 #define configIP_ADDR1 168
#define configIP_ADDR2 0 #define configIP_ADDR2 1
#define configIP_ADDR3 1 #define configIP_ADDR3 2
/* Default gateway IP address configuration. Used in ipconfigUSE_DHCP is set to /* 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. */ * 0, or ipconfigUSE_DHCP is set to 1 but a DNS server cannot be contacted. */
#define configGATEWAY_ADDR0 192 #define configGATEWAY_ADDR0 192
#define configGATEWAY_ADDR1 168 #define configGATEWAY_ADDR1 168
#define configGATEWAY_ADDR2 0 #define configGATEWAY_ADDR2 1
#define configGATEWAY_ADDR3 1 #define configGATEWAY_ADDR3 2
/* Default DNS server configuration. OpenDNS addresses are 208.67.222.222 and /* 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 * 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> <Name>UL2CM3(-S0 -C0 -P0 -FD20000000 -FC1000 -FN1 -FF0GD32F10x_CL -FS08000000 -FL040000 -FP0($$Device:GD32F107VC$Flash\GD32F10x_CL.FLM))</Name>
</SetRegEntry> </SetRegEntry>
</TargetDriverDllRegistry> </TargetDriverDllRegistry>
<Breakpoint> <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>
<WatchWindow1> <WatchWindow1>
<Ww> <Ww>
<count>0</count> <count>0</count>
@ -208,12 +175,17 @@
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<ItemText>PHY</ItemText> <ItemText>PHY</ItemText>
</Ww> </Ww>
<Ww>
<count>4</count>
<WinNumber>1</WinNumber>
<ItemText>frame</ItemText>
</Ww>
</WatchWindow1> </WatchWindow1>
<MemoryWindow1> <MemoryWindow1>
<Mm> <Mm>
<WinNumber>1</WinNumber> <WinNumber>1</WinNumber>
<SubType>0</SubType> <SubType>0</SubType>
<ItemText>0x40028014</ItemText> <ItemText>pxNetworkBuffer</ItemText>
<AccSizeX>0</AccSizeX> <AccSizeX>0</AccSizeX>
</Mm> </Mm>
</MemoryWindow1> </MemoryWindow1>
@ -234,7 +206,7 @@
</Mm> </Mm>
</MemoryWindow3> </MemoryWindow3>
<ScvdPack> <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> <Type>ARM.CMSIS-FreeRTOS.10.5.1</Type>
<SubType>1</SubType> <SubType>1</SubType>
</ScvdPack> </ScvdPack>
@ -285,7 +257,7 @@
<Group> <Group>
<GroupName>Source Group 1</GroupName> <GroupName>Source Group 1</GroupName>
<tvExp>1</tvExp> <tvExp>0</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -353,7 +325,7 @@
<Group> <Group>
<GroupName>FreeRTOS</GroupName> <GroupName>FreeRTOS</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>0</RteFlg> <RteFlg>0</RteFlg>
@ -373,7 +345,7 @@
<GroupNumber>2</GroupNumber> <GroupNumber>2</GroupNumber>
<FileNumber>7</FileNumber> <FileNumber>7</FileNumber>
<FileType>1</FileType> <FileType>1</FileType>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<bDave2>0</bDave2> <bDave2>0</bDave2>
<PathWithFileName>.\FreeRTOS\source\FreeRTOS_IP.c</PathWithFileName> <PathWithFileName>.\FreeRTOS\source\FreeRTOS_IP.c</PathWithFileName>
@ -665,7 +637,7 @@
<Group> <Group>
<GroupName>::Compiler</GroupName> <GroupName>::Compiler</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>1</RteFlg> <RteFlg>1</RteFlg>
@ -681,7 +653,7 @@
<Group> <Group>
<GroupName>::RTOS</GroupName> <GroupName>::RTOS</GroupName>
<tvExp>0</tvExp> <tvExp>1</tvExp>
<tvExpOptDlg>0</tvExpOptDlg> <tvExpOptDlg>0</tvExpOptDlg>
<cbSel>0</cbSel> <cbSel>0</cbSel>
<RteFlg>1</RteFlg> <RteFlg>1</RteFlg>

View File

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

48
main.c
View File

@ -3,6 +3,8 @@
#include "gd32f107c_eval.h" #include "gd32f107c_eval.h"
#include "gd32f10x_gpio.h" #include "gd32f10x_gpio.h"
#include "stdio.h" #include "stdio.h"
/* System application includes. */ /* System application includes. */
#include "FreeRTOSIPConfig.h" #include "FreeRTOSIPConfig.h"
@ -200,13 +202,7 @@ static void vInitMCU(void)
gpio_bit_set(LED5_TICK_PORT, LED5_TICK); gpio_bit_set(LED5_TICK_PORT, LED5_TICK);
/*Enable PLL2 to generate 50MHz clocks */ /*Enable PLL2 to generate 50MHz clocks */
if (ERROR == xInitPLL2()) if (ERROR == xInitPLL2()) FreeRTOS_debug_printf(("PLL2 initialization failed\n"));
{
#ifdef DEBUG
printf("PLL2 initialization failed\n");
__ASM("BKPT #0\n");
#endif
}
/* Put PLL2 clocks into CKOUT0(PA1) as ref clock for ethernet phy */ /* Put PLL2 clocks into CKOUT0(PA1) as ref clock for ethernet phy */
rcu_ckout0_config(RCU_CKOUT0SRC_CKPLL2); rcu_ckout0_config(RCU_CKOUT0SRC_CKPLL2);
@ -242,7 +238,7 @@ void vTaskHelloWorld( void *pvParameters)
ButtonState = !gpio_input_bit_get(GPIOB, BUTTON_USER); ButtonState = !gpio_input_bit_get(GPIOB, BUTTON_USER);
if (ButtonState) if (ButtonState)
{ {
printf("Hello world\n"); FreeRTOS_debug_printf(("Key pressed\n"));
fflush( stdout ); fflush( stdout );
vTaskDelay(TASK_HELLO_WORLD_DELAY); vTaskDelay(TASK_HELLO_WORLD_DELAY);
} }
@ -270,14 +266,16 @@ void vTaskToggleLed( void *pvParameters)
} }
} }
static void prvMiscInitialisation( void ) static void prvMiscInitialisation( void )
{ {
// time_t xTimeNow; unsigned long xTimeNow;
uint32_t ulRandomNumbers[ 4 ]; uint32_t ulRandomNumbers[ 4 ];
/* Seed the random number generator. */ /* Seed the random number generator. */
// time( &xTimeNow ); // 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 ); // prvSRand( ( uint32_t ) xTimeNow );
( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] ); ( void ) xApplicationGetRandomNumber( &ulRandomNumbers[ 0 ] );
@ -300,11 +298,35 @@ int main(void)
xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL); xTaskCreate( vTaskToggleLed, "ToggleLed", configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY+1, NULL);
xTaskCreate( vTaskHelloWorld, "HelloWorld", 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 ); FreeRTOS_IPInit( ucIPAddress, ucNetMask, ucGatewayAddress, ucDNSServerAddress, ucMACAddress );
// vStartSimpleTCPServerTasks( configMINIMAL_STACK_SIZE*2, tskIDLE_PRIORITY+1 ); enet_enable();
vTaskStartScheduler(); vTaskStartScheduler();
while(1); 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 ) * @brief vApplicationIPNetworkEventHook( eIPCallbackEvent_t eNetworkEvent )
*/ */
@ -563,8 +585,8 @@ extern uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
*/ */
void vApplicationMallocFailedHook( void ) void vApplicationMallocFailedHook( void )
{ {
FreeRTOS_debug_printf(("Malloc Failed Hook\n"));
#if defined (DEBUG) #if defined (DEBUG)
printf("Malloc Failed Hook\n");
__ASM("BKPT #0\n"); __ASM("BKPT #0\n");
#endif #endif
NVIC_SystemReset(); NVIC_SystemReset();
@ -602,7 +624,7 @@ void vApplicationIdleHook( void )
uint32_t currentTick = xTaskGetTickCount(); uint32_t currentTick = xTaskGetTickCount();
if(currentTick > idleHookCounter + delta) 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; idleHookCounter = currentTick;
#endif #endif
@ -613,8 +635,8 @@ void vApplicationIdleHook( void )
*/ */
void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName ) void vApplicationStackOverflowHook( TaskHandle_t pxTask, char *pcTaskName )
{ {
FreeRTOS_debug_printf(("Stack Overflow Hook\n"));
#if defined (DEBUG) #if defined (DEBUG)
printf("Stack Overflow Hook\n");
__ASM("BKPT #0\n"); __ASM("BKPT #0\n");
#endif #endif
NVIC_SystemReset(); NVIC_SystemReset();