Code: Select all
tx
Code: Select all
rx
Das System muss im SPI -Modus 0 funktionieren. Die Verwendung der Funktionen hier unten ist das Ergebnis immer falsch, das erste Byte, den der Master erhält, ist immer ein 0-Byte und das erste Byte von Tx wird immer als 2. Byte übertragen. Transfers wie ich möchte. < /p>
Code: Select all
// Into the SPI class declarations (header file)
inline ssize_t write(const void *b, int l) {
uint16_t t = 0;
m_ftStatus = FT4222_SPISlave_Write(m_ftHandleTx, (uint8_t*) b, l, &t);
if (m_ftStatus != FT4222_OK)
return -m_ftStatus;
return t;
}
inline ssize_t read(const void *b, int l) {
uint16_t t = 0;
m_ftStatus = FT4222_SPISlave_Read(m_ftHandleRx, (uint8_t*) b, l,
&t);
if (m_ftStatus != FT4222_OK)
return -m_ftStatus;
return t;
}
// Member function of the class SPI
ssize_t SPI::transfer(void *rx, const void *tx, size_t length) {
// m_ftStatus = FT4222_SPI_ResetTransaction(m_ftHandleRx, 0);
ssize_t l;
if (tx != nullptr) {
/*if (m_ftStatus == FT4222_OK && m_ftHandleTx != m_ftHandleRx)
m_ftStatus = FT4222_SPI_ResetTransaction(m_ftHandleTx, 0);
*/
if (m_ftStatus != FT4222_OK)
return m_ftStatus;
l = write(tx, length);
if (l < 0)
return l;
}
l = read(rx, length);
if (l < 0)
return l;
return l;
}