Author: wmb Date: Sat Jan 8 11:16:58 2011 New Revision: 2106 URL: http://tracker.coreboot.org/trac/openfirmware/changeset/2106
Log: OLPC XO-1.75 A2 - Made compass driver work and tweaked on accelerometer driver.
Modified: cpu/arm/olpc/1.75/compass.fth
Modified: cpu/arm/olpc/1.75/compass.fth ============================================================================== --- cpu/arm/olpc/1.75/compass.fth Sat Jan 8 11:15:54 2011 (r2105) +++ cpu/arm/olpc/1.75/compass.fth Sat Jan 8 11:16:58 2011 (r2106) @@ -5,6 +5,7 @@ 4 to smb-clock-gpio# 5 to smb-data-gpio# h# 3c to smb-slave + 5 smb-data-gpio# gpio-dir-out ; : smb-init ( -- ) set-compass-slave smb-on smb-pulses ;
@@ -12,31 +13,48 @@ : compass! ( byte reg# -- ) set-compass-slave smb-byte! ; : open ( -- okay? ) 0 0 ['] compass! catch if false exit then - h# a compass@ [char] H <> + h# a compass@ [char] H = if + 0 2 compass! \ Continuous conversion mode + true + else + false + then ; : close ( -- ) + 2 2 compass! \ Idle mode +; +: dir@ ( reg# -- n ) + dup compass@ swap 1+ compass@ swap bwjoin wextend +; +: direction@ ( -- x y z ) + begin 9 compass@ 1 and until + 3 dir@ 5 dir@ 7 dir@ ( x y z ) ; -\ XXX need some words to take compass readings - end-package
0 0 " " " /" begin-package " combo-accelerometer" name
-: set-sensor-slave ( -- ) h# 30 6 set-twsi-target ; -: sensor@ ( reg# -- byte ) set-sensor-slave twsi-b@ ; -: sensor! ( byte reg# -- ) set-sensor-slave twsi-b@ ; +\ : set-sensor-slave ( -- ) h# 30 6 set-twsi-target ; +: set-sensor-slave ( -- ) + 4 to smb-clock-gpio# + 5 to smb-data-gpio# + h# 30 to smb-slave + 5 smb-data-gpio# gpio-dir-out +; + +: sensor@ ( reg# -- byte ) set-sensor-slave smb-byte@ ; +: sensor! ( byte reg# -- ) set-sensor-slave smb-byte@ ;
: accelerometer-on ( -- ) h# 27 h# 20 sensor! ; : accelerometer-off ( -- ) h# 07 h# 20 sensor! ; -: wext ( w -- l ) dup h# 8000 and if h# ffff0000 or then ; : acceleration@ ( -- x y z ) set-sensor-slave - h# 28 1 6 twsi-get ( xl xh yl yh zl zh ) + 6 h# 28 smb-read-n ( xl xh yl yh zl zh ) 2>r 2>r ( xl xh ) - bwjoin wext ( x r: zl,zh yl,yh ) - 2r> bwjoin wext ( x y r: zl,zh ) - 2r> bwjoin wext ( x y z ) + bwjoin wextend ( x r: zl,zh yl,yh ) + 2r> bwjoin wextend ( x y r: zl,zh ) + 2r> bwjoin wextend ( x y z ) ;
: open ( -- okay? )
openfirmware@openfirmware.info