Quality RTOS & Embedded Software

 Real time embedded FreeRTOS RSS feed 
Quick Start Supported MCUs PDF Books Trace Tools Ecosystem


Loading

vApplicationIdleHook in a C++ application

Posted by stanislaus123 on January 5, 2018

I am using ZYNQ on a MicroZed My application is defined as a C++ application ! Below is the absolute minimum program

void vApplicationIdleHook( void );

void MyTask(void* param) { for(;;){ print("blah blahn"); vTaskDelay(100); } } void vApplicationIdleHook( void ) { int i=0; for(;;){ i++; //In my application will never be called }

int main() { xTaskCreate( MyTask, "MyTask", 1024, NULL, 2, NULL); vTaskStartScheduler(); for(;;) return 0; }

FreeRTOS provides an idle task function called void vApplicationIdleHook( void ) attribute((weak)); //in portZynq7000.c To enable the idle function you must

define configUSEIDLEHOOK 1 //in FreeRTOSConfig.h

Since the idle hook function is declared as "weak", I should be able to override it inside my own application simply by declaring and defining it again like usual This works just fine in C and the linker will give me NO error, but it does not work when the main application was created as a C++ application like main.cc The overridden function will not be called, but instead the weak function in portZynq7000.c will be called.

Does anybody know a simple trick to make this work in a simple manner?

Thanks Kurt


vApplicationIdleHook in a C++ application

Posted by rtel on January 5, 2018

Does anybody know a simple trick to make this work in a simple manner?

No, I don't, but sure the C++ folks here will have a more knowledgeable answer....that said, is portZynq7000.c being compiled as C or C++? If it were compiled as C, or extern "C" were used, then maybe it would work?


vApplicationIdleHook in a C++ application

Posted by richard_damon on January 5, 2018

For FreeRTOS callback functions yoou need to define them something like:

extern "C" { void vApplicationIdleHook( void ); }

To force name mangling off for the function. You can either include the full defintion of the function inside the extern "C" block or just a forward decleration.


vApplicationIdleHook in a C++ application

Posted by stanislaus123 on January 5, 2018

Thanks Richard (both of them) this actually does work

Kurt


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


Copyright (C) Amazon Web Services, Inc. or its affiliates. All rights reserved.

Careers

FreeRTOS and other careers at AWS.


Latest News

FreeRTOS kernel V10.0.1 is available for immediate download. Now MIT licensed.


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

Espressif ESP32

IAR Partner

Microchip Premier RTOS Partner

RTOS partner of NXP for all NXP ARM microcontrollers

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

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

OpenRTOS and SafeRTOS

Xilinx Microblaze and Zynq partner