text: /***************************************************************************//**
   * @file
   * @brief EzRadio direct reception plug-in managed by the plug-in manager if enabled.
   *******************************************************************************
   * # License
   * <b>Copyright 2018 Silicon Laboratories Inc. www.silabs.com</b>
   *******************************************************************************
   *
   * SPDX-License-Identifier: Zlib
   *
   * The licensor of this software is Silicon Laboratories Inc.
   *
   * This software is provided 'as-is', without any express or implied
   * warranty. In no event will the authors be held liable for any damages
   * arising from the use of this software.
   *
   * 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. If you use this software
   *    in a product, an acknowledgment in the product documentation would be
   *    appreciated but is not required.
   * 2. Altered source versions must be plainly marked as such, and must not be
   *    misrepresented as being the original software.
   * 3. This notice may not be removed or altered from any source distribution.
   *
   ******************************************************************************/
  
  #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_transmit_plugin.h"
  
  #if defined(EZRADIO_PLUGIN_DIRECT_RECEIVE)
  
  /**************************************************************************//**
   * @brief Starts direct reception with the radio configurations
   *        from the radioHandle parameter.
   *
   *  @param radioHandle Handler of the EzRadio driver instance where channel
   *         configuration is set.
   *
   *  @return
   *    @ref ECODE_EMDRV_EZRADIODRV_OK on success. On failure an appropriate EZRADIODRV
   *    @ref Ecode_t is returned.
   *****************************************************************************/
  Ecode_t ezradioStartDirectReceive(EZRADIODRV_Handle_t radioHandle)
  {
    if ( radioHandle == NULL ) {
      return ECODE_EMDRV_EZRADIODRV_ILLEGAL_HANDLE;
    }
  
    /* Read ITs, clear pending ones */
    ezradio_get_int_status(0u, 0u, 0u, NULL);
  
    /* Start sending packet, channel 0, START immediately, Packet n bytes long, go READY when done */
    ezradio_start_rx(radioHandle->directRx.channel, 0u, 0u,
                     EZRADIO_CMD_START_RX_ARG_NEXT_STATE1_RXTIMEOUT_STATE_ENUM_NOCHANGE,
                     EZRADIO_CMD_START_RX_ARG_NEXT_STATE2_RXVALID_STATE_ENUM_RX,
                     EZRADIO_CMD_START_RX_ARG_NEXT_STATE3_RXINVALID_STATE_ENUM_RX);
  
    return ECODE_EMDRV_EZRADIODRV_OK;
  }
  
  /**************************************************************************//**
   * @brief Stops direct reception.
   *
   *  @return
   *    @ref ECODE_EMDRV_EZRADIODRV_OK on success. On failure an appropriate EZRADIODRV
   *    @ref Ecode_t is returned.
   *****************************************************************************/
  Ecode_t ezradioStopDirectReceive(void)
  {
    ezradio_change_state(EZRADIO_CMD_CHANGE_STATE_ARG_NEXT_STATE1_NEW_STATE_ENUM_READY);
  
    return ECODE_EMDRV_EZRADIODRV_OK;
  }
  
  #endif //#if defined( EZRADIO_PLUGIN_DIRECT_RECEIVE )
  