message_buffer.h
Go to the documentation of this file.
/*
* 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!
*/
/*
* Message buffers build functionality on top of FreeRTOS stream buffers.
* Whereas stream buffers are used to send a continuous stream of data from one
* task or interrupt to another, message buffers are used to send variable
* length discrete messages from one task or interrupt to another. Their
* implementation is light weight, making them particularly suited for interrupt
* to task and core to core communication scenarios.
*
* ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
* implementation (so also the message buffer implementation, as message buffers
* are built on top of stream buffers) assumes there is only one task or
* interrupt that will write to the buffer (the writer), and only one task or
* interrupt that will read from the buffer (the reader). It is safe for the
* writer and reader to be different tasks or interrupts, but, unlike other
* FreeRTOS objects, it is not safe to have multiple different writers or
* multiple different readers. If there are to be multiple different writers
* then the application writer must place each call to a writing API function
* (such as xMessageBufferSend()) inside a critical section and set the send
* block time to 0. Likewise, if there are to be multiple different readers
* then the application writer must place each call to a reading API function
* (such as xMessageBufferRead()) inside a critical section and set the receive
* timeout to 0.
*
* Message buffers hold variable length messages. To enable that, when a
* message is written to the message buffer an additional sizeof( size_t ) bytes
* are also written to store the message's length (that happens internally, with
* the API function). sizeof( size_t ) is typically 4 bytes on a 32-bit
* architecture, so writing a 10 byte message to a message buffer on a 32-bit
* architecture will actually reduce the available space in the message buffer
* by 14 bytes (10 byte are used by the message, and 4 bytes to hold the length
* of the message).
*/
#ifndef FREERTOS_MESSAGE_BUFFER_H
#define FREERTOS_MESSAGE_BUFFER_H
/* Message buffers are built onto of stream buffers. */
#include "stream_buffer.h"
#if defined( __cplusplus )
extern "C" {
#endif
typedef void * MessageBufferHandle_t;
/*-----------------------------------------------------------*/
#define xMessageBufferCreate( xBufferSizeBytes ) ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE )
#define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer )
#define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait )
#define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken )
#define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait )
#define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken )
#define vMessageBufferDelete( xMessageBuffer ) vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer )
#define xMessageBufferIsFull( xMessageBuffer ) xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer )
#define xMessageBufferIsEmpty( xMessageBuffer ) xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer )
#define xMessageBufferReset( xMessageBuffer ) xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer )
#define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer )
#define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken )
#define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken )
#if defined( __cplusplus )
} /* extern "C" */
#endif
#endif /* !defined( FREERTOS_MESSAGE_BUFFER_H ) */
main
int main(void)
app entry point
Definition: Main.c:26
vTask_FsmTape
void vTask_FsmTape(void *pvParameters)
run FSM for Tape
Definition: Threads.c:52
vDisplayTask
void vDisplayTask(void *pvParameters)
Definition: displaytask.c:4
portTICK_RATE_MS
#define portTICK_RATE_MS
Definition: FreeRTOS.h:913
GLCD_Command::eDisplayCommand
enum DisplayCommand eDisplayCommand
Definition: displaytask.h:99
ES2_V4_app.h
global header file for project
vTaskStartScheduler
void vTaskStartScheduler(void) PRIVILEGED_FUNCTION
Definition: tasks.c:1900
vTask_FsmVCR
void vTask_FsmVCR(void *pvParameters)
run FSM for VCR
Definition: Threads.c:19
vApplicationIdleHook
void vApplicationIdleHook(void)
count cycles for idle task
Definition: Main.c:134
xQueueTape
void * xQueueTape
Definition: Globals.c:14
cmd_GLCD_SetBackgroundColor
@ cmd_GLCD_SetBackgroundColor
Definition: displaytask.h:12
TickType_t
uint32_t TickType_t
Definition: portmacro.h:64
vAppboard2ButtonsInitialize
void vAppboard2ButtonsInitialize(void)
Initialization of all buttons of Application Board 2.
Definition: AppBoard2Buttons.c:35
cmd_GLCD_SetForegroundColor
@ cmd_GLCD_SetForegroundColor
Definition: displaytask.h:11
GLCD_Command
Definition: displaytask.h:98
cmd_GLCD_Initialize
@ cmd_GLCD_Initialize
Definition: displaytask.h:9
cmd_GLCD_SetFont
@ cmd_GLCD_SetFont
Definition: displaytask.h:14
GLCD_Font_16x24
GLCD_FONT GLCD_Font_16x24
xQueueVCR
void * xQueueVCR
Definition: Globals.c:13
vMainInitApp
static void vMainInitApp(void)
initialize app
Definition: Main.c:50
vTask_Read_Buttons
void vTask_Read_Buttons(void *pvParameters)
read buttons and store events in queue
Definition: Threads.c:84
bFsmTapeInitialize
_Bool bFsmTapeInitialize(void)
init Tape FSM
Definition: FsmTape.c:55
MessageBufferHandle_t
void * MessageBufferHandle_t
Definition: message_buffer.h:79
xTaskGetTickCount
TickType_t xTaskGetTickCount(void) PRIVILEGED_FUNCTION
Definition: tasks.c:2214
bFsmVCRInitialize
_Bool bFsmVCRInitialize(void)
init VCR FSM
Definition: FsmVCR.c:87
xQueueDisplay
void * xQueueDisplay
Definition: Globals.c:15
stream_buffer.h
cmd_GLCD_DrawString
@ cmd_GLCD_DrawString
Definition: displaytask.h:20
cmd_GLCD_ClearScreen
@ cmd_GLCD_ClearScreen
Definition: displaytask.h:13
u32IdleCycleCount
volatile uint32_t u32IdleCycleCount
Definition: Main.c:16
xQueueSend
#define xQueueSend(xQueue, pvItemToQueue, xTicksToWait)
Definition: queue.h:478