Flipper Zero Firmware
No Matches
expansion_worker.h File Reference

Expansion module handling thread wrapper. More...

#include <furi_hal_serial_types.h>

Go to the source code of this file.


typedef struct ExpansionWorker ExpansionWorker
 Expansion worker opaque type declaration.
typedef void(* ExpansionWorkerCallback) (void *context)
 Worker callback type.


ExpansionWorkerexpansion_worker_alloc (FuriHalSerialId serial_id)
 Create an expansion worker instance.
void expansion_worker_free (ExpansionWorker *instance)
 Delete an expansion worker instance.
void expansion_worker_set_callback (ExpansionWorker *instance, ExpansionWorkerCallback callback, void *context)
 Set the module disconnect callback.
void expansion_worker_start (ExpansionWorker *instance)
 Start the expansion module worker.
void expansion_worker_stop (ExpansionWorker *instance)
 Stop the expansion module worker.

Detailed Description

Expansion module handling thread wrapper.

The worker is started each time an expansion module is detected and handles all of the communication protocols. Likewise, it is stopped upon module disconnection or communication error.

This file is a private implementation detail. Please do not attempt to use it in applications.

Typedef Documentation

◆ ExpansionWorkerCallback

typedef void(* ExpansionWorkerCallback) (void *context)

Worker callback type.

See also
[in,out]contextpointer to a user-defined object.

Function Documentation

◆ expansion_worker_alloc()

ExpansionWorker * expansion_worker_alloc ( FuriHalSerialId serial_id)

Create an expansion worker instance.

[in]serial_idnumerical identifier of the serial to be used by the worker.
pointer to the created instance.

◆ expansion_worker_free()

void expansion_worker_free ( ExpansionWorker * instance)

Delete an expansion worker instance.

[in,out]instancepointer to the instance to be deleted.

◆ expansion_worker_set_callback()

void expansion_worker_set_callback ( ExpansionWorker * instance,
ExpansionWorkerCallback callback,
void * context )

Set the module disconnect callback.

The callback will be triggered upon worker stop EXCEPT when it was stopped via an expansion_worker_stop() call.

In other words, the callback will ONLY be triggered if the worker was stopped due to the user disconnecting/resetting/powering down the module, or due to some communication error.

[in,out]instancepointer to the worker instance to be modified.
[in]callbackpointer to the callback function to be called under the above conditions.
[in]contextpointer to a user-defined object, will be passed as a parameter to the callback.

◆ expansion_worker_start()

void expansion_worker_start ( ExpansionWorker * instance)

Start the expansion module worker.

[in,out]instancepointer to the worker instance to be started.

◆ expansion_worker_stop()

void expansion_worker_stop ( ExpansionWorker * instance)

Stop the expansion module worker.

If the worker was stopped via this call (and not because of module disconnect/ protocol error), the callback will not be triggered.

[in,out]instancepointer to the worker instance to be stopped.