Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_DoubleStackCoroutine.h File Reference
#include <setjmp.h>
Include dependency graph for cs_DoubleStackCoroutine.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  coroutine_t
 Struct with the context to jump between bluenet and coroutine. More...
 
struct  stack_params_t
 Struct with all the state we need for a coroutine. More...
 

Macros

#define DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE   8
 This class implements a coroutine with its own stack. More...
 

Typedefs

typedef void(* coroutine_function_t) (void *)
 

Functions

int initCoroutine (coroutine_function_t coroutineFunction, void *argument, uint8_t argumentSize, const uintptr_t ramEnd)
 Initialize the coroutine. More...
 
void yieldCoroutine ()
 Yield the coroutine: resume in bluenet. More...
 
int resumeCoroutine ()
 Resume the coroutine. More...
 
uint8_t * getCoroutineArgumentBuffer ()
 Get the coroutine argument buffer. More...
 

Macro Definition Documentation

◆ DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE

#define DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE   8

This class implements a coroutine with its own stack.

The coroutine implementation:

  • Makes it possible to stop the coroutine half way a function, and resume from there later.
  • Is used by the microapp, so that blocking calls can be used in the microapp code, without blocking bluenet.
  • Uses setjmp and longjmp to jump back and forth. Max buffer size for coroutine arguments.

Typedef Documentation

◆ coroutine_function_t

typedef void(* coroutine_function_t) (void *)

Function Documentation

◆ getCoroutineArgumentBuffer()

uint8_t * getCoroutineArgumentBuffer ( )

Get the coroutine argument buffer.

◆ initCoroutine()

int initCoroutine ( coroutine_function_t  coroutineFunction,
void *  argument,
uint8_t  argumentSize,
const uintptr_t  ramEnd 
)

Initialize the coroutine.

Make sure to first set the coroutine arguments.

Parameters
[in]coroutineFunctionThe first function of the coroutine to be executed.
[in]argumentThe argument for the coroutine function, this will be copied, and can be retrieved again with getCoroutineArgumentBuffer().
[in]argumentSizeSize of the argument.
[in]ramEndPointer to the end of the ram reserved for this coroutine.
Returns
0 on success.

◆ resumeCoroutine()

int resumeCoroutine ( )

Resume the coroutine.

Returns
0 When the coroutine finished.

◆ yieldCoroutine()

void yieldCoroutine ( )

Yield the coroutine: resume in bluenet.