88//!
99//! Let's get through the functionality and configurations provided by this GPIO
1010//! module:
11- //! - `get_io_mux_reg(gpio_num: u8) -> &'static
12- //! crate::peripherals::io_mux::GPIO0:`:
11+ //! - `get_io_mux_reg(gpio_num: u8) -> &'static io_mux::GPIO0:`:
1312//! * This function returns a reference to the GPIO register associated
1413//! with the given GPIO number. It uses unsafe code and transmutation to
1514//! access the GPIO registers based on the provided GPIO number.
4645//! registers for both the `PRO CPU` and `APP CPU`. The implementation uses the
4746//! `gpio` peripheral to access the appropriate registers.
4847
48+ use core:: mem:: transmute;
49+
4950use crate :: {
5051 gpio:: {
5152 AlternateFunction ,
@@ -54,7 +55,7 @@ use crate::{
5455 InterruptStatusRegisterAccessBank0 ,
5556 InterruptStatusRegisterAccessBank1 ,
5657 } ,
57- peripherals:: GPIO ,
58+ peripherals:: { io_mux , GPIO , IO_MUX } ,
5859 Cpu ,
5960} ;
6061
@@ -72,155 +73,47 @@ pub(crate) const ZERO_INPUT: u8 = 0x30;
7273
7374pub ( crate ) const GPIO_FUNCTION : AlternateFunction = AlternateFunction :: Function2 ;
7475
75- pub ( crate ) fn get_io_mux_reg ( gpio_num : u8 ) -> & ' static crate :: peripherals :: io_mux:: GPIO0 {
76+ pub ( crate ) fn get_io_mux_reg ( gpio_num : u8 ) -> & ' static io_mux:: GPIO0 {
7677 unsafe {
77- let iomux = & * crate :: peripherals :: IO_MUX :: PTR ;
78+ let iomux = & * IO_MUX :: PTR ;
7879
7980 match gpio_num {
80- 0 => core:: mem:: transmute :: <
81- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
82- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
83- > ( iomux. gpio0 ( ) ) ,
84- 1 => core:: mem:: transmute :: <
85- & ' static crate :: peripherals:: io_mux:: GPIO1 ,
86- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
87- > ( iomux. gpio1 ( ) ) ,
88- 2 => core:: mem:: transmute :: <
89- & ' static crate :: peripherals:: io_mux:: GPIO2 ,
90- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
91- > ( iomux. gpio2 ( ) ) ,
92- 3 => core:: mem:: transmute :: <
93- & ' static crate :: peripherals:: io_mux:: GPIO3 ,
94- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
95- > ( iomux. gpio3 ( ) ) ,
96- 4 => core:: mem:: transmute :: <
97- & ' static crate :: peripherals:: io_mux:: GPIO4 ,
98- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
99- > ( iomux. gpio4 ( ) ) ,
100- 5 => core:: mem:: transmute :: <
101- & ' static crate :: peripherals:: io_mux:: GPIO5 ,
102- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
103- > ( iomux. gpio5 ( ) ) ,
104- 6 => core:: mem:: transmute :: <
105- & ' static crate :: peripherals:: io_mux:: GPIO6 ,
106- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
107- > ( iomux. gpio6 ( ) ) ,
108- 7 => core:: mem:: transmute :: <
109- & ' static crate :: peripherals:: io_mux:: GPIO7 ,
110- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
111- > ( iomux. gpio7 ( ) ) ,
112- 8 => core:: mem:: transmute :: <
113- & ' static crate :: peripherals:: io_mux:: GPIO8 ,
114- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
115- > ( iomux. gpio8 ( ) ) ,
116- 9 => core:: mem:: transmute :: <
117- & ' static crate :: peripherals:: io_mux:: GPIO9 ,
118- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
119- > ( iomux. gpio9 ( ) ) ,
120- 10 => core:: mem:: transmute :: <
121- & ' static crate :: peripherals:: io_mux:: GPIO10 ,
122- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
123- > ( iomux. gpio10 ( ) ) ,
124- 11 => core:: mem:: transmute :: <
125- & ' static crate :: peripherals:: io_mux:: GPIO11 ,
126- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
127- > ( iomux. gpio11 ( ) ) ,
128- 12 => core:: mem:: transmute :: <
129- & ' static crate :: peripherals:: io_mux:: GPIO12 ,
130- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
131- > ( iomux. gpio12 ( ) ) ,
132- 13 => core:: mem:: transmute :: <
133- & ' static crate :: peripherals:: io_mux:: GPIO13 ,
134- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
135- > ( iomux. gpio13 ( ) ) ,
136- 14 => core:: mem:: transmute :: <
137- & ' static crate :: peripherals:: io_mux:: GPIO14 ,
138- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
139- > ( iomux. gpio14 ( ) ) ,
140- 15 => core:: mem:: transmute :: <
141- & ' static crate :: peripherals:: io_mux:: GPIO15 ,
142- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
143- > ( iomux. gpio15 ( ) ) ,
144- 16 => core:: mem:: transmute :: <
145- & ' static crate :: peripherals:: io_mux:: GPIO16 ,
146- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
147- > ( iomux. gpio16 ( ) ) ,
148- 17 => core:: mem:: transmute :: <
149- & ' static crate :: peripherals:: io_mux:: GPIO17 ,
150- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
151- > ( iomux. gpio17 ( ) ) ,
152- 18 => core:: mem:: transmute :: <
153- & ' static crate :: peripherals:: io_mux:: GPIO18 ,
154- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
155- > ( iomux. gpio18 ( ) ) ,
156- 19 => core:: mem:: transmute :: <
157- & ' static crate :: peripherals:: io_mux:: GPIO19 ,
158- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
159- > ( iomux. gpio19 ( ) ) ,
160- 20 => core:: mem:: transmute :: <
161- & ' static crate :: peripherals:: io_mux:: GPIO20 ,
162- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
163- > ( iomux. gpio20 ( ) ) ,
164- 21 => core:: mem:: transmute :: <
165- & ' static crate :: peripherals:: io_mux:: GPIO21 ,
166- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
167- > ( iomux. gpio21 ( ) ) ,
168- 22 => core:: mem:: transmute :: <
169- & ' static crate :: peripherals:: io_mux:: GPIO22 ,
170- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
171- > ( iomux. gpio22 ( ) ) ,
172- 23 => core:: mem:: transmute :: <
173- & ' static crate :: peripherals:: io_mux:: GPIO23 ,
174- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
175- > ( iomux. gpio23 ( ) ) ,
176- 24 => core:: mem:: transmute :: <
177- & ' static crate :: peripherals:: io_mux:: GPIO24 ,
178- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
179- > ( iomux. gpio24 ( ) ) ,
180- 25 => core:: mem:: transmute :: <
181- & ' static crate :: peripherals:: io_mux:: GPIO25 ,
182- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
183- > ( iomux. gpio25 ( ) ) ,
184- 26 => core:: mem:: transmute :: <
185- & ' static crate :: peripherals:: io_mux:: GPIO26 ,
186- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
187- > ( iomux. gpio26 ( ) ) ,
188- 27 => core:: mem:: transmute :: <
189- & ' static crate :: peripherals:: io_mux:: GPIO27 ,
190- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
191- > ( iomux. gpio27 ( ) ) ,
192- 32 => core:: mem:: transmute :: <
193- & ' static crate :: peripherals:: io_mux:: GPIO32 ,
194- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
195- > ( iomux. gpio32 ( ) ) ,
196- 33 => core:: mem:: transmute :: <
197- & ' static crate :: peripherals:: io_mux:: GPIO33 ,
198- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
199- > ( iomux. gpio33 ( ) ) ,
200- 34 => core:: mem:: transmute :: <
201- & ' static crate :: peripherals:: io_mux:: GPIO34 ,
202- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
203- > ( iomux. gpio34 ( ) ) ,
204- 35 => core:: mem:: transmute :: <
205- & ' static crate :: peripherals:: io_mux:: GPIO35 ,
206- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
207- > ( iomux. gpio35 ( ) ) ,
208- 36 => core:: mem:: transmute :: <
209- & ' static crate :: peripherals:: io_mux:: GPIO36 ,
210- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
211- > ( iomux. gpio36 ( ) ) ,
212- 37 => core:: mem:: transmute :: <
213- & ' static crate :: peripherals:: io_mux:: GPIO37 ,
214- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
215- > ( iomux. gpio37 ( ) ) ,
216- 38 => core:: mem:: transmute :: <
217- & ' static crate :: peripherals:: io_mux:: GPIO38 ,
218- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
219- > ( iomux. gpio38 ( ) ) ,
220- 39 => core:: mem:: transmute :: <
221- & ' static crate :: peripherals:: io_mux:: GPIO39 ,
222- & ' static crate :: peripherals:: io_mux:: GPIO0 ,
223- > ( iomux. gpio39 ( ) ) ,
81+ 0 => transmute :: < & ' static io_mux:: GPIO0 , & ' static io_mux:: GPIO0 > ( iomux. gpio0 ( ) ) ,
82+ 1 => transmute :: < & ' static io_mux:: GPIO1 , & ' static io_mux:: GPIO0 > ( iomux. gpio1 ( ) ) ,
83+ 2 => transmute :: < & ' static io_mux:: GPIO2 , & ' static io_mux:: GPIO0 > ( iomux. gpio2 ( ) ) ,
84+ 3 => transmute :: < & ' static io_mux:: GPIO3 , & ' static io_mux:: GPIO0 > ( iomux. gpio3 ( ) ) ,
85+ 4 => transmute :: < & ' static io_mux:: GPIO4 , & ' static io_mux:: GPIO0 > ( iomux. gpio4 ( ) ) ,
86+ 5 => transmute :: < & ' static io_mux:: GPIO5 , & ' static io_mux:: GPIO0 > ( iomux. gpio5 ( ) ) ,
87+ 6 => transmute :: < & ' static io_mux:: GPIO6 , & ' static io_mux:: GPIO0 > ( iomux. gpio6 ( ) ) ,
88+ 7 => transmute :: < & ' static io_mux:: GPIO7 , & ' static io_mux:: GPIO0 > ( iomux. gpio7 ( ) ) ,
89+ 8 => transmute :: < & ' static io_mux:: GPIO8 , & ' static io_mux:: GPIO0 > ( iomux. gpio8 ( ) ) ,
90+ 9 => transmute :: < & ' static io_mux:: GPIO9 , & ' static io_mux:: GPIO0 > ( iomux. gpio9 ( ) ) ,
91+ 10 => transmute :: < & ' static io_mux:: GPIO10 , & ' static io_mux:: GPIO0 > ( iomux. gpio10 ( ) ) ,
92+ 11 => transmute :: < & ' static io_mux:: GPIO11 , & ' static io_mux:: GPIO0 > ( iomux. gpio11 ( ) ) ,
93+ 12 => transmute :: < & ' static io_mux:: GPIO12 , & ' static io_mux:: GPIO0 > ( iomux. gpio12 ( ) ) ,
94+ 13 => transmute :: < & ' static io_mux:: GPIO13 , & ' static io_mux:: GPIO0 > ( iomux. gpio13 ( ) ) ,
95+ 14 => transmute :: < & ' static io_mux:: GPIO14 , & ' static io_mux:: GPIO0 > ( iomux. gpio14 ( ) ) ,
96+ 15 => transmute :: < & ' static io_mux:: GPIO15 , & ' static io_mux:: GPIO0 > ( iomux. gpio15 ( ) ) ,
97+ 16 => transmute :: < & ' static io_mux:: GPIO16 , & ' static io_mux:: GPIO0 > ( iomux. gpio16 ( ) ) ,
98+ 17 => transmute :: < & ' static io_mux:: GPIO17 , & ' static io_mux:: GPIO0 > ( iomux. gpio17 ( ) ) ,
99+ 18 => transmute :: < & ' static io_mux:: GPIO18 , & ' static io_mux:: GPIO0 > ( iomux. gpio18 ( ) ) ,
100+ 19 => transmute :: < & ' static io_mux:: GPIO19 , & ' static io_mux:: GPIO0 > ( iomux. gpio19 ( ) ) ,
101+ 20 => transmute :: < & ' static io_mux:: GPIO20 , & ' static io_mux:: GPIO0 > ( iomux. gpio20 ( ) ) ,
102+ 21 => transmute :: < & ' static io_mux:: GPIO21 , & ' static io_mux:: GPIO0 > ( iomux. gpio21 ( ) ) ,
103+ 22 => transmute :: < & ' static io_mux:: GPIO22 , & ' static io_mux:: GPIO0 > ( iomux. gpio22 ( ) ) ,
104+ 23 => transmute :: < & ' static io_mux:: GPIO23 , & ' static io_mux:: GPIO0 > ( iomux. gpio23 ( ) ) ,
105+ 24 => transmute :: < & ' static io_mux:: GPIO24 , & ' static io_mux:: GPIO0 > ( iomux. gpio24 ( ) ) ,
106+ 25 => transmute :: < & ' static io_mux:: GPIO25 , & ' static io_mux:: GPIO0 > ( iomux. gpio25 ( ) ) ,
107+ 26 => transmute :: < & ' static io_mux:: GPIO26 , & ' static io_mux:: GPIO0 > ( iomux. gpio26 ( ) ) ,
108+ 27 => transmute :: < & ' static io_mux:: GPIO27 , & ' static io_mux:: GPIO0 > ( iomux. gpio27 ( ) ) ,
109+ 32 => transmute :: < & ' static io_mux:: GPIO32 , & ' static io_mux:: GPIO0 > ( iomux. gpio32 ( ) ) ,
110+ 33 => transmute :: < & ' static io_mux:: GPIO33 , & ' static io_mux:: GPIO0 > ( iomux. gpio33 ( ) ) ,
111+ 34 => transmute :: < & ' static io_mux:: GPIO34 , & ' static io_mux:: GPIO0 > ( iomux. gpio34 ( ) ) ,
112+ 35 => transmute :: < & ' static io_mux:: GPIO35 , & ' static io_mux:: GPIO0 > ( iomux. gpio35 ( ) ) ,
113+ 36 => transmute :: < & ' static io_mux:: GPIO36 , & ' static io_mux:: GPIO0 > ( iomux. gpio36 ( ) ) ,
114+ 37 => transmute :: < & ' static io_mux:: GPIO37 , & ' static io_mux:: GPIO0 > ( iomux. gpio37 ( ) ) ,
115+ 38 => transmute :: < & ' static io_mux:: GPIO38 , & ' static io_mux:: GPIO0 > ( iomux. gpio38 ( ) ) ,
116+ 39 => transmute :: < & ' static io_mux:: GPIO39 , & ' static io_mux:: GPIO0 > ( iomux. gpio39 ( ) ) ,
224117 _ => panic ! ( ) ,
225118 }
226119 }
0 commit comments