Update all the BSPs.

Crate names now have hyphens, to match rp2040-hal.
Every BSP has its own CHANGELOG.
Embassy stuff is removed (it blocks publishing on crates.io)
This commit is contained in:
Jonathan Pallant 2021-12-20 21:10:10 +00:00
parent c83a31ab2b
commit 37e7d2e7b6
46 changed files with 284 additions and 346 deletions

View file

@ -2,15 +2,15 @@
resolver = "2"
members = [
"rp2040-hal",
"boards/feather_rp2040",
"boards/qt_py_rp2040",
"boards/itsy_bitsy_rp2040",
"boards/feather-rp2040",
"boards/qt-py-rp2040",
"boards/itsy-bitsy-rp2040",
"boards/kb2040",
"boards/pico",
"boards/pico_explorer",
"boards/pico_lipo_16mb",
"boards/adafruit_macropad",
"boards/pro_micro_rp2040",
"boards/pico-explorer",
"boards/pico-lipo-16mb",
"boards/adafruit-macropad",
"boards/pro-micro-rp2040",
]
[patch.'https://github.com/rp-rs/rp-hal.git']

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/adafruit-macropad-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/adafruit-macropad-v0.1.0

View file

@ -1,11 +1,12 @@
[package]
name = "adafruit_macropad"
name = "adafruit-macropad"
version = "0.1.0"
authors = ["Andrea Nall <anall@andreanal.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/adafruit_macropad"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/adafruit_macropad"
description = "Board Support Package for the Adafruit Macropad"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,4 +1,4 @@
# [adafruit_macropad] - Board Support for the [Adafruit Macropad]
# [adafruit-macropad] - Board Support for the [Adafruit Macropad]
You should include this crate if you are writing code that you want to run on
an [Adafruit Macropad] - a 3x4 keyboard and OLED combo board from Adafruit.
@ -6,7 +6,7 @@ an [Adafruit Macropad] - a 3x4 keyboard and OLED combo board from Adafruit.
This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Feather.
[adafruit_macropad]: https://github.com/rp-rs/rp-hal/tree/main/boards/adafruit_macropad
[adafruit-macropad]: https://github.com/rp-rs/rp-hal/tree/main/boards/adafruit-macropad
[Adafruit Macropad]: https://www.adafruit.com/product/5128
[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal
[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/
@ -16,7 +16,7 @@ RP2040 chip according to how it is connected up on the Feather.
To use this crate, your `Cargo.toml` file should contain:
```toml
adafruit_macropad = { git = "https://github.com/rp-rs/rp-hal.git" }
adafruit-macropad = "0.1.0"
```
In your program, you will need to call `adafruit_macropad::Pins::new` to create
@ -30,7 +30,7 @@ devices. See the [examples](./examples) folder for more details.
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/adafruit_macropad $ cargo build --release --example <name>
rp-hal/boards/adafruit-macropad $ cargo build --release --example <name>
```
You will get an ELF file called
@ -44,7 +44,7 @@ USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:
```console
rp-hal/boards/adafruit_macropad $ cargo run --release --example <name>
rp-hal/boards/adafruit-macropad $ cargo run --release --example <name>
```
If you get an error about not being able to find `elf2uf2-rs`, try:

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/feather-rp2040-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/feather-rp2040-v0.1.0

View file

@ -1,11 +1,12 @@
[package]
name = "feather_rp2040"
name = "feather-rp2040"
version = "0.1.0"
authors = ["Andrea Nall <anall@andreanal.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/feather_rp2040"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/feather-rp2040"
description = "Board Support Package for the Adafruit Feather RP2040"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,4 +1,4 @@
# [feather_rp2040] - Board Support for the [Adafruit Feather RP2040]
# [feather-rp2040] - Board Support for the [Adafruit Feather RP2040]
You should include this crate if you are writing code that you want to run on
an [Adafruit Feather RP2040] - a Feather form-factor RP2040 board from Adafruit.
@ -7,7 +7,7 @@ This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Feather.
[Adafruit Feather RP2040]: https://www.adafruit.com/product/4884
[feather_rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/feather_rp2040
[feather-rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/feather-rp2040
[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal
[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/
@ -16,7 +16,7 @@ RP2040 chip according to how it is connected up on the Feather.
To use this crate, your `Cargo.toml` file should contain:
```toml
feather_rp2040 = { git = "https://github.com/rp-rs/rp-hal.git" }
feather-rp2040 = "0.1.0"
```
In your program, you will need to call `feather_rp2040::Pins::new` to create
@ -30,7 +30,7 @@ devices. See the [examples](./examples) folder for more details.
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/feather_rp2040 $ cargo build --release --example <name>
rp-hal/boards/feather-rp2040 $ cargo build --release --example <name>
```
You will get an ELF file called
@ -44,7 +44,7 @@ USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:
```console
rp-hal/boards/feather_rp2040 $ cargo run --release --example <name>
rp-hal/boards/feather-rp2040 $ cargo run --release --example <name>
```
If you get an error about not being able to find `elf2uf2-rs`, try:

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/itsy-bitsy-rp2040-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/itsy-bitsy-rp2040-v0.1.0

View file

@ -1,11 +1,12 @@
[package]
name = "itsy_bitsy_rp2040"
name = "itsy-bitsy-rp2040"
version = "0.1.0"
authors = ["Andrew Christiansen <andrewtaylorchristiansen@gmail.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/itsy_bitsy_rp2040"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/itsy_bitsy_rp2040"
description = "Board Support Package for the Adafruit ItsyBitsy RP2040"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,4 +1,4 @@
# [itsy_bitsy_rp2040] - Board Support for the [Adafruit ItsyBitsy RP2040]
# [itsy-bitsy-rp2040] - Board Support for the [Adafruit ItsyBitsy RP2040]
You should include this crate if you are writing code that you want to run on
an [Adafruit ItsyBitsy RP2040] - an RP2040 board in the Itsy family from Adafruit.
@ -7,7 +7,7 @@ This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the ItsyBitsy RP2040.
[Adafruit ItsyBitsy RP2040]: https://www.adafruit.com/product/4888
[itsy_bitsy_rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/itsy_bitsy_rp2040
[itsy-bitsy-rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/itsy-bitsy-rp2040
[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal
[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/
@ -16,7 +16,7 @@ RP2040 chip according to how it is connected up on the ItsyBitsy RP2040.
To use this crate, your `Cargo.toml` file should contain:
```toml
itsy_bitsy_rp2040 = { git = "https://github.com/rp-rs/rp-hal.git" }
itsy-bitsy-rp2040 = "0.1.0"
```
In your program, you will need to call `itsy_bitsy_rp2040::Pins::new` to create
@ -30,7 +30,7 @@ devices. See the [examples](./examples) folder for more details.
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/itsy_bitsy_rp2040 $ cargo build --release --example <name>
rp-hal/boards/itsy-bitsy-rp2040 $ cargo build --release --example <name>
```
You will get an ELF file called
@ -44,7 +44,7 @@ USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:
```console
rp-hal/boards/itsy_bitsy_rp2040 $ cargo run --release --example <name>
rp-hal/boards/itsy-bitsy-rp2040 $ cargo run --release --example <name>
```
If you get an error about not being able to find `elf2uf2-rs`, try:

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/kb2040-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/kb2040-v0.1.0

View file

@ -3,9 +3,10 @@ name = "kb2040"
version = "0.1.0"
authors = ["Andrew Christiansen <andrewtaylorchristiansen@gmail.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/kb2040"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/kb2040"
description = "Board Support Package for the Adafruit KB2040"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -16,7 +16,7 @@ RP2040 chip according to how it is connected up on the KB2040.
To use this crate, your `Cargo.toml` file should contain:
```toml
kb2040 = { git = "https://github.com/rp-rs/rp-hal.git" }
kb2040 = "0.1.0"
```
In your program, you will need to call `kb2040::Pins::new` to create

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/pico-explorer-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/pico-explorer-v0.1.0

View file

@ -1,11 +1,12 @@
[package]
name = "pico_explorer"
name = "pico-explorer"
version = "0.1.0"
authors = ["Hmvp <hmvp@users.noreply.github.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/pico_explorer"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/pico-explorer"
description = "Board Support Package for the Pico Explorer"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,4 +1,4 @@
# [pico_explorer] - Board Support for the [Pimoroni Pico Explorer]
# [pico-explorer] - Board Support for the [Pimoroni Pico Explorer]
You should include this crate if you are writing code that you want to run on
a [Pimoroni Pico Explorer] - a board featuring a small LCD screen, a
@ -8,7 +8,7 @@ This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Pico Explorer.
[Pimoroni Pico Explorer]: https://shop.pimoroni.com/products/pico-explorer-base
[pico_explorer]: https://github.com/rp-rs/rp-hal/tree/main/boards/pico_explorer
[pico-explorer]: https://github.com/rp-rs/rp-hal/tree/main/boards/pico-explorer
[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal
[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/
@ -17,7 +17,7 @@ RP2040 chip according to how it is connected up on the Pico Explorer.
To use this crate, your `Cargo.toml` file should contain:
```toml
pico_explorer = { git = "https://github.com/rp-rs/rp-hal.git" }
pico-explorer = "0.1.0"
```
In your program, you will need to call `pico_explorer::Pins::new` to create
@ -31,7 +31,7 @@ devices. See the [examples](./examples) folder for more details.
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/pico_explorer $ cargo build --release --example <name>
rp-hal/boards/pico-explorer $ cargo build --release --example <name>
```
You will get an ELF file called
@ -45,7 +45,7 @@ USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:
```console
rp-hal/boards/pico_explorer $ cargo run --release --example <name>
rp-hal/boards/pico-explorer $ cargo run --release --example <name>
```
If you get an error about not being able to find `elf2uf2-rs`, try:

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/pico-lipo-16mb-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/pico-lipo-16mb-v0.1.0

View file

@ -1,11 +1,12 @@
[package]
name = "pico_lipo_16_mb"
name = "pico-lipo-16mb"
version = "0.1.0"
authors = ["Hmvp <hmvp@users.noreply.github.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/pico_lipo_16_mb"
description = "Board Support Package for the Pico LiPo 16 Mb"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/pico-lipo-16mb"
description = "Board Support Package for the Pico LiPo 16MB"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,4 +1,4 @@
# [pico_lipo_16mb] - Board Support for the [Pimoroni Pico Lipo 16MB]
# [pico-lipo-16mb] - Board Support for the [Pimoroni Pico Lipo 16MB]
You should include this crate if you are writing code that you want to run on
a [Pimoroni Pico Lipo 16MB] - a board with USB-C, STEMMA QT/Qwiic connectors,
@ -11,14 +11,14 @@ Note that if you use this crate the compiler will expect the full 16MB flash
space, and so it may not work if you only have the 4MB variant.
[Pimoroni Pico Lipo 16MB]: https://shop.pimoroni.com/products/pimoroni-pico-lipo?variant=39335427080275
[pico_lipo_16mb]: https://github.com/rp-rs/rp-hal/tree/main/boards/pico_lipo_16mb
[pico-lipo-16mb]: https://github.com/rp-rs/rp-hal/tree/main/boards/pico-lipo-16mb
## Using
To use this crate, your `Cargo.toml` file should contain:
```toml
pico_lipo_16mb = { git = "https://github.com/rp-rs/rp-hal.git" }
pico-lipo-16mb = { git = "https://github.com/rp-rs/rp-hal.git" }
```
In your program, you will need to call `pico_lipo_16mb::Pins::new` to create
@ -32,7 +32,7 @@ devices. See the [examples](./examples) folder for more details.
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/pico_lipo_16mb $ cargo build --release --example <name>
rp-hal/boards/pico-lipo-16mb $ cargo build --release --example <name>
```
You will get an ELF file called
@ -46,7 +46,7 @@ USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:
```console
rp-hal/boards/pico_lipo_16mb $ cargo run --release --example <name>
rp-hal/boards/pico-lipo-16mb $ cargo run --release --example <name>
```
If you get an error about not being able to find `elf2uf2-rs`, try:

View file

@ -24,15 +24,15 @@ use embedded_time::rate::*;
use panic_halt as _;
// Pull in any important traits
use pico_lipo_16_mb::hal::prelude::*;
use pico_lipo_16mb::hal::prelude::*;
// A shorter alias for the Peripheral Access Crate, which provides low-level
// register access
use pico_lipo_16_mb::hal::pac;
use pico_lipo_16mb::hal::pac;
// A shorter alias for the Hardware Abstraction Layer, which provides
// higher-level drivers.
use pico_lipo_16_mb::hal;
use pico_lipo_16mb::hal;
/// Entry point to our bare-metal application.
///
@ -54,7 +54,7 @@ fn main() -> ! {
//
// The default is to generate a 125 MHz system clock
let clocks = hal::clocks::init_clocks_and_plls(
pico_lipo_16_mb::XOSC_CRYSTAL_FREQ,
pico_lipo_16mb::XOSC_CRYSTAL_FREQ,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
@ -73,7 +73,7 @@ fn main() -> ! {
let sio = hal::Sio::new(pac.SIO);
// Set the pins up according to their function on this particular board
let pins = pico_lipo_16_mb::Pins::new(
let pins = pico_lipo_16mb::Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
sio.gpio_bank0,

23
boards/pico/CHANGELOG.md Normal file
View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/pico-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/pico-v0.1.0

View file

@ -3,9 +3,10 @@ name = "pico"
version = "0.1.0"
authors = ["evan <evanmolder@gmail.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/pico"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/pico"
description = "Board Support Package for the Raspberry Pi Pico"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@ -20,19 +21,6 @@ usbd-serial = "0.1.1"
usbd-hid = "0.5.1"
futures = { version = "0.3", default-features = false, optional = true }
[dependencies.embassy]
git = "https://github.com/embassy-rs/embassy"
rev = "6d6e6f55b8a9ecd38b5a6d3bb11f74b2654afdeb"
optional = true
# namespaced features will let use use "dep:embassy-traits" in the features rather than using this
# trick of renaming the crate.
[dependencies.embassy_traits]
git = "https://github.com/embassy-rs/embassy"
rev = "6d6e6f55b8a9ecd38b5a6d3bb11f74b2654afdeb"
package = "embassy-traits"
optional = true
[dev-dependencies]
panic-halt= "0.2.0"
embedded-hal ="0.2.5"
@ -44,8 +32,3 @@ i2c-pio = { git = "https://github.com/ithinuel/i2c-pio-rs", rev = "df06e4ac94a5b
default = ["boot2", "rt"]
boot2 = ["rp2040-boot2"]
rt = ["cortex-m-rt","rp2040-hal/rt"]
embassy-traits = ["futures", "embassy", "embassy_traits"]
[[example]]
name = "pico_i2c_controller_peripheral"
required-features = ["embassy-traits"]

View file

@ -16,7 +16,7 @@ RP2040 chip according to how it is connected up on the Pico.
To use this crate, your `Cargo.toml` file should contain:
```toml
pico = { git = "https://github.com/rp-rs/rp-hal.git" }
pico = "0.1.0"
```
In your program, you will need to call `pico::Pins::new` to create

View file

@ -1,47 +0,0 @@
//! I2C Controller demo
//!
//! This module implements a demonstration of an I2C controller sending read & write requests to a
//! peripheral.
//! This demo takes advandage of rust's async.await support to run read & write operation while
//! serving those request from an independant context.
use super::ADDRESS;
use core::ops::Deref;
use rp2040_hal::i2c::I2C;
use rp2040_hal::pac::i2c0::RegisterBlock as I2CBlock;
use embassy_traits::i2c::I2c;
/// Controller demo
pub async fn run_demo<Block, Pins>(i2c: &mut I2C<Block, Pins>) -> Result<(), rp2040_hal::i2c::Error>
where
Block: Deref<Target = I2CBlock>,
{
let mut tx_filler = 0;
let mut tx = [0u8; 24];
let mut rx = [0u8; 24];
i2c.read(ADDRESS, &mut rx).await?;
rx.iter()
.cloned()
.zip(0x80..)
.for_each(|(a, b)| assert_eq!(a, b));
tx.iter_mut().for_each(|b| {
*b = tx_filler;
tx_filler += 1;
});
i2c.write_read(ADDRESS, &tx, &mut rx).await?;
rx.iter()
.cloned()
.zip(0x80 + 24..) // follows the inital read
.for_each(|(a, b)| assert_eq!(a, b));
tx.iter_mut().for_each(|b| {
*b = tx_filler;
tx_filler += 1;
});
i2c.write(ADDRESS, &tx).await?;
Ok(())
}

View file

@ -1,119 +0,0 @@
//! I2C controller and I2C peripheral async demo.
//!
//! This example demonstrates use of both I2C peripherals (I2C0 and I2C1) at the same time on a single Pico using [Embassy](https://github.com/embassy-rs/embassy), an async executor.
//!
//! Each peripheral is passed to an async task, which allows them to operate independently of each other:
//! - The controller task (ctrl_demo) uses I2C0. It calls the demo controller code in `controller.rs`
//! - The peripheral task (prph_demo) uses I2C1. It calls the demo peripheral code in `peripheral.rs`
//!
//! ### Wiring notes:
//!
//! I2C0 uses pin `GP0` for `SDA`, and `GP1` for `SCL`.
//!
//! I2C1 uses `GP2` for `SDA`, and `GP3` for `SCL`.
//!
//! For this demo to function you must connect the `SDA` signals (`GP0` and `GP2`) to each other using wires.
//! You must also connect the `SCL` signals (`GP1` and `GP3`) to each other.
//!
//! A pull up resistor (to 3.3V, which is available on pin `36`) is required on SCL & SDA lines in order to reach the expected 1MHz. Although it
//! depends on the hardware context (wire length, impedance & capacitance), a typical value of 2KOhm
//! should generally work fine.
//!
//! If you do not connect the resistor and instead use the internal pull-ups on the I2C pins, you may need to lower the I2C frequency to avoid transmission errors.
#![no_std]
#![no_main]
#![feature(type_alias_impl_trait)]
use embassy::{executor::Executor, util::Forever};
use embedded_time::rate::Extensions;
use hal::{
clocks::{init_clocks_and_plls, Clock},
gpio::{bank0, FunctionI2C, Pin},
i2c::{peripheral::I2CPeripheralEventIterator, I2C},
pac,
watchdog::Watchdog,
Sio,
};
use pico::{hal, Pins, XOSC_CRYSTAL_FREQ};
use panic_halt as _;
mod controller;
mod peripheral;
const ADDRESS: u16 = 0x55;
#[embassy::task]
async fn ctrl_demo(
mut i2c: I2C<
pac::I2C0,
(
Pin<bank0::Gpio0, FunctionI2C>,
Pin<bank0::Gpio1, FunctionI2C>,
),
>,
) {
controller::run_demo(&mut i2c).await.expect("Demo failed")
}
#[embassy::task]
async fn prph_demo(
mut i2c: I2CPeripheralEventIterator<
pac::I2C1,
(
Pin<bank0::Gpio2, FunctionI2C>,
Pin<bank0::Gpio3, FunctionI2C>,
),
>,
) {
peripheral::run_demo(&mut i2c).await.expect("Demo failed")
}
#[cortex_m_rt::entry]
fn main() -> ! {
let mut pac = pac::Peripherals::take().unwrap();
let mut watchdog = Watchdog::new(pac.WATCHDOG);
let clocks = init_clocks_and_plls(
XOSC_CRYSTAL_FREQ,
pac.XOSC,
pac.CLOCKS,
pac.PLL_SYS,
pac.PLL_USB,
&mut pac.RESETS,
&mut watchdog,
)
.ok()
.unwrap();
let pins = Pins::new(
pac.IO_BANK0,
pac.PADS_BANK0,
Sio::new(pac.SIO).gpio_bank0,
&mut pac.RESETS,
);
let i2c0 = I2C::new_controller(
pac.I2C0,
pins.gpio0.into_mode(),
pins.gpio1.into_mode(),
1_000.kHz(),
&mut pac.RESETS,
clocks.system_clock.freq(),
);
let i2c1 = I2C::new_peripheral_event_iterator(
pac.I2C1,
pins.gpio2.into_mode(),
pins.gpio3.into_mode(),
&mut pac.RESETS,
ADDRESS,
);
static EXECUTOR: Forever<Executor> = Forever::new();
let executor = EXECUTOR.put(Executor::new());
executor.run(|spawner| {
spawner.spawn(ctrl_demo(i2c0)).unwrap();
spawner.spawn(prph_demo(i2c1)).unwrap();
});
}

View file

@ -1,95 +0,0 @@
//! I2C Peripheral demo
//!
//! This module implements a state machine serving the I2C requests from the controller in this
//! demo. In a real-life application the state machine may not need to be validated as thoroughly
//! demonstrated here.
use core::ops::Deref;
use rp2040_hal::i2c::peripheral::I2CEvent;
use rp2040_hal::i2c::peripheral::I2CPeripheralEventIterator;
use rp2040_hal::pac::i2c0::RegisterBlock as I2CBlock;
pub async fn run_demo<Block, Pins>(
i2c: &mut I2CPeripheralEventIterator<Block, Pins>,
) -> Result<(), rp2040_hal::i2c::Error>
where
Block: Deref<Target = I2CBlock>,
{
let mut expected_value = 0..;
let mut output = 128;
#[derive(Debug, PartialEq)]
enum Stage {
Idle0,
FirstRead,
Idle1,
FirstWrite,
SecondRead,
Idle2,
SecondWrite,
Done,
}
let mut stage = Stage::Idle0;
while stage != Stage::Done {
let ev = futures::future::poll_fn(|cx| {
cx.waker().wake_by_ref();
i2c.next()
.map(core::task::Poll::Ready)
.unwrap_or(core::task::Poll::Pending)
})
.await;
match ev {
I2CEvent::Start => {
stage = match stage {
Stage::Idle0 => Stage::FirstRead,
Stage::Idle1 => Stage::FirstWrite,
Stage::Idle2 => Stage::SecondWrite,
_ => panic!("Unexpected {:?} while in {:?}", ev, stage),
}
}
I2CEvent::TransferRead => {
if stage != Stage::FirstRead && stage != Stage::SecondRead {
panic!("Unexpected {:?} while in {:?}", ev, stage);
}
i2c.write(&[output, output + 1, output + 2, output + 3]);
output += 4;
}
I2CEvent::TransferWrite => {
if stage != Stage::FirstWrite && stage != Stage::SecondWrite {
panic!("Unexpected {:?} while in {:?}", ev, stage);
}
let mut buf = [0; 16];
loop {
let read = i2c.read(&mut buf);
if read == 0 {
break;
}
buf.iter()
.take(read)
.cloned()
.zip(&mut expected_value)
.for_each(|(a, b)| assert_eq!(a, b));
}
}
I2CEvent::Stop => {
stage = match stage {
Stage::FirstRead => Stage::Idle1,
Stage::SecondRead => Stage::Idle2,
Stage::SecondWrite => Stage::Done,
_ => panic!("Unexpected {:?} while in {:?}", ev, stage),
}
}
I2CEvent::Restart => {
stage = match stage {
Stage::FirstWrite => Stage::SecondRead,
_ => panic!("Unexpected {:?} while in {:?}", ev, stage),
}
}
}
}
Ok(())
}

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/pro-micro-rp2040-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/pro-micro-rp2040-v0.1.0

View file

@ -1,11 +1,12 @@
[package]
name = "pro_micro_rp2040"
name = "pro-micro-rp2040"
version = "0.1.0"
authors = ["Wilfried Chauveau <wilfried.chauveau@ithinuel.me>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/pro_micro_rp2040"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/pro-micro-rp2040"
description = "Board Support Package for the Sparkfun Pro Micro RP2040"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,13 +1,14 @@
# [pro_micro_rp2040] - Board Support for the [Sparkfun Pro Micro RP2040]
# [pro-micro-rp2040] - Board Support for the [Sparkfun Pro Micro RP2040]
You should include this crate if you are writing code that you want to run on
a [Sparkfun Pro Micro RP2040] - a smaller [RP2040][Raspberry Silicon RP2040] board with USB-C and a WS2812B addressable LED.
a [Sparkfun Pro Micro RP2040] - a smaller [RP2040][Raspberry Silicon RP2040]
board with USB-C and a WS2812B addressable LED.
This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the Pro Micro RP2040.
[Sparkfun Pro Micro RP2040]: https://www.sparkfun.com/products/18288
[pro_micro_rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/pro_micro_rp2040
[pro-micro-rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/pro-micro-rp2040
[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal
[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/
@ -16,7 +17,7 @@ RP2040 chip according to how it is connected up on the Pro Micro RP2040.
To use this crate, your `Cargo.toml` file should contain:
```toml
pro_micro_rp2040 = { git = "https://github.com/rp-rs/rp-hal.git" }
pro-micro-rp2040 = { git = "https://github.com/rp-rs/rp-hal.git" }
```
In your program, you will need to call `pro_micro_rp2040::Pins::new` to create
@ -30,7 +31,7 @@ devices. See the [examples](./examples) folder for more details.
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/pro_micro_rp2040 $ cargo build --release --example <name>
rp-hal/boards/pro-micro-rp2040 $ cargo build --release --example <name>
```
You will get an ELF file called
@ -44,7 +45,7 @@ USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:
```console
rp-hal/boards/pro_micro_rp2040 $ cargo run --release --example <name>
rp-hal/boards/pro-micro-rp2040 $ cargo run --release --example <name>
```
If you get an error about not being able to find `elf2uf2-rs`, try:

View file

@ -0,0 +1,23 @@
# Changelog
All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
## [Unreleased]
### Added
- None
### Changed
- None
## [0.1.0] - 2021-12-20
- Initial release
[Unreleased]: https://github.com/rp-rs/rp-hal/compare/qt-py-rp2040-v0.1.0...HEAD
[0.1.0]: https://github.com/rp-rs/rp-hal/releases/tag/qt-py-rp2040-v0.1.0

View file

@ -1,11 +1,12 @@
[package]
name = "qt_py_rp2040"
name = "qt-py-rp2040"
version = "0.1.0"
authors = ["Stephen Onnen <stephen.onnen@gmail.com>"]
edition = "2018"
homepage = "https://github.com/rp-rs/rp-hal/boards/qt_py_rp2040"
homepage = "https://github.com/rp-rs/rp-hal/tree/main/boards/qt-py-rp2040"
description = "Board Support Package for the Adafruit QT Py RP2040"
license = "MIT OR Apache-2.0"
repository = "https://github.com/rp-rs/rp-hal.git"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

View file

@ -1,4 +1,4 @@
# [qt_py_rp2040] - Board Support for the [Adafruit QT Py RP2040]
# [qt-py-rp2040] - Board Support for the [Adafruit QT Py RP2040]
You should include this crate if you are writing code that you want to run on
an [Adafruit QT Py RP2040] - an extremely small form-factor RP2040 board from Adafruit.
@ -7,7 +7,7 @@ This crate includes the [rp2040-hal], but also configures each pin of the
RP2040 chip according to how it is connected up on the QT Py.
[Adafruit QT Py RP2040]: https://www.adafruit.com/product/4900
[qt_py_rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/qt_py_rp2040
[qt-py-rp2040]: https://github.com/rp-rs/rp-hal/tree/main/boards/qt-py-rp2040
[rp2040-hal]: https://github.com/rp-rs/rp-hal/tree/main/rp2040-hal
[Raspberry Silicon RP2040]: https://www.raspberrypi.org/products/rp2040/
@ -16,7 +16,7 @@ RP2040 chip according to how it is connected up on the QT Py.
To use this crate, your `Cargo.toml` file should contain:
```toml
qt_py_rp2040 = { git = "https://github.com/rp-rs/rp-hal.git" }
qt-py-rp2040 = { git = "https://github.com/rp-rs/rp-hal.git" }
```
In your program, you will need to call `qt_py_rp2040::Pins::new` to create
@ -30,7 +30,7 @@ devices. See the [examples](./examples) folder for more details.
To compile an example, clone the _rp-hal_ repository and run:
```console
rp-hal/boards/qt_py_rp2040 $ cargo build --release --example <name>
rp-hal/boards/qt-py-rp2040 $ cargo build --release --example <name>
```
You will get an ELF file called
@ -44,7 +44,7 @@ USB drive exported by the RP2040 bootloader, simply boot your board into
bootloader mode and run:
```console
rp-hal/boards/qt_py_rp2040 $ cargo run --release --example <name>
rp-hal/boards/qt-py-rp2040 $ cargo run --release --example <name>
```
If you get an error about not being able to find `elf2uf2-rs`, try: