This commit is contained in:
BENEDEK László 2025-02-13 10:02:33 +01:00
commit f342f4001d
6 changed files with 93 additions and 0 deletions

9
.clang-format Normal file
View File

@ -0,0 +1,9 @@
BasedOnStyle: Chromium
IndentWidth: 2
ColumnLimit: 160
SpaceAfterCStyleCast: false
UseTab: Never
AllowShortIfStatementsOnASingleLine: false
AlignTrailingComments: false
SpacesBeforeTrailingComments: 1
AlignConsecutiveMacros: Consecutive

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
build
.cache

10
CMakeLists.txt Normal file
View File

@ -0,0 +1,10 @@
cmake_minimum_required(VERSION 3.12)
project(pico-radio C)
set(CMAKE_EXPORT_COMPILE_COMMANDS true)
include_directories(include /opt/picoscope/include)
link_directories(/opt/picoscope/lib)
add_subdirectory(src/pico-radio)

7
Readme.md Normal file
View File

@ -0,0 +1,7 @@
# Pico Radio
## Fast-streaming buffer format
1. Channel A min
2. Channel A max
3. Channel B min
4. Channel B max

View File

@ -0,0 +1,7 @@
file(GLOB_RECURSE SOURCES "./*.c")
add_executable(pico-radio ${SOURCES})
target_compile_options(pico-radio PRIVATE -Wall -Wextra)
target_link_libraries(pico-radio ps2000)
set_target_properties(pico-radio PROPERTIES
RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}"
)

58
src/pico-radio/main.c Normal file
View File

@ -0,0 +1,58 @@
#include <signal.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdio.h>
#include <libps2000/ps2000.h>
bool stop = false;
void capture_stop(int signal) {
(void)signal;
stop = true;
}
void get_overview_buffers(int16_t** overviewBuffers, int16_t overflow, uint32_t triggeredAt, int16_t triggered, int16_t auto_stop, uint32_t nValues) {
(void)overflow;
(void)triggeredAt;
(void)triggered;
(void)auto_stop;
fwrite(overviewBuffers[0], sizeof(int16_t), nValues, stdout);
}
int main(int argc, char** argv) {
(void)argc;
(void)argv;
signal(SIGINT, &capture_stop);
int16_t unit = ps2000_open_unit();
if (ps2000_set_channel(unit, PS2000_CHANNEL_A, true, false, PS2000_100MV) == 0) {
fprintf(stderr, "set channel unsuccesful!\n");
ps2000_close_unit(unit);
return 1;
}
if (ps2000_set_trigger(unit, PS2000_NONE, 0, 0, 0, 0) == 0) {
fprintf(stderr, "set trigger unsuccesful!\n");
ps2000_close_unit(unit);
return 1;
}
if (ps2000_run_streaming_ns(unit, 100, PS2000_US, 100000, false, 1, 100000) == 0) {
fprintf(stderr, "run streaming unsuccesful!\n");
ps2000_close_unit(unit);
return 1;
}
while (!stop) {
ps2000_get_streaming_last_values(unit, &get_overview_buffers);
}
ps2000_stop(unit);
ps2000_close_unit(unit);
return 0;
}