Skip to content

Commit

Permalink
compliance
Browse files Browse the repository at this point in the history
  • Loading branch information
Peter-Herrmann committed Sep 16, 2023
1 parent fa491d1 commit 9dc12dc
Show file tree
Hide file tree
Showing 6 changed files with 182 additions and 216 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -54,3 +54,4 @@ dkms.conf
SAME70-FreeRTOS-Plus-TCP/Debug
jlink.*
.vs
.clang-format
21 changes: 9 additions & 12 deletions SAME70-FreeRTOS-Plus-TCP/src/app/LED_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,16 @@

#include "LED_task.h"


#define LED_STAT IOPORT_CREATE_PIN(PIOC , 8)

#define LED_STAT IOPORT_CREATE_PIN(PIOC, 8)

void LED_task(void *pvParameters)
{
UNUSED(pvParameters);
ioport_set_pin_dir(LED_STAT, IOPORT_DIR_OUTPUT);
for (;;)
{
ioport_toggle_pin_level(LED_STAT);
//printf(" .");
vTaskDelay(100);
}
UNUSED(pvParameters);
ioport_set_pin_dir(LED_STAT, IOPORT_DIR_OUTPUT);
for (;;)
{
ioport_toggle_pin_level(LED_STAT);
// printf(" .");
vTaskDelay(100);
}
}

87 changes: 36 additions & 51 deletions SAME70-FreeRTOS-Plus-TCP/src/app/hooks.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,20 @@
//// FreeRTOS Kernel Hooks ////
///////////////////////////////

extern void vApplicationStackOverflowHook(xTaskHandle *pxTask, signed char *pcTaskName)
extern void vApplicationStackOverflowHook(xTaskHandle *pxTask,
signed char *pcTaskName)
{
for (;;) { }
for (;;) {}
}


extern void vApplicationMallocFailedHook(void)
{
for (;;) { }
for (;;) {}
}

extern void vApplicationIdleHook(void) {}

extern void vApplicationIdleHook(void) { /* */ }
extern void vApplicationTickHook(void) { /* */ }

extern void vApplicationTickHook(void) {}

///////////////////////////////
//// Random Number Utility ////
Expand All @@ -33,101 +32,87 @@ extern void vApplicationTickHook(void) { /* */ }
static UBaseType_t ulNextRand;

/* Generate psuedo-random number. Must be seeded first with vSeedRand(). */
UBaseType_t uxRand( void )
UBaseType_t uxRand(void)
{
const uint32_t ulMultiplier = 0x015a4e35UL, ulIncrement = 1UL;

ulNextRand = ( ulMultiplier * ulNextRand ) + ulIncrement;
return( ( int ) ( ulNextRand >> 16UL ) & 0x7fffUL );
ulNextRand = (ulMultiplier * ulNextRand) + ulIncrement;
return ((int)(ulNextRand >> 16UL) & 0x7fffUL);
}


/* Set the seed for use with uxRand() */
void vSeedRand( UBaseType_t ulSeed )
{
ulNextRand = ulSeed;
}

void vSeedRand(UBaseType_t ulSeed) { ulNextRand = ulSeed; }

//////////////////////////////
//// FreeRTOS + TCP Hooks ////
//////////////////////////////


uint32_t ulApplicationGetNextSequenceNumber( uint32_t ulSourceAddress,
uint16_t usSourcePort,
uint32_t ulDestinationAddress,
uint16_t usDestinationPort )
uint32_t ulApplicationGetNextSequenceNumber(uint32_t ulSourceAddress,
uint16_t usSourcePort,
uint32_t ulDestinationAddress,
uint16_t usDestinationPort)
{
return uxRand();
}


BaseType_t xApplicationGetRandomNumber( uint32_t * pulNumber )
BaseType_t xApplicationGetRandomNumber(uint32_t *pulNumber)
{
return (BaseType_t) uxRand();
return (BaseType_t)uxRand();
}


void vApplicationIPNetworkEventHook_Multi(eIPCallbackEvent_t eNetworkEvent,
void vApplicationIPNetworkEventHook_Multi(eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint *pxEndPoint)
{
uint32_t ulIPAddress, ulNetMask, ulGatewayAddress, ulDNSServerAddress;
char cBuffer[ 16 ];
char cBuffer[16];
static BaseType_t xTasksAlreadyCreated = pdFALSE;

FreeRTOS_printf( ( "vApplicationIPNetworkEventHook: event %ld\n", eNetworkEvent ) );
FreeRTOS_printf(
("vApplicationIPNetworkEventHook: event %ld\n", eNetworkEvent));

/* If the network has just come up...*/
if( eNetworkEvent == eNetworkUp )
if (eNetworkEvent == eNetworkUp)
{
if( xTasksAlreadyCreated == pdFALSE )

if (xTasksAlreadyCreated == pdFALSE)
{
/* Create tasks dependent on NetworkUp here */
xTasksAlreadyCreated = pdTRUE;
}

/* Print ipconfig to console */
FreeRTOS_GetEndPointConfiguration( &ulIPAddress,
&ulNetMask,
&ulGatewayAddress,
&ulDNSServerAddress,
pxEndPoint);
FreeRTOS_inet_ntoa( ulIPAddress, cBuffer );
FreeRTOS_GetEndPointConfiguration(&ulIPAddress, &ulNetMask,
&ulGatewayAddress,
&ulDNSServerAddress, pxEndPoint);
FreeRTOS_inet_ntoa(ulIPAddress, cBuffer);
printf("\r\n\nIP Address: ");
printf("%s", cBuffer);

FreeRTOS_inet_ntoa( ulNetMask, cBuffer );
FreeRTOS_inet_ntoa(ulNetMask, cBuffer);
printf("\r\nSubnet Mask: ");
printf("%s", cBuffer);

FreeRTOS_inet_ntoa( ulGatewayAddress, cBuffer );
FreeRTOS_inet_ntoa(ulGatewayAddress, cBuffer);
printf("\r\nGateway Address: ");
printf("%s", cBuffer);

FreeRTOS_inet_ntoa( ulDNSServerAddress, cBuffer );
FreeRTOS_inet_ntoa(ulDNSServerAddress, cBuffer);
printf("\r\nDNS Server Address: ");
printf("%s", cBuffer);
}
}


BaseType_t xApplicationDNSQueryHook( const char *pcName )
BaseType_t xApplicationDNSQueryHook(const char *pcName)
{
return strcmp(pcName, pcApplicationHostnameHook()) ? pdFAIL : pdPASS;
}


BaseType_t xApplicationDNSQueryHook_Multi(struct xNetworkEndPoint * pxEndPoint,
const char * pcName)
BaseType_t xApplicationDNSQueryHook_Multi(struct xNetworkEndPoint *pxEndPoint,
const char *pcName)
{
/* DNS hooks can be handled differently for different network interfaces here */
/* DNS hooks can be handled differently for different network interfaces
* here */
return strcmp(pcName, pcApplicationHostnameHook()) ? pdFAIL : pdPASS;
}


const char *pcApplicationHostnameHook( void )
{
return mainHOST_NAME;
}
const char *pcApplicationHostnameHook(void) { return mainHOST_NAME; }
5 changes: 2 additions & 3 deletions SAME70-FreeRTOS-Plus-TCP/src/app/include/LED_task.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,9 @@

#include "main.h"

#define TASK_LED_STACK_SIZE (1024/sizeof(portSTACK_TYPE))
#define TASK_LED_STACK_PRIORITY (tskIDLE_PRIORITY)
#define TASK_LED_STACK_SIZE (1024 / sizeof(portSTACK_TYPE))
#define TASK_LED_STACK_PRIORITY (tskIDLE_PRIORITY)

void LED_task(void *pvParameters);


#endif /* LED_TASK_H_ */
41 changes: 19 additions & 22 deletions SAME70-FreeRTOS-Plus-TCP/src/app/include/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@

/* FreeRTOS Kernel */
#include <FreeRTOS.h>
#include <stack_macros.h>
#include <croutine.h>
#include <deprecated_definitions.h>
#include <event_groups.h>
Expand All @@ -24,57 +23,55 @@
#include <task.h>
#include <timers.h>
/* FreeRTOS Plus TCP */
#include "FreeRTOS_ARP.h"
#include "FreeRTOS_DHCP.h"
#include "FreeRTOS_IP.h"
#include "FreeRTOS_Sockets.h"
#include "FreeRTOS_DHCP.h"
#include "NetworkBufferManagement.h"
#include "FreeRTOS_ARP.h"
#include "NetworkInterface.h"
#include "gmac_SAM.h"
#if( ipconfigUSE_IPv6 != 0 )
#if (ipconfigUSE_IPv6 != 0)
#include "FreeRTOS_ND.h"
#endif
#if( USE_LOG_EVENT != 0 )
#if (USE_LOG_EVENT != 0)
#include "eventLogging.h"
#endif
#if( ipconfigMULTI_INTERFACE != 0 )
#if (ipconfigMULTI_INTERFACE != 0)
#include "FreeRTOS_Routing.h"
#endif
/* Standard Library */
#include <stdio.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
/* ASF */
#include "asf.h"
#include "stdio_serial.h"
#include "conf_board.h"
#include "conf_clock.h"

#include "stdio_serial.h"

#define mainHOST_NAME BOARD_NAME


void vSeedRand( UBaseType_t ulSeed );
void vSeedRand(UBaseType_t ulSeed);

/* FreeRTOS Kernel Hooks */
extern void vApplicationStackOverflowHook(xTaskHandle *pxTask, signed char *pcTaskName);
extern void vApplicationStackOverflowHook(xTaskHandle *pxTask,
signed char *pcTaskName);
extern void vApplicationIdleHook(void);
extern void vApplicationTickHook(void);
extern void vApplicationMallocFailedHook(void);
extern void xPortSysTickHandler(void);

/* FreeRTOS+TCP Library Hooks */
extern BaseType_t xApplicationGetRandomNumber(uint32_t *pulNumber);
extern uint32_t ulApplicationGetNextSequenceNumber(uint32_t ulSourceAddress,
uint16_t usSourcePort,
uint32_t ulDestinationAddress,
uint16_t usDestinationPort);
extern uint32_t ulApplicationGetNextSequenceNumber(
uint32_t ulSourceAddress, uint16_t usSourcePort,
uint32_t ulDestinationAddress, uint16_t usDestinationPort);
extern BaseType_t xApplicationDNSQueryHook(const char *pcName);
extern BaseType_t xApplicationDNSQueryHook_Multi(struct xNetworkEndPoint *pxEndPoint,
const char *pcName);
extern void vApplicationIPNetworkEventHook_Multi(eIPCallbackEvent_t eNetworkEvent,
struct xNetworkEndPoint *pxEndPoint );
extern NetworkInterface_t * pxSAM_FillInterfaceDescriptor(BaseType_t xEMACIndex,
NetworkInterface_t * pxInterface );
extern BaseType_t xApplicationDNSQueryHook_Multi(
struct xNetworkEndPoint *pxEndPoint, const char *pcName);
extern void vApplicationIPNetworkEventHook_Multi(
eIPCallbackEvent_t eNetworkEvent, struct xNetworkEndPoint *pxEndPoint);
extern NetworkInterface_t *pxSAM_FillInterfaceDescriptor(
BaseType_t xEMACIndex, NetworkInterface_t *pxInterface);

#endif /* MAIN_H_ */
Loading

0 comments on commit 9dc12dc

Please sign in to comment.