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