1
0
Fork 0
forked from len0rd/rockbox

hwstub: port hwstub_shell to the new library

Also use this opportunity to cleanup support for multiple devices: the shell
now supports dynamic changes in the device and will call init() everytime
a new device is selected, to prepare a new environment. The shell now
honors register width on register read/write. The shell also provides access
to variants as follows by creating a subtable under the register using the
variant type in UPPER case and having the same layout as a register.
For example if register HW.GPIO.DIR has variants "set" and "clr", those can
be used like this:
HW.GPIO.DIR.SET.write(0xff)
HW.GPIO.DIR.CLR.write(0xff00)

Change-Id: I943947fa98bce875de0cba4338e8b7196a4c1165
This commit is contained in:
Amaury Pouly 2016-02-07 21:46:58 +00:00
parent a2f4c5201d
commit f6c61eb11a
9 changed files with 740 additions and 266 deletions

View file

@ -1,7 +1,6 @@
---
--- Chip Identification
---
STMP = { info = {} }
local h = HELP:create_topic("STMP")
@ -49,18 +48,6 @@ 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.")
@ -70,11 +57,24 @@ 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"
require "stmp/clkctrl"
require "stmp/i2c"
end
-- init
function STMP.init()
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
end
require "stmp/digctl"
require "stmp/pinctrl"
require "stmp/lcdif"
require "stmp/pwm"
require "stmp/clkctrl"
require "stmp/i2c"