From 98baabec937532658127b9fe28873e458be1c0cc Mon Sep 17 00:00:00 2001 From: evan Date: Mon, 25 Jan 2021 15:42:43 -0500 Subject: [PATCH] Added skeleton for HAL and updated readme --- .gitignore | 1 + README.md | 10 +++----- boards/{pico-bsc => pico-bsp}/.gitignore | 0 boards/{pico-bsc => pico-bsp}/Cargo.toml | 4 +-- boards/{pico-bsc => pico-bsp}/README.md | 0 boards/{pico-bsc => pico-bsp}/src/lib.rs | 0 rp2040-hal/Cargo.toml | 6 +++-- rp2040-hal/src/adc.rs | 3 +++ rp2040-hal/src/i2c.rs | 3 +++ rp2040-hal/src/lib.rs | 32 ++++++++++++++++++------ rp2040-hal/src/prelude.rs | 1 + rp2040-hal/src/pwm.rs | 3 +++ rp2040-hal/src/rtc.rs | 3 +++ rp2040-hal/src/spi.rs | 3 +++ rp2040-hal/src/ssi.rs | 3 +++ rp2040-hal/src/time.rs | 1 + rp2040-hal/src/timer.rs | 3 +++ rp2040-hal/src/uart.rs | 3 +++ rp2040-hal/src/usb.rs | 3 +++ rp2040-hal/src/watchdog.rs | 3 +++ 20 files changed, 67 insertions(+), 18 deletions(-) create mode 100644 .gitignore rename boards/{pico-bsc => pico-bsp}/.gitignore (100%) rename boards/{pico-bsc => pico-bsp}/Cargo.toml (79%) rename boards/{pico-bsc => pico-bsp}/README.md (100%) rename boards/{pico-bsc => pico-bsp}/src/lib.rs (100%) create mode 100644 rp2040-hal/src/adc.rs create mode 100644 rp2040-hal/src/i2c.rs create mode 100644 rp2040-hal/src/prelude.rs create mode 100644 rp2040-hal/src/pwm.rs create mode 100644 rp2040-hal/src/rtc.rs create mode 100644 rp2040-hal/src/spi.rs create mode 100644 rp2040-hal/src/ssi.rs create mode 100644 rp2040-hal/src/time.rs create mode 100644 rp2040-hal/src/timer.rs create mode 100644 rp2040-hal/src/uart.rs create mode 100644 rp2040-hal/src/usb.rs create mode 100644 rp2040-hal/src/watchdog.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9f11b75 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.idea/ diff --git a/README.md b/README.md index df67b18..5af08ec 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,7 @@

Table of Contents

    -
  1. - About The Project - -
  2. -
  3. +
  4. Getting Started
    • Prerequisites
    • @@ -81,6 +75,8 @@ For more examples, please refer to the [Documentation](https://github.com/rp-rs/ ## Roadmap +NOTE This HAL is under active development. As such, it is likely to remain volatile until a 1.0.0 release. + See the [open issues](https://github.com/rp-rs/rp-hal/issues) for a list of proposed features (and known issues). diff --git a/boards/pico-bsc/.gitignore b/boards/pico-bsp/.gitignore similarity index 100% rename from boards/pico-bsc/.gitignore rename to boards/pico-bsp/.gitignore diff --git a/boards/pico-bsc/Cargo.toml b/boards/pico-bsp/Cargo.toml similarity index 79% rename from boards/pico-bsc/Cargo.toml rename to boards/pico-bsp/Cargo.toml index 88cc425..45fd684 100644 --- a/boards/pico-bsc/Cargo.toml +++ b/boards/pico-bsp/Cargo.toml @@ -1,10 +1,10 @@ [package] -name = "pico-bsc" +name = "pico-bsp" version = "0.1.0" authors = ["evan "] edition = "2018" homepage = "https://github.com/rp-rs/rp-hal/boards/pico-bsc" -description = "Board Support Crate for the Raspberry Pi Pico" +description = "Board Support Package for the Raspberry Pi Pico" license = "MIT OR Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/boards/pico-bsc/README.md b/boards/pico-bsp/README.md similarity index 100% rename from boards/pico-bsc/README.md rename to boards/pico-bsp/README.md diff --git a/boards/pico-bsc/src/lib.rs b/boards/pico-bsp/src/lib.rs similarity index 100% rename from boards/pico-bsc/src/lib.rs rename to boards/pico-bsp/src/lib.rs diff --git a/rp2040-hal/Cargo.toml b/rp2040-hal/Cargo.toml index 118a375..782adb1 100644 --- a/rp2040-hal/Cargo.toml +++ b/rp2040-hal/Cargo.toml @@ -10,5 +10,7 @@ license = "MIT OR Apache-2.0" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] -rp2040-pac = "0.1.0" -embedded-hal = "1.0.0-alpha.4" \ No newline at end of file +cortex-m = "0.7.1" +embedded-hal = "0.2.4" +nb = "1.0.0" +rp2040-pac = "0.1.1" diff --git a/rp2040-hal/src/adc.rs b/rp2040-hal/src/adc.rs new file mode 100644 index 0000000..905455b --- /dev/null +++ b/rp2040-hal/src/adc.rs @@ -0,0 +1,3 @@ +//! Analog-Digital Converter (ADC) +// See [Chapter 4 Section 9](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/i2c.rs b/rp2040-hal/src/i2c.rs new file mode 100644 index 0000000..253b33d --- /dev/null +++ b/rp2040-hal/src/i2c.rs @@ -0,0 +1,3 @@ +//! Inter-Integrated Circuit (I2C) bus +// See [Chapter 4 Section 3](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/lib.rs b/rp2040-hal/src/lib.rs index 31e1bb2..471b40f 100644 --- a/rp2040-hal/src/lib.rs +++ b/rp2040-hal/src/lib.rs @@ -1,7 +1,25 @@ -#[cfg(test)] -mod tests { - #[test] - fn it_works() { - assert_eq!(2 + 2, 4); - } -} +//! HAL for the RP2040 microcontroller +//! +//! This is an implementation of the [`embedded-hal`] traits for the RP2040 microcontroller +//! NOTE This HAL is still under active development. This API will remain volatile until 1.0.0 + +#![deny(missing_docs)] +#![deny(warnings)] +#![no_std] + +extern crate cortex_m; +extern crate embedded_hal as hal; +extern crate nb; +pub extern crate rp2040_pac as pac; + +pub mod adc; +pub mod i2c; +pub mod prelude; +pub mod pwm; +pub mod rtc; +pub mod spi; +pub mod ssi; +pub mod timer; +pub mod uart; +pub mod usb; +pub mod watchdog; diff --git a/rp2040-hal/src/prelude.rs b/rp2040-hal/src/prelude.rs new file mode 100644 index 0000000..8e3e645 --- /dev/null +++ b/rp2040-hal/src/prelude.rs @@ -0,0 +1 @@ +//! Prelude diff --git a/rp2040-hal/src/pwm.rs b/rp2040-hal/src/pwm.rs new file mode 100644 index 0000000..a1ab1ec --- /dev/null +++ b/rp2040-hal/src/pwm.rs @@ -0,0 +1,3 @@ +//! Pulse Width Modulation (PWM) +// See [Chapter 4 Section 5](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/rtc.rs b/rp2040-hal/src/rtc.rs new file mode 100644 index 0000000..15b7b5f --- /dev/null +++ b/rp2040-hal/src/rtc.rs @@ -0,0 +1,3 @@ +//! Real Time Clock (RTC) +// See [Chapter 4 Section 8](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/spi.rs b/rp2040-hal/src/spi.rs new file mode 100644 index 0000000..187fa2e --- /dev/null +++ b/rp2040-hal/src/spi.rs @@ -0,0 +1,3 @@ +//! Serial Peripheral Interface (SPI) +// See [Chapter 4 Section 4](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/ssi.rs b/rp2040-hal/src/ssi.rs new file mode 100644 index 0000000..382a68b --- /dev/null +++ b/rp2040-hal/src/ssi.rs @@ -0,0 +1,3 @@ +//! Synchronous Serial Interface (SSI) +// See [Chapter 4 Section 10](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/time.rs b/rp2040-hal/src/time.rs new file mode 100644 index 0000000..8201e0f --- /dev/null +++ b/rp2040-hal/src/time.rs @@ -0,0 +1 @@ +//! Time units diff --git a/rp2040-hal/src/timer.rs b/rp2040-hal/src/timer.rs new file mode 100644 index 0000000..5ac28cb --- /dev/null +++ b/rp2040-hal/src/timer.rs @@ -0,0 +1,3 @@ +//! Timers +// See [Chapter 4 Section 6](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/uart.rs b/rp2040-hal/src/uart.rs new file mode 100644 index 0000000..c4e1f76 --- /dev/null +++ b/rp2040-hal/src/uart.rs @@ -0,0 +1,3 @@ +//! Universal asynchronous receiver-transmitter (UART) +// See [Chapter 4 Section 2](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/usb.rs b/rp2040-hal/src/usb.rs new file mode 100644 index 0000000..332df6e --- /dev/null +++ b/rp2040-hal/src/usb.rs @@ -0,0 +1,3 @@ +//! Universal Serial Bus (USB) +// See [Chapter 4 Section 1](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO diff --git a/rp2040-hal/src/watchdog.rs b/rp2040-hal/src/watchdog.rs new file mode 100644 index 0000000..31c93dc --- /dev/null +++ b/rp2040-hal/src/watchdog.rs @@ -0,0 +1,3 @@ +//! Watchdog +// See [Chapter 4 Section 7](https://datasheets.raspberrypi.org/rp2040/rp2040_datasheet.pdf) for more details +// TODO