JeVois  1.20
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
IMUspi.H
Go to the documentation of this file.
1 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 //
3 // JeVois Smart Embedded Machine Vision Toolkit - Copyright (C) 2020 by Laurent Itti, the University of Southern
4 // California (USC), and iLab at USC. See http://iLab.usc.edu and http://jevois.org for information about this project.
5 //
6 // This file is part of the JeVois Smart Embedded Machine Vision Toolkit. This program is free software; you can
7 // redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software
8 // Foundation, version 2. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
9 // without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
10 // License for more details. You should have received a copy of the GNU General Public License along with this program;
11 // if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
12 //
13 // Contact information: Laurent Itti - 3641 Watt Way, HNB-07A - Los Angeles, CA 90089-2520 - USA.
14 // Tel: +1 213 740 3527 - itti@pollux.usc.edu - http://iLab.usc.edu - http://jevois.org
15 // ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
16 /*! \file */
17 
18 #pragma once
19 
20 #ifdef JEVOIS_PRO
21 
22 #include <jevois/Core/IMU.H>
23 #include <string>
24 
25 namespace jevois
26 {
27  //! IMU with SPI interface, such as the ICM20948 IMU on the JeVois-Pro IMX290 camera sensor board
28  class IMUspi : public IMU
29  {
30  public:
31  //! Constructor
32  IMUspi(std::string const & devname);
33 
34  //! Destructor
35  virtual ~IMUspi();
36 
37  //! Returns true if we use SPI for transfers. Used when ICM20948_REG_USER_CTRL is written to
38  virtual bool isSPI() const override;
39 
40  //! @name Access functions for IMU registers
41  //! @{
42 
43  //! Write a value to one of the IMU registers
44  /*! See base class jevois::IMU for full docs. */
45  void writeRegister(unsigned short reg, unsigned char val) override;
46 
47  //! Read a value from one of the camera's IMU registers
48  /*! See base class jevois::IMU for full docs. */
49  unsigned char readRegister(unsigned short reg) override;
50 
51  //! Write an array of values to the camera's IMU registers
52  /*! See base class jevois::IMU for full docs. */
53  void writeRegisterArray(unsigned short reg, unsigned char const * vals, size_t num) override;
54 
55  //! Read an array of values from the camera's IMU registers
56  /*! See base class jevois::IMU for full docs. */
57  void readRegisterArray(unsigned short reg, unsigned char * vals, size_t num) override;
58 
59  //! @}
60 
61  protected:
62  std::string const itsDevName;
63  int itsFd;
64  void selectBank(unsigned short reg);
65  uint8_t itsIMUbank;
66  void spi_xfer(unsigned char addr, unsigned char dir, size_t siz,
67  unsigned char * datain, unsigned char const * dataout);
68  };
69 
70 } // namespace jevois
71 
72 #endif // JEVOIS_PRO
jevois::IMUspi::itsFd
int itsFd
Definition: IMUspi.H:63
jevois::IMUspi::writeRegisterArray
void writeRegisterArray(unsigned short reg, unsigned char const *vals, size_t num) override
Write an array of values to the camera's IMU registers.
Definition: IMUspi.C:221
jevois::IMUspi::isSPI
virtual bool isSPI() const override
Returns true if we use SPI for transfers. Used when ICM20948_REG_USER_CTRL is written to.
Definition: IMUspi.C:103
jevois::IMUspi::writeRegister
void writeRegister(unsigned short reg, unsigned char val) override
Write a value to one of the IMU registers.
Definition: IMUspi.C:159
jevois::IMUspi::~IMUspi
virtual ~IMUspi()
Destructor.
Definition: IMUspi.C:97
jevois
Definition: Concepts.dox:1
jevois::IMUspi::IMUspi
IMUspi(std::string const &devname)
Constructor.
Definition: IMUspi.C:33
jevois::IMUspi
IMU with SPI interface, such as the ICM20948 IMU on the JeVois-Pro IMX290 camera sensor board.
Definition: IMUspi.H:28
jevois::IMU
Abstract interface to an ICM20948 inertial measurement unit (IMU)
Definition: IMU.H:27
jevois::IMUspi::itsDevName
const std::string itsDevName
Definition: IMUspi.H:62
jevois::IMUspi::itsIMUbank
uint8_t itsIMUbank
Definition: IMUspi.H:65
jevois::IMUspi::readRegister
unsigned char readRegister(unsigned short reg) override
Read a value from one of the camera's IMU registers.
Definition: IMUspi.C:211
jevois::IMUspi::spi_xfer
void spi_xfer(unsigned char addr, unsigned char dir, size_t siz, unsigned char *datain, unsigned char const *dataout)
Definition: IMUspi.C:107
IMU.H
jevois::IMUspi::selectBank
void selectBank(unsigned short reg)
Definition: IMUspi.C:147
jevois::IMUspi::readRegisterArray
void readRegisterArray(unsigned short reg, unsigned char *vals, size_t num) override
Read an array of values from the camera's IMU registers.
Definition: IMUspi.C:230