Many hyperlinks are disabled.
Use anonymous login
to enable hyperlinks.
Overview
Comment: | Working bno055 module and Gryo Exmaple program using it. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: | ba6362892ddb7f0a6a313eba8ab30c04e29c62c3c0bdba9a50086937569bd6c7 |
User & Date: | gwlester 2018-01-25 00:26:44 |
Context
2018-01-29
| ||
06:15 | changes for dIMU initial implementation of gryoscope. check-in: bfc9ec1028 user: gwlester tags: trunk | |
2018-01-25
| ||
00:26 | Working bno055 module and Gryo Exmaple program using it. check-in: ba6362892d user: gwlester tags: trunk | |
2018-01-24
| ||
03:56 | Added low and higher level interfaces. check-in: c6c68c2381 user: gwlester tags: trunk | |
Changes
Changes to Gryo_Example.tcl.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 .. 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 ... 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 ... 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 ... 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 |
## Name: Gyroscope Example ## Author: Gerald W. Lester, 2018 ## Copyright 2018, Gerald W. Lester ## ## This program utilizes a BSD copyright, please see the license file in the ## same directory. ## ## This program is based on a C program by the same name from Dexter Industries. ## See (https://github.com/DexterInd/DI_LEGO_NXT/blob/master/dIMU/RobotC/Gryo_Example.c) ## package require piio ## ## These bytes set the full scale range of the gyroscope. ## it is important to define full_scale_range. Values are: ## 0x00 - 250 dps. Full scale range. ## 0x10 - 500 dps. Full scale range. ## 0x30 - 2000 dps. Full scale range. ................................................................................ gryo,y,axis 0x16 gryo,z,axis 0x18 rate 50 freq 10 } set i2cbus 1 set dIMUaddress {} set range 2000dps proc writeRegister {handle register value} { global Registers lassign $Registers($register) page addr type mask twowrite writeregbye $handle [lindex $Registers(page) 1] $page if {$mask eq {}} { set writeValue $value } else { ## ## Masked values are always byte oriented ## set writeValue [twowire readregbyte $handle $addr] set writeValue [format {%8.8b} $writeValue] lassign [split $mask] highBit lowBit set size [expr {1 + ($highBit - $lowBit)}] set tmp [format "%${size}.${size}b" $value] set writeValue [string replace $writeValue end-$hightBit end-$lowBit $tmp] scan $writeValue {%8.8b} writeValue } switch -exact -- $type { b { twowire writeregbyte $handle $addr $writeValue } w { twowire writeregword $handle $addr $writeValue } } return; } proc readRegister {handle register} { global Registers lassign $Registers($register) page addr type mask set result {} twowrite writeregbye $handle [lindex $Registers(page) 1] $page switch -exact -- $type { b { twowire readregbyte $handle $addr } w { twowire readregword $handle $addr } } if {$mask ne {}} { lassign [split $mask {:}] startbit stopbit set result [string range [format {%16.16b} $result] end-$startbit end-$stopbit] scan $result {%b} result } return $result } proc StartGyro {handle range} { global GyroValues set base $GyroValues(gryo,offset) ## ## Write CTRL_REG1 - Enable all axes. Disable power down. ## twowire writeregbyte $handle [expr {$base + 0x20}] 0x0F piio usleep 10 ## ## Write CTRL_REG2 - No High Pass Filter. ## twowire writeregbyte $handle [expr {$base + 0x21}] 0x00 piio usleep 10 ## ## Write CTRL_REG3 - No interrupts. Date ready. ## twowire writeregbyte $handle [expr {$base + 0x22}] 0x08 piio usleep 10 ## ## Write CTRL_REG4 - Specified scale range. ## twowire writeregbyte $handle [expr {$base + 0x23}] $GyroValues($range) piio usleep 10 ## ## Write CTRL_REG5 - Enable all axes. Disable power down. ## twowire writeregbyte $handle [expr {$base + 0x24}] 0x00 set status [twowire readbyte $handle] ## ## Set divisor so that the output of our gyro axis readings can be turned ## into scaled values. ## set GyroValues(divisor) $GyroValues($range,divisor) ................................................................................ ## ## Gyro: gets a full axis reading, scaled to the full scale reading. Returns ## in degrees per second. ## proc GryoAxisGeading {axis} { global GyroValues set base $GyroValues(gryo,offset) set intValue [twowire readregword $GyroValues(handle) [expr {$base + $GyroValues(gryo,$axis,axis)}]] piio usleep 10 return [format {%8.3f} [expr {$intValue / $GyroValues(divisor)}]] } proc ClearHistory {} { global CurrentValue ................................................................................ if {$dIMUaddress eq {}} { return } .main.controls.buttons.start configure -state disabled .main.controls.buttons.stop configure -state normal set GyroValues(handle) [twowire twowire $i2cbus $dIMUaddress] StartGyro $GyroValues(handle) $range set GyroValues(count) 0 ReadGyro LogValues } proc StopReading {} { global GyroValues ................................................................................ -textvariable ::i2cbus \ -values [list 1] \ -state readonly ttk::label $w.addrLbl \ -text {iDMU Address:} ttk::entry $w.addrEnt \ -width 5 \ -textvariable ::dIMUaddress ttk::label $w.rangeLbl \ -text {Range:} ttk::combobox $w.rangeCMB \ -textvariable ::range \ -values [list 250dps 500dps 2000dps] \ -state readonly ttk::label $w.rateLbl1 \ |
| > | > > > > > > | | | < > > > > > < < < < < | < > | > | < < < < < < | < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < < > < > > > > > > | | > > | | > > > | | | < < < < < < | | < | < | > |
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 .. 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 ... 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 ... 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 ... 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 |
## Name: Gyroscope Example ## Author: Gerald W. Lester, 2018 ## Copyright 2018, Gerald W. Lester ## ## This program utilizes a BSD copyright, please see the license file in the ## same directory. ## ## This program is loosely based on a C program by the same name from Dexter ## Industries. See ## https://github.com/DexterInd/DI_LEGO_NXT/blob/master/dIMU/RobotC/Gryo_Example.c ## ## It utilizes the low leve bno055 package. ## lappend atuo_path [file dirname [info script]] [pwd] ::tcl::tm::path add [file dirname [info script]] [pwd] package require piio package require bno055 ## ## These bytes set the full scale range of the gyroscope. ## it is important to define full_scale_range. Values are: ## 0x00 - 250 dps. Full scale range. ## 0x10 - 500 dps. Full scale range. ## 0x30 - 2000 dps. Full scale range. ................................................................................ gryo,y,axis 0x16 gryo,z,axis 0x18 rate 50 freq 10 } set i2cbus 1 set dIMUaddress 0x28 set range 2000dps proc StartGyro {handle range} { global GyroValues ## ## Place the dIMU in configuration mode ## bno055 writeRegister $handle operMode [bno055 getValue OPER_MODE_CONFIGMODE] piio usleep 20 ## ## Disable power down. ## bno055 writeRegister $handle powerMode [bno055 getValue PWR_MODE_NORMAL] piio usleep 10 ## ## No High Pass Filter, Enable Any Motion ## bno055 writeRegisterBlock $handle \ gyr,am,x,enab 1 \ gyr,am,y,enab 1 \ gyr,am,z,enab 1 \ gyr,am,filter 0 \ gyr,hr,filter 0 piio usleep 10 ## ## No interrupts. ## bno055 writeRegisterBlock $handle \ gyr,am,intEnab 0 \ gyr,hiR,intEnab \ piio usleep 10 ## ## Specified scale range, power mode and bandwidth. ## bno055 writeRegisterBlock $handle \ gyr,range [bno055 getValue2 GRY_RANGE [string toupper $range]] \ gyr,bandwidth [bno055 getValue GRY_BANDWIDTH_32HZ] \ gyr,pwrMode [bno055 getValue GRY_POWER_MODE_NORMAL] piio usleep 10 ## ## Switch to Gryo Only mode. ## bno055 writeRegister $handle operMode [bno055 getValue OPER_MODE_GYROONLY] piio usleep 20 ## ## Set divisor so that the output of our gyro axis readings can be turned ## into scaled values. ## set GyroValues(divisor) $GyroValues($range,divisor) ................................................................................ ## ## Gyro: gets a full axis reading, scaled to the full scale reading. Returns ## in degrees per second. ## proc GryoAxisGeading {axis} { global GyroValues set handle $GyroValues(handle) set intValue [bno055 readRegister $handle grv,data,$axis] piio usleep 10 return [format {%8.3f} [expr {$intValue / $GyroValues(divisor)}]] } proc ClearHistory {} { global CurrentValue ................................................................................ if {$dIMUaddress eq {}} { return } .main.controls.buttons.start configure -state disabled .main.controls.buttons.stop configure -state normal set GyroValues(handle) [::twowire twowire $i2cbus $dIMUaddress] StartGyro $GyroValues(handle) $range ReadGyro LogValues } proc StopReading {} { global GyroValues ................................................................................ -textvariable ::i2cbus \ -values [list 1] \ -state readonly ttk::label $w.addrLbl \ -text {iDMU Address:} ttk::entry $w.addrEnt \ -width 5 \ -textvariable ::dIMUaddress \ -state readonly ttk::label $w.rangeLbl \ -text {Range:} ttk::combobox $w.rangeCMB \ -textvariable ::range \ -values [list 250dps 500dps 2000dps] \ -state readonly ttk::label $w.rateLbl1 \ |
Name change from bno055_1.0.0.tm to bno055-1.0.0.tm.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 .. 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 .. 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 ... 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 ... 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 ... 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 ... 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 |
## ## This sensor can appear at the following addresses: ## I2C: 0x29 (primary) or 0x28 (alternate) ## HID-I2C: 0x40 ## ## Please see sction 4.6 of the Data Sheet for details of selecting the address. ## package require piio namespace eval bno055 { ## ## Register definition format: page address b(yte)|w(word) ?highBit:lowBit? ## least significant bit is 0. ## ................................................................................ ## ## NOTE -- no checks are preformed to see if the device is in the correct ## mode to read or write a perticular register. Accessing a register ## when the device is not in the correct mode may result in either ## an error or garbage being return. ## ## NOTE -- in the Data Sheet, PAGE_ID is colored as read only but the textual # description in section 4.2 explicitly states it is used to switch # between pages. ## array set Registers { main,chipId {0 0x00 b} acc,chipId {0 0x01 b} mag,chipId {0 0x02 b} gyro,chipId {0 0x03 b} sw,rev {0 0x04 w} ................................................................................ gyr,selftest {0 0x36 b 2:2} mcu,selftest {0 0x36 b 3:3} gyr,anymotion {0 0x37 b 2:2} gyr,highrate {0 0x37 b 3:3} acc,highG {0 0x37 b 5:5} acc,anymotion {0 0x37 b 6:6} acc,nomotion {0 0x37 b 7:7} sys,clk,status (0 0x38 b 0:0) sys,status {0 0x39 b} sys,error (0 0x3a b) acc,units {0 0x3b b 0:0} gyr,units {0 0x3b b 1:1} eul,units {0 0x3b b 2:2} temp,units {0 0x3b b 4:4} format,opt {0 0x3b b 7:7} operMode {0 0x3d b 3:0} powerMode {0 0x3e b 1:0} ................................................................................ SYS_ERROR,9 {Fusion algorithm configuration error} SYS_ERROR,10 {Sensor configuration error} } proc SymDef {type symbolic value} { variable Constants set Constants($type,$value) ${type}_${symbolic} set Constants(CONST,${type}_${symbolic}) $value } SymDef ORI_MODE WINDOWS 0 SymDef ORI_MODE ANDROID 1 SymDef TEMP_UNIT C 0 SymDef TEMP_UNIT F 1 ................................................................................ SymDef TEMP_SRC ACC 0 SymDef TEMP_SRC GRY 1 SymDef REMAP_TO X 0b00 SymDef REMAP_TO Y 0b01 SymDef REMAP_TO Z 0b10 SymDef REMAP_SIGN POS 0 SymDef REMAP_SIGN NEG 1 SymDef ACC_RANGE 2G 0b00B SymDef ACC_RANGE 4G 0b01B SymDef ACC_RANGE 8G 0b10B SymDef ACC_RANGE 16G 0b11B SymDef ACC_BANDWIDTH 7.81HZ 0b000 SymDef ACC_BANDWIDTH 15.63HZ 0b001 SymDef ACC_BANDWIDTH 31.25HZ 0b010 SymDef ACC_BANDWIDTH 62.5HZ 0b011 SymDef ACC_BANDWIDTH 125HZ 0b100 SymDef ACC_BANDWIDTH 250HZ 0b101 SymDef ACC_BANDWIDTH 500HZ 0b110 ................................................................................ SymDef GYR_AWAKE_DURR 16SAMPLES 1 SymDef GYR_AWAKE_DURR 32SAMPLES 2 SymDef GYR_AWAKE_DURR 64SAMPLES 3 proc getValue {symbolic} { variable Constants return $Constants(symbol,$symbolic) } proc getSymbol {type value} { variable Constants return $Constants($type,$value) } proc writeRegister {handle register value} { global Registers lassign $Registers($register) page addr type mask twowrite writeregbye $handle [lindex $Registers(page) 0] $page if {$mask eq {}} { set writeValue $value } else { ## ## Masked values are always byte oriented ## set writeValue [twowire readregbyte $handle $addr] set writeValue [format {%16.16b} $writeValue] lassign [split $mask] highBit lowBit set size [expr {1 + ($highBit - $lowBit)}] set tmp [format "%${size}.${size}b" $value] set writeValue [string replace $writeValue end-$hightBit end-$lowBit $tmp] scan $writeValue {%b} writeValue } switch -exact -- $type { b { twowire writeregbyte $handle $addr $writeValue } w { twowire writeregword $handle $addr $writeValue } m { ## ## Not supported in write mode ## throw {UNSUP WRTMODE} "Multibyte writes are not supported at this time" } } return; } proc writeRegisterBlock {handle args} { global Registers ## ## Verify we need to do something ## if {[llength $args]} { return } elseif {[llength $args] == 2} { ................................................................................ ## ## Build the value to write ## set writeValue [string repeat 0 [expr {$size * 8}]] foreach registerInfo $detailList { lassign $registerInfo page address type mask value lassign [split $mask] highBit lowBit if {$address ne $addr} { incr highBit 8 incr lowBit 8 } set size [expr {1 + ($highBit - $lowBit)}] set tmp [format "%${size}.${size}b" $value] set writeValue [string replace $writeValue end-$hightBit end-$lowBit $tmp] } scan $writeValue {%b} writeValue twowrite writeregbye $handle [lindex $Registers(page) 0] $page switch -exact -- $size { 1 { twowire writeregbyte $handle $addr $writeValue } 2 { twowire writeregword $handle $addr $writeValue } } return; } proc readRegister {handle register} { global Registers lassign $Registers($register) page addr type mask set result {} twowrite writeregbye $handle [lindex $Registers(page) 0] $page switch -exact -- $type { b { set result [twowire readregbyte $handle $addr] } w { set result [twowire readregword $handle $addr] } m { for {set cnt 1} {$cnt <= $mask} {incr cnt; incr addr} { append result [format {%2.2x} [twowire readregbyte $handle $addr]] } } } if {$mask ne {} && $type ne {m}} { lassign [split $mask {:}] startbit stopbit set result [string range [format {%16.16b} $result] end-$startbit end-$stopbit] scan $result {%b} result } return $result } namespace ensemble create -subcommands { getValue getSymbol readRegister writeRegister writeRegisterBlock } } |
> | | | | > | | | | | | > > > > > > > | | | | | | | | | | | | | | | | | | | | | > |
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 .. 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 .. 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 ... 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 ... 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 ... 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 ... 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 |
## ## This sensor can appear at the following addresses: ## I2C: 0x29 (primary) or 0x28 (alternate) ## HID-I2C: 0x40 ## ## Please see sction 4.6 of the Data Sheet for details of selecting the address. ## package provide bno055 1.0.0 package require piio namespace eval bno055 { ## ## Register definition format: page address b(yte)|w(word) ?highBit:lowBit? ## least significant bit is 0. ## ................................................................................ ## ## NOTE -- no checks are preformed to see if the device is in the correct ## mode to read or write a perticular register. Accessing a register ## when the device is not in the correct mode may result in either ## an error or garbage being return. ## ## NOTE -- in the Data Sheet, PAGE_ID is colored as read only but the textual ## description in section 4.2 explicitly states it is used to switch ## between pages. ## array set Registers { main,chipId {0 0x00 b} acc,chipId {0 0x01 b} mag,chipId {0 0x02 b} gyro,chipId {0 0x03 b} sw,rev {0 0x04 w} ................................................................................ gyr,selftest {0 0x36 b 2:2} mcu,selftest {0 0x36 b 3:3} gyr,anymotion {0 0x37 b 2:2} gyr,highrate {0 0x37 b 3:3} acc,highG {0 0x37 b 5:5} acc,anymotion {0 0x37 b 6:6} acc,nomotion {0 0x37 b 7:7} sys,clk,status {0 0x38 b 0:0} sys,status {0 0x39 b} sys,error {0 0x3a b} acc,units {0 0x3b b 0:0} gyr,units {0 0x3b b 1:1} eul,units {0 0x3b b 2:2} temp,units {0 0x3b b 4:4} format,opt {0 0x3b b 7:7} operMode {0 0x3d b 3:0} powerMode {0 0x3e b 1:0} ................................................................................ SYS_ERROR,9 {Fusion algorithm configuration error} SYS_ERROR,10 {Sensor configuration error} } proc SymDef {type symbolic value} { variable Constants set binaryValue [format %b $value] set Constants($type,$binaryValue) ${type}_${symbolic} set Constants(CONST,${type}_${symbolic}) $value } SymDef ORI_MODE WINDOWS 0 SymDef ORI_MODE ANDROID 1 SymDef TEMP_UNIT C 0 SymDef TEMP_UNIT F 1 ................................................................................ SymDef TEMP_SRC ACC 0 SymDef TEMP_SRC GRY 1 SymDef REMAP_TO X 0b00 SymDef REMAP_TO Y 0b01 SymDef REMAP_TO Z 0b10 SymDef REMAP_SIGN POS 0 SymDef REMAP_SIGN NEG 1 SymDef ACC_RANGE 2G 0b00 SymDef ACC_RANGE 4G 0b01 SymDef ACC_RANGE 8G 0b10 SymDef ACC_RANGE 16G 0b11 SymDef ACC_BANDWIDTH 7.81HZ 0b000 SymDef ACC_BANDWIDTH 15.63HZ 0b001 SymDef ACC_BANDWIDTH 31.25HZ 0b010 SymDef ACC_BANDWIDTH 62.5HZ 0b011 SymDef ACC_BANDWIDTH 125HZ 0b100 SymDef ACC_BANDWIDTH 250HZ 0b101 SymDef ACC_BANDWIDTH 500HZ 0b110 ................................................................................ SymDef GYR_AWAKE_DURR 16SAMPLES 1 SymDef GYR_AWAKE_DURR 32SAMPLES 2 SymDef GYR_AWAKE_DURR 64SAMPLES 3 proc getValue {symbolic} { variable Constants return $Constants(CONST,$symbolic) } proc getValue2 {type symbol} { variable Constants return $Constants(CONST,${type}_${symbol}) } proc getSymbol {type value} { variable Constants set binaryValue [format %b $value] return $Constants($type,$binaryValue) } proc writeRegister {handle register value} { variable Registers lassign $Registers($register) page addr type mask ::twowire writeregbyte $handle [lindex $Registers(page) 0] $page if {$mask eq {}} { set writeValue $value } else { ## ## Masked values are always byte oriented ## set writeValue [::twowire readregbyte $handle $addr] set writeValue [format {%16.16b} $writeValue] lassign [split $mask {:}] highBit lowBit set size [expr {1 + ($highBit - $lowBit)}] set tmp [format "%${size}.${size}b" $value] set writeValue [string replace $writeValue end-$highBit end-$lowBit $tmp] scan $writeValue {%b} writeValue } switch -exact -- $type { b { ::twowire writeregbyte $handle $addr $writeValue } w { ::twowire writeregword $handle $addr $writeValue } m { ## ## Not supported in write mode ## throw {UNSUP WRTMODE} "Multibyte writes are not supported at this time" } } return; } proc writeRegisterBlock {handle args} { variable Registers ## ## Verify we need to do something ## if {[llength $args]} { return } elseif {[llength $args] == 2} { ................................................................................ ## ## Build the value to write ## set writeValue [string repeat 0 [expr {$size * 8}]] foreach registerInfo $detailList { lassign $registerInfo page address type mask value lassign [split $mask {:}] highBit lowBit if {$address ne $addr} { incr highBit 8 incr lowBit 8 } set size [expr {1 + ($highBit - $lowBit)}] set tmp [format "%${size}.${size}b" $value] set writeValue [string replace $writeValue end-$highBit end-$lowBit $tmp] } scan $writeValue {%b} writeValue ::twowire writeregbyte $handle [lindex $Registers(page) 0] $page switch -exact -- $size { 1 { ::twowire writeregbyte $handle $addr $writeValue } 2 { ::twowire writeregword $handle $addr $writeValue } } return; } proc readRegister {handle register} { variable Registers lassign $Registers($register) page addr type mask set result {} ::twowire writeregbyte $handle [lindex $Registers(page) 0] $page switch -exact -- $type { b { set result [::twowire readregbyte $handle $addr] } w { set result [::twowire readregword $handle $addr] } m { for {set cnt 1} {$cnt <= $mask} {incr cnt; incr addr} { append result [format {%2.2x} [::twowire readregbyte $handle $addr]] } } } if {$mask ne {} && $type ne {m}} { lassign [split $mask {:}] highBit lowBit set result [string range [format {%16.16b} $result] end-$lowBit end-$highBit] scan $result {%b} result } return $result } namespace ensemble create -subcommands { getValue getValue2 getSymbol readRegister writeRegister writeRegisterBlock } } |
Name change from dimu_1.0.0.tm to dimu-1.0.0.tm.