diff options
| author | Dario Nieuwenhuis <[email protected]> | 2024-08-05 20:58:04 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2024-08-05 21:07:42 +0200 |
| commit | 4f7ac1946a43379306aa432961fb97bba1139a6e (patch) | |
| tree | 2589e67baa770acf244dfdea355e16585d683d16 /cyw43/src/util.rs | |
| parent | afc8e684dd16c3bc947b365ca293f0f37d95b342 (diff) | |
cyw43: add Bluetooth support.
Co-Authored-By: Brandon Ros <[email protected]>
Diffstat (limited to 'cyw43/src/util.rs')
| -rw-r--r-- | cyw43/src/util.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/cyw43/src/util.rs b/cyw43/src/util.rs new file mode 100644 index 000000000..a4adbd4ed --- /dev/null +++ b/cyw43/src/util.rs | |||
| @@ -0,0 +1,20 @@ | |||
| 1 | #![allow(unused)] | ||
| 2 | |||
| 3 | use core::slice; | ||
| 4 | |||
| 5 | pub(crate) fn slice8_mut(x: &mut [u32]) -> &mut [u8] { | ||
| 6 | let len = x.len() * 4; | ||
| 7 | unsafe { slice::from_raw_parts_mut(x.as_mut_ptr() as _, len) } | ||
| 8 | } | ||
| 9 | |||
| 10 | pub(crate) fn is_aligned(a: u32, x: u32) -> bool { | ||
| 11 | (a & (x - 1)) == 0 | ||
| 12 | } | ||
| 13 | |||
| 14 | pub(crate) fn round_down(x: u32, a: u32) -> u32 { | ||
| 15 | x & !(a - 1) | ||
| 16 | } | ||
| 17 | |||
| 18 | pub(crate) fn round_up(x: u32, a: u32) -> u32 { | ||
| 19 | ((x + a - 1) / a) * a | ||
| 20 | } | ||
