-
Notifications
You must be signed in to change notification settings - Fork 22
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
base: Daniil.Petrov
Are you sure you want to change the base?
Lesson mpu6050 #146
Conversation
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
Signed-off-by: Daniil Petrov <[email protected]>
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); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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]); |
There was a problem hiding this comment.
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
MPU6050 Practice. Kernel object module development
Homework
@galkinletter @oleg-h2o Check please my task.