File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -208,7 +208,7 @@ struct _pbio_os_process_t {
208208
209209/**
210210 * Awaits two protothreads until one of them completes successfully or returns
211- * an error.
211+ * an error. There is no cleanup of the other protothread.
212212 *
213213 * @param [in] host_state State of the host protothread in which this macro is used.
214214 * @param [in] sub_state_1 State of the first sub protothread.
@@ -250,6 +250,13 @@ struct _pbio_os_process_t {
250250 } \
251251 } while (0)
252252
253+ /**
254+ * Yields the protothread until the specified timer expires.
255+ *
256+ * @param [in] state Protothread state.
257+ * @param [in] timer The timer to check.
258+ * @param [in] duration The duration to wait for in milliseconds.
259+ */
253260#define PBIO_OS_AWAIT_MS (state , timer , duration ) \
254261 do { \
255262 pbio_os_timer_set(timer, duration); \
@@ -269,7 +276,7 @@ pbio_error_t pbio_port_process_none_thread(pbio_os_state_t *state, void *context
269276
270277void pbio_os_process_start (pbio_os_process_t * process , pbio_os_process_func_t func , void * context );
271278
272- void pbio_os_process_reset (pbio_os_process_t * process , pbio_os_process_func_t func );
279+ void pbio_os_process_init (pbio_os_process_t * process , pbio_os_process_func_t func );
273280
274281/**
275282 * Disables interrupts and returns the previous interrupt state.
Original file line number Diff line number Diff line change @@ -80,16 +80,20 @@ void pbio_os_process_start(pbio_os_process_t *process, pbio_os_process_func_t fu
8080 process -> next = NULL ;
8181 process -> context = context ;
8282
83- pbio_os_process_reset (process , func );
83+ pbio_os_process_init (process , func );
8484}
8585
8686/**
87- * Resets an existing process to the initial state with a new function and context.
87+ * Initializes a process to the initial state with a protothread function to run.
88+ *
89+ * Can also be used to reset a process to the initial state or to change the
90+ * protothread function. Doing so should be done with caution, but can be useful
91+ * to make a process behave in distinct operation modes.
8892 *
8993 * @param process The process to start.
9094 * @param func The process thread function. Choose NULL if it does not need changing.
9195 */
92- void pbio_os_process_reset (pbio_os_process_t * process , pbio_os_process_func_t func ) {
96+ void pbio_os_process_init (pbio_os_process_t * process , pbio_os_process_func_t func ) {
9397 process -> err = PBIO_ERROR_AGAIN ;
9498 process -> state = 0 ;
9599 if (func ) {
Original file line number Diff line number Diff line change @@ -500,7 +500,7 @@ pbio_error_t pbio_port_set_mode(pbio_port_t *port, pbio_port_mode_t mode) {
500500 }
501501
502502 // Disable thread activity by attaching a thread that does nothing.
503- pbio_os_process_reset (& port -> process , pbio_port_process_none_thread );
503+ pbio_os_process_init (& port -> process , pbio_port_process_none_thread );
504504 port -> mode = mode ;
505505
506506 switch (mode ) {
@@ -511,7 +511,7 @@ pbio_error_t pbio_port_set_mode(pbio_port_t *port, pbio_port_mode_t mode) {
511511 case PBIO_PORT_MODE_LEGO_DCM :
512512 // Physical modes for this mode will be set by the process so this
513513 // is all we need to do here.
514- pbio_os_process_reset (& port -> process , pbio_port_process_pup_thread );
514+ pbio_os_process_init (& port -> process , pbio_port_process_pup_thread );
515515 // Returning e-again allows user module to wait for the port to be
516516 // ready after first entering LEGO mode, avoiding NODEV errors when
517517 // switching from direct access modes back to LEGO mode.
You can’t perform that action at this time.
0 commit comments