Labor04
message_buffer.h
Go to the documentation of this file.
1 /*
2  * FreeRTOS Kernel V10.0.0
3  * Copyright (C) 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a copy of
6  * this software and associated documentation files (the "Software"), to deal in
7  * the Software without restriction, including without limitation the rights to
8  * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
9  * the Software, and to permit persons to whom the Software is furnished to do so,
10  * subject to the following conditions:
11  *
12  * The above copyright notice and this permission notice shall be included in all
13  * copies or substantial portions of the Software. If you wish to use our Amazon
14  * FreeRTOS name, please do so in a fair use way that does not cause confusion.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18  * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19  * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20  * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21  * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22  *
23  * http://www.FreeRTOS.org
24  * http://aws.amazon.com/freertos
25  *
26  * 1 tab == 4 spaces!
27  */
28 
29 
30 /*
31  * Message buffers build functionality on top of FreeRTOS stream buffers.
32  * Whereas stream buffers are used to send a continuous stream of data from one
33  * task or interrupt to another, message buffers are used to send variable
34  * length discrete messages from one task or interrupt to another. Their
35  * implementation is light weight, making them particularly suited for interrupt
36  * to task and core to core communication scenarios.
37  *
38  * ***NOTE***: Uniquely among FreeRTOS objects, the stream buffer
39  * implementation (so also the message buffer implementation, as message buffers
40  * are built on top of stream buffers) assumes there is only one task or
41  * interrupt that will write to the buffer (the writer), and only one task or
42  * interrupt that will read from the buffer (the reader). It is safe for the
43  * writer and reader to be different tasks or interrupts, but, unlike other
44  * FreeRTOS objects, it is not safe to have multiple different writers or
45  * multiple different readers. If there are to be multiple different writers
46  * then the application writer must place each call to a writing API function
47  * (such as xMessageBufferSend()) inside a critical section and set the send
48  * block time to 0. Likewise, if there are to be multiple different readers
49  * then the application writer must place each call to a reading API function
50  * (such as xMessageBufferRead()) inside a critical section and set the receive
51  * timeout to 0.
52  *
53  * Message buffers hold variable length messages. To enable that, when a
54  * message is written to the message buffer an additional sizeof( size_t ) bytes
55  * are also written to store the message's length (that happens internally, with
56  * the API function). sizeof( size_t ) is typically 4 bytes on a 32-bit
57  * architecture, so writing a 10 byte message to a message buffer on a 32-bit
58  * architecture will actually reduce the available space in the message buffer
59  * by 14 bytes (10 byte are used by the message, and 4 bytes to hold the length
60  * of the message).
61  */
62 
63 #ifndef FREERTOS_MESSAGE_BUFFER_H
64 #define FREERTOS_MESSAGE_BUFFER_H
65 
66 /* Message buffers are built onto of stream buffers. */
67 #include "stream_buffer.h"
68 
69 #if defined( __cplusplus )
70 extern "C" {
71 #endif
72 
79 typedef void * MessageBufferHandle_t;
80 
81 /*-----------------------------------------------------------*/
82 
139 #define xMessageBufferCreate( xBufferSizeBytes ) ( MessageBufferHandle_t ) xStreamBufferGenericCreate( xBufferSizeBytes, ( size_t ) 0, pdTRUE )
140 
205 #define xMessageBufferCreateStatic( xBufferSizeBytes, pucMessageBufferStorageArea, pxStaticMessageBuffer ) ( MessageBufferHandle_t ) xStreamBufferGenericCreateStatic( xBufferSizeBytes, 0, pdTRUE, pucMessageBufferStorageArea, pxStaticMessageBuffer )
206 
304 #define xMessageBufferSend( xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait ) xStreamBufferSend( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, xTicksToWait )
305 
408 #define xMessageBufferSendFromISR( xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferSendFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvTxData, xDataLengthBytes, pxHigherPriorityTaskWoken )
409 
496 #define xMessageBufferReceive( xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait ) xStreamBufferReceive( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, xTicksToWait )
497 
498 
597 #define xMessageBufferReceiveFromISR( xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken ) xStreamBufferReceiveFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pvRxData, xBufferLengthBytes, pxHigherPriorityTaskWoken )
598 
617 #define vMessageBufferDelete( xMessageBuffer ) vStreamBufferDelete( ( StreamBufferHandle_t ) xMessageBuffer )
618 
634 #define xMessageBufferIsFull( xMessageBuffer ) xStreamBufferIsFull( ( StreamBufferHandle_t ) xMessageBuffer )
635 
650 #define xMessageBufferIsEmpty( xMessageBuffer ) xStreamBufferIsEmpty( ( StreamBufferHandle_t ) xMessageBuffer )
651 
673 #define xMessageBufferReset( xMessageBuffer ) xStreamBufferReset( ( StreamBufferHandle_t ) xMessageBuffer )
674 
675 
695 #define xMessageBufferSpaceAvailable( xMessageBuffer ) xStreamBufferSpacesAvailable( ( StreamBufferHandle_t ) xMessageBuffer )
696 
734 #define xMessageBufferSendCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferSendCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken )
735 
774 #define xMessageBufferReceiveCompletedFromISR( xMessageBuffer, pxHigherPriorityTaskWoken ) xStreamBufferReceiveCompletedFromISR( ( StreamBufferHandle_t ) xMessageBuffer, pxHigherPriorityTaskWoken )
775 
776 #if defined( __cplusplus )
777 } /* extern "C" */
778 #endif
779 
780 #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