removed some changes which belong in separate PR
This commit is contained in:
parent
18b342e94b
commit
7b3de87364
@ -205,5 +205,3 @@ ReturnValue_t CommandExecutor::executeBlocking() {
|
|||||||
}
|
}
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
const std::vector<char>& CommandExecutor::getReadVector() const { return readVec; }
|
|
||||||
|
@ -401,33 +401,12 @@ void SpiComIF::setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed)
|
|||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Setting SPI speed failed");
|
utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Setting SPI speed failed");
|
||||||
}
|
}
|
||||||
}
|
// This updates the SPI clock default polarity. Only setting the mode does not update
|
||||||
|
// the line state, which can be an issue on mode switches because the clock line will
|
||||||
void SpiComIF::getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& speed) const {
|
// switch the state after the chip select is pulled low
|
||||||
uint8_t tmpMode = 0;
|
|
||||||
int retval = ioctl(spiFd, SPI_IOC_RD_MODE, &tmpMode);
|
|
||||||
if (retval != 0) {
|
|
||||||
utility::handleIoctlError("SpiComIF::getSpiSpeedAndMode: Reading SPI mode failed");
|
|
||||||
}
|
|
||||||
mode = static_cast<spi::SpiModes>(tmpMode);
|
|
||||||
|
|
||||||
retval = ioctl(spiFd, SPI_IOC_RD_MAX_SPEED_HZ, &speed);
|
|
||||||
if (retval != 0) {
|
|
||||||
utility::handleIoctlError("SpiComIF::getSpiSpeedAndMode: Getting SPI speed failed");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
const std::string& SpiComIF::getSpiDev() const { return dev; }
|
|
||||||
|
|
||||||
void SpiComIF::updateLinePolarity(int spiFd) {
|
|
||||||
clockUpdateTransfer.len = 0;
|
clockUpdateTransfer.len = 0;
|
||||||
retval = ioctl(spiFd, SPI_IOC_MESSAGE(1), &clockUpdateTransfer);
|
retval = ioctl(spiFd, SPI_IOC_MESSAGE(1), &clockUpdateTransfer);
|
||||||
if (retval != 0) {
|
if (retval != 0) {
|
||||||
utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Updating SPI default clock failed");
|
utility::handleIoctlError("SpiComIF::setSpiSpeedAndMode: Updating SPI default clock failed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void SpiComIF::setMutexParams(MutexIF::TimeoutType timeoutType_, uint32_t timeoutMs_) {
|
|
||||||
timeoutType = timeoutType_;
|
|
||||||
timeoutMs = timeoutMs_;
|
|
||||||
}
|
|
||||||
|
@ -22,17 +22,15 @@ class SpiCookie;
|
|||||||
*/
|
*/
|
||||||
class SpiComIF : public DeviceCommunicationIF, public SystemObject {
|
class SpiComIF : public DeviceCommunicationIF, public SystemObject {
|
||||||
public:
|
public:
|
||||||
static constexpr dur_millis_t DEFAULT_MUTEX_TIMEOUT = 20;
|
static constexpr uint8_t spiRetvalId = CLASS_ID::HAL_SPI;
|
||||||
|
|
||||||
static constexpr uint8_t CLASS_ID = CLASS_ID::HAL_SPI;
|
|
||||||
static constexpr ReturnValue_t OPENING_FILE_FAILED =
|
static constexpr ReturnValue_t OPENING_FILE_FAILED =
|
||||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 0);
|
HasReturnvaluesIF::makeReturnCode(spiRetvalId, 0);
|
||||||
/* Full duplex (ioctl) transfer failure */
|
/* Full duplex (ioctl) transfer failure */
|
||||||
static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED =
|
static constexpr ReturnValue_t FULL_DUPLEX_TRANSFER_FAILED =
|
||||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 1);
|
HasReturnvaluesIF::makeReturnCode(spiRetvalId, 1);
|
||||||
/* Half duplex (read/write) transfer failure */
|
/* Half duplex (read/write) transfer failure */
|
||||||
static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED =
|
static constexpr ReturnValue_t HALF_DUPLEX_TRANSFER_FAILED =
|
||||||
HasReturnvaluesIF::makeReturnCode(CLASS_ID, 2);
|
HasReturnvaluesIF::makeReturnCode(spiRetvalId, 2);
|
||||||
|
|
||||||
SpiComIF(object_id_t objectId, GpioIF* gpioComIF);
|
SpiComIF(object_id_t objectId, GpioIF* gpioComIF);
|
||||||
|
|
||||||
@ -47,7 +45,6 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
|
|||||||
* the chip select must be driven from outside of the com if.
|
* the chip select must be driven from outside of the com if.
|
||||||
*/
|
*/
|
||||||
MutexIF* getMutex(MutexIF::TimeoutType* timeoutType = nullptr, uint32_t* timeoutMs = nullptr);
|
MutexIF* getMutex(MutexIF::TimeoutType* timeoutType = nullptr, uint32_t* timeoutMs = nullptr);
|
||||||
void setMutexParams(MutexIF::TimeoutType timeoutType, uint32_t timeoutMs);
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Perform a regular send operation using Linux iotcl. This is public so it can be used
|
* Perform a regular send operation using Linux iotcl. This is public so it can be used
|
||||||
@ -62,23 +59,6 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
|
|||||||
|
|
||||||
GpioIF* getGpioInterface();
|
GpioIF* getGpioInterface();
|
||||||
void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed);
|
void setSpiSpeedAndMode(int spiFd, spi::SpiModes mode, uint32_t speed);
|
||||||
<<<<<<< Updated upstream
|
|
||||||
=======
|
|
||||||
void getSpiSpeedAndMode(int spiFd, spi::SpiModes& mode, uint32_t& speed) const;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This updates the SPI clock default polarity. Only setting the mode does not update
|
|
||||||
* the line state, which can be an issue on mode switches because the clock line will
|
|
||||||
* switch the state after the chip select is pulled low.
|
|
||||||
*
|
|
||||||
* It is recommended to call this function after #setSpiSpeedAndMode and after locking the
|
|
||||||
* CS mutex if the SPI bus has multiple SPI devices with different speed and SPI modes attached.
|
|
||||||
* @param spiFd
|
|
||||||
*/
|
|
||||||
void updateLinePolarity(int spiFd);
|
|
||||||
|
|
||||||
const std::string& getSpiDev() const;
|
|
||||||
>>>>>>> Stashed changes
|
|
||||||
void performSpiWiretapping(SpiCookie* spiCookie);
|
void performSpiWiretapping(SpiCookie* spiCookie);
|
||||||
|
|
||||||
ReturnValue_t getReadBuffer(address_t spiAddress, uint8_t** buffer);
|
ReturnValue_t getReadBuffer(address_t spiAddress, uint8_t** buffer);
|
||||||
@ -93,7 +73,7 @@ class SpiComIF : public DeviceCommunicationIF, public SystemObject {
|
|||||||
|
|
||||||
MutexIF* spiMutex = nullptr;
|
MutexIF* spiMutex = nullptr;
|
||||||
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
MutexIF::TimeoutType timeoutType = MutexIF::TimeoutType::WAITING;
|
||||||
uint32_t timeoutMs = DEFAULT_MUTEX_TIMEOUT;
|
uint32_t timeoutMs = 20;
|
||||||
spi_ioc_transfer clockUpdateTransfer = {};
|
spi_ioc_transfer clockUpdateTransfer = {};
|
||||||
|
|
||||||
using SpiDeviceMap = std::unordered_map<address_t, SpiInstance>;
|
using SpiDeviceMap = std::unordered_map<address_t, SpiInstance>;
|
||||||
|
Loading…
Reference in New Issue
Block a user