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 the CPM peripheral. 72 73 local cpm = l:new_channel(); 74 75 l:start({ 76 caps = { 77 vbus = io_buses.cpm, 78 cpm = cpm:svr(), 79 }, 80 }, 81 "rom/dev_cpm_jz4730"); 82 83 -- Expose a framebuffer device. 84 85 local fbdrv_fb = l:new_channel(); 86 87 l:start({ 88 caps = { 89 vbus = io_buses.lcd, 90 fb = fbdrv_fb:svr(), 91 cpm = cpm, 92 display = display, -- needed by LCD driver 93 }, 94 }, 95 "rom/fb-drv"); 96 97 -- Multiplex the framebuffer. 98 99 local mag_caps = { 100 mag = l:new_channel(), 101 svc = l:new_channel(), 102 }; 103 104 l:start({ 105 caps = { 106 vbus = io_buses.gpio, -- needed by input driver 107 fb = fbdrv_fb, 108 mag = mag_caps.mag:svr(), 109 svc = mag_caps.svc:svr(), 110 }, 111 }, 112 "rom/mag"); 113 114 -- Expose the keypad matrix. 115 116 local keypad = l:new_channel(); 117 118 l:start({ 119 caps = { 120 vbus = io_buses.gpio, 121 keypad = keypad:svr(), 122 }, 123 }, 124 "rom/dev_keypad_letux400"); 125 126 -- Show the keypad matrix. 127 128 l:startv({ 129 caps = { 130 fb = mag_caps.svc:create(L4.Proto.Goos, "g=800x460+0+0", "barheight=20"), 131 keypad = keypad, 132 }, 133 }, 134 "rom/ex_keypad_ds_client", "17", "8"); -- specifying keypad matrix dimensions