7
mirror of https://github.com/EEVengers/ThunderScope.git synced 2025-04-22 17:43:44 +00:00

several bugfixes, now getting ramp data

This commit is contained in:
profezzorn 2022-01-31 22:57:56 -08:00
parent 61120acf30
commit 79acd473ee
3 changed files with 16 additions and 10 deletions
Software/libthunderscopehw

View File

@ -82,7 +82,8 @@ int mygetopt(int argc, char** argv) {
optind++;
return options[i].return_value;
}
return -1;
fprintf(stderr, "Unknown option: %s\n", argv[optind]);
exit(1);
}
int main(int argc, char** argv) {
@ -252,22 +253,23 @@ int main(int argc, char** argv) {
exit(1);
}
#define BUFFER_SIZE (1<<20)
uint8_t* buffer;
#ifdef _WIN32
buffer = _aligned_malloc(1 << 20, 4096);
#else
posix_memalign((void**)&buffer, 4096, 1 << 20);
buffer = _aligned_malloc(BUFFER_SIZE, 4096);
#else
posix_memalign((void**)&buffer, 4096, BUFFER_SIZE);
#endif
while (samples) {
int64_t to_copy = samples;
if (to_copy > sizeof(buffer)) to_copy = sizeof(buffer);
ret = thunderscopehw_read(ts, buffer, sizeof(buffer));
if (to_copy > BUFFER_SIZE) to_copy = BUFFER_SIZE;
ret = thunderscopehw_read(ts, buffer, to_copy);
if (ret != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Thunderscope read error, error = %s\n", thunderscopehw_describe_error(ret));
exit(1);
}
if (fwrite(buffer, 1, sizeof(buffer), outfile) != sizeof(buffer)) {
if (fwrite(buffer, 1, to_copy, outfile) != to_copy) {
perror("fwrite");
exit(1);
}

View File

@ -119,7 +119,6 @@ static enum ThunderScopeHWStatus thunderscopehw_update_buffer_head(struct Thunde
uint32_t overflow_cycles = (transfer_counter >> 16) & 0x3FFF;
if (overflow_cycles) {
fprintf(stderr, "TRANSFER COUNTER = %llx\n", (long long)transfer_counter);
return THUNDERSCOPEHW_STATUS_PIPELINE_OVERFLOW;
}
@ -168,7 +167,7 @@ enum ThunderScopeHWStatus thunderscopehw_read(struct ThunderScopeHW* ts, uint8_t
if (pages_to_read > ts->ram_size_pages - buffer_read_pos) pages_to_read = ts->ram_size_pages - buffer_read_pos;
if (pages_to_read > ts->ram_size_pages / 4) pages_to_read = ts->ram_size_pages / 4;
thunderscopehw_read_handle(ts, ts->user_handle, data, buffer_read_pos << 12, pages_to_read << 12);
THUNDERSCOPEHW_RUN(read_handle(ts, ts->c2h0_handle, data, buffer_read_pos << 12, pages_to_read << 12));
data += pages_to_read << 12;
length -= pages_to_read << 12;

View File

@ -1,6 +1,8 @@
#include "thunderscopehw_private.h"
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#ifdef WIN32
#else
@ -209,7 +211,10 @@ enum ThunderScopeHWStatus thunderscopehw_configure_channel(struct ThunderScopeHW
uint32_t thunderscopehw_read32(struct ThunderScopeHW* ts, size_t addr)
{
uint8_t bytes[4];
thunderscopehw_read_handle(ts, ts->user_handle, bytes, addr, 4);
if (thunderscopehw_read_handle(ts, ts->user_handle, bytes, addr, 4) != THUNDERSCOPEHW_STATUS_OK) {
fprintf(stderr, "Error in thunderscopehw_read32\n");
exit(1);
}
return (bytes[3] << 24) | (bytes[2] << 16) | (bytes[1] << 8) | bytes[0];
}