Iridescence 1.00
Embedded Graphic Framework
Loading...
Searching...
No Matches
ds_os.h
1/* Copyright (C) 2017 - 2024, Thornwave Labs Inc - All Rights Reserved.
2 * Unauthorized copying of this file, via any medium is strictly prohibited.
3 * Proprietary and confidential.
4 * Written by Razvan Turiac <razvan.turiac@thornwave.com>
5*/
6
7#ifndef _DS_OS_H
8#define _DS_OS_H
9
10
11#include <stdint.h>
12#include <ds_types_lambda.h>
13
14
15typedef uintmax_t ds_thread_t;
16
17
22{
23public:
26
32 bool take(uint32_t wait_ms);
33
34
38 void give(void);
39
40
45 void giveFromIsr(int32_t* woken);
46
47private:
48 void* mHandle;
49};
50
51
53{
54public:
55 DsMutex();
56 ~DsMutex();
57
58 void take(void);
59 void give(void);
60
61private:
62 void* mHandle;
63};
64
65
67{
68public:
69 DsTimer();
70 ~DsTimer();
71
72 void setCallback(const lambda<void(void)> &callback)
73 {
74 mCallback = callback;
75 }
76
77 void setAutoReload(bool autoreload);
78
79 void start(uint32_t period_ms);
80 void start(void);
81 void startFromIsr(int32_t* woken);
82 void startFromIsr(uint32_t period_ms, int32_t* woken);
83
84 void stop(void);
85 void stopFromIsr(int32_t* woken);
86
87 bool isActive(void) const;
88
89protected:
90 void* mHandle;
91 lambda<void(void)> mCallback;
92
93 static void callbackEntry(DsTimer* timer);
94};
95
96
97int32_t DsOsGetTick(void);
98ds_thread_t DsOsGetThreadId(void);
99
100#endif
DsSemaphore is a class that implements a binary semaphore.
Definition ds_os.h:22
void giveFromIsr(int32_t *woken)
Gives the semaphore. Can be called from an interrupt context.
void give(void)
Gives the semaphore.
bool take(uint32_t wait_ms)
Take the semaphore.
Definition ds_os.h:53
Definition ds_os.h:67
Definition ds_types_lambda.h:24