/* * FreeRTOS Kernel V10.0.0 * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a copy of * this software and associated documentation files (the "Software"), to deal in * the Software without restriction, including without limitation the rights to * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of * the Software, and to permit persons to whom the Software is furnished to do so, * subject to the following conditions: * * The above copyright notice and this permission notice shall be included in all * copies or substantial portions of the Software. If you wish to use our Amazon * FreeRTOS name, please do so in a fair use way that does not cause confusion. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. * * http://www.FreeRTOS.org * http://aws.amazon.com/freertos * * 1 tab == 4 spaces! */#ifndefFREERTOS_CONFIG_H#defineFREERTOS_CONFIG_H/* Prevent Renesas headers redefining some stdint.h types. */#define__TYPEDEF__ 1
/*----------------------------------------------------------- * Application specific definitions. * * These definitions should be adjusted for your particular hardware and * application requirements. * * THESE PARAMETERS ARE DESCRIBED WITHIN THE 'CONFIGURATION' SECTION OF THE * FreeRTOS API DOCUMENTATION AVAILABLE ON THE FreeRTOS.org WEB SITE. * * See http://www.freertos.org/a00110.html. *----------------------------------------------------------*/#defineconfigUSE_PREEMPTION 1
#defineconfigUSE_IDLE_HOOK 1
#defineconfigUSE_TICK_HOOK 1
#defineconfigCPU_CLOCK_HZ (BSP_ICLK_HZ)
#defineconfigPERIPHERAL_CLOCK_HZ (BSP_PCLKB_HZ)
#defineconfigTICK_RATE_HZ (( TickType_t ) 1000)
#defineconfigMINIMAL_STACK_SIZE (( unsigned short ) 140)
#defineconfigTOTAL_HEAP_SIZE_N (128)
#defineconfigTOTAL_HEAP_SIZE (( size_t ) ( configTOTAL_HEAP_SIZE_N * 1024 ))
#defineconfigMAX_TASK_NAME_LEN (12)
#defineconfigUSE_TRACE_FACILITY 1
#defineconfigUSE_16_BIT_TICKS 0
#defineconfigIDLE_SHOULD_YIELD 1
#defineconfigUSE_CO_ROUTINES 0
#defineconfigUSE_MUTEXES 1
#defineconfigGENERATE_RUN_TIME_STATS 0
#defineconfigCHECK_FOR_STACK_OVERFLOW 2
#defineconfigUSE_RECURSIVE_MUTEXES 1
#defineconfigQUEUE_REGISTRY_SIZE 0
#defineconfigUSE_MALLOC_FAILED_HOOK 1
#defineconfigUSE_APPLICATION_TASK_TAG 0
#defineconfigUSE_QUEUE_SETS 1
#defineconfigUSE_COUNTING_SEMAPHORES 1
#defineconfigMAX_PRIORITIES (7)
#defineconfigMAX_CO_ROUTINE_PRIORITIES (2)
#defineconfigUSE_TASK_NOTIFICATIONS 1
#defineconfigRECORD_STACK_HIGH_ADDRESS 0
#defineconfigNUM_THREAD_LOCAL_STORAGE_POINTERS 0
/* Dynamic allocation and static allocation. */#defineconfigSUPPORT_DYNAMIC_ALLOCATION 1
#defineconfigSUPPORT_STATIC_ALLOCATION 0
/* Run time stats gathering definitions. */unsigned longulGetRunTimeCounterValue( void );
voidvConfigureTimerForRunTimeStats( void );
#defineconfigGENERATE_RUN_TIME_STATS 0
//#define portCONFIGURE_TIMER_FOR_RUN_TIME_STATS() vConfigureTimerForRunTimeStats()//#define portGET_RUN_TIME_COUNTER_VALUE() ulGetRunTimeCounterValue()/* Software timer definitions. */#defineconfigUSE_TIMERS 1
#defineconfigTIMER_TASK_PRIORITY (6)
#defineconfigTIMER_QUEUE_LENGTH 5
#defineconfigTIMER_TASK_STACK_DEPTH (configMINIMAL_STACK_SIZE)
/* The interrupt priority used by the kernel itself for the tick interrupt andthe pended interrupt. This would normally be the lowest priority. */#defineconfigKERNEL_INTERRUPT_PRIORITY 1
/* The maximum interrupt priority from which FreeRTOS API calls can be made.Interrupts that use a priority above this will not be effected by anything thekernel is doing. */#defineconfigMAX_SYSCALL_INTERRUPT_PRIORITY 4
/* The peripheral used to generate the tick interrupt is configured as part ofthe application code. This constant should be set to the vector number of theperipheral chosen. As supplied this is CMT0. */#defineconfigTICK_VECTOR _CMT0_CMI0
/* Set the following definitions to 1 to include the API function, or zeroto exclude the API function. */#defineINCLUDE_vTaskPrioritySet 1
#defineINCLUDE_uxTaskPriorityGet 1
#defineINCLUDE_vTaskDelete 1
#defineINCLUDE_vTaskCleanUpResources 0
#defineINCLUDE_vTaskSuspend 1
#defineINCLUDE_vTaskDelayUntil 1
#defineINCLUDE_vTaskDelay 1
#defineINCLUDE_uxTaskGetStackHighWaterMark 1
#defineINCLUDE_xTaskGetSchedulerState 1
#defineINCLUDE_eTaskGetState 1
#defineINCLUDE_xTimerPendFunctionCall 1
voidvAssertCalled( void );
#defineconfigASSERT( x ) if( ( x ) == 0 ) vAssertCalled()
/* Override some of the priorities set in the common demo tasks. This isrequired to ensure flase positive timing errors are not reported. */#definebktPRIMARY_PRIORITY (( configMAX_PRIORITIES - 3 ))
#definebktSECONDARY_PRIORITY (( configMAX_PRIORITIES - 4 ))
#defineintqHIGHER_PRIORITY (( configMAX_PRIORITIES - 3 ))
/*----------------------------------------------------------- * Ethernet configuration. *-----------------------------------------------------------*//* MAC address configuration. */#defineconfigMAC_ADDR0 0x74
#defineconfigMAC_ADDR1 0x90
#defineconfigMAC_ADDR2 0x50
#defineconfigMAC_ADDR3 0x00
#defineconfigMAC_ADDR4 0x79
#defineconfigMAC_ADDR5 0x03
/* IP address configuration. */#defineconfigIP_ADDR0 192
#defineconfigIP_ADDR1 168
#defineconfigIP_ADDR2 0
#defineconfigIP_ADDR3 200
/* Netmask configuration. */#defineconfigNET_MASK0 255
#defineconfigNET_MASK1 255
#defineconfigNET_MASK2 255
#defineconfigNET_MASK3 0
/* 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. */#defineconfigGATEWAY_ADDR0 10
#defineconfigGATEWAY_ADDR1 136
#defineconfigGATEWAY_ADDR2 247
#defineconfigGATEWAY_ADDR3 254
/* 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 * set to 1 but a DNS server cannot be contacted.*/#defineconfigDNS_SERVER_ADDR0 172
#defineconfigDNS_SERVER_ADDR1 23
#defineconfigDNS_SERVER_ADDR2 84
#defineconfigDNS_SERVER_ADDR3 110
/* When the FIT configurator or the Smart Configurator is used, platform.h has to be used. */#defineconfigINCLUDE_PLATFORM_H_INSTEAD_OF_IODEFINE_H 1
#endif/* FREERTOS_CONFIG_H */
/src/rx65n_rsk_freertos_tcp.c
/************************************************************************* FILE : rx65n_rsk_freertos_tcp.c* DATE : 2021-11-24* DESCRIPTION : Main Program** NOTE:THIS IS A TYPICAL EXAMPLE.************************************************************************/#include"FreeRTOS.h"#include"FreeRTOS_IP.h"#include"FreeRTOSIPConfig.h"#include"task.h"staticconstuint8_tucIPAddress[ 4 ] =
{
configIP_ADDR0,
configIP_ADDR1,
configIP_ADDR2,
configIP_ADDR3
};
staticconstuint8_tucNetMask[ 4 ] =
{
configNET_MASK0,
configNET_MASK1,
configNET_MASK2,
configNET_MASK3
};
staticconstuint8_tucGatewayAddress[ 4 ] =
{
configGATEWAY_ADDR0,
configGATEWAY_ADDR1,
configGATEWAY_ADDR2,
configGATEWAY_ADDR3
};
/* The following is the address of an OpenDNS server. */staticconstuint8_tucDNSServerAddress[ 4 ] =
{
configDNS_SERVER_ADDR0,
configDNS_SERVER_ADDR1,
configDNS_SERVER_ADDR2,
configDNS_SERVER_ADDR3
};
staticuint8_tucMACAddress[ 6 ] =
{
configMAC_ADDR0,
configMAC_ADDR1,
configMAC_ADDR2,
configMAC_ADDR3,
configMAC_ADDR4,
configMAC_ADDR5
}; //XXXvoidmain_task(void*pvParameters)
{
/* Create all other application tasks here */FreeRTOS_IPInit( ucIPAddress,
ucNetMask,
ucGatewayAddress,
ucDNSServerAddress,
ucMACAddress );
while(1)
{
vTaskDelay(1);
}
vTaskDelete(NULL);
}
uint32_tulApplicationGetNextSequenceNumber( uint32_tulSourceAddress,
uint16_tusSourcePort,
uint32_tulDestinationAddress,
uint16_tusDestinationPort )
{
uint32_trandom;
xApplicationGetRandomNumber(&random);
returnrandom;
}
BaseType_txApplicationGetRandomNumber( uint32_t*pulNumber )
{
staticuint32_ty=2463534242;
staticuint32_t*z= (uint32_t*)&ucMACAddress[0];
uint32_tres;
uint32_tlp;
uint8_t*bPtr;
uint32_tlen=4;
if(z!=NULL)
{
y ^= *z;
z=NULL;
}
res=len / 4;
/* WAIT_LOOP */for (lp=0; lp<res; lp++)
{
y=y ^ (y << 13);
y=y ^ (y >> 17);
y=y ^ (y << 5);
bPtr= (uint8_t*) &y;
#if__LIT*((uint32_t*)pulNumber) = (*(bPtr+3) << 24) | (*(bPtr+2) << 16) | (*(bPtr+1) << 8) | *(bPtr+0);
#else*((uint32_t*)data) =y;
#endifpulNumber+=4;
}
y=y ^ (y << 13);
y=y ^ (y >> 17);
y=y ^ (y << 5);
res= (uint32_t)len % 4;
bPtr= (uint8_t*) &y;
switch (res)
{
case3:
#if__LIT*pulNumber++=bPtr[3];
*pulNumber++=bPtr[2];
*pulNumber++=bPtr[1];
#else*pulNumber++=bPtr[0];
*pulNumber++=bPtr[1];
*pulNumber++=bPtr[2];
#endifbreak;
case2:
#if__LIT*pulNumber++=bPtr[3];
*pulNumber++=bPtr[2];
#else*pulNumber++=bPtr[0];
*pulNumber++=bPtr[1];
#endifbreak;
case1:
#if__LIT*pulNumber++=bPtr[3];
#else*pulNumber++=bPtr[0];
#endifbreak;
default:
/* no op */break;
}
returnpdTRUE;
}
constchar*pcApplicationHostnameHook( void )
{
/* This function will be called during the DHCP: the machine will be registered * with an IP address plus this name. */return"RX65NRSK";
}
voidvApplicationIPNetworkEventHook( eIPCallbackEvent_teNetworkEvent )
{
staticBaseType_txTasksAlreadyCreated=pdFALSE;
uint32_tulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
charcBuffer[ 16 ];
/* If the network has just come up...*/if( ( eNetworkEvent==eNetworkUp ) && ( xTasksAlreadyCreated==pdFALSE ) )
{
xTasksAlreadyCreated=pdTRUE;
/* Print out the network configuration, which may have come from a DHCP * server. */FreeRTOS_GetAddressConfiguration( &ulIPAddress, &ulNetMask, &ulGatewayAddress, &ulDNSServerAddress );
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
FreeRTOS_printf( ( "\r\n\r\nIP Address: %s\r\n", cBuffer ) );
FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
FreeRTOS_printf( ( "Subnet Mask: %s\r\n", cBuffer ) );
FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
FreeRTOS_printf( ( "Gateway Address: %s\r\n", cBuffer ) );
FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
FreeRTOS_printf( ( "DNS Server Address: %s\r\n\r\n\r\n", cBuffer ) );
}
}