spi mutex only blocked when gpio != NO_GPIO
This commit is contained in:
parent
a85c01465b
commit
8a38c7958b
@ -82,7 +82,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular
|
||||
chipname = regularGpio->chipname;
|
||||
chip = gpiod_chip_open_by_name(chipname.c_str());
|
||||
if (!chip) {
|
||||
sif::warning << "LinuxLibgpioIF::configureGpios: Failed to open chip "
|
||||
sif::warning << "LinuxLibgpioIF::configureRegularGpio: Failed to open chip "
|
||||
<< chipname << ". Gpio ID: " << gpioId << std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
@ -90,9 +90,10 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular
|
||||
lineNum = regularGpio->lineNum;
|
||||
lineHandle = gpiod_chip_get_line(chip, lineNum);
|
||||
if (!lineHandle) {
|
||||
sif::warning << "LinuxLibgpioIF::configureGpios: Failed to open line for GPIO" << std::endl;
|
||||
sif::warning << "GPIO ID " << gpioId << "with line number " << lineNum <<
|
||||
" and chipname " << chipname << std::endl;
|
||||
sif::debug << "LinuxLibgpioIF::configureRegularGpio: Failed to open line " << std::endl;
|
||||
sif::debug << "GPIO ID: " << gpioId << ", line number: " << lineNum <<
|
||||
", chipname: " << chipname << std::endl;
|
||||
sif::debug << "Check if linux GPIO configuration has changed. " << std::endl;
|
||||
gpiod_chip_close(chip);
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
@ -105,7 +106,7 @@ ReturnValue_t LinuxLibgpioIF::configureRegularGpio(gpioId_t gpioId, GpiodRegular
|
||||
result = gpiod_line_request_output(lineHandle, consumer.c_str(),
|
||||
regularGpio->initValue);
|
||||
if (result < 0) {
|
||||
sif::error << "LinuxLibgpioIF::configureGpios: Failed to request line " << lineNum <<
|
||||
sif::error << "LinuxLibgpioIF::configureRegularGpio: Failed to request line " << lineNum <<
|
||||
" from GPIO instance with ID: " << gpioId << std::endl;
|
||||
gpiod_line_release(lineHandle);
|
||||
return RETURN_FAILED;
|
||||
|
@ -178,11 +178,10 @@ ReturnValue_t SpiComIF::sendMessage(CookieIF *cookie, const uint8_t *sendData, s
|
||||
bool fullDuplex = spiCookie->isFullDuplex();
|
||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||
|
||||
/* GPIO access is mutex protected */
|
||||
MutexGuard(spiMutex, timeoutType, timeoutMs);
|
||||
|
||||
/* Pull SPI CS low. For now, no support for active high given */
|
||||
if(gpioId != gpio::NO_GPIO) {
|
||||
/* GPIO access is mutex protected */
|
||||
MutexGuard(spiMutex, timeoutType, timeoutMs);
|
||||
gpioComIF->pullLow(gpioId);
|
||||
}
|
||||
|
||||
@ -263,8 +262,8 @@ ReturnValue_t SpiComIF::requestReceiveMessage(CookieIF *cookie, size_t requestLe
|
||||
}
|
||||
|
||||
gpioId_t gpioId = spiCookie->getChipSelectPin();
|
||||
MutexGuard(spiMutex, timeoutType, timeoutMs);
|
||||
if(gpioId != gpio::NO_GPIO) {
|
||||
MutexGuard(spiMutex, timeoutType, timeoutMs);
|
||||
gpioComIF->pullLow(gpioId);
|
||||
}
|
||||
|
||||
@ -302,6 +301,10 @@ ReturnValue_t SpiComIF::readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
MutexIF* SpiComIF::getMutex() {
|
||||
return spiMutex;
|
||||
}
|
||||
|
||||
ReturnValue_t SpiComIF::getReadBuffer(address_t spiAddress, uint8_t** buffer) {
|
||||
if(buffer == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
|
@ -39,6 +39,11 @@ public:
|
||||
size_t requestLen) override;
|
||||
ReturnValue_t readReceivedMessage(CookieIF *cookie, uint8_t **buffer,
|
||||
size_t *size) override;
|
||||
/**
|
||||
* @brief This function returns the mutex which can be used to protect the spi bus when
|
||||
* the chip select must be driven from outside of the com if.
|
||||
*/
|
||||
MutexIF* getMutex();
|
||||
private:
|
||||
|
||||
struct SpiInstance {
|
||||
|
Loading…
Reference in New Issue
Block a user