Expand description
SyscallDriver for the MEMS L3gd20Spi motion sensor, 3 axys digital output gyroscope and temperature sensor.
May be used with NineDof and Temperature
SPI Interface
https://www.pololu.com/file/0J563/L3gd20Spi.pdf
§Syscall Interface
§Command
All commands are asynchronous, they return a one shot callback when done Only one command can be issued at a time.
§command num
0
: Returns Ok(())data
: Unused.- Return: Success
1
: Is Presentdata
: unused- Return:
Ok(())
if no other command is in progress,BUSY
otherwise.
2
: Power Ondata
: unused- Return:
Ok(())
if no other command is in progress,BUSY
otherwise.
3
: Set Scaledata1
: 0, 1 or 2- Return:
Ok(())
if no other command is in progress,BUSY
otherwise.
4
: Enable high pass filterdata
: 1 for enable, 0 for disable- Return:
Ok(())
if no other command is in progress,BUSY
otherwise.
5
: Set High Pass Filter Mode and Divider (manual page 33)data1
: modedata2
: divider- Return:
Ok(())
if no other command is in progress,BUSY
otherwise.
6
: Read XYZdata
: unused- Return:
Ok(())
if no other command is in progress,BUSY
otherwise.
7
: Read Temperaturedata
: unused- Return:
Ok(())
if no other command is in progress,BUSY
otherwise.
§Subscribe
All commands call this callback when done, usually subscribes should be one time functions
§subscribe num
0
: Done callback- ’data1`: depends on command
1
- 1 for is present, 0 for not present6
- X rotation7
- temperature in deg C
- ’data2`: depends on command
6
- Y rotation
- ’data3`: depends on command
6
- Z rotation
- ’data1`: depends on command
§Usage
ⓘ
let mux_spi = components::spi::SpiMuxComponent::new(&stm32f3xx::spi::SPI1)
.finalize(components::spi_mux_component_helper!(stm32f3xx::spi::Spi));
let l3gd20 = components::l3gd20::L3gd20SpiComponent::new()
.finalize(components::l3gd20_spi_component_helper!(stm32f3xx::spi::Spi, stm32f3xx::gpio::PinId::PE03, mux_spi));
NineDof Example
ⓘ
let grant_cap = create_capability!(capabilities::MemoryAllocationCapability);
let grant_ninedof = board_kernel.create_grant(&grant_cap);
l3gd20.power_on();
let ninedof = static_init!(
capsules::ninedof::NineDof<'static>,
capsules::ninedof::NineDof::new(l3gd20, grant_ninedof));
hil::sensors::NineDof::set_client(l3gd20, ninedof);
Temperature Example
ⓘ
let grant_cap = create_capability!(capabilities::MemoryAllocationCapability);
let grant_temp = board_kernel.create_grant(&grant_cap);
l3gd20.power_on();
let temp = static_init!(
capsules::temperature::TemperatureSensor<'static>,
capsules::temperature::TemperatureSensor::new(l3gd20, grant_temperature));
kernel::hil::sensors::TemperatureDriver::set_client(l3gd20, temp);
Author: Alexandru Radovici msg4alex@gmail.com