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