paul@123 | 1 | -- vim: ft=lua ts=2 et sw=2 |
paul@123 | 2 | |
paul@123 | 3 | -- Start Mag to multiplex the framebuffer showing only a single program. |
paul@123 | 4 | -- This example shows a framebuffer terminal showing the hello example's output. |
paul@123 | 5 | -- The target platform is the Letux 400 notebook computer. |
paul@123 | 6 | |
paul@123 | 7 | local L4 = require("L4"); |
paul@123 | 8 | |
paul@123 | 9 | local l = L4.default_loader; |
paul@123 | 10 | |
paul@123 | 11 | -- Define general access to peripherals. |
paul@123 | 12 | |
paul@123 | 13 | local io_buses = { |
paul@123 | 14 | cpm = l:new_channel(); |
paul@123 | 15 | dma = l:new_channel(); |
paul@123 | 16 | gpio = l:new_channel(); |
paul@123 | 17 | lcd = l:new_channel(); |
paul@123 | 18 | pwm = l:new_channel(); -- exposes GPIO, PWM |
paul@123 | 19 | }; |
paul@123 | 20 | |
paul@123 | 21 | l:start({ |
paul@123 | 22 | caps = { |
paul@123 | 23 | cpm = io_buses.cpm:svr(), |
paul@123 | 24 | dma = io_buses.dma:svr(), |
paul@123 | 25 | gpio = io_buses.gpio:svr(), |
paul@123 | 26 | lcd = io_buses.lcd:svr(), |
paul@123 | 27 | pwm = io_buses.pwm:svr(), |
paul@123 | 28 | |
paul@123 | 29 | icu = L4.Env.icu, |
paul@123 | 30 | sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), |
paul@123 | 31 | }, |
paul@123 | 32 | }, |
paul@123 | 33 | "rom/io rom/hw_devices.io rom/mips-letux400-common.io"); |
paul@123 | 34 | |
paul@123 | 35 | -- Expose a PWM peripheral as a device. |
paul@123 | 36 | |
paul@123 | 37 | local pwm = l:new_channel(); |
paul@123 | 38 | |
paul@123 | 39 | l:startv({ |
paul@123 | 40 | caps = { |
paul@123 | 41 | vbus = io_buses.pwm, |
paul@123 | 42 | pwm = pwm:svr(), |
paul@123 | 43 | }, |
paul@123 | 44 | }, |
paul@123 | 45 | "rom/dev_pwm_jz4730", "0", "250", "299", "47"); -- specifying peripheral number, parameters |
paul@123 | 46 | |
paul@123 | 47 | -- Expose a PWM backlight device. |
paul@123 | 48 | |
paul@123 | 49 | local backlight = l:new_channel(); -- exposes backlight device |
paul@123 | 50 | |
paul@123 | 51 | l:startv({ |
paul@123 | 52 | caps = { |
paul@123 | 53 | pwm = pwm, |
paul@123 | 54 | backlight = backlight:svr(), |
paul@123 | 55 | }, |
paul@123 | 56 | }, |
paul@123 | 57 | "rom/dev_backlight_pwm", "0", "300"); -- specifying limits |
paul@123 | 58 | |
paul@123 | 59 | -- Expose a display device for the Letux. |
paul@123 | 60 | |
paul@123 | 61 | local display = l:new_channel(); -- exposes display device |
paul@123 | 62 | |
paul@123 | 63 | l:start({ |
paul@123 | 64 | caps = { |
paul@123 | 65 | backlight = backlight, |
paul@123 | 66 | display = display:svr(), |
paul@123 | 67 | vbus = io_buses.gpio, |
paul@123 | 68 | }, |
paul@123 | 69 | }, |
paul@123 | 70 | "rom/dev_display_letux400"); |
paul@123 | 71 | |
paul@123 | 72 | -- Expose the CPM peripheral. |
paul@123 | 73 | |
paul@123 | 74 | local cpm = l:new_channel(); |
paul@123 | 75 | |
paul@123 | 76 | l:start({ |
paul@123 | 77 | caps = { |
paul@123 | 78 | vbus = io_buses.cpm, |
paul@123 | 79 | cpm = cpm:svr(), |
paul@123 | 80 | }, |
paul@123 | 81 | }, |
paul@123 | 82 | "rom/dev_cpm_jz4730"); |
paul@123 | 83 | |
paul@123 | 84 | -- Expose a framebuffer device. |
paul@123 | 85 | |
paul@123 | 86 | local fbdrv_fb = l:new_channel(); |
paul@123 | 87 | |
paul@123 | 88 | l:start({ |
paul@123 | 89 | caps = { |
paul@123 | 90 | vbus = io_buses.lcd, |
paul@123 | 91 | fb = fbdrv_fb:svr(), |
paul@123 | 92 | cpm = cpm, |
paul@123 | 93 | display = display, -- needed by LCD driver |
paul@123 | 94 | }, |
paul@123 | 95 | }, |
paul@123 | 96 | "rom/fb-drv"); |
paul@123 | 97 | |
paul@123 | 98 | -- Multiplex the framebuffer. |
paul@123 | 99 | |
paul@123 | 100 | local mag_caps = { |
paul@123 | 101 | mag = l:new_channel(), |
paul@123 | 102 | svc = l:new_channel(), |
paul@123 | 103 | }; |
paul@123 | 104 | |
paul@123 | 105 | l:start({ |
paul@123 | 106 | caps = { |
paul@123 | 107 | vbus = io_buses.gpio, -- needed by input driver |
paul@123 | 108 | fb = fbdrv_fb, |
paul@123 | 109 | mag = mag_caps.mag:svr(), |
paul@123 | 110 | svc = mag_caps.svc:svr(), |
paul@123 | 111 | }, |
paul@123 | 112 | }, |
paul@123 | 113 | "rom/mag"); |
paul@123 | 114 | |
paul@123 | 115 | -- Show the terminal. |
paul@123 | 116 | |
paul@123 | 117 | local term = l:new_channel(); |
paul@123 | 118 | |
paul@123 | 119 | l:start({ |
paul@123 | 120 | caps = { |
paul@123 | 121 | fb = mag_caps.svc:create(L4.Proto.Goos, "g=800x460+0+0", "barheight=20"), |
paul@123 | 122 | term = term:svr(), |
paul@123 | 123 | }, |
paul@123 | 124 | }, |
paul@123 | 125 | "rom/fbterminal"); |
paul@123 | 126 | |
paul@123 | 127 | -- Show the DMA example. |
paul@123 | 128 | |
paul@123 | 129 | l:start({ |
paul@123 | 130 | caps = { |
paul@123 | 131 | icu = L4.Env.icu, |
paul@123 | 132 | vbus = io_buses.dma, |
paul@123 | 133 | }, |
paul@123 | 134 | log_cap = term, |
paul@123 | 135 | }, |
paul@123 | 136 | "rom/ex_letux400_dma"); |