Expand description
Provides userspace with access to proximity sensors.
§Userspace Interface
§subscribe
System Call
The subscribe
system call supports the single subscribe_number
zero,
which is used to provide a callback that will return back the result of
a proximity reading.
The subscribe
call return codes indicate the following:
Ok(())
: the callback been successfully been configured.ENOSUPPORT
: Invalid allow_num.
§command
System Call
The command
system call support one argument cmd
which is used to specify the specific
operation, currently the following cmd’s are supported:
0
: driver existence check1
: read proximity2
: read proximity on interrupt
The possible return from the ‘command’ system call indicates the following:
Ok(())
: The operation has been successful.BUSY
: The driver is busy.ENOSUPPORT
: Invalidcmd
.
§Usage
You need a device that provides the hil::sensors::ProximityDriver
trait.
Here is an example of how to set up a proximity sensor with the apds9960 IC
ⓘ
let grant_cap = create_capability!(capabilities::MemoryAllocationCapability);
let proximity = static_init!(
capsules::proximity::ProximitySensor<'static>,
capsules::proximity::ProximitySensor::new(apds9960 , board_kernel.create_grant(&grant_cap)));
kernel::hil::sensors::ProximityDriver::set_client(apds9960, proximity);