Skip to content

Commit a88bfe7

Browse files
itirdeajic23
authored andcommitted
iio: core: Introduce STEPS channel, ENABLE mask and INSTANCE event
These changes are needed to support the functionality of a pedometer. A pedometer has two basic functionalities: step counter and step detector. The step counter needs to be enabled and then it will count the steps in its hardware register. Whenever the application needs to check the step count, it will read the step counter register. To support the step counter a new channel type STEPS is added. Since the pedometer needs to be enabled first so that the hardware can count and store the steps, we need a specific ENABLE channel info mask. The step detector will generate an interrupt each time a step is detected. To support this functionality we add a new event type INSTANCE. For more information on the Android requirements for step counter and step detector see: http://source.android.com/devices/sensors/composite_sensors.html#counter and http://source.android.com/devices/sensors/composite_sensors.html#detector. A device that has the pedometer functionality this interface needs to support is Freescale's MMA9553L: http://www.freescale.com/files/sensors/doc/ref_manual/MMA9553LSWRM.pdf Signed-off-by: Irina Tirdea <[email protected]> Signed-off-by: Daniel Baluta <[email protected]> Signed-off-by: Jonathan Cameron <[email protected]>
1 parent 1843c2f commit a88bfe7

File tree

5 files changed

+28
-0
lines changed

5 files changed

+28
-0
lines changed

Documentation/ABI/testing/sysfs-bus-iio

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -856,6 +856,13 @@ Description:
856856
number or direction is not specified, applies to all channels of
857857
this type.
858858

859+
What: /sys/.../events/in_steps_instance_en
860+
KernelVersion: 3.19
861+
862+
Description:
863+
Enables or disables step detection. Each time the user takes a step an
864+
event of this type will be generated.
865+
859866
What: /sys/bus/iio/devices/iio:deviceX/trigger/current_trigger
860867
KernelVersion: 2.6.35
861868
@@ -1095,3 +1102,18 @@ Description:
10951102
after application of scale and offset. If no offset or scale is
10961103
present, output should be considered as processed with the
10971104
unit in milliamps.
1105+
1106+
What: /sys/.../iio:deviceX/in_steps_en
1107+
KernelVersion: 3.19
1108+
1109+
Description:
1110+
Activates the step counter. After activation, the number of steps
1111+
taken by the user will be counted in hardware and exported through
1112+
in_steps_input.
1113+
1114+
What: /sys/.../iio:deviceX/in_steps_input
1115+
KernelVersion: 3.19
1116+
1117+
Description:
1118+
This attribute is used to read the number of steps taken by the user
1119+
since the last reboot while activated.

drivers/iio/industrialio-core.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ static const char * const iio_chan_type_name_spec[] = {
7171
[IIO_PRESSURE] = "pressure",
7272
[IIO_HUMIDITYRELATIVE] = "humidityrelative",
7373
[IIO_ACTIVITY] = "activity",
74+
[IIO_STEPS] = "steps",
7475
};
7576

7677
static const char * const iio_modifier_names[] = {
@@ -118,6 +119,7 @@ static const char * const iio_chan_info_postfix[] = {
118119
[IIO_CHAN_INFO_HARDWAREGAIN] = "hardwaregain",
119120
[IIO_CHAN_INFO_HYSTERESIS] = "hysteresis",
120121
[IIO_CHAN_INFO_INT_TIME] = "integration_time",
122+
[IIO_CHAN_INFO_ENABLE] = "en",
121123
};
122124

123125
/**

drivers/iio/industrialio-event.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ static const char * const iio_ev_type_text[] = {
197197
[IIO_EV_TYPE_ROC] = "roc",
198198
[IIO_EV_TYPE_THRESH_ADAPTIVE] = "thresh_adaptive",
199199
[IIO_EV_TYPE_MAG_ADAPTIVE] = "mag_adaptive",
200+
[IIO_EV_TYPE_INSTANCE] = "instance",
200201
};
201202

202203
static const char * const iio_ev_dir_text[] = {

include/linux/iio/iio.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ enum iio_chan_info_enum {
3838
IIO_CHAN_INFO_HARDWAREGAIN,
3939
IIO_CHAN_INFO_HYSTERESIS,
4040
IIO_CHAN_INFO_INT_TIME,
41+
IIO_CHAN_INFO_ENABLE,
4142
};
4243

4344
enum iio_shared_by {

include/linux/iio/types.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ enum iio_chan_type {
3131
IIO_PRESSURE,
3232
IIO_HUMIDITYRELATIVE,
3333
IIO_ACTIVITY,
34+
IIO_STEPS,
3435
};
3536

3637
enum iio_modifier {
@@ -73,6 +74,7 @@ enum iio_event_type {
7374
IIO_EV_TYPE_ROC,
7475
IIO_EV_TYPE_THRESH_ADAPTIVE,
7576
IIO_EV_TYPE_MAG_ADAPTIVE,
77+
IIO_EV_TYPE_INSTANCE,
7678
};
7779

7880
enum iio_event_info {

0 commit comments

Comments
 (0)