libClearCore/src/SerialBase.cpp
uint8_t SerialBase::SpiTransferData(uint8_t data) {
    if (!m_portOpen || m_portMode != PortModes::SPI) {
        return 0;
    }
    // Write data into Data register
    m_serPort->SPI.DATA.bit.DATA = data;

    while (!m_serPort->SPI.INTFLAG.bit.RXC ||
            !m_serPort->SPI.INTFLAG.bit.TXC) {
        // If the port is not open, bail out
        if (!m_portOpen) {
            return 0;
        }
        // Wait for it to complete
        continue;
    }
    return m_serPort->SPI.DATA.bit.DATA;
}
/**
    SPI's TX and RX function
**/
SPI's TX and RX function
SPI ' s TX and RX function
uint8_t SerialBase::SpiTransferData(uint8_t data) {
    if (!m_portOpen || m_portMode != PortModes::SPI) {
        return 0;
    }
    m_serPort->SPI.DATA.bit.DATA = data;
    while (!m_serPort->SPI.INTFLAG.bit.RXC ||
            !m_serPort->SPI.INTFLAG.bit.TXC) {
        if (!m_portOpen) {
            return 0;
        }
        continue;
    }
    return m_serPort->SPI.DATA.bit.DATA;
}
uint8_t SerialBase :: SpiTransferData ( uint8_t data ) { if ( ! m_portOpen || m_portMode != PortModes :: SPI ) { return 0 ; } m_serPort -> SPI . DATA . bit . DATA = data ; while ( ! m_serPort -> SPI . INTFLAG . bit . RXC || ! m_serPort -> SPI . INTFLAG . bit . TXC ) { if ( ! m_portOpen ) { return 0 ; } continue ; } return m_serPort -> SPI . DATA . bit . DATA ; }
SPI's TX and RX function
SPI ' s TX and RX function
// Write data into Data register // If the port is not open, bail out // Wait for it to complete