2022-02-13 21:29:35 +01:00
|
|
|
|
#ifndef LAYER1_TX_H
|
|
|
|
|
#define LAYER1_TX_H
|
|
|
|
|
|
|
|
|
|
#include <complex.h>
|
|
|
|
|
|
|
|
|
|
#include <stddef.h>
|
|
|
|
|
#include <stdint.h>
|
|
|
|
|
|
|
|
|
|
#include "results.h"
|
|
|
|
|
#include "transmission.h"
|
|
|
|
|
#include "packet_mod.h"
|
|
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
float complex *samples;
|
|
|
|
|
size_t samples_allocated;
|
|
|
|
|
size_t samples_used;
|
|
|
|
|
|
2024-03-31 22:23:04 +02:00
|
|
|
|
float carrier_frequency_offset;
|
|
|
|
|
|
2022-02-13 21:29:35 +01:00
|
|
|
|
transmission_ctx_t transmission;
|
|
|
|
|
packet_mod_ctx_t pmod;
|
|
|
|
|
} layer1_tx_t;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Initialize the transmitter.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \returns The result of the initialization.
|
|
|
|
|
*/
|
|
|
|
|
result_t layer1_tx_init(layer1_tx_t *tx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Shut the transmitter down. Frees all memory.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \returns The result of the shutdown.
|
|
|
|
|
*/
|
|
|
|
|
result_t layer1_tx_shutdown(layer1_tx_t *tx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Reset the transmitter.
|
|
|
|
|
*
|
|
|
|
|
* Logically removes all internal data, but does not free memory.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \returns The result of the reset.
|
|
|
|
|
*/
|
|
|
|
|
result_t layer1_tx_reset(layer1_tx_t *tx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Add a packet to the burst.
|
|
|
|
|
*
|
|
|
|
|
* Encodes the raw data, modulates it, applies pulse filtering and appends the
|
|
|
|
|
* result to the internal buffer.
|
|
|
|
|
*
|
|
|
|
|
* If the buffer is empty (after init or reset), it first generates a ramp-up
|
|
|
|
|
* sequence.
|
|
|
|
|
*
|
|
|
|
|
* You can add arbitrarily many packets, the only limit is the available memory.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \param data Pointer to the packet’s raw data.
|
|
|
|
|
* \param length The number of bytes in the data array.
|
|
|
|
|
* \returns The result of the operation.
|
|
|
|
|
*/
|
|
|
|
|
result_t layer1_tx_add_packet_to_burst(layer1_tx_t *tx, const uint8_t *data, size_t length);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Generate the ramp-down sequence.
|
|
|
|
|
*
|
|
|
|
|
* The burst is considered complete after calling this function. You should
|
|
|
|
|
* retrieve the generated samples and call \ref layer1_tx_reset() before adding
|
|
|
|
|
* further packets.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \returns The result of the finalization.
|
|
|
|
|
*/
|
|
|
|
|
result_t layer1_tx_finalize_burst(layer1_tx_t *tx);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Retrieve the number of generated samples.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \returns The number of samples returned by \ref layer1_tx_get_sample_data().
|
|
|
|
|
*/
|
|
|
|
|
size_t layer1_tx_get_sample_count(const layer1_tx_t *tx);
|
|
|
|
|
|
|
|
|
|
/*!
|
|
|
|
|
* \brief Retrieve the generated samples.
|
|
|
|
|
*
|
|
|
|
|
* Calling this after \ref layer1_tx_finalize_burst() returns the complete burst ready for transmission.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \returns A pointer to the generated samples.
|
|
|
|
|
*/
|
|
|
|
|
const float complex* layer1_tx_get_sample_data(const layer1_tx_t *tx);
|
|
|
|
|
|
2024-03-31 22:23:04 +02:00
|
|
|
|
/*!
|
|
|
|
|
* \brief Set the carrier frequency correction in the RRC-filtered domain.
|
|
|
|
|
*
|
|
|
|
|
* The carrier frequency is measured in radians per sample in the RRC-filtered baseband domain, i.e. the sampling rate is SYMBOL_RATE * RRC_SPS.
|
|
|
|
|
*
|
|
|
|
|
* \param tx Pointer to the transmitter context.
|
|
|
|
|
* \param freq The carrier frequency offset to use.
|
|
|
|
|
*/
|
|
|
|
|
void layer1_tx_set_carrier_frequency_offset(layer1_tx_t *tx, float freq);
|
|
|
|
|
|
2022-02-13 21:29:35 +01:00
|
|
|
|
#endif // LAYER1_TX_H
|