1 -- vim: ft=lua ts=2 et sw=2 2 3 -- Start Mag to multiplex the framebuffer between several example programs. 4 -- These programs show the keypad status and also allow the backlight to be 5 -- adjusted. 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(); -- exposes framebuffer 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 -- Show the keypad matrix. 138 139 l:startv({ 140 caps = { 141 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+0+0", "barheight=20"), 142 keypad = keypad, 143 }, 144 }, 145 "rom/ex_keypad_ds_client", "17", "8"); -- specifying keypad matrix dimensions 146 147 -- Show the physical keypad layout. 148 149 l:start({ 150 caps = { 151 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+400+0", "barheight=20"), 152 keypad = keypad, 153 }, 154 }, 155 "rom/ex_letux400_keypad_physical"); 156 157 -- Expose the keypad events. 158 159 local ev1 = l:new_channel(); 160 161 l:start({ 162 caps = { 163 keypad = keypad, 164 ev = ev1:svr(), 165 }, 166 }, 167 "rom/dev_input_keypad_letux400"); 168 169 -- Show key event values. 170 171 l:start({ 172 caps = { 173 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+0+240", "barheight=20"), 174 ev = ev1, 175 }, 176 }, 177 "rom/ex_input_event_client"); 178 179 -- Expose the keypad events. 180 181 local ev2 = l:new_channel(); 182 183 l:start({ 184 caps = { 185 keypad = keypad, 186 ev = ev2:svr(), 187 }, 188 }, 189 "rom/dev_input_keypad_letux400"); 190 191 -- Show key strings. 192 193 l:startv({ 194 caps = { 195 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+400+240", "barheight=20"), 196 ev = ev2, 197 }, 198 }, 199 "rom/ex_input_event_client", "chars"); 200 201 -- Control the backlight using the keyboard. 202 203 l:start({ 204 caps = { 205 backlight = backlight, 206 keypad = keypad, 207 }, 208 }, 209 "rom/ex_letux400_backlight");