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