1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/***************************************************************************
*
* osal-rs
* Copyright (C) 2026 Antonio Salsi <passy.linux@zresa.it>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see <https://www.gnu.org/licenses/>.
*
***************************************************************************/
//! FreeRTOS type definitions and handle wrappers.
//!
//! This module provides type aliases and handle types that interface with FreeRTOS.
//! Types are generated at build time from the FreeRTOS configuration.
//!
//! # Generated Types
//!
//! The following types are generated from `FreeRTOSConfig.h` at build time:
//!
//! - `TickType` - System tick counter type (typically `u32` or `u64`)
//! - `BaseType` - Basic signed integer type for return values
//! - `UBaseType` - Basic unsigned integer type
//! - `StackType` - Type used for stack allocation
//!
//! # Handle Types
//!
//! FreeRTOS uses opaque pointers (handles) to reference OS objects:
//!
//! - `ThreadHandle` - References a FreeRTOS task
//! - `QueueHandle` - References a message queue
//! - `SemaphoreHandle` - References a semaphore
//! - `MutexHandle` - References a mutex
//! - `EventGroupHandle` - References an event group
//! - `TimerHandle` - References a software timer
//!
//! # Examples
//!
//! ```ignore
//! use osal_rs::os::types::*;
//!
//! // Using tick types for timing
//! let delay_ticks: TickType = 1000;
//!
//! // Using handles (typically obtained from create functions)
//! let handle: ThreadHandle = std::ptr::null_mut();
//! ```
// Include build-time generated types from FreeRTOS configuration
// This file is generated by the build script and contains:
// - TickType: System tick counter type
// - BaseType: Basic signed integer type
// - UBaseType: Basic unsigned integer type
// - StackType: Stack allocation type
include!;
/// FreeRTOS opaque handle types for OS primitives.
///
/// These handles are opaque pointers used to reference FreeRTOS objects.
/// They should not be dereferenced directly; instead, use the safe wrappers
/// provided by this crate (e.g., `Thread`, `Queue`, `Semaphore`, etc.).
///
/// # Handle Types
///
/// - **`ThreadHandle`**: Handle to a FreeRTOS task/thread
/// - **`QueueHandle`**: Handle to a message queue for inter-thread communication
/// - **`SemaphoreHandle`**: Handle to a counting or binary semaphore
/// - **`MutexHandle`**: Handle to a recursive mutex with priority inheritance
/// - **`EventGroupHandle`**: Handle to an event group for multi-bit synchronization
/// - **`TimerHandle`**: Handle to a software timer
///
/// # Safety
///
/// These are raw pointers to FreeRTOS internal structures. Always use the
/// safe Rust wrappers instead of manipulating handles directly.
///
/// # Examples
///
/// ```ignore
/// use osal_rs::os::{Thread, types::ThreadHandle};
///
/// // Typically you get handles from wrapper constructors
/// let thread = Thread::new("worker", 2048, 5).unwrap();
/// // The handle is managed internally by the Thread wrapper
/// ```
pub use ;
/// Type alias for event group bits.
///
/// Represents a set of event flags where each bit can be set or cleared independently.
/// The underlying type is `TickType`, which is typically `u32` or `u64` depending on
/// the FreeRTOS configuration.
///
/// # Bit Usage
///
/// - **Usable bits**: For `u32`, 24 bits (0-23) are usable; top 8 bits are reserved
/// by FreeRTOS for internal use. For `u64`, 56 bits are usable.
/// - **Maximum mask**: Use `EventGroup::MAX_MASK` for the maximum safe mask value.
///
/// # Examples
///
/// ```ignore
/// use osal_rs::os::types::EventBits;
/// use osal_rs::os::{EventGroup, EventGroupFn};
///
/// const EVENT_A: EventBits = 1 << 0; // Bit 0
/// const EVENT_B: EventBits = 1 << 1; // Bit 1
/// const EVENT_C: EventBits = 1 << 2; // Bit 2
///
/// let event_group = EventGroup::new().unwrap();
///
/// // Set multiple bits
/// event_group.set(EVENT_A | EVENT_B);
///
/// // Wait for any bit
/// let result = event_group.wait(EVENT_A | EVENT_C, 1000);
///
/// // Check specific bits
/// if result & EVENT_A != 0 {
/// println!("Event A occurred");
/// }
/// ```
pub type EventBits = TickType;