Skip to content

Commit

Permalink
Partial fix suggested by @henrygab
Browse files Browse the repository at this point in the history
  • Loading branch information
wh201906 committed Nov 11, 2023
1 parent 045a10c commit 175c141
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 8 deletions.
10 changes: 6 additions & 4 deletions armsrc/appmain.c
Original file line number Diff line number Diff line change
Expand Up @@ -858,10 +858,11 @@ static void PacketReceived(PacketCommandNG *packet) {
} PACKED;
struct p *payload = (struct p *)packet->data.asBytes;
uint32_t bits;
if (payload->realtime)
if (payload->realtime) {
bits = ReadLF_realtime(true);
else
} else {
bits = SampleLF(payload->verbose, payload->samples, true);
}
reply_ng(CMD_LF_ACQ_RAW_ADC, PM3_SUCCESS, (uint8_t *)&bits, sizeof(bits));
break;
}
Expand Down Expand Up @@ -892,10 +893,11 @@ static void PacketReceived(PacketCommandNG *packet) {
} PACKED;
struct p *payload = (struct p *)packet->data.asBytes;
uint32_t bits;
if (payload->realtime)
if (payload->realtime) {
bits = ReadLF_realtime(false);
else
} else {
bits = SniffLF(payload->verbose, payload->samples, true);
}
reply_ng(CMD_LF_SNIFF_RAW_ADC, PM3_SUCCESS, (uint8_t *)&bits, sizeof(bits));
break;
}
Expand Down
7 changes: 4 additions & 3 deletions armsrc/lfsampling.c
Original file line number Diff line number Diff line change
Expand Up @@ -441,8 +441,8 @@ int ReadLF_realtime(bool reader_field) {
const uint8_t decimation = config.decimation;

uint32_t sample_size = 64;
const int8_t size_threshold_table[9] = {0, 64, 64, 48, 64, 40, 48, 56, 64};
const int8_t size_threshold = size_threshold_table[decimation];
const int8_t size_threshold_table[9] = {0, 64, 64, 60, 64, 60, 60, 56, 64};
const int8_t size_threshold = size_threshold_table[bits_per_sample];

// DoAcquisition() start
uint8_t last_byte = 0;
Expand Down Expand Up @@ -500,8 +500,9 @@ int ReadLF_realtime(bool reader_field) {

// write to USB FIFO if byte changed
curr_byte = data.numbits >> 3;
if (curr_byte > last_byte)
if (curr_byte > last_byte) {
usb_write_byte_async(data.buffer[last_byte]);
}
last_byte = curr_byte;

if(samples.total_saved == size_threshold)
Expand Down
3 changes: 2 additions & 1 deletion common_arm/usb_cdc.c
Original file line number Diff line number Diff line change
Expand Up @@ -833,8 +833,9 @@ inline bool usb_write_request(void)
while (pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXCOMP) {};

// can we write?
if ((pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXPKTRDY) != 0)
if ((pUdp->UDP_CSR[AT91C_EP_IN] & AT91C_UDP_TXPKTRDY) != 0) {
return false;
}

// start of transmission
UDP_SET_EP_FLAGS(AT91C_EP_IN, AT91C_UDP_TXPKTRDY);
Expand Down

0 comments on commit 175c141

Please sign in to comment.