1
0
Fork 0
forked from len0rd/rockbox

hwstub: introduce lua code for the STMP and Creative ZEN V/Mozaic

Change-Id: Ice5f509a2e0d2114436d4760f338b9203ef96691
This commit is contained in:
Amaury Pouly 2013-06-13 02:12:01 +02:00
parent c5357940ab
commit f9cb5de580
8 changed files with 661 additions and 0 deletions

View file

@ -0,0 +1,3 @@
package.path = string.sub(string.gsub(debug.getinfo(1).source, "load.lua", "?.lua"),2) .. ";" .. package.path
require "stmp"

View file

@ -0,0 +1,78 @@
---
--- Chip Identification
---
STMP = { info = {} }
local h = HELP:create_topic("STMP")
h:add("This table contains the abstraction of the different device blocks for the STMP.")
h:add("It allows one to use higher-level primitives rather than poking at register directly.")
h:add("Furthermore, it tries as much as possible to hide the differences between the different STMP families.")
local function identify(name, family, desc)
STMP.chipid = hwstub.dev.stmp.chipid
STMP.info.chip = name
STMP.info.revision = "TA" .. tostring(hwstub.dev.stmp.rev+1)
STMP.desc = desc
STMP.family = family
print("Chip identified as " .. name ..", ROM " .. STMP.info.revision)
if not hwstub.soc:select(desc) then
print("Looking for soc " .. desc .. ": not found. Please load a soc by hand.")
end
end
local hh = h:create_topic("is_imx233")
hh:add("STMP.is_imx233() returns true if the chip ID reports a i.MX233")
function STMP.is_imx233()
return hwstub.dev.stmp.chipid == 0x3780
end
hh = h:create_topic("is_stmp3700")
hh:add("STMP.is_stmp3700() returns true if the chip ID reports a STMP3700")
function STMP.is_stmp3700()
return hwstub.dev.stmp.chipid == 0x3700
end
hh = h:create_topic("is_stmp3770")
hh:add("STMP.is_stmp3770() returns true if the chip ID reports a STMP3770")
function STMP.is_stmp3770()
return hwstub.dev.stmp.chipid == 0x37b0
end
hh = h:create_topic("is_stmp3600")
hh:add("STMP.is_stmp3600() returns true if the chip ID reports a STMP36xx")
function STMP.is_stmp3600()
return hwstub.dev.stmp.chipid >= 0x3600 and hwstub.dev.stmp.chipid < 0x3700
end
if STMP.is_imx233() then
identify("STMP3780 (aka i.MX233)", "imx233", "imx233")
elseif STMP.is_stmp3700() then
identify("STMP3700", "stmp3700", "stmp3700")
elseif STMP.is_stmp3770() then
identify("STMP3770", "stmp3770", "stmp3700")
elseif STMP.is_stmp3600() then
identify("STMP3600", "stmp3600", "stmp3600")
else
print(string.format("Unable to identify this chip as a STMP: chipid=0x%x", hwstub.dev.stmp.chipid));
end
hh = h:create_topic("debug")
hh:add("STMP.debug(...) prints some debug output if STMP.debug_on is true and does nothing otherwise.")
STMP.debug_on = false
function STMP.debug(...)
if STMP.debug_on then print(...) end
end
if STMP.info.chip ~= nil then
require "stmp/digctl"
require "stmp/pinctrl"
require "stmp/lcdif"
require "stmp/pwm"
end

View file

@ -0,0 +1,38 @@
---
--- DIGCTL
---
STMP.digctl = {}
local h = HELP:get_topic("STMP"):create_topic("digctl")
h:add("The STMP.digctl table handles the digctl device for all STMPs.")
local hh = h:create_topic("package")
hh:add("The STMP.digctl.package() function returns the name of the package.")
hh:add("The following packages can be returned:")
hh:add("* bga100")
hh:add("* bga169")
hh:add("* tqfp100")
hh:add("* lqfp100")
hh:add("* lqfp128")
function STMP.digctl.package()
local pack = nil
if STMP.is_stmp3600() then
HW.DIGCTL.CTRL.PACKAGE_SENSE_ENABLE.set()
if HW.DIGCTL.STATUS.PACKAGE_TYPE.read() == 1 then
pack = "lqfp100"
else
pack = "bga169"
end
HW.DIGCTL.CTRL.PACKAGE_SENSE_ENABLE.clr()
elseif STMP.is_stmp3700() or STMP.is_stmp3770() or STMP.is_imx233() then
local t = HW.DIGCTL.STATUS.PACKAGE_TYPE.read()
if t == 0 then pack = "bga169"
elseif t == 1 then pack = "bga100"
elseif t == 2 then pack = "tqfp100"
elseif t == 3 then pack = "tqfp128"
end
end
return pack
end

View file

@ -0,0 +1,100 @@
--
-- LCDIF
--
STMP.lcdif = {}
function STMP.lcdif.init()
HW.LCDIF.CTRL.SFTRST.set()
HW.LCDIF.CTRL.SFTRST.clr()
HW.LCDIF.CTRL.CLKGATE.clr()
end
function STMP.lcdif.set_system_timing(data_setup, data_hold, cmd_setup, cmd_hold)
HW.LCDIF.TIMING.CMD_HOLD.write(cmd_hold)
HW.LCDIF.TIMING.CMD_SETUP.write(cmd_setup)
HW.LCDIF.TIMING.DATA_HOLD.write(data_hold)
HW.LCDIF.TIMING.DATA_SETUP.write(data_setup)
end
function STMP.lcdif.set_byte_packing_format(val)
HW.LCDIF.CTRL1.BYTE_PACKING_FORMAT.write(val)
end
function STMP.lcdif.set_reset(val)
if STMP.is_stmp3600() then
HW.LCDIF.CTRL.RESET.write(val)
else
HW.LCDIF.CTRL1.RESET.write(val)
end
end
function STMP.lcdif.set_word_length(bus_width)
if STMP.is_stmp3600() or STMP.is_stmp3700() then
if bus_width == 8 then
HW.LCDIF.CTRL.WORD_LENGTH.set()
else
HW.LCDIF.CTRL.WORD_LENGTH.clr()
end
else
error("STMP.lcdif.set_word_length: unimplemented")
end
end
function STMP.lcdif.get_word_length()
if STMP.is_stmp3600() or STMP.is_stmp3700() then
if HW.LCDIF.CTRL.WORD_LENGTH.read() == 1 then
return 8
else
return 16
end
else
error("STMP.lcdif.get_word_length: unimplemented")
end
end
function STMP.lcdif.set_data_swizzle(swizzle)
local v = swizzle
if type(swizzle) == "string" then
if swizzle == "NONE" then
v = 0
else
error("unimplemented")
end
end
HW.LCDIF.CTRL.DATA_SWIZZLE.write(v)
end
function STMP.lcdif.is_busy()
if STMP.is_stmp3600() then
return HW.LCDIF.CTRL.FIFO_STATUS.read() == 0
else
return HW.LCDIF.STAT.TXFIFO_FULL.read() == 1
end
end
function STMP.lcdif.send_pio(data_mode, data)
local wl = STMP.lcdif.get_word_length()
if data_mode then
HW.LCDIF.CTRL.DATA_SELECT.set()
else
HW.LCDIF.CTRL.DATA_SELECT.clr()
end
STMP.debug(string.format("lcdif: count = %d", #data))
HW.LCDIF.CTRL.RUN.clr()
HW.LCDIF.CTRL.COUNT.write(#data)
HW.LCDIF.CTRL.RUN.set()
local i = 1
while i <= #data do
local v = 0
local v_size = 0
while i <= #data and v_size + wl <= 32 do
v = bit32.bor(v, bit32.lshift(data[i], v_size))
v_size = v_size + wl
i = i + 1
end
STMP.debug(string.format("lcdif: i=%d send 0x%x", i, v))
while STMP.lcdif.is_busy() do STMP.debug("lcdif: fifo full") end
HW.LCDIF.DATA.write(v)
end
end

View file

@ -0,0 +1,253 @@
---
--- PINCTRL
---
STMP.pinctrl = {}
local h = HELP:get_topic("STMP"):create_topic("pinctrl")
h:add("The STMP.pinctrl table handles the pinctrl device for all STMPs.")
h:add("It provides a simple abstraction to set individual pins.")
local hh = h:create_topic("pin")
hh:add("The STMP.pinctrl.pin(x,yy) function returns a table for the pin BxPyy.")
hh:add("Depending on the STMP family, the following function might be available.")
hh:add("* read() returns the value of the pin (the pin does not need to be configured as GPIO)")
hh:add("* write(x) sets the value of the pin (provided it is a GPIO with output enabled)")
hh:add("* set() is equivalent to write(1)")
hh:add("* clr() is equivalent to write(0)")
hh:add("* enable() enables the gpio output (provided it is configured as GPIO).")
hh:add("* disable() disables the gpio output (provided it is configured as GPIO)")
hh:add("* muxsel(x) set pin function to x, which can be an integer or one of: MAIN, ALT1, ALT2, GPIO")
function STMP.pinctrl.pin(bank,pin)
local t = {
read = function()
return bit32.extract(HW.PINCTRL.DINn[bank].read(), pin)
end,
write = function(val)
if val then t.set() else t.clr() end
end,
set = function()
HW.PINCTRL.DOUTn[bank].set(bit32.lshift(1, pin))
end,
clr = function()
HW.PINCTRL.DOUTn[bank].clr(bit32.lshift(1, pin))
end,
enable = function()
HW.PINCTRL.DOEn[bank].set(bit32.lshift(1, pin))
end,
disable = function()
HW.PINCTRL.DOEn[bank].clr(bit32.lshift(1, pin))
end,
muxsel = function(x)
if type(x) == "string" then
if x == "MAIN" then x = 0
elseif x == "ALT1" then x = 1
elseif x == "ALT2" then x = 2
elseif x == "GPIO" then x = 3
else error("Invalid muxsel string " .. x) end
end
local v = nil
if STMP.is_stmp3600() then
if pin < 16 then
v = HW.PINCTRL.MUXSELLn[bank]
else
v = HW.PINCTRL.MUXSELHn[bank]
end
else
v = HW.PINCTRL.MUXSELn[2 * bank + math.floor(pin / 16)]
end
v.write(bit32.replace(v.read(), x, (pin % 16) * 2, 2))
end
}
return t
end
hh = h:create_topic("configure")
hh:add("The STMP.pinctrl.configure(tbl) function configures pins according to a table.")
hh:add("The table must contain a list of subtable, each corresponding to a pin.")
hh:add("Each subtable can configure one or more aspects of a specific pin.")
hh:add("The following characteristics are understood:")
hh:add("* bank: pin bank (mandatory)")
hh:add("* pin: pin number (mandatory) ")
hh:add("* muxsel: same values as STMP.pinctrl.pin().muxsel (optional)")
hh:add("* enable: enable/disable output (optional)")
hh:add("* output: set/clear output (optional)")
hh:add("All non-subtable entries are ignored")
hh:add("All unknown parameters in subtablkes are ignored")
hh:add("")
hh:add("Example:")
hh:add("STMP.pinctrl.configure({{bank=0,pin=1,muxsel=\"GPIO\",enable=false},{bank=0,pin=2,muxsel=\"MAIN\"}})")
function STMP.pinctrl.configure(tbl)
if type(tbl) ~= "table" then error("Parameter must be a table") end
for i,v in pairs(tbl) do
if type(v) == "table" then
if v.bank ~= nil and v.pin ~= nil then
local pin = STMP.pinctrl.pin(v.bank,v.pin)
if v.muxsel ~= nil then
STMP.debug(string.format("cfg B%dP%02d muxsel %s", v.bank, v.pin, v.muxsel))
pin.muxsel(v.muxsel)
end
if v.enable ~= nil then
STMP.debug(string.format("cfg B%dP%02d enable %s", v.bank, v.pin, v.enable))
if v.enable then pin.enable()
else pin.disable() end
end
if v.output ~= nil then
STMP.debug(string.format("cfg B%dP%02d output %s", v.bank, v.pin, v.output))
if v.output then pin.set()
else pin.clr() end
end
end
end
end
end
hh = h:create_topic("configure_ex")
hh:add("The STMP.pinctrl.configure_ex(tbl) function configures pins according to a table.")
hh:add("It is an enhanced version of configure which handles the different families and packages.")
hh:add("The argument must be a table with one entry per STMP family.")
hh:add("Each entry must a subtable with one subentry per package.")
hh:add("Each subentry must be a valid argument to STMP.pinctrl.configure().")
hh:add("The family names are the one returned by STMP.family.")
hh:add("The table can also contain an entry \"all\" which apply to all families")
hh:add("The package names are the one returned by STMP.digctl.package().")
hh:add("The table can also contain an entry \"all\" which apply to all packages.")
function STMP.pinctrl.configure_ex(tbl)
if type(tbl) ~= "table" then error("Parameter must be a table") end
local pack = STMP.digctl.package()
if tbl[STMP.family] ~= nil then
if tbl[STMP.family][pack] ~= nil then STMP.pinctrl.configure(tbl[STMP.family][pack]) end
if tbl[STMP.family]["all"] ~= nil then STMP.pinctrl.configure(tbl[STMP.family]["all"]) end
end
if tbl["all"] ~= nil then
if tbl["all"][pack] ~= nil then STMP.pinctrl.configure(tbl["all"][pack]) end
if tbl["all"]["all"] ~= nil then STMP.pinctrl.configure(tbl["all"]["all"]) end
end
end
hh = h:create_topic("lcdif")
hh:add("The STMP.pinctrl.lcdif tables provides some high level routines to configure the pins.")
hh:add("It is specialised to configure the LCDIF pins correctly.")
hh:add("Some of the modes may not be available on all STMP families.")
STMP.pinctrl.lcdif = {}
local hhh = hh:create_topic("setup_system")
hhh:add("The STMP.pinctrl.lcdif.setup_system(bus_width,busy) functions configure the LCDIF pins.")
hhh:add("It only take cares of the pins used in system mode and for a specified bus width.")
hhh:add("The handled bus widths are 8, 16 and 18")
hhh:add("The busy pin is configured only if busy is true")
function STMP.pinctrl.lcdif.setup_system(bus_width, busy)
local common =
{
stmp3600 =
{
all =
{
lcd_reset = { bank = 1, pin = 16, muxsel = "MAIN"},
lcd_rs = { bank = 1, pin = 17, muxsel = "MAIN"},
lcd_wr = { bank = 1, pin = 18, muxsel = "MAIN"},
lcd_cs = { bank = 1, pin = 19, muxsel = "MAIN"},
lcd_d0 = {bank = 1, pin = 0, muxsel = "MAIN"},
lcd_d1 = {bank = 1, pin = 1, muxsel = "MAIN"},
lcd_d2 = {bank = 1, pin = 2, muxsel = "MAIN"},
lcd_d3 = {bank = 1, pin = 3, muxsel = "MAIN"},
lcd_d4 = {bank = 1, pin = 4, muxsel = "MAIN"},
lcd_d5 = {bank = 1, pin = 5, muxsel = "MAIN"},
lcd_d6 = {bank = 1, pin = 6, muxsel = "MAIN"},
lcd_d7 = {bank = 1, pin = 7, muxsel = "MAIN"}
}
},
stmp3700 =
{
all =
{
lcd_reset = { bank = 1, pin = 16, muxsel = "MAIN"},
lcd_rs = { bank = 1, pin = 17, muxsel = "MAIN"},
lcd_wr = { bank = 1, pin = 18, muxsel = "MAIN"},
lcd_rd = { bank = 1, pin = 19, muxsel = "MAIN"},
lcd_cs = { bank = 1, pin = 20, muxsel = "MAIN"},
lcd_d0 = {bank = 1, pin = 0, muxsel = "MAIN"},
lcd_d1 = {bank = 1, pin = 1, muxsel = "MAIN"},
lcd_d2 = {bank = 1, pin = 2, muxsel = "MAIN"},
lcd_d3 = {bank = 1, pin = 3, muxsel = "MAIN"},
lcd_d4 = {bank = 1, pin = 4, muxsel = "MAIN"},
lcd_d5 = {bank = 1, pin = 5, muxsel = "MAIN"},
lcd_d6 = {bank = 1, pin = 6, muxsel = "MAIN"},
lcd_d7 = {bank = 1, pin = 7, muxsel = "MAIN"}
}
}
}
local bus8_15 =
{
stmp3600 =
{
all =
{
lcd_d8 = {bank = 1, pin = 8, muxsel = "MAIN"},
lcd_d9 = {bank = 1, pin = 9, muxsel = "MAIN"},
lcd_d10 = {bank = 1, pin = 10, muxsel = "MAIN"},
lcd_d11 = {bank = 1, pin = 11, muxsel = "MAIN"},
lcd_d12 = {bank = 1, pin = 12, muxsel = "MAIN"},
lcd_d13 = {bank = 1, pin = 13, muxsel = "MAIN"},
lcd_d14 = {bank = 1, pin = 14, muxsel = "MAIN"},
lcd_d15 = {bank = 1, pin = 15, muxsel = "MAIN"}
}
},
stmp3700 =
{
all =
{
lcd_d8 = {bank = 1, pin = 8, muxsel = "MAIN"},
lcd_d9 = {bank = 1, pin = 9, muxsel = "MAIN"},
lcd_d10 = {bank = 1, pin = 10, muxsel = "MAIN"},
lcd_d11 = {bank = 1, pin = 11, muxsel = "MAIN"},
lcd_d12 = {bank = 1, pin = 12, muxsel = "MAIN"},
lcd_d13 = {bank = 1, pin = 13, muxsel = "MAIN"},
lcd_d14 = {bank = 1, pin = 14, muxsel = "MAIN"},
lcd_d15 = {bank = 1, pin = 15, muxsel = "MAIN"}
}
}
}
local bus16_17 =
{
}
local busy_pin =
{
stmp3600 =
{
all =
{
lcd_busy = { bank = 1, pin = 21, muxsel = "MAIN"},
}
},
stmp3700 =
{
all =
{
lcd_busy = { bank = 1, pin = 21, muxsel = "MAIN"},
}
},
}
STMP.pinctrl.configure_ex(common)
if bus_width > 8 then
STMP.pinctrl.configure_ex(bus8_15)
end
if bus_width > 16 then
STMP.pinctrl.configure_ex(bus16_17)
end
if busy then
STMP.pinctrl.configure_ex(busy_pin)
end
end

View file

@ -0,0 +1,35 @@
--
-- LCDIF
--
STMP.pwm = {}
function STMP.pwm.init()
HW.LCDIF.CTRL.SFTRST.clr()
HW.LCDIF.CTRL.CLKGATE.clr()
end
function STMP.pwm.enable(chan, en)
if en then
HW.PWM.CTRL.set(bit32.lshift(1, chan))
else
HW.PWM.CTRL.clr(bit32.lshift(1, chan))
end
end
function STMP.pwm.setup(channel, period, cdiv, active, active_state, inactive, inactive_state)
-- stop
STMP.pwm.enable(channel, false)
-- setup pin
--FIXME
-- watch the order ! active THEN period
-- NOTE: the register value is period-1
HW.PWM.ACTIVEn[channel].ACTIVE.write(active)
HW.PWM.ACTIVEn[channel].INACTIVE.write(inactive)
HW.PWM.PERIODn[channel].PERIOD.write(period - 1)
HW.PWM.PERIODn[channel].ACTIVE_STATE.write(active_state)
HW.PWM.PERIODn[channel].INACTIVE_STATE.write(inactive_state)
HW.PWM.PERIODn[channel].CDIV.write(cdiv)
-- restore
STMP.pwm.enable(channel, true)
end

View file

@ -0,0 +1,98 @@
--
-- ZEN MOZAIC
--
ZENMOZAIC = {}
function ZENMOZAIC.lcd_send(cmd, data)
STMP.lcdif.set_data_swizzle(3)
STMP.lcdif.send_pio(false, {bit32.band(cmd, 0xff), bit32.rshift(cmd, 8)})
if cmd ~= 0x22 then
STMP.lcdif.send_pio(true, {bit32.band(data, 0xff), bit32.rshift(data, 8)})
end
end
function ZENMOZAIC.lcd_init()
STMP.pinctrl.lcdif.setup_system(8, false)
STMP.lcdif.init()
STMP.lcdif.set_word_length(8)
STMP.lcdif.set_system_timing(2, 2, 2, 2)
STMP.lcdif.set_reset(1)
STMP.lcdif.set_reset(0)
STMP.lcdif.set_reset(1)
STMP.lcdif.set_byte_packing_format(0xf)
ZENMOZAIC.lcd_send(0, 1)
ZENMOZAIC.lcd_send(3, 0)
ZENMOZAIC.lcd_send(3, 0x510)
ZENMOZAIC.lcd_send(9, 8)
ZENMOZAIC.lcd_send(0xc, 0)
ZENMOZAIC.lcd_send(0xd, 0)
ZENMOZAIC.lcd_send(0xe, 0)
ZENMOZAIC.lcd_send(0x5b, 4)
ZENMOZAIC.lcd_send(0xd, 0x10)
ZENMOZAIC.lcd_send(9, 0)
ZENMOZAIC.lcd_send(3, 0x10)
ZENMOZAIC.lcd_send(0xd, 0x14)
ZENMOZAIC.lcd_send(0xe, 0x2b12)
ZENMOZAIC.lcd_send(1, 0x21f)
ZENMOZAIC.lcd_send(2, 0x700)
ZENMOZAIC.lcd_send(5, 0x30)
ZENMOZAIC.lcd_send(6, 0)
ZENMOZAIC.lcd_send(8, 0x202)
ZENMOZAIC.lcd_send(0xa, 0xc003)
ZENMOZAIC.lcd_send(0xb, 0)
ZENMOZAIC.lcd_send(0xf, 0)
ZENMOZAIC.lcd_send(0x10, 0)
ZENMOZAIC.lcd_send(0x11, 0)
ZENMOZAIC.lcd_send(0x14, 0x9f00)
ZENMOZAIC.lcd_send(0x15, 0x9f00)
ZENMOZAIC.lcd_send(0x16, 0x7f00)
ZENMOZAIC.lcd_send(0x17, 0x9f00)
ZENMOZAIC.lcd_send(0x20, 0)
ZENMOZAIC.lcd_send(0x21, 0)
ZENMOZAIC.lcd_send(0x23, 0)
ZENMOZAIC.lcd_send(0x24, 0)
ZENMOZAIC.lcd_send(0x25, 0)
ZENMOZAIC.lcd_send(0x26, 0)
ZENMOZAIC.lcd_send(0x30, 0x707)
ZENMOZAIC.lcd_send(0x31, 0x504)
ZENMOZAIC.lcd_send(0x32, 7)
ZENMOZAIC.lcd_send(0x33, 0x307)
ZENMOZAIC.lcd_send(0x34, 7)
ZENMOZAIC.lcd_send(0x35, 0x400)
ZENMOZAIC.lcd_send(0x36, 0x607)
ZENMOZAIC.lcd_send(0x37, 0x703)
ZENMOZAIC.lcd_send(0x3a, 0x1a0d)
ZENMOZAIC.lcd_send(0x3b, 0x1309)
ZENMOZAIC.lcd_send(9, 4)
ZENMOZAIC.lcd_send(7, 5)
ZENMOZAIC.lcd_send(7, 0x25)
ZENMOZAIC.lcd_send(7, 0x27)
ZENMOZAIC.lcd_send(0x5b, 0)
ZENMOZAIC.lcd_send(7, 0x37)
ZENMOZAIC.lcd_send(0x22, 0)
for i=0,128 do
STMP.lcdif.send_pio(true, {0xff, 0})
end
end
function ZENMOZAIC.set_backlight(val)
local v = math.floor((val + 200) * val / 1000)
for i=4,0,-1 do
if bit32.btest(v,bit32.lshift(1,i)) then
HW.UARTDBG.DR.write(0xff)
else
HW.UARTDBG.DR.write(0xf8)
end
while HW.UARTDBG.FR.TXFF.read() == 1 do end
end
HW.UARTDBG.DR.write(0)
end
function ZENMOZAIC.init()
ZENMOZAIC.lcd_init()
end

View file

@ -0,0 +1,56 @@
--
-- ZEN V
--
ZENV = {}
function ZENV.lcd_send(cmd, data)
if #cmd == 1 and cmd[1] == 0x5c then
STMP.lcdif.set_word_length(16)
STMP.lcdif.set_data_swizzle("NONE")
else
STMP.lcdif.set_word_length(8)
STMP.lcdif.set_data_swizzle("NONE")
end
STMP.lcdif.send_pio(false, cmd)
STMP.lcdif.send_pio(true, data)
end
function ZENV.lcd_init()
STMP.pinctrl.lcdif.setup_system(16, false)
STMP.pinctrl.pin(3, 16).muxsel("GPIO")
STMP.pinctrl.pin(3, 16).disable()
if STMP.pinctrl.pin(3, 16).read() == 0 then
STMP.debug("ZENV: need lcd power init")
STMP.pinctrl.pin(0, 27).muxsel("GPIO")
STMP.pinctrl.pin(0, 27).enable()
STMP.pinctrl.pin(0, 27).set()
end
STMP.lcdif.init()
STMP.lcdif.set_system_timing(2, 2, 2, 2)
STMP.lcdif.set_reset(1)
STMP.lcdif.set_reset(0)
STMP.lcdif.set_reset(1)
ZENV.lcd_send({0xca}, {0x7f})
ZENV.lcd_send({0xa0}, {0x75})
ZENV.lcd_send({0xc7}, {0x08})
ZENV.lcd_send({0xbe}, {0x18})
ZENV.lcd_send({0xc1}, {0x7b, 0x69, 0x9f})
ZENV.lcd_send({0xb1}, {0x1f})
ZENV.lcd_send({0xb3}, {0x80})
ZENV.lcd_send({0xbb}, {0x00, 0x00, 0x00})
ZENV.lcd_send({0xad}, {0x8a})
ZENV.lcd_send({0xb0}, {0x00})
ZENV.lcd_send({0xd1}, {0x02})
ZENV.lcd_send({0xb9}, {})
ZENV.lcd_send({0x92}, {0x01})
ZENV.lcd_send({0xa2}, {0x80})
ZENV.lcd_send({0x9e}, {})
ZENV.lcd_send({0xa6}, {})
ZENV.lcd_send({0xaf}, {})
end
function ZENV.init()
ZENV.lcd_init()
end