Diolan DLN-4M adapter operates through 3 interfaces: usb to i2c, spi interface and usb to gpio interface. The abilities for single adapter are pretty wide. Lets look on spi master module of DLN-4 adapter. DLN-4S adapter has spi master and spi slave interface as opposed to DLN-4M adapter which has only spi master interface abilities as only i2c master interface abilities as well. GPIO abilities for all DLN-4-series adapters are similar.
Lets give more detailed look on spi master module of DLN-4 adapters. First of all you need to enable spi master port. After you do it, you can set Mode (CPOL and CPHA) parameters. The example to Set Mode by using DlnSpiMasterSetMode():
uint8_t mode = 0; if(ui->cphaComboBox->currentText().toUInt() == 1) mode |= DLN_SPI_MASTER_CPHA_1; if(ui->cpolComboBox->currentText().toUInt() == 1) mode |= DLN_SPI_MASTER_CPOL_1; DLN_RESULT result = DlnSpiMasterSetMode(_handle, ui->port->currentIndex(), mode);
Also you can set spi frequency (), Slave Select pins, delays between and after Slave Select, delay between frames. After you call DlnSpiMasterSetFrequency() function with frequency parameter it would be automatically rounded to the closest proper frequency value for adapter. DlnSpiMasterReadWrite() function performs transaction with slave device. The call example of DlnSpiMasterReadWrite():
QByteArray writeData = QByteArray::fromHex(ui->writeData->toPlainText().toAscii()); uint8_t transferSize; DlnSpiMasterGetFrameSize(_handle, ui->port->currentIndex(), &transferSize); if(transferSize >{ QByteArray invertedData; int j = writeData.size()-1; for(int i = 0; i < writeData.size(); i++) invertedData[i] = writeData[j--]; writeData = invertedData; } QByteArray readData(writeData.size(), 0); DLN_RESULT result = DlnSpiMasterReadWrite(_handle, ui->port->currentIndex(), writeData.size(), (uint8_t*)writeData.data(), (uint8_t*)readData.data());
You can use spi_gui demo examples source code or binary to look through abilities of DLN-4 series adapters