#ifndef LINUX_BOARDTEST_SPITESTCLASS_H_ #define LINUX_BOARDTEST_SPITESTCLASS_H_ #include #include #include #include class SpiTestClass: public TestTask { public: enum TestModes { MGM_LIS3MDL, MGM_RM3100, GYRO_L3GD20H, }; TestModes testMode; SpiTestClass(object_id_t objectId, GpioIF* gpioIF); ReturnValue_t performOneShotAction() override; ReturnValue_t performPeriodicAction() override; private: GpioIF* gpioIF; std::array recvBuffer; std::array sendBuffer; struct spi_ioc_transfer spiTransferStruct; void performRm3100Test(uint8_t mgmId); /* ACS board specific code which pulls all GPIOs high */ void acsInit(); /* ACS board specific variables */ uint8_t mgm0Lis3ChipSelect = 0; uint8_t mgm1Rm3100ChipSelect = 1; uint8_t gyro0AdisChipSelect = 5; uint8_t gyro1L3gd20ChipSelect = 6; uint8_t gyro2L3gd20ChipSelect = 4; uint8_t mgm2Lis3mdlChipSelect = 17; uint8_t mgm3Rm3100ChipSelect = 27; static constexpr uint8_t STM_READ_MASK = 0b1000'0000; static constexpr uint8_t STM_AUTO_INCR_MASK = 0b0100'0000; void setSpiSpeedAndMode(int spiFd, spi::SpiMode mode, uint32_t speed); void writeStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, uint8_t value, bool autoIncrement); uint8_t readStmRegister(int fd, gpioId_t chipSelect, uint8_t reg, bool autoIncrement); }; #endif /* LINUX_BOARDTEST_SPITESTCLASS_H_ */