@@ -42,28 +42,31 @@ namespace rtos {
42
42
* \defgroup rtos_Mail Mail class
43
43
* @{
44
44
*/
45
-
46
- /* * The Mail class allow to control, send, receive, or wait for mail.
47
- A mail is a memory block that is send to a thread or interrupt service routine.
48
- @tparam T data type of a single message element.
49
- @tparam queue_sz maximum number of messages in queue.
50
-
51
- @note
52
- Memory considerations: The mail data store and control structures will be created on current thread's stack,
53
- both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory pools are not being used).
54
- */
45
+
46
+ /* * The Mail class allows you to control, send, receive, or wait for mail.
47
+ * A mail is a memory block that is sent to a thread or interrupt service routine.
48
+ * @tparam T Data type of a single mail message element.
49
+ * @tparam queue_sz Maximum number of mail messages in queue.
50
+ *
51
+ * @note
52
+ * Memory considerations: The mail data store and control structures are part of this class - they do not (themselves)
53
+ * allocate memory on the heap, both for the mbed OS and underlying RTOS objects (static or dynamic RTOS memory
54
+ * pools are not being used).
55
+ */
55
56
template <typename T, uint32_t queue_sz>
56
57
class Mail : private mbed ::NonCopyable<Mail<T, queue_sz> > {
57
58
public:
58
- /* * Create and Initialize Mail queue.
59
+ /* * Create and initialize Mail queue.
59
60
*
60
61
* @note You cannot call this function from ISR context.
61
- */
62
+ */
62
63
Mail () { };
63
64
64
- /* * Check if the mail queue is empty
65
+ /* * Check if the mail queue is empty.
65
66
*
66
- * @return True if the mail queue is empty, false if not
67
+ * @return State of queue.
68
+ * @retval true Mail queue is empty.
69
+ * @retval false Mail queue contains mail.
67
70
*
68
71
* @note You may call this function from ISR context.
69
72
*/
@@ -72,9 +75,11 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
72
75
return _queue.empty ();
73
76
}
74
77
75
- /* * Check if the mail queue is full
78
+ /* * Check if the mail queue is full.
76
79
*
77
- * @return True if the mail queue is full, false if not
80
+ * @return State of queue.
81
+ * @retval true Mail queue is full.
82
+ * @retval false Mail queue is not full.
78
83
*
79
84
* @note You may call this function from ISR context.
80
85
*/
@@ -83,47 +88,55 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
83
88
return _queue.full ();
84
89
}
85
90
86
- /* * Allocate a memory block of type T
87
- @param millisec timeout value or 0 in case of no time-out. (default: 0).
88
- @return pointer to memory block that can be filled with mail or NULL in case error.
89
-
90
- @note You may call this function from ISR context if the millisec parameter is set to 0.
91
- */
92
- T *alloc (uint32_t millisec = 0 )
93
- {
91
+ /* * Allocate a memory block of type T.
92
+ *
93
+ * @param millisec Not used.
94
+ *
95
+ * @return Pointer to memory block that can be filled with mail or NULL in case error.
96
+ *
97
+ * @note You may call this function from ISR context.
98
+ */
99
+ T* alloc (uint32_t millisec=0 ) {
94
100
return _pool.alloc ();
95
101
}
96
102
97
103
/* * Allocate a memory block of type T and set memory block to zero.
98
- @param millisec timeout value or 0 in case of no time-out. (default: 0).
99
- @return pointer to memory block that can be filled with mail or NULL in case error.
100
-
101
- @note You may call this function from ISR context if the millisec parameter is set to 0.
102
- */
103
- T *calloc (uint32_t millisec = 0 )
104
- {
104
+ *
105
+ * @param millisec Not used.
106
+ *
107
+ * @return Pointer to memory block that can be filled with mail or NULL in case error.
108
+ *
109
+ * @note You may call this function from ISR context.
110
+ */
111
+ T* calloc (uint32_t millisec=0 ) {
105
112
return _pool.calloc ();
106
113
}
107
114
108
115
/* * Put a mail in the queue.
109
- @param mptr memory block previously allocated with Mail::alloc or Mail::calloc.
110
- @return status code that indicates the execution status of the function.
111
-
112
- @note You may call this function from ISR context.
113
- */
114
- osStatus put (T *mptr)
115
- {
116
+ *
117
+ * @param mptr Memory block previously allocated with Mail::alloc or Mail::calloc.
118
+ *
119
+ * @return Status code that indicates the execution status of the function (osOK on success).
120
+ *
121
+ * @note You may call this function from ISR context.
122
+ */
123
+ osStatus put (T *mptr) {
116
124
return _queue.put (mptr);
117
125
}
118
126
119
- /* * Get a mail from a queue.
120
- @param millisec timeout value or 0 in case of no time-out. (default: osWaitForever).
121
- @return event that contains mail information or error code.
122
-
123
- @note You may call this function from ISR context if the millisec parameter is set to 0.
124
- */
125
- osEvent get (uint32_t millisec = osWaitForever)
126
- {
127
+ /* * Get a mail from the queue.
128
+ *
129
+ * @param millisec Timeout value or 0 in case of no timeout (default: osWaitForever).
130
+ *
131
+ * @return Event that contains mail information or error code.
132
+ * @retval osEventMessage Message received.
133
+ * @retval osOK No mail is available (and no timeout was specified).
134
+ * @retval osEventTimeout No mail has arrived during the given timeout period.
135
+ * @retval osErrorParameter A parameter is invalid or outside of a permitted range.
136
+ *
137
+ * @note You may call this function from ISR context if the millisec parameter is set to 0.
138
+ */
139
+ osEvent get (uint32_t millisec=osWaitForever) {
127
140
osEvent evt = _queue.get (millisec);
128
141
if (evt.status == osEventMessage) {
129
142
evt.status = osEventMail;
@@ -132,19 +145,24 @@ class Mail : private mbed::NonCopyable<Mail<T, queue_sz> > {
132
145
}
133
146
134
147
/* * Free a memory block from a mail.
135
- @param mptr pointer to the memory block that was obtained with Mail::get.
136
- @return status code that indicates the execution status of the function.
137
-
138
- @note You may call this function from ISR context.
139
- */
140
- osStatus free (T *mptr)
141
- {
148
+ *
149
+ * @param mptr Pointer to the memory block that was obtained with Mail::get.
150
+ *
151
+ * @return Status code that indicates the execution status of the function (osOK on success).
152
+ *
153
+ * @note You may call this function from ISR context.
154
+ */
155
+ osStatus free (T *mptr) {
142
156
return _pool.free (mptr);
143
157
}
144
158
159
+ #if !defined(DOXYGEN_ONLY)
160
+
145
161
private:
146
162
Queue<T, queue_sz> _queue;
147
163
MemoryPool<T, queue_sz> _pool;
164
+
165
+ #endif // !defined(DOXYGEN_ONLY)
148
166
};
149
167
150
168
/* * @}*/
0 commit comments