1 -- vim: ft=lua ts=2 et sw=2 2 3 -- Start Mag to multiplex the framebuffer between several example programs. 4 -- These programs show the keypad status and also allow the backlight to be 5 -- adjusted. 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 -- Show the keypad matrix. 124 125 l:startv({ 126 caps = { 127 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+0+0", "barheight=10"), 128 keypad = keypad, 129 }, 130 }, 131 "rom/ex_keypad_ds_client", "8", "8"); -- specifying keypad matrix dimensions 132 133 -- Show the physical keypad layout. 134 135 l:start({ 136 caps = { 137 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+160+0", "barheight=10"), 138 keypad = keypad, 139 }, 140 }, 141 "rom/ex_qi_lb60_keypad_physical"); 142 143 -- Expose the keypad events. 144 145 local ev1 = l:new_channel(); 146 147 l:start({ 148 caps = { 149 keypad = keypad, 150 ev = ev1:svr(), 151 }, 152 }, 153 "rom/dev_input_keypad"); 154 155 -- Show key event values. 156 157 l:start({ 158 caps = { 159 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+0+120", "barheight=10"), 160 ev = ev1, 161 }, 162 }, 163 "rom/ex_input_event_client"); 164 165 -- Expose the keypad events. 166 167 local ev2 = l:new_channel(); 168 169 l:start({ 170 caps = { 171 keypad = keypad, 172 ev = ev2:svr(), 173 }, 174 }, 175 "rom/dev_input_keypad"); 176 177 -- Show key strings. 178 179 l:startv({ 180 caps = { 181 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+160+120", "barheight=10"), 182 ev = ev2, 183 }, 184 }, 185 "rom/ex_input_event_client", "chars"); 186 187 -- Control the backlight using the keyboard. 188 189 l:start({ 190 caps = { 191 backlight = backlight, 192 keypad = keypad, 193 }, 194 }, 195 "rom/ex_qi_lb60_backlight");