Skip to content

Commit

Permalink
now the right file
Browse files Browse the repository at this point in the history
  • Loading branch information
pa3gsb committed Jun 24, 2024
1 parent e06a201 commit 8faf11e
Showing 1 changed file with 41 additions and 1 deletion.
42 changes: 41 additions & 1 deletion SBC/rpi-4/device_driver/driver/radioberry_firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,9 @@
#define SPI_LTOH 4
#define SPI_DC 5

#define SAMPLE_BYTES 512
static int initialize_firmware(void);
int rxStream(int nrx, unsigned char stream[]);
void read_iq_sample(int lnrx, int iqs, unsigned char iqdata[]);
int spiXfer(int spi_channel, char *txBuf, char *rxBuf, unsigned cnt);
int write_iq_sample(unsigned char tx_iqdata[]);

Expand Down Expand Up @@ -125,6 +126,45 @@ int spiXfer(int spi_channel, char *txBuf, char *rxBuf, unsigned cnt){
return 0;
}

int rxStream(int nrx, unsigned char stream[]){
unsigned char iqdata[6];
int iqs = 1;

int nr_samples = (nrx == 1)? 63 : (nrx == 2)? 72: (nrx ==3)? 75: (nrx ==4)? 76: (nrx ==5)? 75: (nrx ==6)? 78: (nrx ==7)? 77: 80;

int s = 0;
for (s = 0; s < nr_samples; s++) {
read_iq_sample(nrx, iqs, iqdata);
memcpy(stream + (s * 6), iqdata, 6);
iqs++;
}
return nr_samples * 6;
}

void read_iq_sample(int lnrx, int iqs, unsigned char iqdata[]){
uint32_t value = 0;

int i = 0;
for (i = 0; i < 6 ; i++) {

if (i % 2 == 0) {
*rpi_set_io_high = (1<<RPI_RX_CLK);
value = *rpi_read_io;
} else {
*rpi_set_io_low = (1<<RPI_RX_CLK);
value = *rpi_read_io;
}
iqdata[i] = (((value >> 23) & 1) << 7);
iqdata[i] |= (((value >> 20) & 1) << 6);
iqdata[i] |= (((value >> 19) & 1) << 5);
iqdata[i] |= (((value >> 18) & 1) << 4);
iqdata[i] |= (((value >> 16) & 1) << 3);
iqdata[i] |= (((value >> 13) & 1) << 2);
iqdata[i] |= (((value >> 12) & 1) << 1);
iqdata[i] |= (((value >> 5) & 1));
}
}

int write_iq_sample(unsigned char tx_iqdata[]) {

unsigned char data[4];
Expand Down

0 comments on commit 8faf11e

Please sign in to comment.