Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Real time embedded FreeRTOS mailing list 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem TCP & FAT Training




Loading

initialization of PhyProperties_t

Posted by josesimoes on February 29, 2016

Hi,

I'm testing the FREERTOS+TCP implementation with an STM32F407. I've run into the following issue when building with GCC (5.1):

error: NetworkInterface.cpp:289:1: sorry, unimplemented : non-trivial designated initializers not supported };

It turns out to be an issue with using C initializers with C++.

I've moved the initializers into the struct definition, remove the const PhyProperties_t xPHYProperties declaration and called the initilizer in vMACBProbePhy. All this seem to have made the compiler happy.

~~~~ typedef struct PhyPropertiest { uint8t speed; uint8t mdix; uint8t duplex; uint8t spare;

void  intialize()
{
    #if( ipconfigETHERNET_AN_ENABLE != 0 )
        speed = PHY_SPEED_AUTO;
        duplex = PHY_DUPLEX_AUTO;
    #else
        #if( ipconfigETHERNET_USE_100MB != 0 )
            speed = PHY_SPEED_100;
        #else
            speed = PHY_SPEED_10;
        #endif

        #if( ipconfigETHERNET_USE_FULL_DUPLEX != 0 )
            duplex = PHY_DUPLEX_FULL;
        #else
            duplex = PHY_DUPLEX_HALF;
        #endif
    #endif

    #if( ipconfigETHERNET_AN_ENABLE != 0 ) && ( ipconfigETHERNET_AUTO_CROSS_ENABLE != 0 )
        mdix = PHY_MDIX_AUTO;
    #elif( ipconfigETHERNET_CROSSED_LINK != 0 )
        mdix = PHY_MDIX_CROSSED;
    #else
        mdix = PHY_MDIX_DIRECT;
    #endif
}

} PhyProperties_t; ~~~~

~~~~ void vMACBProbePhy( void ) { uint32t ulPhyControl, ulConfig, ulAdvertise, ulLower, ulUpper, ulMACPhyID, ulValue; TimeOutt xPhyTime; TickType_t xRemTime = 0;

/* For local use only: describe the PHY's properties: */
PhyProperties_t xPHYProperties;
xPHYProperties.intialize();

HAL_ETH_ReadPHYRegister(&xETH, PHY_REG_03_PHYSID2, &ulLower);
...

~~~~


initialization of PhyProperties_t

Posted by josesimoes on February 29, 2016

Forget this. I just realized that I had changed the NetworkInterface.c to NetworkInterface.cpp for some testing and, obviouslly the struct initializers wouldn't work.


initialization of PhyProperties_t

Posted by heinbali01 on February 29, 2016

No problem.

The struct initialisers, in my opinion, was something very useful that was dropped in C++.

Maybe because they were rarely used.

Here is an example of an array:

~~~~ Topologyt xTopologies[ XPARXEMACPSNUMINSTANCES ] = { [0] = { .emacbaseaddr = XPARPS7ETHERNET0BASEADDR, .emactype = xemactypeemacps, }, [1] = { .emacbaseaddr = XPARPS7ETHERNET1BASEADDR, .emactype = xemactypeemacps, }, }; ~~~~

All fields not mentioned will default to zero, great!

Within C++, this would be the unsafe surrogate:

~~~~ Topologyt xTopologies[ XPARXEMACPSNUMINSTANCES ] = { { XPARPS7ETHERNET0BASEADDR, xemactypeemacps, }, { XPARPS7ETHERNET1BASEADDR, xemactypeemacps, }, }; ~~~~

it just assumes that emac_baseaddr and emac_type are the first two fields of the struct.

Regards, Hein


[ Back to the top ]    [ About FreeRTOS ]    [ Sitemap ]    [ ]




Copyright (C) 2004-2010 Richard Barry. Copyright (C) 2010-2016 Real Time Engineers Ltd.
Any and all data, files, source code, html content and documentation included in the FreeRTOSTM distribution or available on this site are the exclusive property of Real Time Engineers Ltd.. See the files license.txt (included in the distribution) and this copyright notice for more information. FreeRTOSTM and FreeRTOS.orgTM are trade marks of Real Time Engineers Ltd.

Latest News:

FreeRTOS V9.0.0 is now available for download.


Free TCP/IP and file system demos for the RTOS


Sponsored Links

⇓ Now With No Code Size Limit! ⇓
⇑ Free Download Without Registering ⇑


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Renesas Electronics Gold Alliance RTOS Partner.jpg

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

Atmel RTOS partner supporting ARM Cortex-M3 and AVR32 microcontrollers

STMicro RTOS partner supporting ARM7, ARM Cortex-M3, ARM Cortex-M4 and ARM Cortex-M0

Xilinx Microblaze and Zynq partner

Silicon Labs low power RTOS partner

Altera RTOS partner for Nios II and Cortex-A9 SoC

Freescale Alliance RTOS Member supporting ARM and ColdFire microcontrollers

Infineon ARM Cortex-M microcontrollers

Texas Instruments MCU Developer Network RTOS partner for ARM and MSP430 microcontrollers

Cypress RTOS partner supporting ARM Cortex-M3

Fujitsu RTOS partner supporting ARM Cortex-M3 and FM3

Microsemi (previously Actel) RTOS partner supporting ARM Cortex-M3

Atollic Partner

IAR Partner

Keil ARM Partner

Embedded Artists