Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lesson mpu6050 #146

Open
wants to merge 11 commits into
base: Daniil.Petrov
Choose a base branch
from

Conversation

daaaanil81
Copy link

MPU6050 Practice. Kernel object module development
Homework
@galkinletter @oleg-h2o Check please my task.

@daaaanil81 daaaanil81 added the ready The PR is ready for review label May 9, 2019
h = i2c_smbus_read_byte_data(gl_mpu6050_data.drv_client, REG_ACCEL_YOUT_H);
l = i2c_smbus_read_byte_data(gl_mpu6050_data.drv_client, REG_ACCEL_YOUT_L);
t = (h << 8 | l);
gl_mpu6050_data.accel_values[1] = (t & 0x7fff) - (t & 0x8000);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the reason for this conversation? Variable t is already 16 bit long.

uint8_t h;
uint8_t l;
uint16_t t;
h = i2c_smbus_read_byte_data(gl_mpu6050_data.drv_client, REG_ACCEL_YOUT_H);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is possible to read complete work using i2c_smbus_read_word_swapped()

gl_mpu6050_data.temperatureF[1] = ((result*9/5)+32*DISCHARGE) % DISCHARGE;
printk(KERN_INFO "Temperature: %d.%03d C\n", gl_mpu6050_data.temperatureC[0], gl_mpu6050_data.temperatureC[1]);
printk(KERN_INFO "Temperature: %d.%03d F\n", gl_mpu6050_data.temperatureF[0], gl_mpu6050_data.temperatureF[1]);
sprintf(buf,"Temperature: %d.%03d C\nTemperature: %d.%03d F\n", gl_mpu6050_data.temperatureC[0], gl_mpu6050_data.temperatureC[1], gl_mpu6050_data.temperatureF[0], gl_mpu6050_data.temperatureF[1]);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How mane symbols in this string? Please check your code with checkpatch.pl

@yekovalyov yekovalyov added changes requested The PR review revealed issues which should be fixed (set by reviewer). and removed ready The PR is ready for review labels May 10, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changes requested The PR review revealed issues which should be fixed (set by reviewer).
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants