Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SNS - UART Trait #84

Merged
merged 4 commits into from
Feb 14, 2025
Merged
Show file tree
Hide file tree
Changes from 3 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
8 changes: 8 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions lib/io/hyped_uart/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[package]
name = "hyped_uart"
version = "0.1.0"
edition = "2021"

[dependencies]
heapless = "0.8.0"
embassy-sync = { version = "0.6.0", features = ["defmt"], git = "https://github.com/embassy-rs/embassy"}
46 changes: 46 additions & 0 deletions lib/io/hyped_uart/hyped_uart_derive/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions lib/io/hyped_uart/hyped_uart_derive/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
[package]
name = "hyped_uart_derive"
version = "0.1.0"
edition = "2021"

[lib]
proc-macro = true

[dependencies]
syn = { version = "2", features = ["full"] }
quote = "1"
29 changes: 29 additions & 0 deletions lib/io/hyped_uart/hyped_uart_derive/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
extern crate proc_macro;

use proc_macro::TokenStream;
use quote::quote;
use syn::{self, Generics};

#[proc_macro_derive(HypedUart)]
pub fn hyped_uart_derive(input: TokenStream) -> TokenStream {
let ast = syn::parse(input).unwrap();
impl_hyped_uart(&ast)
}

fn impl_hyped_uart(ast: &syn::DeriveInput) -> TokenStream {
let name = &ast.ident;
let generics: &Generics = &ast.generics;
let (impl_generics, ty_generics, _) = generics.split_for_impl();
let gen = quote! {
impl #impl_generics HypedUart for #name #ty_generics {

}

impl #impl_generics #name #ty_generics {
pub fn new() -> Self {
Self {}
}
}
};
gen.into()
}
21 changes: 21 additions & 0 deletions lib/io/hyped_uart/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#![no_std]

pub trait HypedUart {
// Add required functions here
}

pub mod mock_adc {
/// A mock UART instance which can be used for testing
pub struct MockUart {}

impl crate::HypedUart for MockUart {
// Add required functions here
}

impl MockUart {
#[allow(clippy::new_without_default)]
pub fn new() -> Self {
Self {}
}
}
}
Loading