rp2040/
deferred_calls.rs

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
// Licensed under the Apache License, Version 2.0 or the MIT License.
// SPDX-License-Identifier: Apache-2.0 OR MIT
// Copyright Tock Contributors 2022.

//! Definition of Deferred Call tasks.
//!
//! Deferred calls also peripheral drivers to register pseudo interrupts.
//! These are the definitions of which deferred calls this chip needs.

/// A type of task to defer a call for
#[derive(Copy, Clone)]
pub enum DeferredCallTask {
    DateTimeGet = 0,
    DateTimeSet = 1,
}

impl TryFrom<usize> for DeferredCallTask {
    type Error = ();

    fn try_from(value: usize) -> Result<DeferredCallTask, ()> {
        match value {
            0 => Ok(DeferredCallTask::DateTimeGet),
            1 => Ok(DeferredCallTask::DateTimeSet),
            _ => Err(()),
        }
    }
}

impl From<DeferredCallTask> for usize {
    fn from(val: DeferredCallTask) -> Self {
        val as usize
    }
}