-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This mpu6050 driver functionality consist of reading relevant values and exporting them to the user space. Needed parameters are: accelerometer x, y, z, gyroscope x, y, z and temperature (as an easiest check that device is configured and operating properly). First, the chip must be configured. This consist of programming all setup registers with correct values. For example: clear power down, set prescalers, configures fifos and so on. Configuration is usually done in driver probe routine. Second, reading values or performing needed actions can be done in a separate theread inside driver, or in the workqueue. But this driver is supposed to give values on demand so there is no need for that. All values are read at once in a single function. To export data to the user space was decided to use sysfs. A class was created and 7 attributes for each parameter. Since all parameters are read-only, all attributes have only show function and their access rights are set to 0444. So all _show() fuctions are almost the same: read all parameters first, then return the needed one. The summary how this driver works: 1. Create i2c device in module_init() and configure the chip from i2c_probe(). 2. Create sysfs class and attributes for each parameter from module_init(). 3. Read and return mpu6050 parameters in each sysfs_attribute_x_show(). Signed-off-by: Andriy.Khulap <[email protected]>
- Loading branch information
Showing
1 changed file
with
204 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters