paul@83 | 1 | -- vim: ft=lua ts=2 et sw=2 |
paul@83 | 2 | |
paul@83 | 3 | -- Start Mag to multiplex the framebuffer showing only a single program. |
paul@83 | 4 | -- This example shows an animation showing off a spectrum of colours. |
paul@83 | 5 | -- The target platform is the MIPS Creator CI20. |
paul@83 | 6 | |
paul@83 | 7 | local L4 = require("L4"); |
paul@83 | 8 | |
paul@83 | 9 | local l = L4.default_loader; |
paul@83 | 10 | |
paul@83 | 11 | -- Define general access to peripherals. |
paul@83 | 12 | |
paul@83 | 13 | local io_buses = { |
paul@83 | 14 | cpm = l:new_channel(); |
paul@83 | 15 | gpio = l:new_channel(); |
paul@83 | 16 | hdmi = l:new_channel(); |
paul@83 | 17 | lcd = l:new_channel(); |
paul@83 | 18 | }; |
paul@83 | 19 | |
paul@83 | 20 | l:start({ |
paul@83 | 21 | caps = { |
paul@83 | 22 | cpm = io_buses.cpm:svr(), |
paul@83 | 23 | gpio = io_buses.gpio:svr(), |
paul@83 | 24 | hdmi = io_buses.hdmi:svr(), |
paul@83 | 25 | lcd = io_buses.lcd:svr(), |
paul@83 | 26 | |
paul@83 | 27 | icu = L4.Env.icu, |
paul@83 | 28 | sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), |
paul@83 | 29 | }, |
paul@83 | 30 | }, |
paul@83 | 31 | "rom/io rom/hw_devices.io rom/mips-ci20-common.io"); |
paul@83 | 32 | |
paul@83 | 33 | -- Expose the CPM peripheral. |
paul@83 | 34 | |
paul@83 | 35 | local cpm = l:new_channel(); |
paul@83 | 36 | |
paul@83 | 37 | l:start({ |
paul@83 | 38 | caps = { |
paul@83 | 39 | vbus = io_buses.cpm, |
paul@83 | 40 | cpm = cpm:svr(), |
paul@83 | 41 | }, |
paul@83 | 42 | }, |
paul@83 | 43 | "rom/dev_cpm_jz4780"); |
paul@83 | 44 | |
paul@83 | 45 | -- Expose a display device for the CI20. |
paul@83 | 46 | |
paul@83 | 47 | local display = l:new_channel(); -- exposes display device |
paul@83 | 48 | |
paul@83 | 49 | l:start({ |
paul@83 | 50 | caps = { |
paul@83 | 51 | cpm = cpm, |
paul@83 | 52 | display = display:svr(), |
paul@83 | 53 | icu = L4.Env.icu, |
paul@83 | 54 | vbus = io_buses.hdmi, -- for HDMI resource access |
paul@83 | 55 | }, |
paul@83 | 56 | }, |
paul@83 | 57 | "rom/dev_display_ci20_hdmi"); |
paul@83 | 58 | |
paul@83 | 59 | -- Expose a framebuffer device. |
paul@83 | 60 | |
paul@83 | 61 | local fbdrv_fb = l:new_channel(); |
paul@83 | 62 | |
paul@83 | 63 | l:start({ |
paul@83 | 64 | caps = { |
paul@83 | 65 | vbus = io_buses.lcd, |
paul@83 | 66 | fb = fbdrv_fb:svr(), |
paul@83 | 67 | cpm = cpm, |
paul@83 | 68 | display = display, -- needed by LCD driver |
paul@83 | 69 | }, |
paul@83 | 70 | }, |
paul@83 | 71 | "rom/fb-drv"); |
paul@83 | 72 | |
paul@83 | 73 | -- Multiplex the framebuffer. |
paul@83 | 74 | |
paul@83 | 75 | local mag_caps = { |
paul@83 | 76 | mag = l:new_channel(), |
paul@83 | 77 | svc = l:new_channel(), |
paul@83 | 78 | }; |
paul@83 | 79 | |
paul@83 | 80 | l:start({ |
paul@83 | 81 | caps = { |
paul@83 | 82 | vbus = io_buses.gpio, -- needed by input driver |
paul@83 | 83 | fb = fbdrv_fb, |
paul@83 | 84 | mag = mag_caps.mag:svr(), |
paul@83 | 85 | svc = mag_caps.svc:svr(), |
paul@83 | 86 | }, |
paul@83 | 87 | }, |
paul@83 | 88 | "rom/mag"); |
paul@83 | 89 | |
paul@83 | 90 | -- Show the spectrum example. |
paul@83 | 91 | |
paul@83 | 92 | l:start({ |
paul@83 | 93 | caps = { |
paul@83 | 94 | fb = mag_caps.svc:create(L4.Proto.Goos, "g=1280x1014+0+0", "barheight=10"), |
paul@83 | 95 | }, |
paul@83 | 96 | }, |
paul@83 | 97 | "rom/ex_fb_spectrum_cc"); |