hamnet70/impl/src/layer1/tx.h

116 lines
3.0 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
float carrier_frequency_offset;
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 packets 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);
/*!
* \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);
#endif // LAYER1_TX_H