opentitanlib/test_utils/bitbanging/
mod.rs

1// Copyright lowRISC contributors (OpenTitan project).
2// Licensed under the Apache License, Version 2.0, see LICENSE for details.
3// SPDX-License-Identifier: Apache-2.0
4
5pub mod i2c;
6pub mod pwm;
7pub mod spi;
8pub mod uart;
9pub mod uart_rx_sampling;
10
11use serde::{Deserialize, Serialize};
12
13#[repr(u8)]
14#[derive(Debug, PartialEq, Clone, Copy, Serialize, Deserialize)]
15pub enum Bit {
16    Low = 0,
17    High = 1,
18}
19
20impl From<bool> for Bit {
21    fn from(val: bool) -> Self {
22        if val { Self::High } else { Self::Low }
23    }
24}
25
26impl From<u8> for Bit {
27    fn from(val: u8) -> Self {
28        match val {
29            0x00 => Self::Low,
30            _ => Self::High,
31        }
32    }
33}