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
//! Floating Point Unit.

#![cfg_attr(feature = "std", allow(unreachable_code))]

use crate::{map::periph::fpu::FpuPeriph, reg::prelude::*};

/// FPU driver.
pub struct Fpu {
    periph: FpuPeriph,
}

impl Fpu {
    /// Creates a new driver from the peripheral.
    #[inline]
    pub fn new(periph: FpuPeriph) -> Self {
        Self { periph }
    }

    /// Releases the peripheral.
    #[inline]
    pub fn free(self) -> FpuPeriph {
        self.periph
    }
}

impl Fpu {
    /// Enables the FPU.
    pub fn enable(&self) {
        self.periph
            .fpu_cpacr
            .store(|r| r.write_cp10(0b11).write_cp11(0b11));
        #[cfg(feature = "std")]
        return unimplemented!();
        unsafe {
            asm!("
                dsb
                isb
            "   :
                :
                :
                : "volatile"
            );
        }
    }
}