1 -- vim: ft=lua ts=2 et sw=2 2 3 -- Start Mag to multiplex the framebuffer showing only a single program. 4 -- This example shows the key values produced by the input event driver. 5 -- The target platform is the Letux 400 notebook computer. 6 7 local L4 = require("L4"); 8 9 local l = L4.default_loader; 10 11 -- Define general access to peripherals. 12 13 local io_buses = { 14 cpm = l:new_channel(); 15 gpio = l:new_channel(); 16 lcd = l:new_channel(); 17 pwm = l:new_channel(); -- exposes GPIO, PWM 18 }; 19 20 l:start({ 21 caps = { 22 cpm = io_buses.cpm:svr(), 23 gpio = io_buses.gpio:svr(), 24 lcd = io_buses.lcd:svr(), 25 pwm = io_buses.pwm:svr(), 26 27 icu = L4.Env.icu, 28 sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), 29 }, 30 }, 31 "rom/io rom/hw_devices.io rom/mips-letux400-common.io"); 32 33 -- Expose a PWM peripheral as a device. 34 35 local pwm = l:new_channel(); 36 37 l:startv({ 38 caps = { 39 vbus = io_buses.pwm, 40 pwm = pwm:svr(), 41 }, 42 }, 43 "rom/dev_pwm_jz4730", "0", "250", "299", "47"); -- specifying peripheral number, parameters 44 45 -- Expose a PWM backlight device. 46 47 local backlight = l:new_channel(); -- exposes backlight device 48 49 l:startv({ 50 caps = { 51 pwm = pwm, 52 backlight = backlight:svr(), 53 }, 54 }, 55 "rom/dev_backlight_pwm", "0", "300"); -- specifying limits 56 57 -- Expose a display device for the Letux. 58 59 local display = l:new_channel(); -- exposes display device 60 61 l:start({ 62 caps = { 63 backlight = backlight, 64 display = display:svr(), 65 vbus = io_buses.gpio, 66 }, 67 }, 68 "rom/dev_display_letux400"); 69 70 -- Expose a panel definition for the Letux. 71 72 local panel = l:new_channel(); -- exposes panel 73 74 l:start({ 75 caps = { 76 panel = panel:svr(), 77 }, 78 }, 79 "rom/dev_panel_letux400"); 80 81 -- Expose the CPM peripheral. 82 83 local cpm = l:new_channel(); 84 85 l:start({ 86 caps = { 87 vbus = io_buses.cpm, 88 cpm = cpm:svr(), 89 }, 90 }, 91 "rom/dev_cpm_jz4730"); 92 93 -- Expose a framebuffer device. 94 95 local fbdrv_fb = l:new_channel(); 96 97 l:start({ 98 caps = { 99 vbus = io_buses.lcd, 100 fb = fbdrv_fb:svr(), 101 cpm = cpm, 102 display = display, -- needed by LCD driver 103 panel = panel, 104 }, 105 }, 106 "rom/fb-drv"); 107 108 -- Multiplex the framebuffer. 109 110 local mag_caps = { 111 mag = l:new_channel(), 112 svc = l:new_channel(), 113 }; 114 115 l:start({ 116 caps = { 117 vbus = io_buses.gpio, -- needed by input driver 118 fb = fbdrv_fb, 119 mag = mag_caps.mag:svr(), 120 svc = mag_caps.svc:svr(), 121 }, 122 }, 123 "rom/mag"); 124 125 -- Expose the keypad matrix. 126 127 local keypad = l:new_channel(); 128 129 l:start({ 130 caps = { 131 vbus = io_buses.gpio, 132 keypad = keypad:svr(), 133 }, 134 }, 135 "rom/dev_keypad_letux400"); 136 137 -- Expose the keypad events. 138 139 local ev = l:new_channel(); 140 141 l:start({ 142 caps = { 143 keypad = keypad, 144 ev = ev:svr(), 145 }, 146 }, 147 "rom/dev_input_keypad_letux400"); 148 149 -- Show key event values. 150 151 l:startv({ 152 caps = { 153 fb = mag_caps.svc:create(L4.Proto.Goos, "g=800x460+0+0", "barheight=20"), 154 ev = ev, 155 }, 156 }, 157 "rom/ex_input_event_client", "chars");