Commit 28171c1a authored by Cedric Roux's avatar Cedric Roux

Merge remote-tracking branch 'origin/hack-bladerf-w24' into develop_integration_w25

parents ef87ec51 a8ae85f6
......@@ -82,6 +82,48 @@ openair0_timestamp trx_get_timestamp(openair0_device *device, bladerf_module mod
* \returns 0 on success
*/
int trx_brf_start(openair0_device *device) {
brf_state_t *brf = (brf_state_t*)device->priv;
int status;
brf->meta_tx.flags = 0;
if ((status = bladerf_sync_config(brf->dev,
BLADERF_MODULE_TX,
BLADERF_FORMAT_SC16_Q11_META,
brf->num_buffers,
brf->buffer_size,
brf->num_transfers,
100/*brf->tx_timeout_ms*/)) != 0 ) {
fprintf(stderr,"Failed to configure TX sync interface: %s\n", bladerf_strerror(status));
abort();
}
if ((status = bladerf_sync_config(brf->dev,
BLADERF_MODULE_RX,
BLADERF_FORMAT_SC16_Q11_META,
brf->num_buffers,
brf->buffer_size,
brf->num_transfers,
100/*brf->rx_timeout_ms*/)) != 0 ) {
fprintf(stderr,"Failed to configure RX sync interface: %s\n", bladerf_strerror(status));
abort();
}
if ((status=bladerf_enable_module(brf->dev, BLADERF_MODULE_TX, true)) != 0) {
fprintf(stderr,"Failed to enable TX module: %s\n", bladerf_strerror(status));
abort();
}
if ((status=bladerf_enable_module(brf->dev, BLADERF_MODULE_RX, true)) != 0) {
fprintf(stderr,"Failed to enable RX module: %s\n", bladerf_strerror(status));
abort();
}
if ((status=bladerf_calibrate_dc(brf->dev, BLADERF_MODULE_TX)) != 0) {
fprintf(stderr,"Failed to calibrate TX DC: %s\n", bladerf_strerror(status));
abort();
}
if ((status=bladerf_calibrate_dc(brf->dev, BLADERF_MODULE_RX)) != 0) {
fprintf(stderr,"Failed to calibrate RX DC: %s\n", bladerf_strerror(status));
abort();
}
return 0;
}
......@@ -133,7 +175,7 @@ static int trx_brf_write(openair0_device *device,openair0_timestamp ptimestamp,
brf->tx_count++;
return(0);
return nsamps; //brf->meta_tx.actual_count;
}
/*! \brief Receive samples from hardware.
......@@ -155,6 +197,7 @@ static int trx_brf_read(openair0_device *device, openair0_timestamp *ptimestamp,
// BRF has only one rx/tx chain
int16_t *samples = (int16_t*)buff[0];
brf->meta_rx.actual_count = 0;
brf->meta_rx.flags = BLADERF_META_FLAG_RX_NOW;
status = bladerf_sync_rx(brf->dev, samples, (unsigned int) nsamps, &brf->meta_rx, 2*brf->rx_timeout_ms);
......@@ -170,6 +213,10 @@ static int trx_brf_read(openair0_device *device, openair0_timestamp *ptimestamp,
brf->num_overflows,brf->meta_rx.timestamp, brf->meta_rx.actual_count, nsamps);
}
if (brf->meta_rx.actual_count != nsamps) {
printf("RX bad samples count, wanted %d, got %d\n", nsamps, brf->meta_rx.actual_count);
}
//printf("Current RX timestampe %u\n", brf->meta_rx.timestamp);
//printf("[BRF] (buff %p) ts=0x%"PRIu64" %s\n",samples, brf->meta_rx.timestamp,bladerf_strerror(status));
brf->rx_current_ts=brf->meta_rx.timestamp;
......@@ -180,7 +227,7 @@ static int trx_brf_read(openair0_device *device, openair0_timestamp *ptimestamp,
*ptimestamp = brf->meta_rx.timestamp;
return brf->meta_rx.actual_count;
return nsamps; //brf->meta_rx.actual_count;
}
......@@ -188,6 +235,7 @@ static int trx_brf_read(openair0_device *device, openair0_timestamp *ptimestamp,
* \param device the hardware to use
*/
void trx_brf_end(openair0_device *device) {
abort();
int status;
brf_state_t *brf = (brf_state_t*)device->priv;
......@@ -1081,6 +1129,15 @@ int device_init(openair0_device *device, openair0_config_t *openair0_cfg) {
// memcpy((void*)&device->openair0_cfg,(void*)&openair0_cfg[0],sizeof(openair0_config_t));
if ((status=bladerf_enable_module(brf->dev, BLADERF_MODULE_TX, false)) != 0) {
fprintf(stderr,"Failed to enable TX module: %s\n", bladerf_strerror(status));
abort();
}
if ((status=bladerf_enable_module(brf->dev, BLADERF_MODULE_RX, false)) != 0) {
fprintf(stderr,"Failed to enable RX module: %s\n", bladerf_strerror(status));
abort();
}
return 0;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment