Browse Source

SPI: added set_frequency() API

this allows the bus speed to be changed on the fly by device
drivers. This is needed for the MPU6000
sbg
Andrew Tridgell 11 years ago committed by Lorenz Meier
parent
commit
8df4d636ab
  1. 6
      src/drivers/device/spi.cpp
  2. 11
      src/drivers/device/spi.h

6
src/drivers/device/spi.cpp

@ -181,4 +181,10 @@ SPI::transfer(uint8_t *send, uint8_t *recv, unsigned len) @@ -181,4 +181,10 @@ SPI::transfer(uint8_t *send, uint8_t *recv, unsigned len)
return OK;
}
void
SPI::set_frequency(uint32_t frequency)
{
_frequency = frequency;
}
} // namespace device

11
src/drivers/device/spi.h

@ -101,6 +101,17 @@ protected: @@ -101,6 +101,17 @@ protected:
*/
int transfer(uint8_t *send, uint8_t *recv, unsigned len);
/**
* Set the SPI bus frequency
* This is used to change frequency on the fly. Some sensors
* (such as the MPU6000) need a lower frequency for setup
* registers and can handle higher frequency for sensor
* value registers
*
* @param frequency Frequency to set (Hz)
*/
void set_frequency(uint32_t frequency);
/**
* Locking modes supported by the driver.
*/

Loading…
Cancel
Save