#![no_std]
#![deny(unsafe_code, warnings)]
use num_enum::{IntoPrimitive, TryFromPrimitive};
use registers::Register;
mod communications;
pub mod mpr121;
mod registers;
#[cfg(all(feature = "sync", feature = "async"))]
compile_error!("You cannot use both sync and async features at the same time. Please choose one.");
#[cfg(all(not(feature = "async"), not(feature = "sync")))]
compile_error!("You must enable either the sync or async feature. Please choose one.");
#[derive(Clone, Copy, Debug, PartialEq, PartialOrd, Eq, Ord)]
pub enum Mpr121Error {
ChannelExceed,
ReadError(Register),
DataConversionError(Register),
WriteError(Register),
ResetFailed { was_read: bool, reg: Register },
OverCurrent,
WrongDevice {
mismatched_register: Register,
expected: u8,
actual: u8,
},
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, IntoPrimitive)]
pub enum Mpr121Address {
Default = 0x5a,
Vdd = 0x5b,
Sda = 0x5c,
Scl = 0x5d,
}
#[repr(u8)]
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, IntoPrimitive, TryFromPrimitive, Debug)]
pub enum Channel {
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
Eight,
Nine,
Ten,
Eleven,
}
impl Channel {
pub const NUM_CHANNELS: u8 = 12;
pub(crate) fn get_bit_mask(self) -> u16 {
1 << u8::from(self)
}
}
#[repr(u8)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, PartialOrd, Ord, IntoPrimitive, TryFromPrimitive)]
pub enum DebounceNumber {
Zero,
One,
Two,
Three,
Four,
Five,
Six,
Seven,
}