Bluenet  5.7.0
Bluenet, firmware for nRF52 smart home devices
Loading...
Searching...
No Matches
cs_DoubleStackCoroutine.h
Go to the documentation of this file.
1/*
2 * Author: Crownstone Team
3 * Copyright: Crownstone (https://crownstone.rocks)
4 * Date: Oct 28, 2020
5 * License: LGPLv3+, Apache License 2.0, and/or MIT (triple-licensed)
6 */
7#pragma once
8
9#include <setjmp.h>
10
21#define DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE 8
22
26typedef struct {
30
31typedef void (*coroutine_function_t)(void*);
32
36typedef struct {
39 uint8_t coroutineArgumentBuffer[DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE];
42
55int initCoroutine(coroutine_function_t coroutineFunction, void* argument, uint8_t argumentSize, const uintptr_t ramEnd);
56
61
68
int resumeCoroutine()
Resume the coroutine.
void(* coroutine_function_t)(void *)
Definition: cs_DoubleStackCoroutine.h:31
#define DOUBLE_STACK_COROUTINE_ARGUMENTS_BUFFER_SIZE
This class implements a coroutine with its own stack.
Definition: cs_DoubleStackCoroutine.h:21
int initCoroutine(coroutine_function_t coroutineFunction, void *argument, uint8_t argumentSize, const uintptr_t ramEnd)
Initialize the coroutine.
void yieldCoroutine()
Yield the coroutine: resume in bluenet.
uint8_t * getCoroutineArgumentBuffer()
Get the coroutine argument buffer.
Struct with the context to jump between bluenet and coroutine.
Definition: cs_DoubleStackCoroutine.h:26
jmp_buf coroutineContext
Definition: cs_DoubleStackCoroutine.h:27
jmp_buf bluenetContext
Definition: cs_DoubleStackCoroutine.h:28
Struct with all the state we need for a coroutine.
Definition: cs_DoubleStackCoroutine.h:36
coroutine_t coroutine
Definition: cs_DoubleStackCoroutine.h:37
coroutine_function_t coroutineFunction
Definition: cs_DoubleStackCoroutine.h:38
void * oldStackPointer
Definition: cs_DoubleStackCoroutine.h:40