Quality RTOS & Embedded Software

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




Loading

What's the CORRECT way to send a Queue message from another module?

Posted by groger57 on May 1, 2015

Instead of asking what's WRONG with my code, can someone please point me to an example, or provide an example, of the correct way to use xQueueSend from a module other than where the queue handle and function handler are defined?

I'm using FreeeRTOS 8.2.0, in IAR EWARM 7.3, on an STM32F4 controller. I am unable to find an example on the entire web that shows this, and it just happens to be giving me a big headache right now.

Thank you...


What's the CORRECT way to send a Queue message from another module?

Posted by rtel on May 1, 2015

It shouldn't make any difference which module the queue handle is defined in. A queue handle is just a variable, so it can be declared in one C file, and then extern'ed in another C file, just like any other variable.

File1.c


/* Declared globally. */
QueueHandle_t xQueue = NULL;

int main( void ) { . . .

xQueue = xQueueCreate( 5, sizeof( uint32_t ) );

. . .

/* Start tasks. */

. . .

/* Start scheduler. */ }

void vTask1InFile1( void *pvParameters ) { uint32t DataToSend = 0, DataToReceive; const TickTypet xBlockTime = pdMSTOTICKS( 200 );

for( ;; )
{
    . . .

    xQueueSend( xQueue, &DataToSend, xBlockTime );

    . . .

    xQueueReceive( xQueue, &DataToReceive, xBlockTime );
}

}

File2.c


void vTask2InFile2( void pvParameters )
{
/ Here the queue handle is extern. */
extern QueueHandle_t xQueue;

uint32t DataToSend = 0, DataToReceive; const TickTypet xBlockTime = pdMSTOTICKS( 200 );

for( ;; )
{
    . . .

    xQueueSend( xQueue, &DataToSend, xBlockTime );

    . . .

    xQueueReceive( xQueue, &DataToReceive, xBlockTime );
}

}

Regards.


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




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

Latest News

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


FreeRTOS Partners

ARM Connected RTOS partner for all ARM microcontroller cores

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