EFM32 Wonder Gecko Software Documentation  efm32wg-doc-5.1.2
ezradio_receive_plugin.c
Go to the documentation of this file.
1 /***************************************************************************/
33 #include <stddef.h>
34 #include "em_device.h"
35 
36 #include "ezradio_cmd.h"
37 #include "ezradio_prop.h"
38 #include "ezradio_api_lib.h"
39 #include "ezradio_api_lib_add.h"
40 #include "ezradio_plugin_manager.h"
41 #include "ezradio_receive_plugin.h"
42 
43 #if defined(EZRADIO_PLUGIN_RECEIVE)
44 
46 
47 #if defined( EZRADIO_PLUGIN_AUTO_ACK) && defined(EZRADIO_PLUGIN_TRANSMIT)
48 Ecode_t ezradioTransmitAutoAck(EZRADIODRV_Handle_t radioHandle);
49 #endif
50 
52 
53 /**************************************************************************/
65 {
66  /* Start Receiving packet, channel 0, START immediately, Packet n bytes long */
67  ezradio_start_rx(radioHandle->packetRx.channel, 0u, 0u,
68  EZRADIO_CMD_START_RX_ARG_NEXT_STATE1_RXTIMEOUT_STATE_ENUM_NOCHANGE,
69  EZRADIO_CMD_START_RX_ARG_NEXT_STATE2_RXVALID_STATE_ENUM_READY,
70  EZRADIO_CMD_START_RX_ARG_NEXT_STATE3_RXINVALID_STATE_ENUM_RX );
71 
73 }
74 
76 // Note: These are internal routines used by ezradio plugin manager.
77 
78 /**************************************************************************/
88 Ecode_t ezradioHandleReceivePlugin( EZRADIODRV_Handle_t radioHandle, EZRADIODRV_ReplyHandle_t radioReplyHandle )
89 {
90  if ( radioHandle == NULL )
91  {
93  }
94 
95  /* Check if Pkt Rxd IT is received */
96  if ( radioReplyHandle->GET_INT_STATUS.PH_PEND & EZRADIO_CMD_GET_INT_STATUS_REP_PH_PEND_PACKET_RX_PEND_BIT)
97  {
98 
99  ezradio_cmd_reply_t radioReplyLocal;
100 
101  /* Check how many bytes we received. */
102  ezradio_fifo_info(0u, &radioReplyLocal);
103 
104  /* Read out the RX FIFO content. */
105  ezradio_read_rx_fifo(radioReplyLocal.FIFO_INFO.RX_FIFO_COUNT, radioHandle->packetRx.pktBuf);
106 
107  if ( radioHandle->packetRx.userCallback != NULL )
108  {
109  radioHandle->packetRx.userCallback( radioHandle, ECODE_EMDRV_EZRADIODRV_OK );
110  }
111 
112  /* Note: Workaround for some FIFO issue. */
113  ezradio_fifo_info(EZRADIO_CMD_FIFO_INFO_ARG_FIFO_RX_BIT, NULL);
114  ezradioStartRx( radioHandle );
115 
116 #if defined(EZRADIO_PLUGIN_AUTO_ACK) && defined(EZRADIO_PLUGIN_TRANSMIT)
117  /* Transmit auto acknowledge packet if enabled */
118  if (radioHandle->autoAck.ackMode == ezradiodrvAutoAckSkipOne)
119  {
121  }
122  else if (radioHandle->autoAck.ackMode == ezradiodrvAutoAckImmediate)
123  {
124  ezradioTransmitAutoAck(radioHandle);
125  }
126 #endif
127 
129  }
130 
131  /* Reset FIFO */
132  ezradio_fifo_info(EZRADIO_CMD_FIFO_INFO_ARG_FIFO_RX_BIT, NULL);
133 
135 }
136 
138 
139 #endif //#if defined( EZRADIO_PLUGIN_RECEIVE )
uint8_t * pktBuf
Pointer to the receive buffer.
EzRadio transmit plug-in managed by the plug-in manager if enabled.
#define ECODE_EMDRV_EZRADIODRV_OK
Success return value.
This file contains the common API library of the EZRadio and EZRadioPRO families. ...
This file contains the plug-in manager for the EZRadio and EZRadioPRO chip families.
CMSIS Cortex-M Peripheral Access Layer for Silicon Laboratories microcontroller devices.
Acknowledge transmission is skipped for one cycle, eg. not to transmit ACK if ACK is received...
uint8_t channel
Reception channel.
Ecode_t ezradioStartRx(EZRADIODRV_Handle_t radioHandle)
Set Radio to RX mode, packet length is always coming from the radio configuration.
void ezradio_fifo_info(uint8_t fifo, ezradio_cmd_reply_t *ezradioReply)
EZRADIODRV_AutoAckHandle_t autoAck
Auto-acknowledge plug-in handler.
void ezradio_read_rx_fifo(uint8_t numbytes, uint8_t *prxdata)
void ezradio_start_rx(uint8_t channel, uint8_t condition, uint16_t rx_len, uint8_t next_state1, uint8_t next_state2, uint8_t next_state3)
uint32_t Ecode_t
Typedef for API function error code return values.
Definition: ecode.h:51
EZRADIODRV_PacketRxHandle_t packetRx
Packet reception plug-in handler.
#define ECODE_EMDRV_EZRADIODRV_ILLEGAL_HANDLE
Illegal SPI handle.
Immediate acknowledge transmission.
EZRADIODRV_Callback_t userCallback
User callback.
EZRADIODRV_AutoAckMode_t ackMode
Auto ack mode.
ezradio_cmd_reply_t * EZRADIODRV_ReplyHandle_t
EZradio reply union handle.