|
6 | 6 |
|
7 | 7 | /**
|
8 | 8 | * struct lifesensor_queue_t - generic queue struct
|
9 |
| - * @queue: Holds the FreeRTOS queue. |
| 9 | + * @queue: Holds the FreeRTOS queue. |
10 | 10 | * @handle: Provides a reference to the queue after initialization.
|
11 | 11 | * @buffer: Points to the subsequent queue buffer.
|
12 | 12 | *
|
13 | 13 | * This struct serves as an abstraction for operating with FreeRTOS queues such
|
14 | 14 | * that it includes necessary fields for managing a queues data. It is intended
|
15 | 15 | * to be used with the LIFESENSOR_QUEUE() macro.
|
16 | 16 | */
|
17 |
| -typedef struct { |
18 |
| - QueueHandle_t handle; |
19 |
| - StaticQueue_t queue; |
20 |
| - uint8_t buffer[]; |
| 17 | +typedef struct |
| 18 | +{ |
| 19 | + QueueHandle_t handle; |
| 20 | + StaticQueue_t queue; |
| 21 | + uint8_t buffer[]; |
21 | 22 | } lifesensor_queue_t;
|
22 | 23 |
|
23 | 24 |
|
24 | 25 | /**
|
25 | 26 | * LIFESENSOR_QUEUE() - Generic queue struct declaration macro
|
26 |
| - * @type: The variable type the queue will hold. |
27 |
| - * @item_count Provide how many items of `type` fit into the queue.. |
| 27 | + * @type: The variable type the queue will hold. |
| 28 | + * @item_count Provide how many items of `type` fit into the queue.. |
28 | 29 | *
|
29 | 30 | * The macro is used for easier queue struct allocation. The resulting
|
30 | 31 | * queue struct should be initialized through the corresponding
|
31 | 32 | * lifesensor_queue_init() function macro.
|
32 | 33 | *
|
33 |
| - * NOTE: `queue` houses the actual queue struct of type `lifesensor_queue_t`. |
34 |
| - * `lifesensor_queue_t`s buffer attribute of undefined length will |
35 |
| - * point to the buffer declared here with size `buffersize`. |
| 34 | + * NOTE: `queue` houses the actual queue struct of type `lifesensor_queue_t`. |
| 35 | + * `lifesensor_queue_t`s buffer attribute of undefined length will |
| 36 | + * point to the buffer declared here with size `buffersize`. |
36 | 37 | *
|
37 | 38 | */
|
38 |
| -#define LIFESENSOR_QUEUE(type, item_count) \ |
39 |
| - struct { \ |
40 |
| - lifesensor_queue_t queue; \ |
41 |
| - type buffer[item_count]; \ |
42 |
| - } |
| 39 | +#define LIFESENSOR_QUEUE(type, item_count) \ |
| 40 | + struct { \ |
| 41 | + lifesensor_queue_t queue; \ |
| 42 | + type buffer[item_count]; \ |
| 43 | + } |
43 | 44 |
|
44 | 45 |
|
45 | 46 | /**
|
46 | 47 | * lifesensor_queue_init() - Initialize a queue generated with LIFESENSOR_QUEUE
|
47 |
| - * @anon_queue: Pass a pointer to an instacne created with LIFESENSOR_QUEUE. |
| 48 | + * @anon_queue: Pass a pointer to an instacne created with LIFESENSOR_QUEUE. |
48 | 49 | *
|
49 | 50 | * This is a wrapper for `xTaskCreateStatic()` which initializes several
|
50 | 51 | * internal variables. It provides another layer of abstraction to not bother
|
51 | 52 | * much with the FreeRTOS internals and hides redundant code.
|
52 | 53 | *
|
53 | 54 | * Please consult https://www.freertos.org/xTaskCreateStatic.html
|
54 | 55 | */
|
55 |
| -#define lifesensor_queue_init(anon_queue) \ |
56 |
| -{ \ |
57 |
| - (*anon_queue).queue.handle = xQueueCreateStatic( \ |
58 |
| - sizeof((*anon_queue).buffer) / sizeof((*anon_queue).buffer[0]), \ |
59 |
| - sizeof((*anon_queue).buffer[0]), \ |
60 |
| - (*anon_queue).queue.buffer, \ |
61 |
| - &(*anon_queue).queue.queue \ |
62 |
| - ); \ |
63 |
| -} |
| 56 | +#define lifesensor_queue_init(anon_queue) \ |
| 57 | + { \ |
| 58 | + (*anon_queue).queue.handle \ |
| 59 | + = xQueueCreateStatic(sizeof((*anon_queue).buffer) \ |
| 60 | + / sizeof((*anon_queue).buffer[0]), \ |
| 61 | + sizeof((*anon_queue).buffer[0]), \ |
| 62 | + (*anon_queue).queue.buffer, \ |
| 63 | + &(*anon_queue).queue.queue \ |
| 64 | + ); \ |
| 65 | + } |
64 | 66 |
|
65 | 67 | #endif
|
0 commit comments