rockbox/utils/hwstub/tools/lua/rk27xx/lradc.lua
Marcin Bukat 4f950e0af9 hwstub: Add support for rk27xx lradc block
Change-Id: I8fe15ad8207ac7098944bb85d6b66b91b9858e8f
2014-06-15 12:53:28 +02:00

12 lines
371 B
Lua

RK27XX.adc = {}
function RK27XX.adc.init()
-- setup ADC clock divider to reach max 1MHz
HW.SCU.DIVCON1.write(bit32.replace(HW.SCU.DIVCON1.read(), 49, 10, 8))
end
function RK27XX.adc.read(channel)
HW.ADC.CTRL.write(bit32.bor(bit32.lshift(1,4), bit32.lshift(1,3), bit32.band(channel,3)))
-- udelay(20)
return bit32.band(HW.ADC.DATA.read(), 0x3ff)
end