rx: added function to determine whether rx is busy

This commit is contained in:
Thomas Kolb 2022-03-01 21:51:41 +01:00
parent 45156e64a0
commit 88145d74ba
2 changed files with 22 additions and 3 deletions

View file

@ -311,3 +311,9 @@ result_t layer1_rx_shutdown(layer1_rx_t *rx)
return OK; return OK;
} }
bool layer1_rx_is_busy(const layer1_rx_t *rx)
{
return rx->state != RX_STATE_ACQUISITION;
}

View file

@ -69,7 +69,7 @@ typedef struct
/*! /*!
* \brief Initialize the receiver. * \brief Initialize the receiver.
* *
* \param tx Pointer to the receiver context. * \param rx Pointer to the receiver context.
* \param callback Function to be called on receiver events. * \param callback Function to be called on receiver events.
* \returns The result of the initialization. * \returns The result of the initialization.
*/ */
@ -79,7 +79,7 @@ result_t layer1_rx_init(layer1_rx_t *rx, rx_callback_t callback);
/*! /*!
* \brief Shut the receiver down. Frees all memory. * \brief Shut the receiver down. Frees all memory.
* *
* \param tx Pointer to the receiver context. * \param rx Pointer to the receiver context.
* \returns The result of the shutdown. * \returns The result of the shutdown.
*/ */
result_t layer1_rx_shutdown(layer1_rx_t *rx); result_t layer1_rx_shutdown(layer1_rx_t *rx);
@ -96,11 +96,24 @@ result_t layer1_rx_shutdown(layer1_rx_t *rx);
* callback function passed to \ref layer1_rx_init() will be called. See \ref * callback function passed to \ref layer1_rx_init() will be called. See \ref
* rx_evt_t for possible events. * rx_evt_t for possible events.
* *
* \param tx Pointer to the receiver context. * \param rx Pointer to the receiver context.
* \param samples Pointer to the samples to process. * \param samples Pointer to the samples to process.
* \param sample_count Number of samples to process. * \param sample_count Number of samples to process.
* \returns The result of the shutdown. * \returns The result of the shutdown.
*/ */
result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t sample_count); result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t sample_count);
/*!
* \brief Determine whether the receiver is currently receiving a packet.
*
* This function can be used to identify idle periods where packet transmission
* is possible. Switching to TX while this function returns true will very
* probably result in a collision with packet corruption.
*
* \param rx Pointer to the receiver context.
* \returns Whether the receiver is currently receiving a packet.
*/
bool layer1_rx_is_busy(const layer1_rx_t *rx);
#endif // LAYER1_RX_H #endif // LAYER1_RX_H