diff options
author | Martin Braun <martin.braun@ettus.com> | 2017-05-11 12:04:45 -0700 |
---|---|---|
committer | Martin Braun <martin.braun@ettus.com> | 2017-12-22 15:03:53 -0800 |
commit | b39dafa1eebf327a8bbd3959a3c54e85707b56aa (patch) | |
tree | 5b3b4688a5c24404cc7e4ec20442e9e742c8cbaa /mpm/lib/spi | |
parent | e6858a61a81d0ff1762e4b8434fe781acf2fc1ab (diff) | |
download | uhd-b39dafa1eebf327a8bbd3959a3c54e85707b56aa.tar.gz uhd-b39dafa1eebf327a8bbd3959a3c54e85707b56aa.tar.bz2 uhd-b39dafa1eebf327a8bbd3959a3c54e85707b56aa.zip |
mpm: Enabled selection of SPI mode
Diffstat (limited to 'mpm/lib/spi')
-rw-r--r-- | mpm/lib/spi/spi_regs_iface.cpp | 3 | ||||
-rw-r--r-- | mpm/lib/spi/spidev_iface.cpp | 13 |
2 files changed, 10 insertions, 6 deletions
diff --git a/mpm/lib/spi/spi_regs_iface.cpp b/mpm/lib/spi/spi_regs_iface.cpp index a84a14997..ab9e089f8 100644 --- a/mpm/lib/spi/spi_regs_iface.cpp +++ b/mpm/lib/spi/spi_regs_iface.cpp @@ -102,13 +102,14 @@ regs_iface::sptr mpm::spi::make_spi_regs_iface( mpm::types::regs_iface::sptr mpm::spi::make_spidev_regs_iface( const std::string &device, const int speed_hz, + const int spi_mode, uint32_t addr_shift, uint32_t data_shift, uint32_t read_flags, uint32_t write_flags ) { auto spi_iface_sptr = mpm::spi::spi_iface::make_spidev( - device, speed_hz + device, speed_hz, spi_mode ); return std::make_shared<spi_regs_iface_impl>( spi_iface_sptr, diff --git a/mpm/lib/spi/spidev_iface.cpp b/mpm/lib/spi/spidev_iface.cpp index fe37f16d5..74cb6bc88 100644 --- a/mpm/lib/spi/spidev_iface.cpp +++ b/mpm/lib/spi/spidev_iface.cpp @@ -37,8 +37,10 @@ public: spidev_iface_impl( const std::string &device, - const int max_speed_hz - ) : _speed(max_speed_hz) + const int max_speed_hz, + const int spi_mode + ) : _speed(max_speed_hz), + _mode(spi_mode) { if (!init_spi( @@ -94,7 +96,7 @@ public: private: int _fd; - uint32_t _mode = SPI_CPHA | SPI_CPOL; + const uint32_t _mode; uint32_t _speed = 2000000; uint8_t _bits = 8; uint16_t _delay = 0; @@ -105,10 +107,11 @@ private: *****************************************************************************/ spi_iface::sptr spi_iface::make_spidev( const std::string &device, - const int speed_hz + const int speed_hz, + const int spi_mode ) { return std::make_shared<spidev_iface_impl>( - device, speed_hz + device, speed_hz, spi_mode ); } |