1,146 karma · joined March 15, 2009
- svd2rust (https://docs.rs/svd2rust/) generates register-level APIs from SVD files, an XML format provided by most ARM microcontroller vendors. This gets you the equivalent of the low-level C header files for manipulating the hardware registers.
- cortex_m (https://docs.rs/cortex-m/), which provides APIs for the core ARM peripherals in every Cortex-M MCU.
- f3 (https://docs.rs/f3/) - High level APIs for the peripherals and external sensors on the STM32 F3 Discovery board.
No, the only inline ASM in this guide is to cause a debugger breakpoint. You also need inline ASM to enable/disable interrupts, and that's about it.
The code in this guide looks ugly because it's written to show how to use the hardware without any abstraction. Higher level APIs like f3 (https://docs.rs/f3/0.3.1/f3/) exist, though not nearly for every chip or peripheral. Even in C, for anything outside the popular Arduino/mbed/etc boards, your choice is usually between buggy vendor bloatware and using the registers directly after carefully reading the datasheet.
Why isn't this a link? Why isn't there a link to http://sci-hub.cc/ anywhere in this article? Linking isn't illegal.
On microcontrollers, you use libcore instead of the full libstd, for lack of an OS or memory allocator. Libcore is easy to cross compile because it has no dependencies. You provide a target JSON file to specify LLVM options, and a C toolchain to use as a linker, and nightly rustc can cross-compile for platforms supported by LLVM.
https://github.com/hackndev/zinc is a good starting point.
Things like interrupt handlers and statically-allocated global data require big chunks of unsafe code. Rust has a promising future in this space, but it will take more experimentation to get the right abstractions to make microcontroller code more idiomatic.
Or do you have a more specific visualisation for moves/ownership in mind?
Yes, you can get to the underlying Linux system and run anything you want (including Lua), but the point is to abstract away the OS so you only have to think about your code and the hardware.
fn make_a_foo() -> Box<Foo> {
Box::new(Foo { a: 5 })
}
If the function allocated memory and only returned a borrowed reference, who would be responsible for freeing it? Yes, Rust will make you stop and think there, as it enforces memory safety.In cases where it does make sense to return a reference to a new object, like allocating from an arena, the lifetime ('a) of the returned reference will be the same as the lifetime of the arena.
fn new_from_arena<'a>(arena: &'a TypedArena<Foo>) -> &'a mut Foo {
arena.alloc(Foo { a: 5 })
}
But Rust can infer the lifetime, so that can be shortened to: fn new_from_arena(arena: &TypedArena<Foo>) -> &mut Foo {
arena.alloc(Foo { a: 5 })
}http://www.xenproject.org/security-policy.html
They also spell out the policy for who is eligible.
Which is, of course, assuming that none of the equations involve imaginary numbers.
Yesterday, Intel announced a project combining a clang frontend with icc's backend. [1] The backend takes LLVM IR, so hopefully Rust's LLVM IR output could be run through it.
Rust's println! macro also supports named format parameters, which don't need to be in the same order as the format string.
println!("{foo}: {bar}", bar=5, foo="abc");
> It seems that move semantics distinguish between objects and primitives, instead of everything being an object?Structs fulfilling the Copy trait (meaning they don't have destructors and can be duplicated with a simple memcopy) have the same copy semantics as primitive number types.
> Forcing the programmer to manually place values on the heap with “~” is annoying, when other languages can automatically optimize such things. > Lifetimes completely confuse me, as it seems like they would be handled by garbage collection?
Rust is a systems language. The language makes memory allocation and management explicit, by design. Lifetimes allow Rust to provide memory safety at zero run-time cost. They're how the programmer proves to the compiler that pointers are valid at the time of use. There is no garbage collection by default; only when you use the Rc or Gc types from the library.
I write code for both sides of the HTTP request as well as both sides of the USB cable. My current project involves d3.js, node, LLVM, and custom hardware. Somewhere between frontend and embedded, there's probably something I can build for you.
I primarily work with:
- HTML5, JavaScript (CoffeeScript), CSS, jQuery, Backbone
- NodeJS, Python, Flask
- C, C++, Linux, Git
- PCB design, AVR & ARM microcontrollers
- among many more
See some of my projects at http://kevinmehall.net. Shoot me an email: hnfreelance@kevinmehall.netI go a little beyond what they call "full stack". I write code for both sides of the HTTP request as well as both sides of the USB cable. My current project involves d3.js, node, LLVM, and custom hardware. Somewhere between frontend and embedded, there's probably something I can build for you.
I primarily work with:
- HTML5, CSS (LESS), JavaScript (CoffeeScript), jQuery, Backbone
- NodeJS, Python, Flask
- C, C++, Linux, Git
- PCB design, AVR & ARM microcontrollers
- among many more
See some of my projects at http://kevinmehall.net, and shoot me an email: hnfreelance@kevinmehall.net