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
#[allow(unused_must_use)]

pub mod n {
    extern crate rp_sys;

    pub fn set_direction(direction: u32) -> Result<(), String>
    {
        handle_unsafe!(
            rp_sys::rp_GPIOnSetDirection(direction)
        )
    }

    pub fn get_direction() -> Result<u32, String>
    {
        let mut direction = 0;

        match handle_unsafe!(
            rp_sys::rp_GPIOnGetDirection(&mut direction)
        ) {
            Ok(_) => Ok(direction),
            Err(err) => Err(err),
        }
    }

    pub fn set_state(state: u32) -> Result<(), String>
    {
        handle_unsafe!(
            rp_sys::rp_GPIOnSetState(state)
        )
    }

    pub fn get_state() -> Result<u32, String>
    {
        let mut state = 0;

        match handle_unsafe!(
            rp_sys::rp_GPIOnGetState(&mut state)
        ) {
            Ok(_) => Ok(state),
            Err(err) => Err(err),
        }
    }
}

pub mod p {
    extern crate rp_sys;

    pub fn set_direction(direction: u32) -> Result<(), String>
    {
        handle_unsafe!(
            rp_sys::rp_GPIOpSetDirection(direction)
        )
    }

    pub fn get_direction() -> Result<u32, String>
    {
        let mut direction = 0;

        match handle_unsafe!(
            rp_sys::rp_GPIOpGetDirection(&mut direction)
        ) {
            Ok(_) => Ok(direction),
            Err(err) => Err(err),
        }
    }

    pub fn set_state(state: u32) -> Result<(), String>
    {
        handle_unsafe!(
            rp_sys::rp_GPIOpSetState(state)
            )
    }

    pub fn get_state() -> Result<u32, String>
    {
        let mut state = 0;

        match handle_unsafe!(
            rp_sys::rp_GPIOpGetState(&mut state)
        ) {
            Ok(_) => Ok(state),
            Err(err) => Err(err),
        }
    }
}