spi com if almost finished

This commit is contained in:
2021-02-23 11:31:50 +01:00
parent a2e6634208
commit 3550fb6ca7
12 changed files with 649 additions and 11 deletions

View File

@ -181,16 +181,30 @@ ReturnValue_t I2cComIF::openDevice(std::string deviceFile,
address_t i2cAddress, int* fileDescriptor) {
*fileDescriptor = open(deviceFile.c_str(), O_RDWR);
if (*fileDescriptor < 0) {
sif::error << "I2cComIF: Opening i2c device failed with error code "
<< errno << ". Error description: " << strerror(errno)
<< std::endl;
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "I2cComIF: Opening I2C device failed with error code " << errno << "." <<
std::endl;
sif::warning << "Error description: " << strerror(errno) << std::endl;
#else
sif::printWarning("I2cComIF: Opening I2C device failed with error code %d.\n");
sif::printWarning("Error description: %s\n", strerror(errno));
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
return HasReturnvaluesIF::RETURN_FAILED;
}
if (ioctl(*fileDescriptor, I2C_SLAVE, i2cAddress) < 0) {
sif::error << "I2cComIF: Specifying target device failed with error "
<< "code " << errno << ". Error description "
<< strerror(errno) << std::endl;
#if FSFW_VERBOSE_LEVEL >= 1
#if FSFW_CPP_OSTREAM_ENABLED == 1
sif::warning << "I2cComIF: Specifying target device failed with error code " << errno << "."
<< std::endl;
sif::warning << "Error description " << strerror(errno) << std::endl;
#else
sif::printWarning("I2cComIF: Specifying target device failed with error code %d.\n");
sif::printWarning("Error description: %s\n", strerror(errno));
#endif /* FSFW_CPP_OSTREAM_ENABLED == 1 */
#endif /* FSFW_VERBOSE_LEVEL >= 1 */
return HasReturnvaluesIF::RETURN_FAILED;
}
return HasReturnvaluesIF::RETURN_OK;

View File

@ -45,8 +45,8 @@ private:
I2cDeviceMapIter i2cDeviceMapIter;
/**
* @brief This function opens an i2c device and binds the opened file
* to a specific i2c address.
* @brief This function opens an I2C device and binds the opened file
* to a specific I2C address.
* @param deviceFile The name of the device file. E.g. i2c-0
* @param i2cAddress The address of the i2c slave device.
* @param fileDescriptor Pointer to device descriptor.