Skip to content
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

Feature/issues 376 esp32 c3 devkitc 02 riscv support #388

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,18 @@ Drogue device runs on any hardware supported by embassy, which at the time of wr
* STM32
* Raspberry Pi Pico
* Linux, Mac OS X or Windows
* Espressif ESP32
* WASM (WebAssembly)

We provide examples for a subset of hardware that we ensure works and that are relevant for IoT.

## Minimal Quickstart

```
rustup update
cargo install probe-run
```

## Example applications

An overview of the examples can be found in the [documentation](https://book.drogue.io/drogue-device/dev/examples.html).
Expand Down
8 changes: 8 additions & 0 deletions boards/espressif/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Resources

https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitc-02.html

# TODO:

* https://docs.espressif.com/projects/esp-idf/en/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitm-1.html

123 changes: 123 additions & 0 deletions boards/espressif/esp32-C3-12F/board.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,123 @@
//! Board Support Package (BSP) for ESP32C3-12F

use embassy_esp32::{
gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull},
peripherals::{
ADC1, GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9, GPIO10,
GPIO18, GPIO19, GPIO20, GPIO21, PWM0, RNG, SAADC, TIMER0, TWISPI0, UARTE0,
},
};

/// Button for Reset
pub type ResetButton = Input<'static, AnyPin>;

/// Button for Program
pub type ProgramButton = Input<'static, AnyPin>;

/// ADC1 peripheral
pub type Adc = ADC1;

/// GPIO1 with ADC1_1 functionality
pub type PinGpio1 = GPIO1;

/// GPIO2 with ADC1_2 and MISO functionality
pub type PinGpio2 = GPIO2;

/// GPIO3 with ADC1_3 functionality
pub type PinGpio3 = GPIO3;

/// GPIO4 with ADC1_4, FSPIHD, MTMS functionality
pub type PinGpio4 = GPIO4;

/// GPIO5 with ADC2_0, FSPIWP, MTDI functionality
pub type PinGpio5 = GPIO5;

/// GPIO0 with ADC1_0, XTAL_32K_P functionality
pub type PinGpio0 = GPIO0;

/// GPIO19 with D+ functionality
pub type PinGpio19 = GPIO19;

/// GPIO18 with D- functionality
pub type PinGpio18 = GPIO18;

/// GPIO10 with FSPICSO functionality
pub type PinGpio10 = GPIO10;

/// GPIO9 with DTR, BOOT functionality
pub type PinGpio9 = GPIO9;

/// GPIO8
pub type PinGpio8 = GPIO8;

/// GPIO6 with FSPICLK, MTCK, SCLK functionality
pub type PinGpio6 = GPIO6;

/// GPIO7 with FSPID, MTDO, MOSI functionality
pub type PinGpio7 = GPIO7;

/// GPIO21 with U0TXD, TX functionality
pub type PinGpio21 = GPIO21;

/// GPIO20 with U0RXD, RX functionality
pub type PinGpio20 = GPIO20;

/// Reset button
pub type ResetButton = Input<'static, AnyPin>;

/// Program button
pub type ProgramButton = Input<'static, AnyPin>;

/// Board Support Package (BSP) type for ESP32C3-12F

/// Button for Reset
pub type ResetButton = Input<'static, AnyPin>;

/// Button for Program
pub type ProgramButton = Input<'static, AnyPin>;

/// Represents all the peripherals and pins available for the ESP32-C3-12F.
pub struct Esp32C3Board {
/// UART0 peripheral
pub uarte0: UARTE0,
/// TIMER0 peripheral
pub timer0: TIMER0,
/// PWM0 peripheral
pub pwm0: PWM0,
/// Random number generator
pub rng: RNG,
/// Analog digital converter
pub saadc: SAADC,
/// SPI/I2C peripheral
pub twispi0: TWISPI0,
/// Reset button
pub reset_button: ResetButton,
/// Program button
pub program_button: ProgramButton,
// Add other GPIOs, ADCs, etc. here
}

impl Default for Esp32C3Board {
fn default() -> Self {
Self::new(Default::default())
}
}

impl Esp32C3Board {
/// Create a new instance based on HAL configuration
pub fn new(config: embassy_esp32::config::Config) -> Self {
let p = embassy_esp32::init(config);

Self {
uarte0: p.UARTE0,
timer0: p.TIMER0,
pwm0: p.PWM0,
rng: p.RNG,
saadc: p.SAADC,
twispi0: p.TWISPI0,
reset_button: Input::new(p.GPIO9.degrade(), Pull::Up),
program_button: Input::new(p.GPIO8.degrade(), Pull::Up),
// Initialize other GPIOs, ADCs, etc. here
}
}
}
2 changes: 2 additions & 0 deletions boards/espressif/esp32-C3-DevKitC-02/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
https://docs.espressif.com/projects/esp-idf/zh_CN/latest/esp32c3/hw-reference/esp32c3/user-guide-devkitc-02.html

71 changes: 71 additions & 0 deletions boards/espressif/esp32-C3-DevKitC-02/board.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
use embassy_esp32::{
gpio::{AnyPin, Input, Level, Output, OutputDrive, Pin, Pull},
peripherals::{
GPIO0, GPIO1, GPIO2, GPIO3, GPIO4, GPIO5, GPIO6, GPIO7, GPIO8, GPIO9, GPIO10, GPIO18,
GPIO19, GPIO20, GPIO21, UARTE0, ADC1_CH0, ADC1_CH1, ADC1_CH2, ADC1_CH3, ADC1_CH4,
ADC2_CH0,
},
};

pub use embassy_esp32::{config::Config, wdt};

/// Red LED output
pub type RedLed = Output<'static, AnyPin>;

/// Input for user switch
pub type Switch = Input<'static, AnyPin>;

/// Board Support Package (BSP) type for the ESP32-C3-DevKitC-02
pub struct Esp32C3DevKitC02 {
pub uarte0: UARTE0,
pub red_led: RedLed,
pub switch: Switch,
pub gpio0: GPIO0,
pub gpio1: GPIO1,
pub gpio2: GPIO2,
pub gpio3: GPIO3,
pub gpio4: GPIO4,
pub gpio5: GPIO5,
pub gpio6: GPIO6,
pub gpio7: GPIO7,
pub gpio8: GPIO8,
pub gpio9: GPIO9,
pub gpio10: GPIO10,
pub gpio18: GPIO18,
pub gpio19: GPIO19,
pub gpio20: GPIO20,
pub gpio21: GPIO21,
}

impl Default for Esp32C3DevKitC02 {
fn default() -> Self {
Self::new(Default::default())
}
}

impl Esp32C3DevKitC02 {
pub fn new(config: embassy_esp32::config::Config) -> Self {
let p = embassy_esp32::init(config);
Self {
uarte0: p.UARTE0,
red_led: Output::new(p.GPIO8.degrade(), Level::Low, OutputDrive::Standard),
switch: Input::new(p.GPIO0.degrade(), Pull::Up),
gpio0: p.GPIO0,
gpio1: p.GPIO1,
gpio2: p.GPIO2,
gpio3: p.GPIO3,
gpio4: p.GPIO4,
gpio5: p.GPIO5,
gpio6: p.GPIO6,
gpio7: p.GPIO7,
gpio8: p.GPIO8,
gpio9: p.GPIO9,
gpio10: p.GPIO10,
gpio18: p.GPIO18,
gpio19: p.GPIO19,
gpio20: p.GPIO20,
gpio21: p.GPIO21,
}
}
}

8 changes: 8 additions & 0 deletions boards/espressif/esp32-S2-wroom32-generic/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@

# S2 Xtensa Architecture

https://github.com/esp-rs/esp-wifi

https://github.com/esp-rs/esp-wifi/tree/main/examples-esp32s2

https://github.com/esp-rs/esp-hal/blob/main/esp32s2-hal/examples/embassy_hello_world.rs
7 changes: 7 additions & 0 deletions boards/espressif/llvm-Risc_V/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# 🤔

TODO: a generic (non-ESP, any risc-v soc) LLVM Risc-V target, w/ wokwi interface
described here:

https://github.com/esp-rs/rust-build

4 changes: 4 additions & 0 deletions boards/riscv-llvm/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# 🤔
having a risc-v llvm target would enable better simulators
https://github.com/lowRISC/riscv-llvm

Loading