Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions librmcs-sdk-src-3.0.1-0.dev.4.gbaf538b/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
cmake_minimum_required(VERSION 3.28)
project(librmcs_wrapper VERSION 3 LANGUAGES C CXX)
set(LIBRMCS_PROJECT_VERSION "3.0.1-0.dev.4.gbaf538b")
set(LIBRMCS_DEBIAN_VERSION "3.0.1~0.dev.4.gbaf538b")
add_subdirectory(host)
6 changes: 6 additions & 0 deletions librmcs-sdk-src-3.0.1-0.dev.4.gbaf538b/CMakePresets.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"version": 4,
"include": [
"host/CMakePresets.json"
]
}
674 changes: 674 additions & 0 deletions librmcs-sdk-src-3.0.1-0.dev.4.gbaf538b/LICENSE

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
#pragma once

#include <cstddef>
#include <cstdint>
#include <span>

namespace librmcs::data {

enum class DataId : uint8_t {
kExtend = 0,

kGpio = 1,

kCan0 = 2,
kCan1 = 3,
kCan2 = 4,
kCan3 = 5,
kCan4 = 6,
kCan5 = 7,
kCan6 = 8,
kCan7 = 9,

kUartDbus = 10,
kUart0 = 11,
kUart1 = 12,
kUart2 = 13,
kUart3 = 14,

kImu = 15,
};

struct CanDataView {
uint32_t can_id;
std::span<const std::byte> can_data;
bool is_fdcan = false;
bool is_extended_can_id = false;
bool is_remote_transmission = false;
};

struct UartDataView {
std::span<const std::byte> uart_data;
bool idle_delimited = false;
};

struct GpioDigitalDataView {
uint8_t channel;
bool high;
};

struct GpioAnalogDataView {
uint8_t channel;
uint16_t value;
};

struct GpioReadConfigView {
uint8_t channel;
uint16_t period_ms = 0;
bool asap = false;
bool rising_edge = false;
bool falling_edge = false;
};

struct AccelerometerDataView {
int16_t x;
int16_t y;
int16_t z;
};

struct GyroscopeDataView {
int16_t x;
int16_t y;
int16_t z;
};

class DataCallback {
public:
DataCallback() = default;
DataCallback(const DataCallback&) = delete;
DataCallback& operator=(const DataCallback&) = delete;
DataCallback(DataCallback&&) = delete;
DataCallback& operator=(DataCallback&&) = delete;
virtual ~DataCallback() = default;

// `*_receive_callback` returns `true` if id is valid
virtual bool can_receive_callback(DataId id, const CanDataView& data) = 0;

virtual bool uart_receive_callback(DataId id, const UartDataView& data) = 0;

virtual void gpio_digital_read_result_callback(const GpioDigitalDataView& data) = 0;

virtual void gpio_analog_read_result_callback(const GpioAnalogDataView& data) = 0;

virtual void accelerometer_receive_callback(const AccelerometerDataView& data) = 0;

virtual void gyroscope_receive_callback(const GyroscopeDataView& data) = 0;
};

} // namespace librmcs::data
45 changes: 45 additions & 0 deletions librmcs-sdk-src-3.0.1-0.dev.4.gbaf538b/core/setup-clangd
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
#!/usr/bin/env sh
set -eu

usage() {
cat <<'EOF'
Usage: setup-clangd <path>
Creates symlinks in core/:
.clangd -> ../<path>/.clangd
compile_commands.json -> ../<path>/build/compile_commands.json

Example: setup-clangd firmware/rmcs_board
EOF
}

if [ "$#" -ne 1 ]; then
usage
exit 1
fi

core_dir=$(CDPATH='' cd -- "$(dirname -- "$0")" && pwd)
root_dir=$(CDPATH='' cd -- "$core_dir/.." && pwd)
target="$root_dir/$1"

if [ ! -d "$target" ]; then
echo "Error: directory '$1' does not exist." >&2
exit 1
fi

link_clangd="$core_dir/.clangd"
link_compile="$core_dir/compile_commands.json"

for link in "$link_clangd" "$link_compile"; do
if [ -L "$link" ]; then
rm -f "$link"
elif [ -e "$link" ]; then
echo "Error: $link exists and is not a symlink." >&2
exit 1
fi
done

(
cd "$core_dir"
ln -s "../$1/.clangd" .clangd
ln -s "../$1/build/compile_commands.json" compile_commands.json
)
Loading