-
Notifications
You must be signed in to change notification settings - Fork 300
consider code sample for embedded and wasm wgs #350
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
Comments
Scheduled for end of year milestone; not blocking the edition rollout. |
So we had originally discussed embedding webassembly.studio in the wasm page, but decided not to because our target audience for the website was supposed to be CTOs and not hackers, so getting too technical didn't really make sense. Have we changed our target audience such that we should revisit that decision? |
we haven't. i personally don't think this needs to happen- but it was an ask. if there's a good small sample we can consider adding it, but i dont think this is something that must happen. |
@fitzgen the web site is intended to address both audiences. Please take a look at some of the other WG pages to get a sense for what we've done there. If there's something of similar scope for wasm, let's go for it. But if not, no big deal. |
For the embedded WG, I would suggest one of the examples from https://docs.rust-embedded.org/book/start/registers.html, in particular I'm fond of this example, while a bit long, is a pretty good "full, standalone example": #![no_std]
#![no_main]
extern crate panic_halt; // panic handler
use cortex_m_rt::entry;
use tm4c123x_hal as hal;
use tm4c123x_hal::prelude::*;
use tm4c123x_hal::serial::{NewlineMode, Serial};
use tm4c123x_hal::sysctl;
#[entry]
fn main() -> ! {
let p = hal::Peripherals::take().unwrap();
let cp = hal::CorePeripherals::take().unwrap();
// Wrap up the SYSCTL struct into an object with a higher-layer API
let mut sc = p.SYSCTL.constrain();
// Pick our oscillation settings
sc.clock_setup.oscillator = sysctl::Oscillator::Main(
sysctl::CrystalFrequency::_16mhz,
sysctl::SystemClock::UsePll(sysctl::PllOutputFrequency::_80_00mhz),
);
// Configure the PLL with those settings
let clocks = sc.clock_setup.freeze();
// Wrap up the GPIO_PORTA struct into an object with a higher-layer API.
// Note it needs to borrow `sc.power_control` so it can power up the GPIO
// peripheral automatically.
let mut porta = p.GPIO_PORTA.split(&sc.power_control);
// Activate the UART.
let uart = Serial::uart0(
p.UART0,
// The transmit pin
porta
.pa1
.into_af_push_pull::<hal::gpio::AF1>(&mut porta.control),
// The receive pin
porta
.pa0
.into_af_push_pull::<hal::gpio::AF1>(&mut porta.control),
// No RTS or CTS required
(),
(),
// The baud rate
115200_u32.bps(),
// Output handling
NewlineMode::SwapLFtoCRLF,
// We need the clock rates to calculate the baud rate divisors
&clocks,
// We need this to power up the UART peripheral
&sc.power_control,
);
loop {
writeln!(uart, "Hello, World!\r\n").unwrap();
}
} |
@therealprof suggested this blinky light example, which would be easier to trim down to size: https://github.com/therealprof/stm32f042-hal/blob/master/examples/blinky_delay.rs |
I'm going to close this as a duplicate of #838, as I think we should consider adding these as part of addressing that issue, if someone wants to make a PR adding either to the website feel free! |
We have a great precedent with Command Line and Networking: you jump in, and within a few seconds you see your first examples of how easy it is to use Rust in these domains. Would it be possible to have a similar feel for WASM and embedded? This way each of the four sections feels like "Rust is awesome in each of these topics. Look how easy this is!"
The text was updated successfully, but these errors were encountered: