2010-05-10 02:07:17 +03:00
|
|
|
#pypp 0
|
|
|
|
#include <iris.hh>
|
2012-09-26 20:03:36 +03:00
|
|
|
#include <devices.hh>
|
2010-05-10 02:07:17 +03:00
|
|
|
|
2012-09-26 20:03:36 +03:00
|
|
|
enum captypes:
|
|
|
|
CONTROL = 1
|
|
|
|
KBD
|
|
|
|
INTERRUPT
|
2010-05-10 02:07:17 +03:00
|
|
|
|
|
|
|
Iris::Num start ():
|
2012-09-26 20:03:36 +03:00
|
|
|
unsigned *screen = (unsigned *)0x40000000
|
|
|
|
Iris::RTC rtc = Iris::my_parent.get_capability <Iris::RTC> ()
|
|
|
|
Iris::Display display = Iris::my_parent.get_capability <Iris::Display> ()
|
|
|
|
display.map_fb ((unsigned)screen)
|
|
|
|
Iris::Font font = Iris::my_parent.get_capability <Iris::Font> ()
|
|
|
|
font.set_display (display)
|
|
|
|
Iris::Keyboard keyboard = Iris::my_parent.get_capability <Iris::Keyboard> ()
|
|
|
|
Iris::Cap cap = Iris::my_receiver.create_capability (KBD)
|
|
|
|
keyboard.set_cb (cap.copy ())
|
|
|
|
Iris::free_cap (cap)
|
|
|
|
Iris::Buzzer buzzer = Iris::my_parent.get_capability <Iris::Buzzer> ()
|
|
|
|
Iris::Event self = Iris::my_receiver.create_capability (CONTROL)
|
|
|
|
Iris::my_parent.provide_capability <Iris::Event> (self)
|
|
|
|
cap = Iris::my_receiver.create_capability (INTERRUPT)
|
2010-05-10 02:07:17 +03:00
|
|
|
Iris::my_parent.init_done ()
|
2013-05-12 16:46:11 +03:00
|
|
|
font.printf ("Press a key to attempt reboot.\n")
|
2010-05-10 02:07:17 +03:00
|
|
|
while true:
|
|
|
|
Iris::wait ()
|
|
|
|
switch Iris::recv.protected_data.l:
|
2012-09-26 20:03:36 +03:00
|
|
|
case INTERRUPT:
|
|
|
|
// Interrupt
|
|
|
|
if Iris::recv.data[0].l == ~0:
|
|
|
|
// Not a real interrupt, just an abort notification.
|
|
|
|
continue
|
|
|
|
font.printf ("alarm: interrupt\n")
|
|
|
|
break
|
|
|
|
case CONTROL:
|
|
|
|
// Store callback
|
|
|
|
font.printf ("alarm: control event\n")
|
|
|
|
break
|
|
|
|
case KBD:
|
2013-05-12 16:46:11 +03:00
|
|
|
if Iris::recv.data[0].l & Iris::Keyboard::RELEASE:
|
|
|
|
// Key release.
|
|
|
|
Iris::poweroff ()
|
|
|
|
else:
|
|
|
|
// Key press.
|
|
|
|
unsigned time = rtc.get_time ()
|
|
|
|
rtc.set_alarm (time + 5, cap)
|
|
|
|
unsigned alarm = rtc.get_alarm ()
|
|
|
|
unsigned enabled = Iris::recv.data[1].l
|
|
|
|
font.printf ("Debug: %d %d %d\n", time, alarm, enabled)
|
2012-09-26 20:03:36 +03:00
|
|
|
break
|
|
|
|
default:
|
|
|
|
Iris::panic (Iris::recv.protected_data.l, "invalid request for alarm")
|