diff options
author | Andrew Tridgell <tridge@samba.org> | 2013-10-30 09:45:58 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2013-11-30 20:17:09 +1100 |
commit | 244c3602f2959335bfd4ae14c4a25eb06a8355a3 (patch) | |
tree | c59b3cb9f5018ed13ad47ef6ed6241e1aa5db406 /src | |
parent | 7d415b0c42465bffb79a3c69443e7bf85b59eb26 (diff) | |
download | px4-firmware-244c3602f2959335bfd4ae14c4a25eb06a8355a3.tar.gz px4-firmware-244c3602f2959335bfd4ae14c4a25eb06a8355a3.tar.bz2 px4-firmware-244c3602f2959335bfd4ae14c4a25eb06a8355a3.zip |
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
Diffstat (limited to 'src')
-rw-r--r-- | src/drivers/device/spi.cpp | 6 | ||||
-rw-r--r-- | src/drivers/device/spi.h | 11 |
2 files changed, 17 insertions, 0 deletions
diff --git a/src/drivers/device/spi.cpp b/src/drivers/device/spi.cpp index fa6b78d64..fed6c312c 100644 --- a/src/drivers/device/spi.cpp +++ b/src/drivers/device/spi.cpp @@ -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 diff --git a/src/drivers/device/spi.h b/src/drivers/device/spi.h index 9103dca2e..299575dc5 100644 --- a/src/drivers/device/spi.h +++ b/src/drivers/device/spi.h @@ -102,6 +102,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. */ enum LockMode { |