@@ -13,9 +13,78 @@ use kernel::hil;
1313use kernel:: Platform ;
1414use kernel:: { create_capability, debug, static_init} ;
1515
16- mod timer_test;
16+ mod timer_test {
17+ #![ allow( dead_code) ]
1718
18- pub mod io;
19+ use kernel:: debug;
20+ use kernel:: hil:: time:: { self , Alarm } ;
21+
22+ pub struct TimerTest < ' a , A : Alarm < ' a > > {
23+ alarm : & ' a A ,
24+ }
25+
26+ impl < A : Alarm < ' a > > TimerTest < ' a , A > {
27+ pub const fn new ( alarm : & ' a A ) -> TimerTest < ' a , A > {
28+ TimerTest { alarm : alarm }
29+ }
30+
31+ pub fn start ( & self ) {
32+ debug ! ( "starting" ) ;
33+ let start = self . alarm . now ( ) ;
34+ let exp = start + 99999 ;
35+ self . alarm . set_alarm ( exp) ;
36+ }
37+ }
38+
39+ impl < A : Alarm < ' a > > time:: AlarmClient for TimerTest < ' a , A > {
40+ fn fired ( & self ) {
41+ debug ! ( "timer!!" ) ;
42+ }
43+ }
44+ }
45+
46+ pub mod io {
47+ use arty_e21;
48+ use core:: fmt:: Write ;
49+ use core:: panic:: PanicInfo ;
50+ use core:: str;
51+ use kernel:: debug;
52+ use kernel:: hil:: gpio;
53+ use kernel:: hil:: led;
54+ use rv32i;
55+
56+ use crate :: PROCESSES ;
57+
58+ struct Writer ;
59+
60+ static mut WRITER : Writer = Writer { } ;
61+
62+ impl Write for Writer {
63+ fn write_str ( & mut self , s : & str ) -> :: core:: fmt:: Result {
64+ debug ! ( "{}" , s) ;
65+ Ok ( ( ) )
66+ }
67+ }
68+
69+ /// Panic handler.
70+ #[ cfg( not( test) ) ]
71+ #[ no_mangle]
72+ #[ panic_handler]
73+ pub unsafe extern "C" fn panic_fmt ( pi : & PanicInfo ) -> ! {
74+ // turn off the non panic leds, just in case
75+ let led_green = & arty_e21:: gpio:: PORT [ 19 ] ;
76+ gpio:: Pin :: make_output ( led_green) ;
77+ gpio:: Pin :: set ( led_green) ;
78+
79+ let led_blue = & arty_e21:: gpio:: PORT [ 21 ] ;
80+ gpio:: Pin :: make_output ( led_blue) ;
81+ gpio:: Pin :: set ( led_blue) ;
82+
83+ let led_red = & mut led:: LedLow :: new ( & mut arty_e21:: gpio:: PORT [ 22 ] ) ;
84+ let writer = & mut WRITER ;
85+ debug:: panic ( & mut [ led_red] , writer, pi, & rv32i:: support:: nop, & PROCESSES )
86+ }
87+ }
1988
2089// State for loading and holding applications.
2190
0 commit comments