@web-font-path: "roboto-debian.css";
v2.2.0 (RP2040)
Loading...
Searching...
No Matches
async_context_threadsafe_background.h
/*
* Copyright (c) 2022 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#ifndef _PICO_ASYNC_CONTEXT_THREADSAFE_BACKGROUND_H
#define _PICO_ASYNC_CONTEXT_THREADSAFE_BACKGROUND_H
#include "pico/async_context.h"
#include "pico/sem.h"
#include "pico/mutex.h"
#include "hardware/irq.h"
#ifdef __cplusplus
extern "C" {
#endif
#ifndef ASYNC_CONTEXT_THREADSAFE_BACKGROUND_MULTI_CORE
#define ASYNC_CONTEXT_THREADSAFE_BACKGROUND_MULTI_CORE LIB_PICO_MULTICORE
#endif
typedef struct async_context_threadsafe_background async_context_threadsafe_background_t;
typedef struct async_context_threadsafe_background_config {
uint8_t low_priority_irq_handler_priority;
alarm_pool_t *custom_alarm_pool;
} async_context_threadsafe_background_config_t;
struct async_context_threadsafe_background {
async_context_t core;
alarm_pool_t *alarm_pool; // this must be on the same core as core_num
absolute_time_t last_set_alarm_time;
recursive_mutex_t lock_mutex;
semaphore_t work_needed_sem;
volatile alarm_id_t alarm_id;
#if ASYNC_CONTEXT_THREADSAFE_BACKGROUND_MULTI_CORE
volatile alarm_id_t force_alarm_id;
bool alarm_pool_owned;
#endif
uint8_t low_priority_irq_num;
volatile bool alarm_pending;
};
bool async_context_threadsafe_background_init(async_context_threadsafe_background_t *self, async_context_threadsafe_background_config_t *config);
async_context_threadsafe_background_config_t async_context_threadsafe_background_default_config(void);
static inline bool async_context_threadsafe_background_init_with_defaults(async_context_threadsafe_background_t *self) {
async_context_threadsafe_background_config_t config = async_context_threadsafe_background_default_config();
return async_context_threadsafe_background_init(self, &config);
}
#ifdef __cplusplus
}
#endif
#endif
async_context.h
alarm_id_t
int32_t alarm_id_t
The identifier for an alarm.
Definition time.h:367
async_context_threadsafe_background_init_with_defaults
static bool async_context_threadsafe_background_init_with_defaults(async_context_threadsafe_background_t *self)
Initialize an async_context_threadsafe_background instance with default values.
Definition async_context_threadsafe_background.h:103
async_context_threadsafe_background_init
bool async_context_threadsafe_background_init(async_context_threadsafe_background_t *self, async_context_threadsafe_background_config_t *config)
Initialize an async_context_threadsafe_background instance using the specified configuration.
Definition async_context_threadsafe_background.c:201
async_context_threadsafe_background_default_config
async_context_threadsafe_background_config_t async_context_threadsafe_background_default_config(void)
Return a copy of the default configuration object used by async_context_threadsafe_background_init_wi...
Definition async_context_threadsafe_background.c:28
absolute_time_t
uint64_t absolute_time_t
An opaque 64 bit timestamp in microseconds.
Definition types.h:43
irq.h
mutex.h
sem.h
async_context_threadsafe_background_config
Configuration object for async_context_threadsafe_background instances.
Definition async_context_threadsafe_background.h:38
async_context_threadsafe_background_config::custom_alarm_pool
alarm_pool_t * custom_alarm_pool
a specific alarm pool to use (or NULL to use ta default)
Definition async_context_threadsafe_background.h:53
async_context_threadsafe_background_config::low_priority_irq_handler_priority
uint8_t low_priority_irq_handler_priority
the priority of the low priority IRQ
Definition async_context_threadsafe_background.h:42
async_context_threadsafe_background
Definition async_context_threadsafe_background.h:56
recursive_mutex_t
recursive mutex instance
Definition mutex.h:47