@@ -71,7 +71,7 @@ class FXAS21002C:
71
71
def __init__ (self , i2c , address = _FXAS21002C_ADDRESS ,
72
72
gyro_range = GYRO_RANGE_250DPS ):
73
73
assert gyro_range in (GYRO_RANGE_250DPS , GYRO_RANGE_500DPS ,
74
- GYRO_RANGE_100DPS , GYRO_RANGE_2000DPS )
74
+ GYRO_RANGE_1000DPS , GYRO_RANGE_2000DPS )
75
75
self ._gyro_range = gyro_range
76
76
self ._device = i2c_device .I2CDevice (i2c , address )
77
77
# Check for chip ID value.
@@ -87,8 +87,11 @@ def __init__(self, i2c, address=_FXAS21002C_ADDRESS,
87
87
elif gyro_range == GYRO_RANGE_2000DPS :
88
88
ctrlReg0 = 0x00
89
89
# Reset then switch to active mode with 100Hz output
90
- self ._write_u8 (_GYRO_REGISTER_CTRL_REG1 , 0x00 ) # Standby
91
- self ._write_u8 (_GYRO_REGISTER_CTRL_REG1 , (1 << 6 )) # Reset
90
+ # Putting into standy doesn't work as the chip becomes instantly
91
+ # unresponsive. Perhaps CircuitPython is too slow to go into standby
92
+ # and send reset? Keep these two commented for now:
93
+ #self._write_u8(_GYRO_REGISTER_CTRL_REG1, 0x00) # Standby)
94
+ #self._write_u8(_GYRO_REGISTER_CTRL_REG1, (1<<6)) # Reset
92
95
self ._write_u8 (_GYRO_REGISTER_CTRL_REG0 , ctrlReg0 ) # Set sensitivity
93
96
self ._write_u8 (_GYRO_REGISTER_CTRL_REG1 , 0x0E ) # Active
94
97
time .sleep (0.1 ) # 60 ms + 1/ODR
@@ -97,7 +100,7 @@ def _read_u8(self, address):
97
100
# Read an 8-bit unsigned value from the specified 8-bit address.
98
101
with self ._device :
99
102
self ._BUFFER [0 ] = address & 0xFF
100
- self ._device .write (self ._BUFFER , end = 1 )
103
+ self ._device .write (self ._BUFFER , end = 1 , stop = False )
101
104
self ._device .readinto (self ._BUFFER , end = 1 )
102
105
return self ._BUFFER [0 ]
103
106
@@ -115,8 +118,8 @@ def read_raw(self):
115
118
"""
116
119
# Read 7 bytes from the sensor.
117
120
with self ._device :
118
- self ._BUFFER [0 ] = GYRO_REGISTER_STATUS | 0x80
119
- self ._device .write (self ._BUFFER , end = 1 )
121
+ self ._BUFFER [0 ] = _GYRO_REGISTER_STATUS | 0x80
122
+ self ._device .write (self ._BUFFER , end = 1 , stop = False )
120
123
self ._device .readinto (self ._BUFFER )
121
124
# Parse out the gyroscope data.
122
125
status = self ._BUFFER [0 ]
0 commit comments