Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
64 commits
Select commit Hold shift + click to select a range
a571bf6
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
a2c6145
Teach `esp-hal-common` about the ESP32-C6
jessebraham Jan 6, 2023
f358cad
Get a number of peripheral drivers building for the ESP32-C6
jessebraham Jan 6, 2023
fc65b3f
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
bea1242
Simplify and fix the linker script
bjoernQ Jan 20, 2023
5f8e2d1
C6: add I2S
JurajSadel Jan 25, 2023
6db490d
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
a38ced1
Teach `esp-hal-common` about the ESP32-C6
jessebraham Jan 6, 2023
730f57f
Get a number of peripheral drivers building for the ESP32-C6
jessebraham Jan 6, 2023
3cec8bb
Create the `esp32c6-hal` package
jessebraham Jan 5, 2023
1e5ef3c
C6: update
JurajSadel Jan 20, 2023
e6df68d
Simplify and fix the linker script
bjoernQ Jan 20, 2023
d2b0734
update
JurajSadel Jan 24, 2023
bde4bb5
C6: add I2S
JurajSadel Jan 25, 2023
6351eee
update
JurajSadel Jan 24, 2023
51cb4c0
C6 Interrupts
bjoernQ Jan 25, 2023
753414a
C6: Update build.rs, linker scripts and initial examples
JurajSadel Jan 27, 2023
dece8b4
C6: RMT
JurajSadel Jan 27, 2023
3ad20aa
Fix interrupt handling
bjoernQ Jan 26, 2023
731f1cb
Fix `ClockControl::configure`
bjoernQ Jan 27, 2023
b0e7a59
C6: revert to I2S0 instead of just I2S
JurajSadel Jan 30, 2023
ae4e4b5
C6: rebase and update
JurajSadel Feb 1, 2023
a4edc46
RTC not buildable
JurajSadel Feb 2, 2023
988b1d0
Implement RWDT and SWD disable
bjoernQ Feb 2, 2023
ac4c447
C6: working LEDC
JurajSadel Feb 3, 2023
8ddaf7e
C6: working RMT
JurajSadel Feb 3, 2023
2b7fd7d
C6: add aes
JurajSadel Feb 7, 2023
b100cb2
C6: add mcpwm
JurajSadel Feb 7, 2023
9968157
C6: add rtc_cntln - not finished
JurajSadel Feb 7, 2023
cfb8445
C6: update and formatting
JurajSadel Feb 7, 2023
f9b7e19
C6: add pcnt
JurajSadel Feb 7, 2023
a7e14a9
C6: add examples and format
JurajSadel Feb 7, 2023
b7f0316
Remove inline assembly, fix interrupts and linker scripts
jessebraham Feb 7, 2023
a2e4c93
Remove unused features, update cargo config for atomic emu, misc cleanup
jessebraham Feb 7, 2023
8217147
Get ADC building and example "working" (as much as it ever does)
jessebraham Feb 7, 2023
a933093
Remove a bunch of unused constants which were copied from ESP-IDF
jessebraham Feb 7, 2023
93f926f
The `mcpwm` example now works correctly
jessebraham Feb 7, 2023
59a599d
Get `TWAI` peripheral driver building for C6
jessebraham Feb 8, 2023
46487eb
Clean up the `rtc_cntl` module and get all the other HALs building again
jessebraham Feb 8, 2023
4f97342
Add the C6 to our CI workflow
jessebraham Feb 8, 2023
403c640
Fix various things that have been missed when rebasing
jessebraham Feb 8, 2023
08f6f19
C6: Small updates in wdt (#1)
JurajSadel Feb 9, 2023
730b6b3
Update `esp-println` dependency to fix build errors
jessebraham Feb 9, 2023
e903e90
Fix formatting issues causing pre-commit hook to fail
jessebraham Feb 9, 2023
3622bc1
Get some more examples working
jessebraham Feb 9, 2023
9747426
Working `ram` example
jessebraham Feb 10, 2023
e41ecdd
Sync with changes in `main` after rebasing
jessebraham Feb 10, 2023
28ece39
Working `embassy_spi` example
jessebraham Feb 10, 2023
dd7f469
Use a git dependency for the PAC until we publish a release
jessebraham Feb 10, 2023
7dd27e5
Fix I2S for ESP32-C6
bjoernQ Feb 14, 2023
39444ba
Fix esp32c6 direct boot (#4)
MabezDev Feb 22, 2023
d16cab7
Update RWDT and refactor RTC (#3)
JurajSadel Feb 23, 2023
87cf485
Make required changes to include new `RADIO` peripheral
jessebraham Feb 23, 2023
0d3fd81
Use published versions of PAC and `esp-println`
jessebraham Feb 23, 2023
a381487
Use the correct target extensions (`imac`)
jessebraham Feb 24, 2023
572e99d
Fix the super watchdog timer, plus a few more examples
jessebraham Feb 24, 2023
dc309ea
Fix UART clock configuration
jessebraham Feb 24, 2023
716163b
Make sure to sync UART registers when configuring AT cmd detection
bjoernQ Feb 27, 2023
2f5972b
Disable APM in direct-boot mode
bjoernQ Feb 27, 2023
3eb273a
Address a number of review comments
jessebraham Feb 27, 2023
6641a0d
Fix `SPI` clocks and `rtc_watchdog` example (#6)
JurajSadel Feb 27, 2023
9e5f298
README and example fixes/cleanup
jessebraham Feb 27, 2023
ed59cd9
Add I2C peripheral enable and reset
bjoernQ Feb 27, 2023
e678120
Fix `ApbSarAdc` configuration in `system.rs`
jessebraham Feb 27, 2023
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
Prev Previous commit
Next Next commit
Update RWDT and refactor RTC (#3)
* C6: Update RWDT and add example, refactor RTC and add not-really-good example

* Update based on review comments, resolve bunch of warnings and run cargo fmt

* Update C6 esp-pacs rev commit

* Fix clocks_ll/esp32c6.rs

* Fix riscv interrupts

* Remove clock_monitor example for now

* RAM example works in direct-boot mode

* Add a TODO for &mut TIMG0 and cargo fmt

* Fix linker script after a bad rebase

* Update CI and Cargo.toml embassy required features

* use riscv32imac-unknown-none-elf target for C6 in CI

* change default target to riscv32imac-unknown-none-elf

* add riscv32imac-unknown-none-elf target to MSRV job

* another cleanup

---------

Co-authored-by: bjoernQ <[email protected]>
Co-authored-by: Jesse Braham <[email protected]>
  • Loading branch information
3 people committed Feb 23, 2023
commit d16cab70a9b941eb9de8ccbc882b04ca0fa8cded
15 changes: 7 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,11 +108,11 @@ jobs:
# Subsequent steps can just check the examples instead, as we're already
# confident that they link.
- name: check esp32c3-hal (common features)
run: cargo check --manifest-path=esp32c3-hal/Cargo.toml --target=riscv32imc-unknown-none-elf --examples --features=eh1,smartled,ufmt
run: cd esp32c3-hal/ && cargo check --examples --features=eh1,smartled,ufmt
- name: check esp32c3-hal (async, systick)
run: cargo check --manifest-path=esp32c3-hal/Cargo.toml --target=riscv32imc-unknown-none-elf --example=embassy_hello_world --features=embassy,embassy-time-systick
run: cd esp32c3-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
- name: check esp32c3-hal (async, timg0)
run: cargo check --manifest-path=esp32c3-hal/Cargo.toml --target=riscv32imc-unknown-none-elf --example=embassy_hello_world --features=embassy,embassy-time-timg0
run: cd esp32c3-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-timg0
- name: check esp32c3-hal (async, gpio)
run: cd esp32c3-hal/ && cargo check --example=embassy_wait --features=embassy,embassy-time-systick,async
- name: check esp32c3-hal (async, spi)
Expand All @@ -125,7 +125,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
target: riscv32imc-unknown-none-elf
target: riscv32imac-unknown-none-elf
toolchain: nightly
components: rust-src
- uses: Swatinem/rust-cache@v2
Expand All @@ -141,7 +141,7 @@ jobs:
# Subsequent steps can just check the examples instead, as we're already
# confident that they link.
- name: check esp32c6-hal (common features)
run: cd esp32c6-hal/ && cargo check --examples --features=eh1,ufmt
run: cd esp32c6-hal/ && cargo check --examples --features=eh1,smartled,ufmt
- name: check esp32c6-hal (async, systick)
run: cd esp32c6-hal/ && cargo check --example=embassy_hello_world --features=embassy,embassy-time-systick
- name: check esp32c6-hal (async, timg0)
Expand Down Expand Up @@ -213,7 +213,6 @@ jobs:
run: cd esp32s3-hal/ && cargo check --example=embassy_wait --features=embassy,embassy-time-timg0,async
- name: check esp32s3-hal (async, spi)
run: cd esp32s3-hal/ && cargo check --example=embassy_spi --features=embassy,embassy-time-timg0,async

# --------------------------------------------------------------------------
# MSRV

Expand All @@ -224,7 +223,7 @@ jobs:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@v1
with:
target: riscv32imc-unknown-none-elf
target: riscv32imc-unknown-none-elf, riscv32imac-unknown-none-elf
toolchain: "1.65.0"
- uses: Swatinem/rust-cache@v2

Expand Down Expand Up @@ -329,4 +328,4 @@ jobs:
- name: rustfmt (esp32s2-hal)
run: cargo fmt --all --manifest-path=esp32s2-hal/Cargo.toml -- --check
- name: rustfmt (esp32s3-hal)
run: cargo fmt --all --manifest-path=esp32s3-hal/Cargo.toml -- --check
run: cargo fmt --all --manifest-path=esp32s3-hal/Cargo.toml -- --check
2 changes: 1 addition & 1 deletion esp-hal-common/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ ufmt-write = { version = "0.1.0", optional = true }
esp32 = { version = "0.21.0", features = ["critical-section"], optional = true }
esp32c2 = { version = "0.8.0", features = ["critical-section"], optional = true }
esp32c3 = { version = "0.11.0", features = ["critical-section"], optional = true }
esp32c6 = { git = "https://github.com/esp-rs/esp-pacs", rev = "b5a7f1a", package = "esp32c6", features = ["critical-section"], optional = true }
esp32c6 = { git = "https://github.com/esp-rs/esp-pacs", rev = "1124275", package = "esp32c6", features = ["critical-section"], optional = true }
esp32s2 = { version = "0.12.0", features = ["critical-section"], optional = true }
esp32s3 = { version = "0.15.0", features = ["critical-section"], optional = true }

Expand Down
8 changes: 5 additions & 3 deletions esp-hal-common/src/clock/clocks_ll/esp32c6.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ const MODEM_LPCON_CLK_I2C_MST_FO: u32 = 1 << 2;
const MODEM_LPCON_I2C_MST_CLK_CONF_REG: u32 = DR_REG_MODEM_LPCON_BASE + 0x10;
const MODEM_LPCON_CLK_I2C_MST_SEL_160M: u32 = 1 << 0;

pub(crate) fn esp32c6_rtc_bbpll_configure(xtal_freq: XtalClock, pll_freq: PllClock) {
pub(crate) fn esp32c6_rtc_bbpll_configure(_xtal_freq: XtalClock, _pll_freq: PllClock) {
unsafe {
// enable i2c mst clk by force on temporarily
(MODEM_LPCON_CLK_CONF_FORCE_ON_REG as *mut u32).write_volatile(
Expand Down Expand Up @@ -278,6 +278,8 @@ const LP_I2C_ANA_MST_I2C0_DATA_REG: u32 = DR_REG_LP_I2C_ANA_MST_BASE + 0x8;
const LP_I2C_ANA_MST_I2C0_RDATA_V: u32 = 0x000000FF;
const LP_I2C_ANA_MST_I2C0_RDATA_S: u32 = 0;

const REGI2C_BBPLL: u8 = 0x66;

fn regi2c_enable_block(block: u8) {
reg_set_bit(MODEM_LPCON_CLK_CONF_REG, MODEM_LPCON_CLK_I2C_MST_EN);
reg_set_bit(LP_I2C_ANA_MST_DATE_REG, LP_I2C_ANA_MST_I2C_MAT_CLK_EN);
Expand Down Expand Up @@ -324,7 +326,7 @@ fn regi2c_disable_block(block: u8) {
}
}

pub(crate) fn regi2c_write(block: u8, host_id: u8, reg_add: u8, data: u8) {
pub(crate) fn regi2c_write(block: u8, _host_id: u8, reg_add: u8, data: u8) {
regi2c_enable_block(block);

let temp: u32 = ((block as u32 & REGI2C_RTC_SLAVE_ID_V as u32) << REGI2C_RTC_SLAVE_ID_S as u32)
Expand All @@ -337,7 +339,7 @@ pub(crate) fn regi2c_write(block: u8, host_id: u8, reg_add: u8, data: u8) {
regi2c_disable_block(block);
}

pub(crate) fn regi2c_write_mask(block: u8, host_id: u8, reg_add: u8, msb: u8, lsb: u8, data: u8) {
pub(crate) fn regi2c_write_mask(block: u8, _host_id: u8, reg_add: u8, msb: u8, lsb: u8, data: u8) {
assert!(msb - lsb < 8);
regi2c_enable_block(block);

Expand Down
6 changes: 3 additions & 3 deletions esp-hal-common/src/interrupt/riscv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,15 +330,15 @@ mod vectored {
for (prio, num) in PRIORITY_TO_INTERRUPT.iter().enumerate() {
set_kind(
crate::get_core(),
core::mem::transmute(*num),
core::mem::transmute(*num as u32),
InterruptKind::Level,
);
set_priority(
crate::get_core(),
core::mem::transmute(*num),
core::mem::transmute(*num as u32),
core::mem::transmute((prio as u8) + 1),
);
enable_cpu_interrupt(core::mem::transmute(*num));
enable_cpu_interrupt(core::mem::transmute(*num as u32));
}
}

Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/ledc/channel.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,10 +197,10 @@ macro_rules! start_duty_without_fading {
macro_rules! start_duty_without_fading {
($self: ident, $num: literal) => {
paste! {
$self.ledc.[<ch $num _conf1>].write(|w| unsafe {
$self.ledc.[<ch $num _conf1>].write(|w|
w.[<duty_start>]()
.set_bit()
});
);
$self.ledc.[<ch $num _gamma_wr>].write(|w| unsafe {
w.[<ch_gamma_duty_inc>]()
.set_bit()
Expand Down
4 changes: 2 additions & 2 deletions esp-hal-common/src/pulse_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ macro_rules! rmt {
pcr.rmt_sclk_conf.write(|w| w.sclk_en().set_bit());


self.reg.sys_conf.modify(|_, w| unsafe {
self.reg.sys_conf.modify(|_, w|
// Enable clock
w.clk_en()
.set_bit()
Expand All @@ -952,7 +952,7 @@ macro_rules! rmt {
.clear_bit()
// Disable FIFO mode
.apb_fifo_mask()
.set_bit() });
.set_bit());
// Select clock source
#[cfg(not(esp32c6))]
self.reg.sys_conf.modify(|_, w| unsafe {
Expand Down
65 changes: 19 additions & 46 deletions esp-hal-common/src/rtc_cntl/mod.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
use embedded_hal::watchdog::{Watchdog, WatchdogDisable, WatchdogEnable};
use fugit::{HertzU32, MicrosDurationU64};
#[cfg(not(esp32c6))]
use fugit::HertzU32;
use fugit::MicrosDurationU64;

use self::rtc::SocResetReason;
#[cfg(not(any(esp32)))]
#[cfg(not(esp32c6))]
use crate::clock::{Clock, XtalClock};
#[cfg(not(any(esp32, esp32c6)))]
use crate::efuse::Efuse;
#[cfg(esp32c6)]
use crate::peripherals::{LP_AON, LP_CLKRST, LP_WDT, PMU};
use crate::peripherals::LP_WDT;
#[cfg(not(esp32c6))]
use crate::peripherals::{RTC_CNTL, TIMG0};
use crate::{
clock::{Clock, XtalClock},
peripheral::{Peripheral, PeripheralRef},
Cpu,
};
Expand All @@ -27,11 +30,16 @@ type RtcCntl = crate::peripherals::RTC_CNTL;
#[cfg_attr(esp32s3, path = "rtc/esp32s3.rs")]
mod rtc;

#[cfg(esp32c6)]
pub use rtc::RtcClock;

extern "C" {
#[allow(dead_code)]
fn ets_delay_us(us: u32);
fn rtc_get_reset_reason(cpu_num: u32) -> u32;
}

#[cfg(not(esp32c6))]
#[allow(unused)]
#[derive(Debug, Clone, Copy)]
/// RTC SLOW_CLK frequency values
Expand All @@ -42,6 +50,7 @@ pub(crate) enum RtcFastClock {
RtcFastClock8m = 1,
}

#[cfg(not(esp32c6))]
impl Clock for RtcFastClock {
fn frequency(&self) -> HertzU32 {
match self {
Expand All @@ -55,6 +64,7 @@ impl Clock for RtcFastClock {
}

#[cfg(not(esp32c6))]
#[allow(unused)]
#[derive(Debug, Clone, Copy)]
/// RTC SLOW_CLK frequency values
pub(crate) enum RtcSlowClock {
Expand All @@ -66,21 +76,7 @@ pub(crate) enum RtcSlowClock {
RtcSlowClock8mD256 = 2,
}

#[cfg(esp32c6)]
#[derive(Debug, Clone, Copy, PartialEq)]
/// RTC SLOW_CLK frequency values
pub(crate) enum RtcSlowClock {
/// Internal slow RC oscillator
RtcSlowClockRtc = 0,
/// External 32 KHz XTAL
RtcSlowClock32kXtal = 1,
/// TODO
RtcSlowClock32kRc = 2,
/// Internal 150 KHz RC oscillator
RtcCalInternalOsc = 3,
RtcCalRcFast,
}

#[cfg(not(esp32c6))]
impl Clock for RtcSlowClock {
fn frequency(&self) -> HertzU32 {
match self {
Expand Down Expand Up @@ -120,35 +116,10 @@ pub(crate) enum RtcCalSel {
RtcCalInternalOsc = 3,
}

#[cfg(esp32c6)]
#[derive(Debug, Clone, Copy, PartialEq)]
/// Clock source to be calibrated using rtc_clk_cal function
pub(crate) enum RtcCalSel {
/// Currently selected RTC SLOW_CLK
RtcCalRtcMux = -1,
/// Currently selected RTC SLOW_CLK
RtcCalRcSlow = 0,
/// External 32 KHz XTAL
RtcCal32kXtal = 1,
/// TODO
RtcCal32kRc = 2,
#[cfg(not(esp32))]
/// Internal 150 KHz RC oscillator TODO
RtcCalInternalOsc = 3,
RtcCalRcFast,
}

#[cfg(esp32c6)]
pub(crate) enum RtcCaliClkSel {
CaliClkRcSlow = 0,
CaliClkRcFast = 1,
CaliClk32k = 2,
}

pub struct Rtc<'d> {
_inner: PeripheralRef<'d, RtcCntl>,
pub rwdt: Rwdt,
#[cfg(any(esp32c2, esp32c3, esp32c6, esp32s3))]
#[cfg(any(esp32c2, esp32c3, esp32s3, esp32c6))]
pub swd: Swd,
}

Expand All @@ -160,7 +131,7 @@ impl<'d> Rtc<'d> {
Self {
_inner: rtc_cntl.into_ref(),
rwdt: Rwdt::default(),
#[cfg(any(esp32c2, esp32c3, esp32c6, esp32s3))]
#[cfg(any(esp32c2, esp32c3, esp32s3, esp32c6))]
swd: Swd::new(),
}
}
Expand All @@ -170,9 +141,11 @@ impl<'d> Rtc<'d> {
}
}

#[cfg(not(esp32c6))]
/// RTC Watchdog Timer
pub struct RtcClock;

#[cfg(not(esp32c6))]
/// RTC Watchdog Timer driver
impl RtcClock {
const CAL_FRACT: u32 = 19;
Expand Down
Loading