JeVois  1.21
JeVois Smart Embedded Machine Vision Toolkit
Share this page:
Loading...
Searching...
No Matches
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#include <cstdint>
25
26namespace jevois
27{
28 //! IMU with SPI interface, such as the ICM20948 IMU on the JeVois-Pro IMX290 camera sensor board
29 class IMUspi : public IMU
30 {
31 public:
32 //! Constructor
33 IMUspi(std::string const & devname);
34
35 //! Destructor
36 virtual ~IMUspi();
37
38 //! Returns true if we use SPI for transfers. Used when ICM20948_REG_USER_CTRL is written to
39 virtual bool isSPI() const override;
40
41 //! @name Access functions for IMU registers
42 //! @{
43
44 //! Write a value to one of the IMU registers
45 /*! See base class jevois::IMU for full docs. */
46 void writeRegister(unsigned short reg, unsigned char val) override;
47
48 //! Read a value from one of the camera's IMU registers
49 /*! See base class jevois::IMU for full docs. */
50 unsigned char readRegister(unsigned short reg) override;
51
52 //! Write an array of values to the camera's IMU registers
53 /*! See base class jevois::IMU for full docs. */
54 void writeRegisterArray(unsigned short reg, unsigned char const * vals, size_t num) override;
55
56 //! Read an array of values from the camera's IMU registers
57 /*! See base class jevois::IMU for full docs. */
58 void readRegisterArray(unsigned short reg, unsigned char * vals, size_t num) override;
59
60 //! @}
61
62 protected:
63 std::string const itsDevName;
64 int itsFd;
65 void selectBank(unsigned short reg);
66 uint8_t itsIMUbank;
67 void spi_xfer(unsigned char addr, unsigned char dir, size_t siz,
68 unsigned char * datain, unsigned char const * dataout);
69 };
70
71} // namespace jevois
72
73#endif // JEVOIS_PRO
Abstract interface to an ICM20948 inertial measurement unit (IMU)
Definition IMU.H:28
IMU with SPI interface, such as the ICM20948 IMU on the JeVois-Pro IMX290 camera sensor board.
Definition IMUspi.H:30
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
void writeRegister(unsigned short reg, unsigned char val) override
Write a value to one of the IMU registers.
Definition IMUspi.C:159
virtual ~IMUspi()
Destructor.
Definition IMUspi.C:97
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
uint8_t itsIMUbank
Definition IMUspi.H:66
unsigned char readRegister(unsigned short reg) override
Read a value from one of the camera's IMU registers.
Definition IMUspi.C:211
void selectBank(unsigned short reg)
Definition IMUspi.C:147
std::string const itsDevName
Definition IMUspi.H:63
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
void spi_xfer(unsigned char addr, unsigned char dir, size_t siz, unsigned char *datain, unsigned char const *dataout)
Definition IMUspi.C:107
Main namespace for all JeVois classes and functions.
Definition Concepts.dox:2