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