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 a panel definition for the Ben. 69 70 local panel = l:new_channel(); -- exposes panel 71 72 l:start({ 73 caps = { 74 panel = panel:svr(), 75 }, 76 }, 77 "rom/dev_panel_qi_lb60"); 78 79 -- Expose the CPM peripheral. 80 81 local cpm = l:new_channel(); 82 83 l:start({ 84 caps = { 85 vbus = io_buses.cpm, 86 cpm = cpm:svr(), 87 }, 88 }, 89 "rom/dev_cpm_jz4740"); 90 91 -- Expose a framebuffer device. 92 93 local fbdrv_fb = l:new_channel(); 94 95 l:start({ 96 caps = { 97 vbus = io_buses.lcd, 98 fb = fbdrv_fb:svr(), 99 cpm = cpm, 100 display = display, -- needed by LCD driver 101 panel = panel, 102 }, 103 }, 104 "rom/fb-drv"); 105 106 -- Multiplex the framebuffer. 107 108 local mag_caps = { 109 mag = l:new_channel(), 110 svc = l:new_channel(), 111 }; 112 113 l:start({ 114 caps = { 115 vbus = io_buses.gpio, -- needed by input driver 116 fb = fbdrv_fb, 117 mag = mag_caps.mag:svr(), 118 svc = mag_caps.svc:svr(), 119 }, 120 }, 121 "rom/mag"); 122 123 -- Expose the keypad matrix. 124 125 local keypad = l:new_channel(); 126 127 l:start({ 128 caps = { 129 vbus = io_buses.gpio, 130 keypad = keypad:svr(), 131 }, 132 }, 133 "rom/dev_keypad_qi_lb60"); 134 135 -- Show the keypad matrix. 136 137 l:startv({ 138 caps = { 139 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+0+0", "barheight=10"), 140 keypad = keypad, 141 }, 142 }, 143 "rom/ex_keypad_ds_client", "8", "8"); -- specifying keypad matrix dimensions 144 145 -- Show the physical keypad layout. 146 147 l:start({ 148 caps = { 149 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+160+0", "barheight=10"), 150 keypad = keypad, 151 }, 152 }, 153 "rom/ex_qi_lb60_keypad_physical"); 154 155 -- Expose the keypad events. 156 157 local ev1 = l:new_channel(); 158 159 l:start({ 160 caps = { 161 keypad = keypad, 162 ev = ev1:svr(), 163 }, 164 }, 165 "rom/dev_input_keypad_qi_lb60"); 166 167 -- Show key event values. 168 169 l:start({ 170 caps = { 171 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+0+120", "barheight=10"), 172 ev = ev1, 173 }, 174 }, 175 "rom/ex_input_event_client"); 176 177 -- Expose the keypad events. 178 179 local ev2 = l:new_channel(); 180 181 l:start({ 182 caps = { 183 keypad = keypad, 184 ev = ev2:svr(), 185 }, 186 }, 187 "rom/dev_input_keypad_qi_lb60"); 188 189 -- Show key strings. 190 191 l:startv({ 192 caps = { 193 fb = mag_caps.svc:create(L4.Proto.Goos, "g=160x110+160+120", "barheight=10"), 194 ev = ev2, 195 }, 196 }, 197 "rom/ex_input_event_client", "chars"); 198 199 -- Control the backlight using the keyboard. 200 201 l:start({ 202 caps = { 203 backlight = backlight, 204 keypad = keypad, 205 }, 206 }, 207 "rom/ex_qi_lb60_backlight");