Skip to content

Commit 8586528

Browse files
committed
Asynchronous Serial API fixes and refactoring, part 3
Updated API documentation to better explain API operation and to explicitly point out that any event ends the operation.
1 parent cbb84d8 commit 8586528

File tree

1 file changed

+40
-12
lines changed

1 file changed

+40
-12
lines changed

drivers/SerialBase.h

Lines changed: 40 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -179,57 +179,85 @@ class SerialBase : private NonCopyable<SerialBase> {
179179

180180
#if DEVICE_SERIAL_ASYNCH
181181

182-
/** Begin asynchronous write using 8bit buffer. The completion invokes registered TX event callback
182+
/** Begin asynchronous write using 8bit buffer.
183183
*
184-
* This function locks the deep sleep until any event has occurred
184+
* The write operation ends with any of the enabled events and invokes
185+
* registered callback function (which can be NULL to not receive callback at all).
186+
* Events that are not enabled by event argument are simply ignored.
187+
* Operation has to be ended explicitly by calling abort_write() when
188+
* no events are enabled.
189+
* This function locks the deep sleep until any event has occurred.
185190
*
186191
* @param buffer The buffer where received data will be stored
187192
* @param length The buffer length in bytes
188193
* @param callback The event callback function
189-
* @param event The logical OR of TX events
194+
* @param event The logical OR of TX events that should end operation
195+
* @return Zero if new transaction was started, -1 if transaction is already on-going
190196
*/
191197
int write(const uint8_t *buffer, int length, const event_callback_t &callback, int event = SERIAL_EVENT_TX_COMPLETE);
192198

193-
/** Begin asynchronous write using 16bit buffer. The completion invokes registered TX event callback
199+
/** Begin asynchronous write using 16bit buffer.
194200
*
195-
* This function locks the deep sleep until any event has occurred
201+
* The write operation ends with any of the enabled events and invokes
202+
* registered callback function (which can be NULL to not receive callback at all).
203+
* Events that are not enabled by event argument are simply ignored.
204+
* Operation has to be ended explicitly by calling abort_write() when
205+
* no events are enabled.
206+
* This function locks the deep sleep until any event has occurred.
196207
*
197208
* @param buffer The buffer where received data will be stored
198209
* @param length The buffer length in bytes
199210
* @param callback The event callback function
200-
* @param event The logical OR of TX events
211+
* @param event The logical OR of TX events that should end operation
212+
* @return Zero if new transaction was started, -1 if transaction is already on-going
201213
*/
202214
int write(const uint16_t *buffer, int length, const event_callback_t &callback, int event = SERIAL_EVENT_TX_COMPLETE);
203215

204216
/** Abort the on-going write transfer
217+
*
218+
* It is safe to call abort_write() when there is no on-going transaction.
205219
*/
206220
void abort_write();
207221

208-
/** Begin asynchronous reading using 8bit buffer. The completion invokes registered RX event callback.
222+
/** Begin asynchronous reading using 8bit buffer.
209223
*
210-
* This function locks the deep sleep until any event has occurred
224+
* The read operation ends with any of the enabled events and invokes registered
225+
* callback function (which can be NULL to not receive callback at all).
226+
* Events that are not enabled by event argument are simply ignored.
227+
* Operation has to be ended explicitly by calling abort_read() when
228+
* no events are enabled.
229+
* This function locks the deep sleep until any event has occurred.
211230
*
212231
* @param buffer The buffer where received data will be stored
213232
* @param length The buffer length in bytes
214233
* @param callback The event callback function
215-
* @param event The logical OR of RX events
234+
* @param event The logical OR of RX events that should end operation
216235
* @param char_match The matching character
236+
* @return Zero if new transaction was started, -1 if transaction is already on-going
217237
*/
218238
int read(uint8_t *buffer, int length, const event_callback_t &callback, int event = SERIAL_EVENT_RX_COMPLETE, unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
219239

220-
/** Begin asynchronous reading using 16bit buffer. The completion invokes registered RX event callback.
240+
/** Begin asynchronous reading using 16bit buffer.
221241
*
222-
* This function locks the deep sleep until any event has occurred
242+
* The read operation ends with any of the enabled events and invokes registered
243+
* callback function (which can be NULL to not receive callback at all).
244+
* Events that are not enabled by event argument are simply ignored.
245+
* Operation has to be ended explicitly by calling abort_read() when
246+
* no events are enabled.
247+
* This function locks the deep sleep until any event has occurred.
223248
*
224249
* @param buffer The buffer where received data will be stored
225250
* @param length The buffer length in bytes
226251
* @param callback The event callback function
227-
* @param event The logical OR of RX events
252+
* @param event The logical OR of RX events that should end operation
228253
* @param char_match The matching character
254+
* @return Zero if new transaction was started, -1 if transaction is already on-going
229255
*/
230256
int read(uint16_t *buffer, int length, const event_callback_t &callback, int event = SERIAL_EVENT_RX_COMPLETE, unsigned char char_match = SERIAL_RESERVED_CHAR_MATCH);
231257

232258
/** Abort the on-going read transfer
259+
*
260+
* It is safe to call abort_read() when there is no on-going transaction.
233261
*/
234262
void abort_read();
235263

0 commit comments

Comments
 (0)