Robus/src/reception.c
void Recep_GetCollision(volatile uint8_t *data)
{
    // Check data integrity
    if ((ctx.tx.data[data_count++] != *data) || (!ctx.tx.lock) || (ctx.rx.status.rx_framing_error == true))
    {
        // Data dont match, or we don't start to send the message, there is a collision
        ctx.tx.collision = true;
        // Stop TX trying to save input datas
        LuosHAL_SetTxState(false);
        // Save the received data into the allocator to be able to continue the reception
        for (uint8_t i = 0; i < data_count - 1; i++)
        {
            MsgAlloc_SetData(*ctx.tx.data + i);
        }
        MsgAlloc_SetData(*data);
        // Switch to get header.
        ctx.rx.callback = Recep_GetHeader;
        ctx.tx.status   = TX_NOK;
        if (data_count >= 3)
        {
            if (Recep_NodeConcerned((header_t *)&current_msg->header) == false)
            {
                MsgAlloc_ValidHeader(false, data_size);
                ctx.rx.callback = Recep_Drop;
                return;
            }
        }
    }
    else
    {
        if (data_count == COLLISION_DETECTION_NUMBER)
        {
#ifdef SELFTEST
            selftest_SetRxFlag();
#endif
            // collision detection end
            LuosHAL_SetRxState(false);
            LuosHAL_ResetTimeout(0);
            if (ctx.tx.status == TX_NOK)
            {
                // switch to catch Ack.
                ctx.rx.callback = Recep_CatchAck;
            }
            else
            {
                // switch to get header.
                ctx.rx.callback = Recep_GetHeader;
            }
            return;
        }
    }
    LuosHAL_ComputeCRC((uint8_t *)data, (uint8_t *)&crc_val);
}
/******************************************************************************
 * @brief Callback to get a collision beetween RX and Tx
 * @param data come from RX
 * @return None
 ******************************************************************************/
@brief Callback to get a collision beetween RX and Tx
@param data come from RX
@return None
@brief Callback to get a collision beetween RX and Tx @param data come from RX @return None
void Recep_GetCollision(volatile uint8_t *data)
{
    if ((ctx.tx.data[data_count++] != *data) || (!ctx.tx.lock) || (ctx.rx.status.rx_framing_error == true))
    {
        ctx.tx.collision = true;
        LuosHAL_SetTxState(false);
        for (uint8_t i = 0; i < data_count - 1; i++)
        {
            MsgAlloc_SetData(*ctx.tx.data + i);
        }
        MsgAlloc_SetData(*data);
        ctx.rx.callback = Recep_GetHeader;
        ctx.tx.status   = TX_NOK;
        if (data_count >= 3)
        {
            if (Recep_NodeConcerned((header_t *)&current_msg->header) == false)
            {
                MsgAlloc_ValidHeader(false, data_size);
                ctx.rx.callback = Recep_Drop;
                return;
            }
        }
    }
    else
    {
        if (data_count == COLLISION_DETECTION_NUMBER)
        {
#ifdef SELFTEST
            selftest_SetRxFlag();
#endif
            LuosHAL_SetRxState(false);
            LuosHAL_ResetTimeout(0);
            if (ctx.tx.status == TX_NOK)
            {
                ctx.rx.callback = Recep_CatchAck;
            }
            else
            {
                ctx.rx.callback = Recep_GetHeader;
            }
            return;
        }
    }
    LuosHAL_ComputeCRC((uint8_t *)data, (uint8_t *)&crc_val);
}
void Recep_GetCollision ( volatile uint8_t * data ) { if ( ( ctx . tx . data [ data_count ++ ] != * data ) || ( ! ctx . tx . lock ) || ( ctx . rx . status . rx_framing_error == true ) ) { ctx . tx . collision = true ; LuosHAL_SetTxState ( false ) ; for ( uint8_t i = 0 ; i < data_count - 1 ; i ++ ) { MsgAlloc_SetData ( * ctx . tx . data + i ) ; } MsgAlloc_SetData ( * data ) ; ctx . rx . callback = Recep_GetHeader ; ctx . tx . status = TX_NOK ; if ( data_count >= 3 ) { if ( Recep_NodeConcerned ( ( header_t * ) & current_msg -> header ) == false ) { MsgAlloc_ValidHeader ( false , data_size ) ; ctx . rx . callback = Recep_Drop ; return ; } } } else { if ( data_count == COLLISION_DETECTION_NUMBER ) { #ifdef SELFTEST selftest_SetRxFlag ( ) ; #endif LuosHAL_SetRxState ( false ) ; LuosHAL_ResetTimeout ( 0 ) ; if ( ctx . tx . status == TX_NOK ) { ctx . rx . callback = Recep_CatchAck ; } else { ctx . rx . callback = Recep_GetHeader ; } return ; } } LuosHAL_ComputeCRC ( ( uint8_t * ) data , ( uint8_t * ) & crc_val ) ; }
@brief Callback to get a collision beetween RX and Tx
 @param data come from RX
 @return None
@brief Callback to get a collision beetween RX and Tx @param data come from RX @return None
// Check data integrity // Data dont match, or we don't start to send the message, there is a collision // Stop TX trying to save input datas // Save the received data into the allocator to be able to continue the reception // Switch to get header. // collision detection end // switch to catch Ack. // switch to get header.