From f342f4001da66d61a029be8c58468c4dac66009f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?BENEDEK=20L=C3=A1szl=C3=B3?= Date: Thu, 13 Feb 2025 10:02:33 +0100 Subject: [PATCH] init --- .clang-format | 9 ++++++ .gitignore | 2 ++ CMakeLists.txt | 10 ++++++ Readme.md | 7 +++++ src/pico-radio/CMakeLists.txt | 7 +++++ src/pico-radio/main.c | 58 +++++++++++++++++++++++++++++++++++ 6 files changed, 93 insertions(+) create mode 100644 .clang-format create mode 100644 .gitignore create mode 100644 CMakeLists.txt create mode 100644 Readme.md create mode 100644 src/pico-radio/CMakeLists.txt create mode 100644 src/pico-radio/main.c diff --git a/.clang-format b/.clang-format new file mode 100644 index 0000000..f89ba5b --- /dev/null +++ b/.clang-format @@ -0,0 +1,9 @@ +BasedOnStyle: Chromium +IndentWidth: 2 +ColumnLimit: 160 +SpaceAfterCStyleCast: false +UseTab: Never +AllowShortIfStatementsOnASingleLine: false +AlignTrailingComments: false +SpacesBeforeTrailingComments: 1 +AlignConsecutiveMacros: Consecutive \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9785597 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +build +.cache diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..866051c --- /dev/null +++ b/CMakeLists.txt @@ -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) diff --git a/Readme.md b/Readme.md new file mode 100644 index 0000000..023bac0 --- /dev/null +++ b/Readme.md @@ -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 diff --git a/src/pico-radio/CMakeLists.txt b/src/pico-radio/CMakeLists.txt new file mode 100644 index 0000000..0300524 --- /dev/null +++ b/src/pico-radio/CMakeLists.txt @@ -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}" +) \ No newline at end of file diff --git a/src/pico-radio/main.c b/src/pico-radio/main.c new file mode 100644 index 0000000..1cbec0c --- /dev/null +++ b/src/pico-radio/main.c @@ -0,0 +1,58 @@ +#include +#include +#include +#include + +#include + +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; +} \ No newline at end of file