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 the CPM peripheral. 71 72 local cpm = l:new_channel(); 73 74 l:start({ 75 caps = { 76 vbus = io_buses.cpm, 77 cpm = cpm:svr(), 78 }, 79 }, 80 "rom/dev_cpm_jz4730"); 81 82 -- Expose a framebuffer device. 83 84 local fbdrv_fb = l:new_channel(); -- exposes framebuffer 85 86 l:start({ 87 caps = { 88 vbus = io_buses.lcd, 89 fb = fbdrv_fb:svr(), 90 cpm = cpm, 91 display = display, -- needed by LCD driver 92 }, 93 }, 94 "rom/fb-drv"); 95 96 -- Multiplex the framebuffer. 97 98 local mag_caps = { 99 mag = l:new_channel(), 100 svc = l:new_channel(), 101 }; 102 103 l:start({ 104 caps = { 105 vbus = io_buses.gpio, -- needed by input driver 106 fb = fbdrv_fb, 107 mag = mag_caps.mag:svr(), 108 svc = mag_caps.svc:svr(), 109 }, 110 }, 111 "rom/mag"); 112 113 -- Expose the keypad matrix. 114 115 local keypad = l:new_channel(); 116 117 l:start({ 118 caps = { 119 vbus = io_buses.gpio, 120 keypad = keypad:svr(), 121 }, 122 }, 123 "rom/dev_keypad_letux400"); 124 125 -- Show the keypad matrix. 126 127 l:startv({ 128 caps = { 129 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+0+0", "barheight=20"), 130 keypad = keypad, 131 }, 132 }, 133 "rom/ex_keypad_ds_client", "17", "8"); -- specifying keypad matrix dimensions 134 135 -- Show the physical keypad layout. 136 137 l:start({ 138 caps = { 139 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+400+0", "barheight=20"), 140 keypad = keypad, 141 }, 142 }, 143 "rom/ex_letux400_keypad_physical"); 144 145 -- Expose the keypad events. 146 147 local ev1 = l:new_channel(); 148 149 l:start({ 150 caps = { 151 keypad = keypad, 152 ev = ev1:svr(), 153 }, 154 }, 155 "rom/dev_input_keypad"); 156 157 -- Show key event values. 158 159 l:start({ 160 caps = { 161 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+0+240", "barheight=20"), 162 ev = ev1, 163 }, 164 }, 165 "rom/ex_input_event_client"); 166 167 -- Expose the keypad events. 168 169 local ev2 = l:new_channel(); 170 171 l:start({ 172 caps = { 173 keypad = keypad, 174 ev = ev2:svr(), 175 }, 176 }, 177 "rom/dev_input_keypad"); 178 179 -- Show key strings. 180 181 l:startv({ 182 caps = { 183 fb = mag_caps.svc:create(L4.Proto.Goos, "g=400x220+400+240", "barheight=20"), 184 ev = ev2, 185 }, 186 }, 187 "rom/ex_input_event_client", "chars"); 188 189 -- Control the backlight using the keyboard. 190 191 l:start({ 192 caps = { 193 backlight = backlight, 194 keypad = keypad, 195 }, 196 }, 197 "rom/ex_letux400_backlight");