Skip to content

Commit

Permalink
quick start
Browse files Browse the repository at this point in the history
  • Loading branch information
ImplFerris committed Oct 22, 2024
1 parent 9ce7aa2 commit b51d58c
Show file tree
Hide file tree
Showing 8 changed files with 56 additions and 89 deletions.
11 changes: 5 additions & 6 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,13 @@

- [Introduction](./index.md)
- [Dev Environment](./setup.md)
- [Quick Start](./quick-start.md)
- [Running the Program](./running.md)
- [Concepts](./concepts/index.md)
- [Approaches](./concepts/approaches.md)

- [Blink LED](./blinky/index.md)
- [With RP HAL](./blinky/rp-hal.md)
- [PWM](./blinky/pwm.md)
- [Watchdog](./blinky/watchdog.md)
- [With Embassy](./blinky/embassy.md)
- [Dim LED with RP HAL](./blinky/rp-hal.md)
- [Basic concepts](./blinky/no-std-main.md)
- [PWM](./blinky/pwm.md)
- [Watchdog](./blinky/watchdog.md)
- [Using External LED](./blinky/external-led.md)
- [Resources](./resources.md)
64 changes: 0 additions & 64 deletions src/blinky/embassy.md

This file was deleted.

6 changes: 0 additions & 6 deletions src/blinky/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,3 @@ In this section, we'll learn how to blink an LED using the Raspberry Pi Pico 2.
The onboard LED of the Pico is connected to GPIO pin 25 (based on the datasheet). To make it blink, we toggle the pin between high and low states at regular intervals. This turns the LED on and off, producing a blinking effect.

<img style="display: block; margin: auto;" alt="pico2" src="../images/pico2-board.png"/>

## Choosing the crate
You can develop using two main approaches: the RP HAL or the Embassy framework.

- [With RP HAL](./rp-hal.md)
- [With embassy](./embassy.md)
2 changes: 1 addition & 1 deletion src/concepts/index.md → src/blinky/no-std-main.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Introduction
# Basic Concepts

If you haven't read "The Embedded Rust Book" yet, I highly recommend you to check it out.
[https://docs.rust-embedded.org/book/intro/index.html](https://docs.rust-embedded.org/book/intro/index.html)
Expand Down
2 changes: 2 additions & 0 deletions src/blinky/rp-hal.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# Blink (Dimming) LED Program with RP HAL

rp-hal is an Embedded-HAL for RP series microcontrollers, and can be used as an alternative to the Embassy framework for pico.

This example code is taken from rp235x-hal repo (It also includes additional examples beyond just the blink examples):

["https://github.com/rp-rs/rp-hal/tree/main/rp235x-hal-examples"](https://github.com/rp-rs/rp-hal/tree/main/rp235x-hal-examples)
Expand Down
10 changes: 0 additions & 10 deletions src/concepts/approaches.md

This file was deleted.

42 changes: 42 additions & 0 deletions src/quick-start.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Quick Start

Before diving into the theory and concepts of how everything works, let's jump straight into action. Use this simple code to turn on the onboard LED of the Pico2.

### Blink LED with Embassy Framework
[Embassy framework](https://github.com/embassy-rs/embassy) is a robust framework for developing asynchronous embedded applications in Rust.

This example code is taken from rp235x-hal repo (It also includes additional examples beyond just the blink examples): ["https://github.com/rp-rs/rp-hal/tree/main/rp235x-hal-examples"](https://github.com/rp-rs/rp-hal/tree/main/rp235x-hal-examples)

It creates a blinking effect by toggling the pin's output state between high and low.

## The code snippet
This is not the entire code. There are things you have to initialize and import crates.
```rust
#[embassy_executor::main]
async fn main(_spawner: Spawner) {
let p = embassy_rp::init(Default::default());

// The onboard LED is actually connected to pin 25
let mut led = Output::new(p.PIN_25, Level::Low);

loop {
led.set_high(); // <- Turn on the LED
Timer::after_millis(500).await;

led.set_low(); // <- Turn off the LED
Timer::after_millis(500).await;
}
}
```

## Clone the Quick start project
You can clone the blinky project I created and navigate to the project folder and run it.

```sh
git clone https://github.com/ImplFerris/pico2-quick
cd pico2-quick
```

## How to Run?

You refer the ["Running The Program"](../running.md) section
8 changes: 6 additions & 2 deletions src/running.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
# Running the program
Before we explore further examples, let’s cover the general steps to build and run any program on the Raspberry Pi Pico 2.
Before we explore further examples, let’s cover the general steps to build and run any program on the Raspberry Pi Pico 2. The Pico 2 contains both ARM Cortex-M33 and Hazard3 RISC-V processors, and we'll provide instructions for both architectures.

Note: These commands should be run from your project folder. This is included here as a general step to avoid repetition. If you haven't created a project yet, begin with the Blink LED section.
Note: These commands should be run from your project folder. This is included here as a general step to avoid repetition. If you haven't created a project yet, begin with the Quick Start or Blink LED section.

## Build and Run for ARM
Use this command to build and run programs on the Raspberry Pi Pico 2 in ARM mode, utilizing the Cortex-M33 processors.

```sh
# build the program
cargo build --target=thumbv8m.main-none-eabihf
Expand All @@ -22,6 +24,8 @@ cargo run --target=thumbv8m.main-none-eabihf


## Build and Run for RISC-V
Use this command to build and run programs on the Raspberry Pi Pico 2 n RISC-V mode, utilizing the Hazard3 processors.

```sh
# build the program
cargo build --target=riscv32imac-unknown-none-elf
Expand Down

0 comments on commit b51d58c

Please sign in to comment.