1use crate::pins;
2
3use super::{
4 function_kind::{Analog, Input, Output},
5 functions::{Function, FunctionTrait},
6 handle::Handle,
7 state::{Assigned, Unassigned},
8};
9
10macro_rules! fixed_functions {
11 ($(
12 $type:ident,
13 $kind:ident,
14 $register:ident,
15 $field:ident,
16 $pin:ident,
17 $default_state:ty;
18 )*) => {
19 #[allow(missing_docs)]
25 pub struct FixedFunctions {
26 $(pub $field: Function<$type, $default_state>,)*
27 }
28
29 impl FixedFunctions {
30 pub(crate) fn new() -> Self {
31 FixedFunctions {
32 $($field: Function::new($type(())),)*
33 }
34 }
35 }
36
37
38 $(
39 #[allow(non_camel_case_types)]
45 pub struct $type(());
46
47 impl FunctionTrait<pins::$pin> for $type {
48 type Kind = $kind;
49
50
51 fn assign(&mut self, _: &mut pins::$pin, swm : &mut Handle) {
52 swm.swm.$register.modify(|_, w| w.$field().clear_bit());
53 }
54
55 fn unassign(&mut self, _: &mut pins::$pin, swm : &mut Handle)
56 {
57 swm.swm.$register.modify(|_, w| w.$field().set_bit());
58 }
59 }
60 )*
61 }
62}
63
64#[cfg(feature = "82x")]
65fixed_functions!(
66 ACMP_I1 , Input , pinenable0, acmp_i1 , PIO0_0 , Unassigned;
67 ACMP_I2 , Input , pinenable0, acmp_i2 , PIO0_1 , Unassigned;
68 ACMP_I3 , Input , pinenable0, acmp_i3 , PIO0_14, Unassigned;
69 ACMP_I4 , Input , pinenable0, acmp_i4 , PIO0_23, Unassigned;
70 SWCLK , Output, pinenable0, swclk , PIO0_3 , Assigned<pins::PIO0_3>;
71 SWDIO , Output, pinenable0, swdio , PIO0_2 , Assigned<pins::PIO0_2>;
72 XTALIN , Input , pinenable0, xtalin , PIO0_8 , Unassigned;
73 XTALOUT , Output, pinenable0, xtalout , PIO0_9 , Unassigned;
74 RESETN , Input , pinenable0, resetn , PIO0_5 , Assigned<pins::PIO0_5>;
75 CLKIN , Input , pinenable0, clkin , PIO0_1 , Unassigned;
76 VDDCMP , Input , pinenable0, vddcmp , PIO0_6 , Unassigned;
77 I2C0_SDA, Output, pinenable0, i2c0_sda, PIO0_11, Unassigned;
78 I2C0_SCL, Output, pinenable0, i2c0_scl, PIO0_10, Unassigned;
79 ADC_0 , Analog, pinenable0, adc_0 , PIO0_7 , Unassigned;
80 ADC_1 , Analog, pinenable0, adc_1 , PIO0_6 , Unassigned;
81 ADC_2 , Analog, pinenable0, adc_2 , PIO0_14, Unassigned;
82 ADC_3 , Analog, pinenable0, adc_3 , PIO0_23, Unassigned;
83 ADC_4 , Analog, pinenable0, adc_4 , PIO0_22, Unassigned;
84 ADC_5 , Analog, pinenable0, adc_5 , PIO0_21, Unassigned;
85 ADC_6 , Analog, pinenable0, adc_6 , PIO0_20, Unassigned;
86 ADC_7 , Analog, pinenable0, adc_7 , PIO0_19, Unassigned;
87 ADC_8 , Analog, pinenable0, adc_8 , PIO0_18, Unassigned;
88 ADC_9 , Analog, pinenable0, adc_9 , PIO0_17, Unassigned;
89 ADC_10 , Analog, pinenable0, adc_10 , PIO0_13, Unassigned;
90 ADC_11 , Analog, pinenable0, adc_11 , PIO0_4 , Unassigned;
91);
92
93#[cfg(feature = "845")]
94fixed_functions!(
95 ACMP_I1 , Input , pinenable0, acmp_i1 , PIO0_0 , Unassigned;
96 ACMP_I2 , Input , pinenable0, acmp_i2 , PIO0_1 , Unassigned;
97 ACMP_I3 , Input , pinenable0, acmp_i3 , PIO0_14, Unassigned;
98 ACMP_I4 , Input , pinenable0, acmp_i4 , PIO0_23, Unassigned;
99 SWCLK , Output, pinenable0, swclk , PIO0_3 , Assigned<pins::PIO0_3>;
100 SWDIO , Output, pinenable0, swdio , PIO0_2 , Assigned<pins::PIO0_2>;
101 XTALIN , Input , pinenable0, xtalin , PIO0_8 , Unassigned;
102 XTALOUT , Output, pinenable0, xtalout , PIO0_9 , Unassigned;
103 RESETN , Input , pinenable0, resetn , PIO0_5 , Assigned<pins::PIO0_5>;
104 CLKIN , Input , pinenable0, clkin , PIO0_1 , Unassigned;
105 VDDCMP , Input , pinenable0, vddcmp , PIO0_6 , Unassigned;
106 I2C0_SDA, Output, pinenable0, i2c0_sda, PIO0_11, Unassigned;
107 I2C0_SCL, Output, pinenable0, i2c0_scl, PIO0_10, Unassigned;
108 ADC_0 , Analog, pinenable0, adc_0 , PIO0_7 , Unassigned;
109 ADC_1 , Analog, pinenable0, adc_1 , PIO0_6 , Unassigned;
110 ADC_2 , Analog, pinenable0, adc_2 , PIO0_14, Unassigned;
111 ADC_3 , Analog, pinenable0, adc_3 , PIO0_23, Unassigned;
112 ADC_4 , Analog, pinenable0, adc_4 , PIO0_22, Unassigned;
113 ADC_5 , Analog, pinenable0, adc_5 , PIO0_21, Unassigned;
114 ADC_6 , Analog, pinenable0, adc_6 , PIO0_20, Unassigned;
115 ADC_7 , Analog, pinenable0, adc_7 , PIO0_19, Unassigned;
116 ADC_8 , Analog, pinenable0, adc_8 , PIO0_18, Unassigned;
117 ADC_9 , Analog, pinenable0, adc_9 , PIO0_17, Unassigned;
118 ADC_10 , Analog, pinenable0, adc_10 , PIO0_13, Unassigned;
119 ADC_11 , Analog, pinenable0, adc_11 , PIO0_4 , Unassigned;
120 DACOUT0 , Analog, pinenable0, dacout0 , PIO0_17, Unassigned;
121 DACOUT1 , Analog, pinenable0, dacout1 , PIO0_29, Unassigned;
122 CAPT_X0 , Analog, pinenable0, capt_x0 , PIO0_31, Unassigned;
123 CAPT_X1 , Analog, pinenable0, capt_x1 , PIO1_0 , Unassigned;
124 CAPT_X2 , Analog, pinenable0, capt_x2 , PIO1_1 , Unassigned;
125 CAPT_X3 , Analog, pinenable0, capt_x3 , PIO1_2 , Unassigned;
126 CAPT_X4 , Analog, pinenable1, capt_x4 , PIO1_3 , Unassigned;
127 CAPT_X5 , Analog, pinenable1, capt_x5 , PIO1_4 , Unassigned;
128 CAPT_X6 , Analog, pinenable1, capt_x6 , PIO1_5 , Unassigned;
129 CAPT_X7 , Analog, pinenable1, capt_x7 , PIO1_6 , Unassigned;
130 CAPT_X8 , Analog, pinenable1, capt_x8 , PIO1_7 , Unassigned;
131 CAPT_YL , Analog, pinenable1, capt_yl , PIO1_8 , Unassigned;
132 CAPT_YH , Analog, pinenable1, capt_yh , PIO1_8 , Unassigned;
133);