4
4
use core:: sync:: atomic:: AtomicBool ;
5
5
// use core::arch::asm;
6
6
use ast1060_pac:: Peripherals ;
7
- use aspeed_ddk:: { gpio :: { gpioa , Floating , GpioExt } , uart:: { Config , UartController } } ;
7
+ use aspeed_ddk:: uart:: { Config , UartController } ;
8
8
use ast1060_pac:: { Wdt , Wdt1 } ;
9
9
use aspeed_ddk:: watchdog:: WdtController ;
10
10
@@ -13,10 +13,11 @@ use aspeed_ddk::hash::Controller;
13
13
use aspeed_ddk:: syscon:: SysCon ;
14
14
15
15
use aspeed_ddk:: tests:: functional:: hash_test:: run_hash_tests;
16
+ use aspeed_ddk:: tests:: functional:: gpio_test;
16
17
use panic_halt as _;
17
18
18
19
use cortex_m_rt:: entry;
19
- use embedded_hal:: { delay:: DelayNs , digital :: { InputPin , OutputPin , StatefulOutputPin } } ;
20
+ use embedded_hal:: delay:: DelayNs ;
20
21
21
22
use embedded_io:: Write ;
22
23
use cortex_m_rt:: pre_init;
@@ -78,42 +79,6 @@ fn test_wdt( uart:&mut UartController<'_>) {
78
79
}
79
80
}
80
81
}
81
- fn test_gpio ( uart : & mut UartController < ' _ > ) {
82
- let _peripherals = unsafe { Peripherals :: steal ( ) } ;
83
- let gpio = _peripherals. gpio ;
84
-
85
- let gpioa = gpioa:: GPIOA :: new ( gpio) . split ( ) ;
86
- uart. write_all ( b"\r \n ####### GPIO test #######\r \n " ) . unwrap ( ) ;
87
- // input test
88
- let mut pa0 = gpioa. pa0 . into_pull_down_input ( ) ;
89
- if pa0. is_low ( ) . unwrap ( ) {
90
- uart. write_all ( b"\r GPIOA pin0 is low\r \n " ) . unwrap ( ) ;
91
- }
92
- let mut pa1 = gpioa. pa1 . into_pull_up_input ( ) ;
93
- if pa1. is_high ( ) . unwrap ( ) {
94
- uart. write_all ( b"\r GPIOA pin1 is high\r \n " ) . unwrap ( ) ;
95
- }
96
- // output test
97
- let mut pa3 = gpioa. pa3 . into_open_drain_output :: < Floating > ( ) ;
98
- pa3. set_low ( ) . unwrap ( ) ;
99
- if pa3. is_set_low ( ) . unwrap ( ) {
100
- uart. write_all ( b"\r GPIOA pin3 set low successfully\r \n " ) . unwrap ( ) ;
101
- }
102
- pa3. set_high ( ) . unwrap ( ) ;
103
- if pa3. is_set_high ( ) . unwrap ( ) {
104
- uart. write_all ( b"\r GPIOA pin3 set high successfully\r \n " ) . unwrap ( ) ;
105
- }
106
-
107
- let mut pa4 = gpioa. pa4 . into_push_pull_output ( ) ;
108
- pa4. set_low ( ) . unwrap ( ) ;
109
- if pa4. is_set_low ( ) . unwrap ( ) {
110
- uart. write_all ( b"\r GPIOA pin4 set low successfully\r \n " ) . unwrap ( ) ;
111
- }
112
- pa4. set_high ( ) . unwrap ( ) ;
113
- if pa4. is_set_high ( ) . unwrap ( ) {
114
- uart. write_all ( b"\r GPIOA pin4 set high successfully\r \n " ) . unwrap ( ) ;
115
- }
116
- }
117
82
118
83
#[ no_mangle]
119
84
pub static HALT : AtomicBool = AtomicBool :: new ( true ) ;
@@ -170,7 +135,7 @@ fn main() -> ! {
170
135
let mut hace_controller = Controller :: new ( hace) ;
171
136
172
137
run_hash_tests ( & mut uart_controller, & mut hace_controller) ;
173
- test_gpio ( & mut uart_controller) ;
138
+ gpio_test :: test_gpioa ( & mut uart_controller) ;
174
139
test_wdt ( & mut uart_controller) ;
175
140
// Initialize the peripherals here if needed
176
141
loop { }
0 commit comments