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-common.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_ili8960"); 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 the CPM peripheral. 70 71 local cpm = l:new_channel(); 72 73 l:start({ 74 caps = { 75 vbus = io_buses.cpm, 76 cpm = cpm:svr(), 77 }, 78 }, 79 "rom/dev_cpm_jz4740"); 80 81 -- Expose a framebuffer device. 82 83 local fbdrv_fb = l:new_channel(); 84 85 l:start({ 86 caps = { 87 vbus = io_buses.lcd, 88 fb = fbdrv_fb:svr(), 89 cpm = cpm, 90 display = display, -- needed by LCD driver 91 }, 92 }, 93 "rom/fb-drv"); 94 95 -- Multiplex the framebuffer. 96 97 local mag_caps = { 98 mag = l:new_channel(), 99 svc = l:new_channel(), 100 }; 101 102 l:start({ 103 caps = { 104 vbus = io_buses.gpio, -- needed by input driver 105 fb = fbdrv_fb, 106 mag = mag_caps.mag:svr(), 107 svc = mag_caps.svc:svr(), 108 }, 109 }, 110 "rom/mag"); 111 112 -- Expose the keypad matrix. 113 114 local keypad = l:new_channel(); 115 116 l:start({ 117 caps = { 118 vbus = io_buses.gpio, 119 keypad = keypad:svr(), 120 }, 121 }, 122 "rom/dev_keypad_qi_lb60"); 123 124 -- Show the keypad matrix. 125 126 l:startv({ 127 caps = { 128 fb = mag_caps.svc:create(L4.Proto.Goos, "g=320x230+0+0", "barheight=10"), 129 keypad = keypad, 130 }, 131 }, 132 "rom/ex_keypad_ds_client", "8", "8"); -- specifying keypad matrix dimensions