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 the keypad status as read from a memory region exported 5 -- by a separate server that reads the matrix itself. 6 -- The target platform is the Ben NanoNote. 7 8 local L4 = require("L4"); 9 10 local l = L4.default_loader; 11 12 -- Define general access to peripherals. 13 14 local io_buses = { 15 cpm = l:new_channel(); 16 gpio = l:new_channel(); 17 lcd = l:new_channel(); 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 26 icu = L4.Env.icu, 27 sigma0 = L4.cast(L4.Proto.Factory, L4.Env.sigma0):create(L4.Proto.Sigma0), 28 }, 29 }, 30 "rom/io rom/hw_devices.io rom/mips-qi_lb60-keypad-ds.io"); 31 32 -- Expose a SPI peripheral as a device. 33 34 local spi = l:new_channel(); 35 36 l:startv({ 37 caps = { 38 vbus = io_buses.gpio, 39 spi = spi:svr(), 40 }, 41 }, 42 "rom/dev_spi_jz4740", "C23", "C22", "C21"); -- specifying clock, data, enable pin details 43 44 -- Expose a SPI backlight device for the Ben. 45 46 local backlight = l:new_channel(); -- exposes backlight device 47 48 l:start({ 49 caps = { 50 spi = spi, 51 backlight = backlight:svr(), 52 }, 53 }, 54 "rom/dev_backlight_spi_qi_lb60"); 55 56 -- Expose a display device for the Ben. 57 58 local display = l:new_channel(); -- exposes display device 59 60 l:start({ 61 caps = { 62 backlight = backlight, 63 display = display:svr(), 64 vbus = io_buses.gpio, 65 }, 66 }, 67 "rom/dev_display_qi_lb60"); 68 69 -- Expose a panel definition for the Ben. 70 71 local panel = l:new_channel(); -- exposes panel 72 73 l:start({ 74 caps = { 75 panel = panel:svr(), 76 }, 77 }, 78 "rom/dev_panel_qi_lb60"); 79 80 -- Expose the CPM peripheral. 81 82 local cpm = l:new_channel(); 83 84 l:start({ 85 caps = { 86 vbus = io_buses.cpm, 87 cpm = cpm:svr(), 88 }, 89 }, 90 "rom/dev_cpm_jz4740"); 91 92 -- Expose a framebuffer device. 93 94 local fbdrv_fb = l:new_channel(); 95 96 l:start({ 97 caps = { 98 vbus = io_buses.lcd, 99 fb = fbdrv_fb:svr(), 100 cpm = cpm, 101 display = display, -- needed by LCD driver 102 panel = panel, 103 }, 104 }, 105 "rom/fb-drv"); 106 107 -- Multiplex the framebuffer. 108 109 local mag_caps = { 110 mag = l:new_channel(), 111 svc = l:new_channel(), 112 }; 113 114 l:start({ 115 caps = { 116 vbus = io_buses.gpio, -- needed by input driver 117 fb = fbdrv_fb, 118 mag = mag_caps.mag:svr(), 119 svc = mag_caps.svc:svr(), 120 }, 121 }, 122 "rom/mag"); 123 124 -- Expose the keypad matrix. 125 126 local keypad = l:new_channel(); 127 128 l:start({ 129 caps = { 130 vbus = io_buses.gpio, 131 keypad = keypad:svr(), 132 }, 133 }, 134 "rom/dev_keypad_qi_lb60"); 135 136 -- Show the keypad matrix. 137 138 l:startv({ 139 caps = { 140 fb = mag_caps.svc:create(L4.Proto.Goos, "g=320x230+0+0", "barheight=10"), 141 keypad = keypad, 142 }, 143 }, 144 "rom/ex_keypad_ds_client", "8", "8"); -- specifying keypad matrix dimensions