text: /***************************************************************************//**
   * @file ezradio_crcerror_plugin.c
   * @brief EzRadio CRC error plug-in managed by the plug-in manager if enabled.
   * @version 4.3.0
   *******************************************************************************
   * @section License
   * <b>(C) Copyright 2015 Silicon Labs, http://www.silabs.com</b>
   *******************************************************************************
   *
   * Permission is granted to anyone to use this software for any purpose,
   * including commercial applications, and to alter it and redistribute it
   * freely, subject to the following restrictions:
   *
   * 1. The origin of this software must not be misrepresented; you must not
   *    claim that you wrote the original software.@n
   * 2. Altered source versions must be plainly marked as such, and must not be
   *    misrepresented as being the original software.@n
   * 3. This notice may not be removed or altered from any source distribution.
   *
   * DISCLAIMER OF WARRANTY/LIMITATION OF REMEDIES: Silicon Labs has no
   * obligation to support this Software. Silicon Labs is providing the
   * Software "AS IS", with no express or implied warranties of any kind,
   * including, but not limited to, any implied warranties of merchantability
   * or fitness for any particular purpose or warranties against infringement
   * of any proprietary rights of a third party.
   *
   * Silicon Labs will not be liable for any consequential, incidental, or
   * special damages, or any other relief, or for any claim by any third party,
   * arising from your use of this Software.
   *
   ******************************************************************************/
  
  
  #include <stddef.h>
  #include "em_device.h"
  
  #include "ezradio_cmd.h"
  #include "ezradio_prop.h"
  #include "ezradio_api_lib.h"
  #include "ezradio_api_lib_add.h"
  #include "ezradio_plugin_manager.h"
  #include "ezradio_receive_plugin.h"
  
  #if defined( EZRADIO_PLUGIN_CRC_ERROR )
  
  /// @cond DO_NOT_INCLUDE_WITH_DOXYGEN
  //  Note: These are internal routines used by ezradio plugin manager.
  
  /**************************************************************************//**
   * @brief EZRadioDrv CRC error plug-in handler routine.
   *
   *  @param radioHandle EzRadio driver instance handler.
   *  @param radioReplyHandle EZRadio communication reply handler.
   *
   *  @return
   *    @ref ECODE_EMDRV_EZRADIODRV_OK on success. On failure an appropriate EZRADIODRV
   *    @ref Ecode_t is returned.
   *****************************************************************************/
  Ecode_t ezradioHandleCrcErrorPlugin( EZRADIODRV_Handle_t radioHandle, EZRADIODRV_ReplyHandle_t radioReplyHandle )
  {
    if ( radioHandle == NULL )
    {
      return ECODE_EMDRV_EZRADIODRV_ILLEGAL_HANDLE;
    }
  
    /* Check if CRC IT is received */
    if ( radioReplyHandle->GET_INT_STATUS.PH_PEND & EZRADIO_CMD_GET_INT_STATUS_REP_PH_PEND_CRC_ERROR_PEND_BIT)
    {
      /* Reset FIFO */
      ezradio_change_state(EZRADIO_CMD_CHANGE_STATE_ARG_NEXT_STATE1_NEW_STATE_ENUM_READY);
      ezradio_fifo_info(EZRADIO_CMD_FIFO_INFO_ARG_FIFO_RX_BIT, NULL);
  
      if ( radioHandle->packetCrcError.userCallback != NULL )
      {
        radioHandle->packetCrcError.userCallback( radioHandle, ECODE_EMDRV_EZRADIODRV_OK );
      }
    }
  
    return ECODE_EMDRV_EZRADIODRV_OK;
  }
  
  /// @endcond
  
  #endif //#if defined( EZRADIO_PLUGIN_CRC_ERROR )
  