File tree 3 files changed +12
-6
lines changed
3 files changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -178,7 +178,7 @@ static bool read_chg(void) {
178
178
179
179
static pbio_os_process_t pbdrv_charger_mp2639a_process ;
180
180
181
- pbio_error_t pbdrv_charger_mp2639a_process_thread (pbio_os_state_t * state ) {
181
+ pbio_error_t pbdrv_charger_mp2639a_process_thread (pbio_os_state_t * state , void * context ) {
182
182
183
183
static pbio_os_timer_t timer ;
184
184
@@ -282,7 +282,7 @@ pbio_error_t pbdrv_charger_mp2639a_process_thread(pbio_os_state_t *state) {
282
282
283
283
void pbdrv_charger_init (void ) {
284
284
pbdrv_init_busy_up ();
285
- pbio_os_start_process (& pbdrv_charger_mp2639a_process , pbdrv_charger_mp2639a_process_thread );
285
+ pbio_os_start_process (& pbdrv_charger_mp2639a_process , pbdrv_charger_mp2639a_process_thread , NULL );
286
286
}
287
287
288
288
#endif // PBDRV_CONFIG_CHARGER_MP2639A
Original file line number Diff line number Diff line change @@ -87,7 +87,7 @@ bool pbio_os_timer_is_expired(pbio_os_timer_t *timer);
87
87
*/
88
88
typedef uint32_t pbio_os_state_t ;
89
89
90
- typedef pbio_error_t (* pbio_os_process_func_t )(pbio_os_state_t * state );
90
+ typedef pbio_error_t (* pbio_os_process_func_t )(pbio_os_state_t * state , void * context );
91
91
92
92
typedef struct _pbio_os_process_t pbio_os_process_t ;
93
93
@@ -107,6 +107,10 @@ struct _pbio_os_process_t {
107
107
* The protothread.
108
108
*/
109
109
pbio_os_process_func_t func ;
110
+ /**
111
+ * Context passed on each call to the protothread.
112
+ */
113
+ void * context ;
110
114
/**
111
115
* Most recent result of running one iteration of the protothread.
112
116
*/
@@ -187,7 +191,7 @@ void pbio_os_run_while_idle(void);
187
191
188
192
void pbio_os_request_poll (void );
189
193
190
- void pbio_os_start_process (pbio_os_process_t * process , pbio_os_process_func_t func );
194
+ void pbio_os_start_process (pbio_os_process_t * process , pbio_os_process_func_t func , void * context );
191
195
192
196
/**
193
197
* Disables interrupts and returns the previous interrupt state.
Original file line number Diff line number Diff line change @@ -53,8 +53,9 @@ static pbio_os_process_t *process_list = NULL;
53
53
*
54
54
* @param process The process to start.
55
55
* @param func The process thread function.
56
+ * @param context The context to pass to the process.
56
57
*/
57
- void pbio_os_start_process (pbio_os_process_t * process , pbio_os_process_func_t func ) {
58
+ void pbio_os_start_process (pbio_os_process_t * process , pbio_os_process_func_t func , void * context ) {
58
59
59
60
// Add the new process to the end of the list.
60
61
pbio_os_process_t * last = process_list ;
@@ -69,6 +70,7 @@ void pbio_os_start_process(pbio_os_process_t *process, pbio_os_process_func_t fu
69
70
70
71
// Initialize the process.
71
72
process -> func = func ;
73
+ process -> context = context ;
72
74
process -> next = NULL ;
73
75
process -> err = PBIO_ERROR_AGAIN ;
74
76
process -> state = 0 ;
@@ -103,7 +105,7 @@ bool pbio_os_run_processes_once(void) {
103
105
while (process ) {
104
106
// Run one iteration of the process if not yet completed or errored.
105
107
if (process -> err == PBIO_ERROR_AGAIN ) {
106
- process -> err = process -> func (& process -> state );
108
+ process -> err = process -> func (& process -> state , process -> context );
107
109
}
108
110
process = process -> next ;
109
111
}
You can’t perform that action at this time.
0 commit comments