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 an animation showing off a spectrum of colours. 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 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(); 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 -- Show the spectrum example. 114 115 l:start({ 116 caps = { 117 fb = mag_caps.svc:create(L4.Proto.Goos, "g=800x460+0+0", "barheight=20"), 118 }, 119 }, 120 "rom/ex_fb_spectrum_cc");