Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Philip A Levis
EE185
Commits
cc0d9a74
Commit
cc0d9a74
authored
Oct 27, 2021
by
Alex Wang Fu
Browse files
update
parent
50aa1288
Changes
1
Hide whitespace changes
Inline
Side-by-side
software/firmware/circuitpython-main/shared-module/ee285/__init__.c
View file @
cc0d9a74
...
...
@@ -269,6 +269,7 @@ void i2c_init(busio_i2c_obj_t* i2c)
common_hal_busio_i2c_construct
(
i2c
,
scl_pin
,
sda_pin
,
I2CBAUD
,
I2CTIMEOUT
);
}
//! TODO: why do we need these delays, and are they an issue?
i2c_accel_sensor_t
i2c_accel_create
(
busio_i2c_obj_t
*
i2c
,
uint8_t
addr
)
{
i2c_accel_sensor_t
i2c_accel_sensor
;
i2c_accel_sensor
.
i2c_sensor
.
i2c
=
i2c
;
...
...
@@ -359,6 +360,9 @@ i2c_accel_sensor_t i2c_accel_create(busio_i2c_obj_t* i2c, uint8_t addr) {
}
void
i2c_read_accel
(
i2c_accel_sensor_t
sensor
)
{
/*
* Logic for this comes from `def acceleration(self):` in `adafruit_lis3dh.py`
*/
uint8_t
buf
[
6
];
i2c_read_register
(
sensor
.
i2c_sensor
,
_REG_OUT_X_L
|
0x80
,
buf
,
6
);
...
...
@@ -368,10 +372,9 @@ void i2c_read_accel(i2c_accel_sensor_t sensor) {
double
divider
=
(
double
)
sensor
.
divider
;
printf
(
"x: %f y: %f z:
%f divider:
%f
\n
"
,
((
double
)
x
/
divider
)
*
STANDARD_GRAVITY
,
((
double
)
y
/
divider
)
*
STANDARD_GRAVITY
,
((
double
)
z
/
divider
)
*
STANDARD_GRAVITY
,
divider
);
printf
(
"x: %f y: %f z: %f
\n
"
,
((
double
)
x
/
divider
)
*
STANDARD_GRAVITY
,
((
double
)
y
/
divider
)
*
STANDARD_GRAVITY
,
((
double
)
z
/
divider
)
*
STANDARD_GRAVITY
);
}
void
shared_module_ee285_test
(
void
)
{
printf
(
"Doing i2c test
\n
"
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment