#![allow(dead_code)]
use crate::device::VADC;
pub trait VadcExt {
fn constrain(self) -> Vadc;
}
impl VadcExt for Vadc {
fn constrain(self) -> Vadc {
Vadc {}
}
}
pub struct Vadc {}
#[derive(Debug, PartialEq, PartialOrd, Copy, Clone)]
pub enum ServiceRequest {
GroupSR0,
GroupSR1,
GroupSR2,
GroupSR3,
SharedSR0,
SharedSR1,
SharedSR2,
SharedSR3,
}
impl From<ServiceRequest> for u8 {
fn from(bits: ServiceRequest) -> Self {
match bits {
ServiceRequest::GroupSR0 => 0,
ServiceRequest::GroupSR1 => 1,
ServiceRequest::GroupSR2 => 2,
ServiceRequest::GroupSR3 => 3,
ServiceRequest::SharedSR0 => 4,
ServiceRequest::SharedSR1 => 5,
ServiceRequest::SharedSR2 => 6,
ServiceRequest::SharedSR3 => 7,
}
}
}
impl From<u8> for ServiceRequest {
fn from(bits: u8) -> Self {
match bits {
0 => ServiceRequest::GroupSR0,
1 => ServiceRequest::GroupSR1,
2 => ServiceRequest::GroupSR2,
3 => ServiceRequest::GroupSR3,
4 => ServiceRequest::SharedSR0,
5 => ServiceRequest::SharedSR1,
6 => ServiceRequest::SharedSR2,
7 => ServiceRequest::SharedSR3,
_ => unimplemented!(),
}
}
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum StartMode {
WithoutInterruption,
InterruptionResume,
InterruptionStop,
}
impl From<StartMode> for u8 {
fn from(bits: StartMode) -> Self {
match bits {
StartMode::WithoutInterruption => 0,
StartMode::InterruptionResume => 1,
StartMode::InterruptionStop => 2,
}
}
}
impl From<u8> for StartMode {
fn from(bits: u8) -> Self {
match bits {
0 => StartMode::WithoutInterruption,
1 => StartMode::InterruptionResume,
2 => StartMode::InterruptionStop,
_ => unimplemented!(),
}
}
}
#[derive(Debug, PartialEq, Copy, Clone)]
pub enum TriggerEdge {
None,
Falling,
Rising,
Any,
}
impl From<TriggerEdge> for u8 {
fn from(bits: TriggerEdge) -> Self {
match bits {
TriggerEdge::None => 0,
TriggerEdge::Falling => 1,
TriggerEdge::Rising => 2,
TriggerEdge::Any => 3,
}
}
}
impl From<u8> for TriggerEdge {
fn from(bits: u8) -> Self {
match bits {
0 => TriggerEdge::None,
1 => TriggerEdge::Falling,
2 => TriggerEdge::Rising,
3 => TriggerEdge::Any,
_ => unimplemented!(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum TriggerInputSelect {
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
}
impl From<TriggerInputSelect> for u8 {
fn from(bits: TriggerInputSelect) -> Self {
match bits {
TriggerInputSelect::A => 0,
TriggerInputSelect::B => 1,
TriggerInputSelect::C => 2,
TriggerInputSelect::D => 3,
TriggerInputSelect::E => 4,
TriggerInputSelect::F => 5,
TriggerInputSelect::G => 6,
TriggerInputSelect::H => 7,
TriggerInputSelect::I => 8,
TriggerInputSelect::J => 9,
TriggerInputSelect::K => 10,
TriggerInputSelect::L => 11,
TriggerInputSelect::M => 12,
TriggerInputSelect::N => 13,
TriggerInputSelect::O => 14,
TriggerInputSelect::P => 15,
}
}
}
impl From<u8> for TriggerInputSelect {
fn from(bits: u8) -> Self {
match bits {
0 => TriggerInputSelect::A,
1 => TriggerInputSelect::B,
2 => TriggerInputSelect::C,
3 => TriggerInputSelect::D,
4 => TriggerInputSelect::E,
5 => TriggerInputSelect::F,
6 => TriggerInputSelect::G,
7 => TriggerInputSelect::H,
8 => TriggerInputSelect::I,
9 => TriggerInputSelect::J,
10 => TriggerInputSelect::K,
11 => TriggerInputSelect::L,
12 => TriggerInputSelect::M,
13 => TriggerInputSelect::N,
14 => TriggerInputSelect::O,
15 => TriggerInputSelect::P,
_ => unimplemented!(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum GateInputSelect {
A,
B,
C,
D,
E,
F,
G,
H,
I,
J,
K,
L,
M,
N,
O,
P,
}
impl From<GateInputSelect> for u8 {
fn from(bits: GateInputSelect) -> Self {
match bits {
GateInputSelect::A => 0,
GateInputSelect::B => 1,
GateInputSelect::C => 2,
GateInputSelect::D => 3,
GateInputSelect::E => 4,
GateInputSelect::F => 5,
GateInputSelect::G => 6,
GateInputSelect::H => 7,
GateInputSelect::I => 8,
GateInputSelect::J => 9,
GateInputSelect::K => 10,
GateInputSelect::L => 11,
GateInputSelect::M => 12,
GateInputSelect::N => 13,
GateInputSelect::O => 14,
GateInputSelect::P => 15,
}
}
}
impl From<u8> for GateInputSelect {
fn from(bits: u8) -> Self {
match bits {
0 => GateInputSelect::A,
1 => GateInputSelect::B,
2 => GateInputSelect::C,
3 => GateInputSelect::D,
4 => GateInputSelect::E,
5 => GateInputSelect::F,
6 => GateInputSelect::G,
7 => GateInputSelect::H,
8 => GateInputSelect::I,
9 => GateInputSelect::J,
10 => GateInputSelect::K,
11 => GateInputSelect::L,
12 => GateInputSelect::M,
13 => GateInputSelect::N,
14 => GateInputSelect::O,
15 => GateInputSelect::P,
_ => unimplemented!(),
}
}
}
#[derive(Debug, Clone, Copy)]
pub enum GateMode {
Block,
Ignore,
ActiveHigh,
ActiveLow,
}
impl From<GateMode> for u8 {
fn from(bits: GateMode) -> Self {
match bits {
GateMode::Block => 0,
GateMode::Ignore => 1,
GateMode::ActiveHigh => 2,
GateMode::ActiveLow => 3,
}
}
}
impl From<u8> for GateMode {
fn from(bits: u8) -> Self {
match bits {
0 => GateMode::Block,
1 => GateMode::Ignore,
2 => GateMode::ActiveHigh,
3 => GateMode::ActiveLow,
_ => unimplemented!(),
}
}
}
impl Vadc {
pub fn enable_module_clock(self) {
set!(VADC, clc, disr);
}
pub fn disable_module_clock(self) {
clear!(VADC, clc, disr);
}
pub fn enable_sleep_mode(self) {
clear!(VADC, clc, edis);
}
pub fn disable_sleep_mode(self) {
set!(VADC, clc, edis);
}
pub fn clock_init(self) {
set!(VADC, globcfg, divwc);
}
pub fn disable_startup_calibration(self) {
clear!(VADC, globcfg, sucal);
}
}
#[cfg(test)]
mod tests {
#[test]
fn nothing() {
}
}