mirror of
https://github.com/esp-rs/esp-hal.git
synced 2025-10-02 06:40:47 +00:00
Feature gate embedded-hal@0.2.x
implementations, rename eh1
feature to embedded-hal
(#1273)
* Create an `embedded-hal-02` feature and gate implementations, rename `eh1` to `embedded-hal` * Use native `Delay` APIs in examples where applicable * Fix example imports, be explicit about about `embedded-hal-02` feature requirements * Update `CHANGELOG.md`
This commit is contained in:
parent
1983a74cb1
commit
3079d9cc49
@ -19,6 +19,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
|
|
||||||
- Prefer mutable references over moving for DMA transactions (#1238)
|
- Prefer mutable references over moving for DMA transactions (#1238)
|
||||||
- Support runtime interrupt binding, adapt GPIO driver (#1231)
|
- Support runtime interrupt binding, adapt GPIO driver (#1231)
|
||||||
|
- Renamed `eh1` feature to `embedded-hal`, feature-gated `embedded-hal@0.2.x` trait implementations (#1273)
|
||||||
|
|
||||||
### Removed
|
### Removed
|
||||||
|
|
||||||
|
@ -27,8 +27,8 @@ embassy-sync = { version = "0.5.0", optional = true }
|
|||||||
embassy-time-driver = { version = "0.1.0", optional = true }
|
embassy-time-driver = { version = "0.1.0", optional = true }
|
||||||
embedded-can = { version = "0.4.1", optional = true }
|
embedded-can = { version = "0.4.1", optional = true }
|
||||||
embedded-dma = "0.2.0"
|
embedded-dma = "0.2.0"
|
||||||
embedded-hal = { version = "0.2.7", features = ["unproven"] }
|
embedded-hal-02 = { version = "0.2.7", optional = true, features = ["unproven"], package = "embedded-hal" }
|
||||||
embedded-hal-1 = { version = "1.0.0", optional = true, package = "embedded-hal" }
|
embedded-hal = { version = "1.0.0", optional = true }
|
||||||
embedded-hal-async = { version = "1.0.0", optional = true }
|
embedded-hal-async = { version = "1.0.0", optional = true }
|
||||||
embedded-hal-nb = { version = "1.0.0", optional = true }
|
embedded-hal-nb = { version = "1.0.0", optional = true }
|
||||||
embedded-io = { version = "0.6.1", optional = true }
|
embedded-io = { version = "0.6.1", optional = true }
|
||||||
@ -74,7 +74,7 @@ esp-metadata = { version = "0.1.0", path = "../esp-metadata" }
|
|||||||
serde = { version = "1.0.197", features = ["derive"] }
|
serde = { version = "1.0.197", features = ["derive"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = ["rt", "vectored"]
|
default = ["embedded-hal-02", "rt", "vectored"]
|
||||||
|
|
||||||
riscv = ["dep:riscv", "critical-section/restore-state-u8", "esp-riscv-rt?/zero-bss"]
|
riscv = ["dep:riscv", "critical-section/restore-state-u8", "esp-riscv-rt?/zero-bss"]
|
||||||
xtensa = ["dep:xtensa-lx", "critical-section/restore-state-u32"]
|
xtensa = ["dep:xtensa-lx", "critical-section/restore-state-u32"]
|
||||||
@ -151,8 +151,8 @@ rv-init-rtc-data = ["esp-riscv-rt?/init-rtc-fast-data", "esp-riscv-rt?/init-rtc-
|
|||||||
## Enable support for asynchronous operation, with interfaces provided by
|
## Enable support for asynchronous operation, with interfaces provided by
|
||||||
## `embedded-hal-async` and `embedded-io-async`.
|
## `embedded-hal-async` and `embedded-io-async`.
|
||||||
async = [
|
async = [
|
||||||
|
"embedded-hal",
|
||||||
"embedded-hal-async",
|
"embedded-hal-async",
|
||||||
"eh1",
|
|
||||||
"embassy-sync",
|
"embassy-sync",
|
||||||
"embassy-futures",
|
"embassy-futures",
|
||||||
"embedded-io",
|
"embedded-io",
|
||||||
@ -164,13 +164,15 @@ defmt = [
|
|||||||
"embassy-executor?/defmt",
|
"embassy-executor?/defmt",
|
||||||
"embassy-futures?/defmt",
|
"embassy-futures?/defmt",
|
||||||
"embassy-sync?/defmt",
|
"embassy-sync?/defmt",
|
||||||
"embedded-hal-1?/defmt-03",
|
"embedded-hal?/defmt-03",
|
||||||
"embedded-io/defmt-03",
|
"embedded-io/defmt-03",
|
||||||
"embedded-io-async?/defmt-03",
|
"embedded-io-async?/defmt-03",
|
||||||
]
|
]
|
||||||
|
## Implement the traits defined in the `0.2.x` release of `embedded-hal`.
|
||||||
|
embedded-hal-02 = ["dep:embedded-hal-02"]
|
||||||
## Implement the traits defined in the `1.0.0` releases of `embedded-hal` and
|
## Implement the traits defined in the `1.0.0` releases of `embedded-hal` and
|
||||||
## `embedded-hal-nb` for the relevant peripherals.
|
## `embedded-hal-nb` for the relevant peripherals.
|
||||||
eh1 = ["embedded-hal-1", "embedded-hal-nb", "embedded-can"]
|
embedded-hal = ["dep:embedded-hal", "dep:embedded-hal-nb", "dep:embedded-can"]
|
||||||
## Implement the traits defined in `embedded-io` for certain peripherals.
|
## Implement the traits defined in `embedded-io` for certain peripherals.
|
||||||
embedded-io = ["dep:embedded-io"]
|
embedded-io = ["dep:embedded-io"]
|
||||||
## Implement the `ufmt_write::uWrite` trait for certain peripherals.
|
## Implement the `ufmt_write::uWrite` trait for certain peripherals.
|
||||||
@ -211,11 +213,11 @@ psram-80mhz = []
|
|||||||
|
|
||||||
#! ### Octal RAM Feature Flags
|
#! ### Octal RAM Feature Flags
|
||||||
## Use externally connected Octal RAM (2MB).
|
## Use externally connected Octal RAM (2MB).
|
||||||
opsram-2m = []
|
opsram-2m = []
|
||||||
## Use externally connected Octal RAM (4MB).
|
## Use externally connected Octal RAM (4MB).
|
||||||
opsram-4m = []
|
opsram-4m = []
|
||||||
## Use externally connected Octal RAM (8MB).
|
## Use externally connected Octal RAM (8MB).
|
||||||
opsram-8m = []
|
opsram-8m = []
|
||||||
## Use externally connected Octal RAM (16MB).
|
## Use externally connected Octal RAM (16MB).
|
||||||
opsram-16m = []
|
opsram-16m = []
|
||||||
|
|
||||||
|
@ -21,9 +21,10 @@ pub struct AdcPin<PIN, ADCI> {
|
|||||||
_phantom: PhantomData<ADCI>,
|
_phantom: PhantomData<ADCI>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<PIN, ADCI> embedded_hal::adc::Channel<ADCI> for AdcPin<PIN, ADCI>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<PIN, ADCI> embedded_hal_02::adc::Channel<ADCI> for AdcPin<PIN, ADCI>
|
||||||
where
|
where
|
||||||
PIN: embedded_hal::adc::Channel<ADCI, ID = u8>,
|
PIN: embedded_hal_02::adc::Channel<ADCI, ID = u8>,
|
||||||
{
|
{
|
||||||
type ID = u8;
|
type ID = u8;
|
||||||
|
|
||||||
@ -346,15 +347,16 @@ impl<'d, ADC1> ADC<'d, ADC1> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, ADCI, PIN> embedded_hal::adc::OneShot<ADCI, u16, AdcPin<PIN, ADCI>> for ADC<'d, ADCI>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<'d, ADCI, PIN> embedded_hal_02::adc::OneShot<ADCI, u16, AdcPin<PIN, ADCI>> for ADC<'d, ADCI>
|
||||||
where
|
where
|
||||||
PIN: embedded_hal::adc::Channel<ADCI, ID = u8>,
|
PIN: embedded_hal_02::adc::Channel<ADCI, ID = u8>,
|
||||||
ADCI: RegisterAccess,
|
ADCI: RegisterAccess,
|
||||||
{
|
{
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn read(&mut self, _pin: &mut AdcPin<PIN, ADCI>) -> nb::Result<u16, Self::Error> {
|
fn read(&mut self, _pin: &mut AdcPin<PIN, ADCI>) -> nb::Result<u16, Self::Error> {
|
||||||
use embedded_hal::adc::Channel;
|
use embedded_hal_02::adc::Channel;
|
||||||
|
|
||||||
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize].is_none() {
|
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize].is_none() {
|
||||||
panic!(
|
panic!(
|
||||||
@ -405,7 +407,8 @@ macro_rules! impl_adc_interface {
|
|||||||
const CHANNEL: u8 = $channel;
|
const CHANNEL: u8 = $channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::adc::Channel<$adc> for crate::gpio::$pin<crate::gpio::Analog> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::adc::Channel<$adc> for crate::gpio::$pin<crate::gpio::Analog> {
|
||||||
type ID = u8;
|
type ID = u8;
|
||||||
|
|
||||||
fn channel() -> u8 { $channel }
|
fn channel() -> u8 { $channel }
|
||||||
|
@ -117,9 +117,10 @@ pub struct AdcPin<PIN, ADCI, CS = ()> {
|
|||||||
_phantom: PhantomData<ADCI>,
|
_phantom: PhantomData<ADCI>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<PIN, ADCI, CS> embedded_hal::adc::Channel<ADCI> for AdcPin<PIN, ADCI, CS>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<PIN, ADCI, CS> embedded_hal_02::adc::Channel<ADCI> for AdcPin<PIN, ADCI, CS>
|
||||||
where
|
where
|
||||||
PIN: embedded_hal::adc::Channel<ADCI, ID = u8>,
|
PIN: embedded_hal_02::adc::Channel<ADCI, ID = u8>,
|
||||||
{
|
{
|
||||||
type ID = u8;
|
type ID = u8;
|
||||||
|
|
||||||
@ -548,17 +549,18 @@ impl AdcCalEfuse for crate::peripherals::ADC2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, ADCI, PIN, CS> embedded_hal::adc::OneShot<ADCI, u16, AdcPin<PIN, ADCI, CS>>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<'d, ADCI, PIN, CS> embedded_hal_02::adc::OneShot<ADCI, u16, AdcPin<PIN, ADCI, CS>>
|
||||||
for ADC<'d, ADCI>
|
for ADC<'d, ADCI>
|
||||||
where
|
where
|
||||||
PIN: embedded_hal::adc::Channel<ADCI, ID = u8>,
|
PIN: embedded_hal_02::adc::Channel<ADCI, ID = u8>,
|
||||||
ADCI: RegisterAccess,
|
ADCI: RegisterAccess,
|
||||||
CS: AdcCalScheme<ADCI>,
|
CS: AdcCalScheme<ADCI>,
|
||||||
{
|
{
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<u16, Self::Error> {
|
fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<u16, Self::Error> {
|
||||||
use embedded_hal::adc::Channel;
|
use embedded_hal_02::adc::Channel;
|
||||||
|
|
||||||
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize].is_none() {
|
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize].is_none() {
|
||||||
panic!(
|
panic!(
|
||||||
@ -639,7 +641,8 @@ macro_rules! impl_adc_interface {
|
|||||||
const CHANNEL: u8 = $channel;
|
const CHANNEL: u8 = $channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::adc::Channel<$adc> for crate::gpio::$pin<crate::gpio::Analog> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::adc::Channel<$adc> for crate::gpio::$pin<crate::gpio::Analog> {
|
||||||
type ID = u8;
|
type ID = u8;
|
||||||
|
|
||||||
fn channel() -> u8 { $channel }
|
fn channel() -> u8 { $channel }
|
||||||
|
@ -86,9 +86,10 @@ pub struct AdcPin<PIN, ADCI, CS = ()> {
|
|||||||
_phantom: PhantomData<ADCI>,
|
_phantom: PhantomData<ADCI>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<PIN, ADCI, CS> embedded_hal::adc::Channel<ADCI> for AdcPin<PIN, ADCI, CS>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<PIN, ADCI, CS> embedded_hal_02::adc::Channel<ADCI> for AdcPin<PIN, ADCI, CS>
|
||||||
where
|
where
|
||||||
PIN: embedded_hal::adc::Channel<ADCI, ID = u8>,
|
PIN: embedded_hal_02::adc::Channel<ADCI, ID = u8>,
|
||||||
{
|
{
|
||||||
type ID = u8;
|
type ID = u8;
|
||||||
|
|
||||||
@ -637,17 +638,18 @@ impl AdcCalEfuse for crate::peripherals::ADC2 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, ADCI, PIN, CS> embedded_hal::adc::OneShot<ADCI, u16, AdcPin<PIN, ADCI, CS>>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<'d, ADCI, PIN, CS> embedded_hal_02::adc::OneShot<ADCI, u16, AdcPin<PIN, ADCI, CS>>
|
||||||
for ADC<'d, ADCI>
|
for ADC<'d, ADCI>
|
||||||
where
|
where
|
||||||
PIN: embedded_hal::adc::Channel<ADCI, ID = u8>,
|
PIN: embedded_hal_02::adc::Channel<ADCI, ID = u8>,
|
||||||
ADCI: RegisterAccess,
|
ADCI: RegisterAccess,
|
||||||
CS: AdcCalScheme<ADCI>,
|
CS: AdcCalScheme<ADCI>,
|
||||||
{
|
{
|
||||||
type Error = ();
|
type Error = ();
|
||||||
|
|
||||||
fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<u16, Self::Error> {
|
fn read(&mut self, pin: &mut AdcPin<PIN, ADCI, CS>) -> nb::Result<u16, Self::Error> {
|
||||||
use embedded_hal::adc::Channel;
|
use embedded_hal_02::adc::Channel;
|
||||||
|
|
||||||
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize].is_none() {
|
if self.attenuations[AdcPin::<PIN, ADCI>::channel() as usize].is_none() {
|
||||||
panic!(
|
panic!(
|
||||||
@ -706,7 +708,8 @@ macro_rules! impl_adc_interface {
|
|||||||
const CHANNEL: u8 = $channel;
|
const CHANNEL: u8 = $channel;
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::adc::Channel<$adc> for crate::gpio::$pin<crate::gpio::Analog> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::adc::Channel<$adc> for crate::gpio::$pin<crate::gpio::Analog> {
|
||||||
type ID = u8;
|
type ID = u8;
|
||||||
|
|
||||||
fn channel() -> u8 { $channel }
|
fn channel() -> u8 { $channel }
|
||||||
|
@ -18,9 +18,9 @@
|
|||||||
//! delay.delay_ms(1000 as u32);
|
//! delay.delay_ms(1000 as u32);
|
||||||
//! ```
|
//! ```
|
||||||
//!
|
//!
|
||||||
//! [DelayMs]: embedded_hal::blocking::delay::DelayMs
|
//! [DelayMs]: embedded_hal_02::blocking::delay::DelayMs
|
||||||
//! [DelayUs]: embedded_hal::blocking::delay::DelayUs
|
//! [DelayUs]: embedded_hal_02::blocking::delay::DelayUs
|
||||||
//! [embedded-hal]: https://docs.rs/embedded-hal/latest/embedded_hal/
|
//! [embedded-hal]: https://docs.rs/embedded-hal/0.2.7/embedded_hal/index.html
|
||||||
|
|
||||||
use fugit::HertzU64;
|
use fugit::HertzU64;
|
||||||
|
|
||||||
@ -33,7 +33,17 @@ pub struct Delay {
|
|||||||
freq: HertzU64,
|
freq: HertzU64,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::blocking::delay::DelayMs<T> for Delay
|
impl Delay {
|
||||||
|
/// Delay for the specified number of milliseconds
|
||||||
|
pub fn delay_millis(&self, ms: u32) {
|
||||||
|
for _ in 0..ms {
|
||||||
|
self.delay_micros(1000u32);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::blocking::delay::DelayMs<T> for Delay
|
||||||
where
|
where
|
||||||
T: Into<u32>,
|
T: Into<u32>,
|
||||||
{
|
{
|
||||||
@ -44,7 +54,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::blocking::delay::DelayUs<T> for Delay
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::blocking::delay::DelayUs<T> for Delay
|
||||||
where
|
where
|
||||||
T: Into<u32>,
|
T: Into<u32>,
|
||||||
{
|
{
|
||||||
@ -53,8 +64,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_1::delay::DelayNs for Delay {
|
impl embedded_hal::delay::DelayNs for Delay {
|
||||||
fn delay_ns(&mut self, ns: u32) {
|
fn delay_ns(&mut self, ns: u32) {
|
||||||
self.delay_nanos(ns);
|
self.delay_nanos(ns);
|
||||||
}
|
}
|
||||||
|
@ -541,7 +541,9 @@ pub struct GpioPin<MODE, const GPIONUM: u8> {
|
|||||||
_mode: PhantomData<MODE>,
|
_mode: PhantomData<MODE>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal::digital::v2::InputPin for GpioPin<Input<MODE>, GPIONUM>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, const GPIONUM: u8> embedded_hal_02::digital::v2::InputPin
|
||||||
|
for GpioPin<Input<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
{
|
{
|
||||||
@ -554,7 +556,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<const GPIONUM: u8> embedded_hal::digital::v2::InputPin for GpioPin<Output<OpenDrain>, GPIONUM>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<const GPIONUM: u8> embedded_hal_02::digital::v2::InputPin
|
||||||
|
for GpioPin<Output<OpenDrain>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
{
|
{
|
||||||
@ -567,16 +571,16 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal_1::digital::ErrorType for GpioPin<Input<MODE>, GPIONUM>
|
impl<MODE, const GPIONUM: u8> embedded_hal::digital::ErrorType for GpioPin<Input<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
{
|
{
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal_1::digital::InputPin for GpioPin<Input<MODE>, GPIONUM>
|
impl<MODE, const GPIONUM: u8> embedded_hal::digital::InputPin for GpioPin<Input<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
{
|
{
|
||||||
@ -588,8 +592,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<const GPIONUM: u8> embedded_hal_1::digital::InputPin for GpioPin<Output<OpenDrain>, GPIONUM>
|
impl<const GPIONUM: u8> embedded_hal::digital::InputPin for GpioPin<Output<OpenDrain>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
<Self as GpioProperties>::PinType: IsOutputPin,
|
<Self as GpioProperties>::PinType: IsOutputPin,
|
||||||
@ -865,7 +869,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal::digital::v2::OutputPin
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, const GPIONUM: u8> embedded_hal_02::digital::v2::OutputPin
|
||||||
for GpioPin<Output<MODE>, GPIONUM>
|
for GpioPin<Output<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
@ -882,7 +887,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal::digital::v2::StatefulOutputPin
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, const GPIONUM: u8> embedded_hal_02::digital::v2::StatefulOutputPin
|
||||||
for GpioPin<Output<MODE>, GPIONUM>
|
for GpioPin<Output<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
@ -896,7 +902,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal::digital::v2::ToggleableOutputPin
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, const GPIONUM: u8> embedded_hal_02::digital::v2::ToggleableOutputPin
|
||||||
for GpioPin<Output<MODE>, GPIONUM>
|
for GpioPin<Output<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
@ -904,7 +911,7 @@ where
|
|||||||
{
|
{
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||||
use embedded_hal::digital::v2::{OutputPin as _, StatefulOutputPin as _};
|
use embedded_hal_02::digital::v2::{OutputPin as _, StatefulOutputPin as _};
|
||||||
if self.is_set_high()? {
|
if self.is_set_high()? {
|
||||||
Ok(self.set_low()?)
|
Ok(self.set_low()?)
|
||||||
} else {
|
} else {
|
||||||
@ -913,8 +920,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal_1::digital::ErrorType for GpioPin<Output<MODE>, GPIONUM>
|
impl<MODE, const GPIONUM: u8> embedded_hal::digital::ErrorType for GpioPin<Output<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
<Self as GpioProperties>::PinType: IsOutputPin,
|
<Self as GpioProperties>::PinType: IsOutputPin,
|
||||||
@ -922,8 +929,8 @@ where
|
|||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal_1::digital::OutputPin for GpioPin<Output<MODE>, GPIONUM>
|
impl<MODE, const GPIONUM: u8> embedded_hal::digital::OutputPin for GpioPin<Output<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
<Self as GpioProperties>::PinType: IsOutputPin,
|
<Self as GpioProperties>::PinType: IsOutputPin,
|
||||||
@ -938,8 +945,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, const GPIONUM: u8> embedded_hal_1::digital::StatefulOutputPin
|
impl<MODE, const GPIONUM: u8> embedded_hal::digital::StatefulOutputPin
|
||||||
for GpioPin<Output<MODE>, GPIONUM>
|
for GpioPin<Output<MODE>, GPIONUM>
|
||||||
where
|
where
|
||||||
Self: GpioProperties,
|
Self: GpioProperties,
|
||||||
@ -1719,7 +1726,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, TYPE> embedded_hal::digital::v2::InputPin for AnyPin<Input<MODE>, TYPE> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, TYPE> embedded_hal_02::digital::v2::InputPin for AnyPin<Input<MODE>, TYPE> {
|
||||||
type Error = core::convert::Infallible;
|
type Error = core::convert::Infallible;
|
||||||
|
|
||||||
fn is_high(&self) -> Result<bool, Self::Error> {
|
fn is_high(&self) -> Result<bool, Self::Error> {
|
||||||
@ -1733,13 +1741,13 @@ impl<MODE, TYPE> embedded_hal::digital::v2::InputPin for AnyPin<Input<MODE>, TYP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, TYPE> embedded_hal_1::digital::ErrorType for AnyPin<Input<MODE>, TYPE> {
|
impl<MODE, TYPE> embedded_hal::digital::ErrorType for AnyPin<Input<MODE>, TYPE> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, TYPE> embedded_hal_1::digital::InputPin for AnyPin<Input<MODE>, TYPE> {
|
impl<MODE, TYPE> embedded_hal::digital::InputPin for AnyPin<Input<MODE>, TYPE> {
|
||||||
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
let inner = &mut self.inner;
|
let inner = &mut self.inner;
|
||||||
handle_gpio_input!(inner, target, { target.is_high() })
|
handle_gpio_input!(inner, target, { target.is_high() })
|
||||||
@ -1751,7 +1759,8 @@ impl<MODE, TYPE> embedded_hal_1::digital::InputPin for AnyPin<Input<MODE>, TYPE>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, TYPE> embedded_hal::digital::v2::OutputPin for AnyPin<Output<MODE>, TYPE> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, TYPE> embedded_hal_02::digital::v2::OutputPin for AnyPin<Output<MODE>, TYPE> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn set_low(&mut self) -> Result<(), Self::Error> {
|
fn set_low(&mut self) -> Result<(), Self::Error> {
|
||||||
@ -1765,7 +1774,8 @@ impl<MODE, TYPE> embedded_hal::digital::v2::OutputPin for AnyPin<Output<MODE>, T
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, TYPE> embedded_hal::digital::v2::StatefulOutputPin for AnyPin<Output<MODE>, TYPE> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, TYPE> embedded_hal_02::digital::v2::StatefulOutputPin for AnyPin<Output<MODE>, TYPE> {
|
||||||
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
fn is_set_high(&self) -> Result<bool, Self::Error> {
|
||||||
let inner = &self.inner;
|
let inner = &self.inner;
|
||||||
handle_gpio_output!(inner, target, { target.is_set_high() })
|
handle_gpio_output!(inner, target, { target.is_set_high() })
|
||||||
@ -1777,7 +1787,8 @@ impl<MODE, TYPE> embedded_hal::digital::v2::StatefulOutputPin for AnyPin<Output<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<MODE, TYPE> embedded_hal::digital::v2::ToggleableOutputPin for AnyPin<Output<MODE>, TYPE> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<MODE, TYPE> embedded_hal_02::digital::v2::ToggleableOutputPin for AnyPin<Output<MODE>, TYPE> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn toggle(&mut self) -> Result<(), Self::Error> {
|
fn toggle(&mut self) -> Result<(), Self::Error> {
|
||||||
@ -1786,13 +1797,13 @@ impl<MODE, TYPE> embedded_hal::digital::v2::ToggleableOutputPin for AnyPin<Outpu
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, TYPE> embedded_hal_1::digital::ErrorType for AnyPin<Output<MODE>, TYPE> {
|
impl<MODE, TYPE> embedded_hal::digital::ErrorType for AnyPin<Output<MODE>, TYPE> {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, TYPE> embedded_hal_1::digital::OutputPin for AnyPin<Output<MODE>, TYPE> {
|
impl<MODE, TYPE> embedded_hal::digital::OutputPin for AnyPin<Output<MODE>, TYPE> {
|
||||||
fn set_low(&mut self) -> Result<(), Self::Error> {
|
fn set_low(&mut self) -> Result<(), Self::Error> {
|
||||||
let inner = &mut self.inner;
|
let inner = &mut self.inner;
|
||||||
handle_gpio_output!(inner, target, { target.set_low() })
|
handle_gpio_output!(inner, target, { target.set_low() })
|
||||||
@ -1804,8 +1815,8 @@ impl<MODE, TYPE> embedded_hal_1::digital::OutputPin for AnyPin<Output<MODE>, TYP
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<MODE, TYPE> embedded_hal_1::digital::StatefulOutputPin for AnyPin<Output<MODE>, TYPE> {
|
impl<MODE, TYPE> embedded_hal::digital::StatefulOutputPin for AnyPin<Output<MODE>, TYPE> {
|
||||||
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
fn is_set_high(&mut self) -> Result<bool, Self::Error> {
|
||||||
let inner = &mut self.inner;
|
let inner = &mut self.inner;
|
||||||
handle_gpio_output!(inner, target, { target.is_set_high() })
|
handle_gpio_output!(inner, target, { target.is_set_high() })
|
||||||
@ -3139,7 +3150,7 @@ mod asynch {
|
|||||||
|
|
||||||
impl<'a, P> PinFuture<'a, P>
|
impl<'a, P> PinFuture<'a, P>
|
||||||
where
|
where
|
||||||
P: crate::gpio::Pin + embedded_hal_1::digital::ErrorType,
|
P: crate::gpio::Pin + embedded_hal::digital::ErrorType,
|
||||||
{
|
{
|
||||||
pub fn new(pin: &'a mut P, event: Event) -> Self {
|
pub fn new(pin: &'a mut P, event: Event) -> Self {
|
||||||
pin.listen(event);
|
pin.listen(event);
|
||||||
@ -3149,7 +3160,7 @@ mod asynch {
|
|||||||
|
|
||||||
impl<'a, P> core::future::Future for PinFuture<'a, P>
|
impl<'a, P> core::future::Future for PinFuture<'a, P>
|
||||||
where
|
where
|
||||||
P: crate::gpio::Pin + embedded_hal_1::digital::ErrorType,
|
P: crate::gpio::Pin + embedded_hal::digital::ErrorType,
|
||||||
{
|
{
|
||||||
type Output = Result<(), P::Error>;
|
type Output = Result<(), P::Error>;
|
||||||
|
|
||||||
|
@ -62,10 +62,10 @@ pub enum Error {
|
|||||||
CommandNrExceeded,
|
CommandNrExceeded,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_1::i2c::Error for Error {
|
impl embedded_hal::i2c::Error for Error {
|
||||||
fn kind(&self) -> embedded_hal_1::i2c::ErrorKind {
|
fn kind(&self) -> embedded_hal::i2c::ErrorKind {
|
||||||
use embedded_hal_1::i2c::ErrorKind;
|
use embedded_hal::i2c::ErrorKind;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Self::ExceedingFifo => ErrorKind::Overrun,
|
Self::ExceedingFifo => ErrorKind::Overrun,
|
||||||
@ -187,7 +187,8 @@ pub struct I2C<'d, T> {
|
|||||||
peripheral: PeripheralRef<'d, T>,
|
peripheral: PeripheralRef<'d, T>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::blocking::i2c::Read for I2C<'_, T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::blocking::i2c::Read for I2C<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -198,7 +199,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::blocking::i2c::Write for I2C<'_, T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::blocking::i2c::Write for I2C<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -209,7 +211,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::blocking::i2c::WriteRead for I2C<'_, T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::blocking::i2c::WriteRead for I2C<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -225,13 +228,13 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_1::i2c::ErrorType for I2C<'_, T> {
|
impl<T> embedded_hal::i2c::ErrorType for I2C<'_, T> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_1::i2c::I2c for I2C<'_, T>
|
impl<T> embedded_hal::i2c::I2c for I2C<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -255,7 +258,7 @@ where
|
|||||||
fn transaction<'a>(
|
fn transaction<'a>(
|
||||||
&mut self,
|
&mut self,
|
||||||
_address: u8,
|
_address: u8,
|
||||||
_operations: &mut [embedded_hal_1::i2c::Operation<'a>],
|
_operations: &mut [embedded_hal::i2c::Operation<'a>],
|
||||||
) -> Result<(), Self::Error> {
|
) -> Result<(), Self::Error> {
|
||||||
todo!()
|
todo!()
|
||||||
}
|
}
|
||||||
@ -337,7 +340,7 @@ mod asynch {
|
|||||||
use cfg_if::cfg_if;
|
use cfg_if::cfg_if;
|
||||||
use embassy_futures::select::select;
|
use embassy_futures::select::select;
|
||||||
use embassy_sync::waitqueue::AtomicWaker;
|
use embassy_sync::waitqueue::AtomicWaker;
|
||||||
use embedded_hal_1::i2c::Operation;
|
use embedded_hal::i2c::Operation;
|
||||||
use procmacros::interrupt;
|
use procmacros::interrupt;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -285,9 +285,9 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
mod ehal1 {
|
mod ehal1 {
|
||||||
use embedded_hal_1::pwm::{self, ErrorKind, ErrorType, SetDutyCycle};
|
use embedded_hal::pwm::{self, ErrorKind, ErrorType, SetDutyCycle};
|
||||||
|
|
||||||
use super::{Channel, ChannelHW, ChannelIFace, Error};
|
use super::{Channel, ChannelHW, ChannelIFace, Error};
|
||||||
use crate::{gpio::OutputPin, ledc::timer::TimerSpeed};
|
use crate::{gpio::OutputPin, ledc::timer::TimerSpeed};
|
||||||
|
@ -638,7 +638,8 @@ impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> embedded_hal::PwmPin
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> embedded_hal_02::PwmPin
|
||||||
for PwmPin<'d, Pin, PWM, OP, IS_A>
|
for PwmPin<'d, Pin, PWM, OP, IS_A>
|
||||||
{
|
{
|
||||||
type Duty = u16;
|
type Duty = u16;
|
||||||
@ -672,17 +673,17 @@ impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool> emb
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// Implement no error type for the PwmPin because the method are infallible
|
/// Implement no error type for the PwmPin because the method are infallible
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool>
|
impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool>
|
||||||
embedded_hal_1::pwm::ErrorType for PwmPin<'d, Pin, PWM, OP, IS_A>
|
embedded_hal::pwm::ErrorType for PwmPin<'d, Pin, PWM, OP, IS_A>
|
||||||
{
|
{
|
||||||
type Error = core::convert::Infallible;
|
type Error = core::convert::Infallible;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implement the trait SetDutyCycle for PwmPin
|
/// Implement the trait SetDutyCycle for PwmPin
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool>
|
impl<'d, Pin: OutputPin, PWM: PwmPeripheral, const OP: u8, const IS_A: bool>
|
||||||
embedded_hal_1::pwm::SetDutyCycle for PwmPin<'d, Pin, PWM, OP, IS_A>
|
embedded_hal::pwm::SetDutyCycle for PwmPin<'d, Pin, PWM, OP, IS_A>
|
||||||
{
|
{
|
||||||
/// Get the max duty of the PwmPin
|
/// Get the max duty of the PwmPin
|
||||||
fn max_duty_cycle(&self) -> u16 {
|
fn max_duty_cycle(&self) -> u16 {
|
||||||
|
@ -10,15 +10,6 @@ pub use embedded_dma::{
|
|||||||
WriteBuffer as _embedded_dma_WriteBuffer,
|
WriteBuffer as _embedded_dma_WriteBuffer,
|
||||||
WriteTarget as _embedded_dma_WriteTarget,
|
WriteTarget as _embedded_dma_WriteTarget,
|
||||||
};
|
};
|
||||||
pub use embedded_hal::{
|
|
||||||
digital::v2::{
|
|
||||||
InputPin as _embedded_hal_digital_v2_InputPin,
|
|
||||||
OutputPin as _embedded_hal_digital_v2_OutputPin,
|
|
||||||
StatefulOutputPin as _embedded_hal_digital_v2_StatefulOutputPin,
|
|
||||||
ToggleableOutputPin as _embedded_hal_digital_v2_ToggleableOutputPin,
|
|
||||||
},
|
|
||||||
prelude::*,
|
|
||||||
};
|
|
||||||
pub use fugit::{
|
pub use fugit::{
|
||||||
ExtU32 as _fugit_ExtU32,
|
ExtU32 as _fugit_ExtU32,
|
||||||
ExtU64 as _fugit_ExtU64,
|
ExtU64 as _fugit_ExtU64,
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
//! method, which returns a 32-bit unsigned integer.
|
//! method, which returns a 32-bit unsigned integer.
|
||||||
//!
|
//!
|
||||||
//! Additionally, this driver implements the
|
//! Additionally, this driver implements the
|
||||||
//! [Read](embedded_hal::blocking::rng::Read) trait from the `embedded_hal`
|
//! [Read](embedded_hal_02::blocking::rng::Read) trait from the `embedded_hal`
|
||||||
//! crate, allowing you to generate random bytes by calling the `read` method.
|
//! crate, allowing you to generate random bytes by calling the `read` method.
|
||||||
//
|
//
|
||||||
//! # Important Note
|
//! # Important Note
|
||||||
@ -95,7 +95,8 @@ impl Rng {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::blocking::rng::Read for Rng {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::blocking::rng::Read for Rng {
|
||||||
type Error = Infallible;
|
type Error = Infallible;
|
||||||
|
|
||||||
fn read(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error> {
|
fn read(&mut self, buffer: &mut [u8]) -> Result<(), Self::Error> {
|
||||||
|
@ -69,7 +69,6 @@
|
|||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
use embedded_hal::watchdog::{Watchdog, WatchdogDisable, WatchdogEnable};
|
|
||||||
#[cfg(not(any(esp32c6, esp32h2)))]
|
#[cfg(not(any(esp32c6, esp32h2)))]
|
||||||
use fugit::HertzU32;
|
use fugit::HertzU32;
|
||||||
use fugit::MicrosDurationU64;
|
use fugit::MicrosDurationU64;
|
||||||
@ -307,9 +306,7 @@ impl<'d> Rtc<'d> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
config.apply();
|
config.apply();
|
||||||
|
delay.delay_millis(100u32);
|
||||||
use embedded_hal::blocking::delay::DelayMs;
|
|
||||||
delay.delay_ms(100u32);
|
|
||||||
|
|
||||||
config.start_sleep(wakeup_triggers);
|
config.start_sleep(wakeup_triggers);
|
||||||
config.finish_sleep();
|
config.finish_sleep();
|
||||||
@ -871,13 +868,15 @@ impl Rwdt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WatchdogDisable for Rwdt {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::watchdog::WatchdogDisable for Rwdt {
|
||||||
fn disable(&mut self) {
|
fn disable(&mut self) {
|
||||||
self.disable();
|
self.disable();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl WatchdogEnable for Rwdt {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::watchdog::WatchdogEnable for Rwdt {
|
||||||
type Time = MicrosDurationU64;
|
type Time = MicrosDurationU64;
|
||||||
|
|
||||||
fn start<T>(&mut self, period: T)
|
fn start<T>(&mut self, period: T)
|
||||||
@ -888,7 +887,8 @@ impl WatchdogEnable for Rwdt {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Watchdog for Rwdt {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::watchdog::Watchdog for Rwdt {
|
||||||
fn feed(&mut self) {
|
fn feed(&mut self) {
|
||||||
self.feed();
|
self.feed();
|
||||||
}
|
}
|
||||||
@ -949,8 +949,11 @@ impl Default for Swd {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3))]
|
#[cfg(all(
|
||||||
impl WatchdogDisable for Swd {
|
any(esp32c2, esp32c3, esp32c6, esp32h2, esp32s3),
|
||||||
|
feature = "embedded-hal-02"
|
||||||
|
))]
|
||||||
|
impl embedded_hal_02::watchdog::WatchdogDisable for Swd {
|
||||||
fn disable(&mut self) {
|
fn disable(&mut self) {
|
||||||
self.disable();
|
self.disable();
|
||||||
}
|
}
|
||||||
|
@ -29,11 +29,11 @@
|
|||||||
//! If all you want to do is to communicate to a single device, and you initiate
|
//! If all you want to do is to communicate to a single device, and you initiate
|
||||||
//! transactions yourself, there are a number of ways to achieve this:
|
//! transactions yourself, there are a number of ways to achieve this:
|
||||||
//!
|
//!
|
||||||
//! - Use the [`FullDuplex`](embedded_hal::spi::FullDuplex) trait to read/write
|
//! - Use the [`FullDuplex`](embedded_hal_02::spi::FullDuplex) trait to
|
||||||
//! single bytes at a time,
|
//! read/write single bytes at a time,
|
||||||
//! - Use the [`SpiBus`](embedded_hal_1::spi::SpiBus) trait (requires the "eh1"
|
//! - Use the [`SpiBus`](embedded_hal::spi::SpiBus) trait (requires the
|
||||||
//! feature) and its associated functions to initiate transactions with
|
//! "embedded-hal" feature) and its associated functions to initiate
|
||||||
//! simultaneous reads and writes, or
|
//! transactions with simultaneous reads and writes, or
|
||||||
//! - Use the `ExclusiveDevice` struct from [`embedded-hal-bus`] or `SpiDevice`
|
//! - Use the `ExclusiveDevice` struct from [`embedded-hal-bus`] or `SpiDevice`
|
||||||
//! from [`embassy-embedded-hal`].
|
//! from [`embassy-embedded-hal`].
|
||||||
//!
|
//!
|
||||||
@ -716,7 +716,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, M> embedded_hal::spi::FullDuplex<u8> for Spi<'_, T, M>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T, M> embedded_hal_02::spi::FullDuplex<u8> for Spi<'_, T, M>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
M: IsFullDuplex,
|
M: IsFullDuplex,
|
||||||
@ -732,7 +733,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, M> embedded_hal::blocking::spi::Transfer<u8> for Spi<'_, T, M>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T, M> embedded_hal_02::blocking::spi::Transfer<u8> for Spi<'_, T, M>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
M: IsFullDuplex,
|
M: IsFullDuplex,
|
||||||
@ -744,7 +746,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T, M> embedded_hal::blocking::spi::Write<u8> for Spi<'_, T, M>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T, M> embedded_hal_02::blocking::spi::Write<u8> for Spi<'_, T, M>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
M: IsFullDuplex,
|
M: IsFullDuplex,
|
||||||
@ -1214,7 +1217,8 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T, C, M> embedded_hal::blocking::spi::Transfer<u8> for SpiDma<'d, T, C, M>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<'d, T, C, M> embedded_hal_02::blocking::spi::Transfer<u8> for SpiDma<'d, T, C, M>
|
||||||
where
|
where
|
||||||
T: InstanceDma<C::Tx<'d>, C::Rx<'d>>,
|
T: InstanceDma<C::Tx<'d>, C::Rx<'d>>,
|
||||||
C: ChannelTypes,
|
C: ChannelTypes,
|
||||||
@ -1229,7 +1233,8 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'d, T, C, M> embedded_hal::blocking::spi::Write<u8> for SpiDma<'d, T, C, M>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<'d, T, C, M> embedded_hal_02::blocking::spi::Write<u8> for SpiDma<'d, T, C, M>
|
||||||
where
|
where
|
||||||
T: InstanceDma<C::Tx<'d>, C::Rx<'d>>,
|
T: InstanceDma<C::Tx<'d>, C::Rx<'d>>,
|
||||||
C: ChannelTypes,
|
C: ChannelTypes,
|
||||||
@ -1245,8 +1250,9 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: embedded_hal::blocking::spi::Transfer<u8>, const SIZE: usize>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
embedded_hal::blocking::spi::Transfer<u8> for FlashSafeDma<T, SIZE>
|
impl<T: embedded_hal_02::blocking::spi::Transfer<u8>, const SIZE: usize>
|
||||||
|
embedded_hal_02::blocking::spi::Transfer<u8> for FlashSafeDma<T, SIZE>
|
||||||
{
|
{
|
||||||
type Error = T::Error;
|
type Error = T::Error;
|
||||||
|
|
||||||
@ -1255,8 +1261,9 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: embedded_hal::blocking::spi::Write<u8>, const SIZE: usize>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
embedded_hal::blocking::spi::Write<u8> for FlashSafeDma<T, SIZE>
|
impl<T: embedded_hal_02::blocking::spi::Write<u8>, const SIZE: usize>
|
||||||
|
embedded_hal_02::blocking::spi::Write<u8> for FlashSafeDma<T, SIZE>
|
||||||
{
|
{
|
||||||
type Error = T::Error;
|
type Error = T::Error;
|
||||||
|
|
||||||
@ -1274,23 +1281,24 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T: embedded_hal::spi::FullDuplex<u8>, const SIZE: usize> embedded_hal::spi::FullDuplex<u8>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
for FlashSafeDma<T, SIZE>
|
impl<T: embedded_hal_02::spi::FullDuplex<u8>, const SIZE: usize>
|
||||||
|
embedded_hal_02::spi::FullDuplex<u8> for FlashSafeDma<T, SIZE>
|
||||||
where
|
where
|
||||||
Self: embedded_hal::blocking::spi::Transfer<u8, Error = T::Error>,
|
Self: embedded_hal_02::blocking::spi::Transfer<u8, Error = T::Error>,
|
||||||
Self: embedded_hal::blocking::spi::Write<u8, Error = T::Error>,
|
Self: embedded_hal_02::blocking::spi::Write<u8, Error = T::Error>,
|
||||||
{
|
{
|
||||||
type Error = T::Error;
|
type Error = T::Error;
|
||||||
|
|
||||||
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
||||||
use embedded_hal::blocking::spi::Transfer;
|
use embedded_hal_02::blocking::spi::Transfer;
|
||||||
let mut buf = [0; 1];
|
let mut buf = [0; 1];
|
||||||
self.transfer(&mut buf)?;
|
self.transfer(&mut buf)?;
|
||||||
Ok(buf[0])
|
Ok(buf[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
fn send(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
fn send(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
||||||
use embedded_hal::blocking::spi::Write;
|
use embedded_hal_02::blocking::spi::Write;
|
||||||
self.write(&[word])?;
|
self.write(&[word])?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
@ -1454,9 +1462,9 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
mod ehal1 {
|
mod ehal1 {
|
||||||
use embedded_hal_1::spi::{ErrorType, SpiBus};
|
use embedded_hal::spi::{ErrorType, SpiBus};
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
@ -1560,14 +1568,14 @@ pub mod dma {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
mod ehal1 {
|
mod ehal1 {
|
||||||
use embedded_hal_1::spi::SpiBus;
|
use embedded_hal::spi::SpiBus;
|
||||||
use embedded_hal_nb::spi::FullDuplex;
|
use embedded_hal_nb::spi::FullDuplex;
|
||||||
|
|
||||||
use super::*;
|
use super::*;
|
||||||
|
|
||||||
impl<T, M> embedded_hal_1::spi::ErrorType for Spi<'_, T, M> {
|
impl<T, M> embedded_hal::spi::ErrorType for Spi<'_, T, M> {
|
||||||
type Error = super::Error;
|
type Error = super::Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,10 +27,10 @@ impl From<DmaError> for Error {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_1::spi::Error for Error {
|
impl embedded_hal::spi::Error for Error {
|
||||||
fn kind(&self) -> embedded_hal_1::spi::ErrorKind {
|
fn kind(&self) -> embedded_hal::spi::ErrorKind {
|
||||||
embedded_hal_1::spi::ErrorKind::Other
|
embedded_hal::spi::ErrorKind::Other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,10 +39,6 @@ use core::{
|
|||||||
ops::{Deref, DerefMut},
|
ops::{Deref, DerefMut},
|
||||||
};
|
};
|
||||||
|
|
||||||
use embedded_hal::{
|
|
||||||
timer::{Cancel, CountDown, Periodic},
|
|
||||||
watchdog::{Watchdog, WatchdogDisable, WatchdogEnable},
|
|
||||||
};
|
|
||||||
use fugit::{HertzU32, MicrosDurationU64};
|
use fugit::{HertzU32, MicrosDurationU64};
|
||||||
use void::Void;
|
use void::Void;
|
||||||
|
|
||||||
@ -650,7 +646,8 @@ where
|
|||||||
(1_000_000 * micros / period as u64) as u64
|
(1_000_000 * micros / period as u64) as u64
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> CountDown for Timer<T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::timer::CountDown for Timer<T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -693,7 +690,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Cancel for Timer<T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::timer::Cancel for Timer<T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -712,7 +710,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> Periodic for Timer<T> where T: Instance {}
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::timer::Periodic for Timer<T> where T: Instance {}
|
||||||
|
|
||||||
/// Watchdog timer
|
/// Watchdog timer
|
||||||
pub struct Wdt<TG> {
|
pub struct Wdt<TG> {
|
||||||
@ -844,7 +843,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TG> WatchdogDisable for Wdt<TG>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<TG> embedded_hal_02::watchdog::WatchdogDisable for Wdt<TG>
|
||||||
where
|
where
|
||||||
TG: TimerGroupInstance,
|
TG: TimerGroupInstance,
|
||||||
{
|
{
|
||||||
@ -853,7 +853,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TG> WatchdogEnable for Wdt<TG>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<TG> embedded_hal_02::watchdog::WatchdogEnable for Wdt<TG>
|
||||||
where
|
where
|
||||||
TG: TimerGroupInstance,
|
TG: TimerGroupInstance,
|
||||||
{
|
{
|
||||||
@ -868,7 +869,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<TG> Watchdog for Wdt<TG>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<TG> embedded_hal_02::watchdog::Watchdog for Wdt<TG>
|
||||||
where
|
where
|
||||||
TG: TimerGroupInstance,
|
TG: TimerGroupInstance,
|
||||||
{
|
{
|
||||||
|
@ -3,10 +3,10 @@
|
|||||||
//! These are acceptance filters that limit which packets are received by the
|
//! These are acceptance filters that limit which packets are received by the
|
||||||
//! TWAI peripheral.
|
//! TWAI peripheral.
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
use embedded_can::{ExtendedId, StandardId};
|
use embedded_can::{ExtendedId, StandardId};
|
||||||
#[cfg(not(feature = "eh1"))]
|
#[cfg(not(feature = "embedded-hal"))] // FIXME
|
||||||
use embedded_hal::can::{ExtendedId, StandardId};
|
use embedded_hal_02::can::{ExtendedId, StandardId};
|
||||||
|
|
||||||
#[derive(Debug, PartialEq, Eq)]
|
#[derive(Debug, PartialEq, Eq)]
|
||||||
pub enum FilterType {
|
pub enum FilterType {
|
||||||
|
@ -75,10 +75,10 @@
|
|||||||
//! }
|
//! }
|
||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
use embedded_can::{nb::Can, Error, ErrorKind, ExtendedId, Frame, Id, StandardId};
|
use embedded_can::{nb::Can, Error, ErrorKind, ExtendedId, Frame, Id, StandardId};
|
||||||
#[cfg(not(feature = "eh1"))]
|
#[cfg(not(feature = "embedded-hal"))] // FIXME
|
||||||
use embedded_hal::can::{Can, Error, ErrorKind, ExtendedId, Frame, Id, StandardId};
|
use embedded_hal_02::can::{Can, Error, ErrorKind, ExtendedId, Frame, Id, StandardId};
|
||||||
use fugit::HertzU32;
|
use fugit::HertzU32;
|
||||||
|
|
||||||
use self::filter::{Filter, FilterType};
|
use self::filter::{Filter, FilterType};
|
||||||
@ -92,7 +92,7 @@ use crate::{
|
|||||||
|
|
||||||
pub mod filter;
|
pub mod filter;
|
||||||
|
|
||||||
/// Structure backing the embedded_hal::can::Frame/embedded_can::Frame trait.
|
/// Structure backing the embedded_hal_02::can::Frame/embedded_can::Frame trait.
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct EspTwaiFrame {
|
pub struct EspTwaiFrame {
|
||||||
id: Id,
|
id: Id,
|
||||||
|
@ -65,7 +65,7 @@ pub enum Error {
|
|||||||
RxFifoOvf,
|
RxFifoOvf,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::Error for Error {
|
impl embedded_hal_nb::serial::Error for Error {
|
||||||
fn kind(&self) -> embedded_hal_nb::serial::ErrorKind {
|
fn kind(&self) -> embedded_hal_nb::serial::ErrorKind {
|
||||||
embedded_hal_nb::serial::ErrorKind::Other
|
embedded_hal_nb::serial::ErrorKind::Other
|
||||||
@ -730,17 +730,17 @@ where
|
|||||||
.write(|w| w.rxfifo_full_int_clr().set_bit());
|
.write(|w| w.rxfifo_full_int_clr().set_bit());
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
fn write_byte(&mut self, word: u8) -> nb::Result<(), Error> {
|
fn write_byte(&mut self, word: u8) -> nb::Result<(), Error> {
|
||||||
self.tx.write_byte(word)
|
self.tx.write_byte(word)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
fn flush_tx(&self) -> nb::Result<(), Error> {
|
fn flush_tx(&self) -> nb::Result<(), Error> {
|
||||||
self.tx.flush_tx()
|
self.tx.flush_tx()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
fn read_byte(&mut self) -> nb::Result<u8, Error> {
|
fn read_byte(&mut self) -> nb::Result<u8, Error> {
|
||||||
self.rx.read_byte()
|
self.rx.read_byte()
|
||||||
}
|
}
|
||||||
@ -1230,7 +1230,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::serial::Write<u8> for Uart<'_, T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::serial::Write<u8> for Uart<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -1245,7 +1246,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::serial::Write<u8> for UartTx<'_, T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::serial::Write<u8> for UartTx<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -1260,7 +1262,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::serial::Read<u8> for Uart<'_, T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::serial::Read<u8> for Uart<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -1271,7 +1274,8 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<T> embedded_hal::serial::Read<u8> for UartRx<'_, T>
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl<T> embedded_hal_02::serial::Read<u8> for UartRx<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
{
|
{
|
||||||
@ -1282,22 +1286,22 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_nb::serial::ErrorType for Uart<'_, T> {
|
impl<T> embedded_hal_nb::serial::ErrorType for Uart<'_, T> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_nb::serial::ErrorType for UartTx<'_, T> {
|
impl<T> embedded_hal_nb::serial::ErrorType for UartTx<'_, T> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_nb::serial::ErrorType for UartRx<'_, T> {
|
impl<T> embedded_hal_nb::serial::ErrorType for UartRx<'_, T> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_nb::serial::Read for Uart<'_, T>
|
impl<T> embedded_hal_nb::serial::Read for Uart<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
@ -1307,7 +1311,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_nb::serial::Read for UartRx<'_, T>
|
impl<T> embedded_hal_nb::serial::Read for UartRx<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
@ -1317,7 +1321,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_nb::serial::Write for Uart<'_, T>
|
impl<T> embedded_hal_nb::serial::Write for Uart<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
@ -1331,7 +1335,7 @@ where
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl<T> embedded_hal_nb::serial::Write for UartTx<'_, T>
|
impl<T> embedded_hal_nb::serial::Write for UartTx<'_, T>
|
||||||
where
|
where
|
||||||
T: Instance,
|
T: Instance,
|
||||||
|
@ -364,15 +364,17 @@ impl ufmt_write::uWrite for UsbSerialJtagTx<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::serial::Read<u8> for UsbSerialJtag<'_> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::serial::Read<u8> for UsbSerialJtag<'_> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
||||||
embedded_hal::serial::Read::read(&mut self.rx)
|
embedded_hal_02::serial::Read::read(&mut self.rx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::serial::Read<u8> for UsbSerialJtagRx<'_> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::serial::Read<u8> for UsbSerialJtagRx<'_> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
||||||
@ -380,19 +382,21 @@ impl embedded_hal::serial::Read<u8> for UsbSerialJtagRx<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::serial::Write<u8> for UsbSerialJtag<'_> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::serial::Write<u8> for UsbSerialJtag<'_> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
||||||
embedded_hal::serial::Write::write(&mut self.tx, word)
|
embedded_hal_02::serial::Write::write(&mut self.tx, word)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> nb::Result<(), Self::Error> {
|
fn flush(&mut self) -> nb::Result<(), Self::Error> {
|
||||||
embedded_hal::serial::Write::flush(&mut self.tx)
|
embedded_hal_02::serial::Write::flush(&mut self.tx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl embedded_hal::serial::Write<u8> for UsbSerialJtagTx<'_> {
|
#[cfg(feature = "embedded-hal-02")]
|
||||||
|
impl embedded_hal_02::serial::Write<u8> for UsbSerialJtagTx<'_> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
|
|
||||||
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
||||||
@ -404,36 +408,36 @@ impl embedded_hal::serial::Write<u8> for UsbSerialJtagTx<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::ErrorType for UsbSerialJtag<'_> {
|
impl embedded_hal_nb::serial::ErrorType for UsbSerialJtag<'_> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagTx<'_> {
|
impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagTx<'_> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagRx<'_> {
|
impl embedded_hal_nb::serial::ErrorType for UsbSerialJtagRx<'_> {
|
||||||
type Error = Error;
|
type Error = Error;
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::Read for UsbSerialJtag<'_> {
|
impl embedded_hal_nb::serial::Read for UsbSerialJtag<'_> {
|
||||||
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
||||||
embedded_hal_nb::serial::Read::read(&mut self.rx)
|
embedded_hal_nb::serial::Read::read(&mut self.rx)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::Read for UsbSerialJtagRx<'_> {
|
impl embedded_hal_nb::serial::Read for UsbSerialJtagRx<'_> {
|
||||||
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
fn read(&mut self) -> nb::Result<u8, Self::Error> {
|
||||||
self.read_byte()
|
self.read_byte()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_> {
|
impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_> {
|
||||||
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
||||||
embedded_hal_nb::serial::Write::write(&mut self.tx, word)
|
embedded_hal_nb::serial::Write::write(&mut self.tx, word)
|
||||||
@ -444,7 +448,7 @@ impl embedded_hal_nb::serial::Write for UsbSerialJtag<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
impl embedded_hal_nb::serial::Write for UsbSerialJtagTx<'_> {
|
impl embedded_hal_nb::serial::Write for UsbSerialJtagTx<'_> {
|
||||||
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
fn write(&mut self, word: u8) -> nb::Result<(), Self::Error> {
|
||||||
self.write_byte_nb(word)
|
self.write_byte_nb(word)
|
||||||
|
@ -17,7 +17,7 @@ embassy-time = "0.3.0"
|
|||||||
embassy-time-driver = { version = "0.1.0", optional = true }
|
embassy-time-driver = { version = "0.1.0", optional = true }
|
||||||
embedded-graphics = "0.8.1"
|
embedded-graphics = "0.8.1"
|
||||||
embedded-hal = "1.0.0"
|
embedded-hal = "1.0.0"
|
||||||
embedded-hal-02 = { version = "0.2.7", package = "embedded-hal" }
|
embedded-hal-02 = { version = "0.2.7", package = "embedded-hal", features = ["unproven"] }
|
||||||
embedded-hal-async = "1.0.0"
|
embedded-hal-async = "1.0.0"
|
||||||
embedded-hal-bus = "0.1.0"
|
embedded-hal-bus = "0.1.0"
|
||||||
embedded-io-async = "0.6.1"
|
embedded-io-async = "0.6.1"
|
||||||
@ -52,7 +52,8 @@ esp32s3 = ["esp-hal/esp32s3", "esp-backtrace/esp32s3", "esp-println/esp32s3", "e
|
|||||||
|
|
||||||
async = ["esp-hal/async"]
|
async = ["esp-hal/async"]
|
||||||
|
|
||||||
eh1 = ["esp-hal/eh1"]
|
embedded-hal-02 = ["esp-hal/embedded-hal-02"]
|
||||||
|
embedded-hal = ["esp-hal/embedded-hal"]
|
||||||
|
|
||||||
embassy = ["esp-hal/embassy"]
|
embassy = ["esp-hal/embassy"]
|
||||||
|
|
||||||
|
@ -5,10 +5,12 @@
|
|||||||
//! maximum and minimum raw values read.
|
//! maximum and minimum raw values read.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::adc::OneShot;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
analog::adc::{AdcConfig, Attenuation, ADC},
|
analog::adc::{AdcConfig, Attenuation, ADC},
|
||||||
@ -42,11 +44,11 @@ fn main() -> ! {
|
|||||||
let mut adc1_pin = adc1_config.enable_pin(analog_pin, Attenuation::Attenuation11dB);
|
let mut adc1_pin = adc1_config.enable_pin(analog_pin, Attenuation::Attenuation11dB);
|
||||||
let mut adc1 = ADC::<ADC1>::new(peripherals.ADC1, adc1_config);
|
let mut adc1 = ADC::<ADC1>::new(peripherals.ADC1, adc1_config);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let pin_value: u16 = nb::block!(adc1.read(&mut adc1_pin)).unwrap();
|
let pin_value: u16 = nb::block!(adc1.read(&mut adc1_pin)).unwrap();
|
||||||
println!("ADC reading = {}", pin_value);
|
println!("ADC reading = {}", pin_value);
|
||||||
delay.delay_ms(1500u32);
|
delay.delay_millis(1500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
//! 3V3 to see the maximum and minimum raw values read.
|
//! 3V3 to see the maximum and minimum raw values read.
|
||||||
|
|
||||||
//% CHIPS: esp32c2 esp32c3 esp32c6 esp32s3
|
//% CHIPS: esp32c2 esp32c3 esp32c6 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::adc::OneShot;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
analog::adc::{AdcConfig, Attenuation, ADC},
|
analog::adc::{AdcConfig, Attenuation, ADC},
|
||||||
@ -48,11 +50,11 @@ fn main() -> ! {
|
|||||||
adc1_config.enable_pin_with_cal::<_, AdcCal>(analog_pin, Attenuation::Attenuation11dB);
|
adc1_config.enable_pin_with_cal::<_, AdcCal>(analog_pin, Attenuation::Attenuation11dB);
|
||||||
let mut adc1 = ADC::<ADC1>::new(peripherals.ADC1, adc1_config);
|
let mut adc1 = ADC::<ADC1>::new(peripherals.ADC1, adc1_config);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let pin_mv = nb::block!(adc1.read(&mut adc1_pin)).unwrap();
|
let pin_mv = nb::block!(adc1.read(&mut adc1_pin)).unwrap();
|
||||||
println!("PIN2 ADC reading = {pin_mv} mV");
|
println!("PIN2 ADC reading = {pin_mv} mV");
|
||||||
delay.delay_ms(1500u32);
|
delay.delay_millis(1500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,10 +8,12 @@
|
|||||||
//! - RX => GPIO5
|
//! - RX => GPIO5
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::serial::{Read, Write};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
@ -49,7 +51,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let mut serial1 = Uart::new_with_config(peripherals.UART1, config, Some(pins), &clocks);
|
let mut serial1 = Uart::new_with_config(peripherals.UART1, config, Some(pins), &clocks);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
println!("Start");
|
println!("Start");
|
||||||
loop {
|
loop {
|
||||||
@ -61,6 +63,6 @@ fn main() -> ! {
|
|||||||
Err(err) => println!("Error {:?}", err),
|
Err(err) => println!("Error {:?}", err),
|
||||||
}
|
}
|
||||||
|
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,10 +3,12 @@
|
|||||||
//! This assumes that a LED is connected to the pin assigned to `led`. (GPIO0)
|
//! This assumes that a LED is connected to the pin assigned to `led`. (GPIO0)
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::digital::v2::{OutputPin, ToggleableOutputPin};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{clock::ClockControl, delay::Delay, gpio::IO, peripherals::Peripherals, prelude::*};
|
use esp_hal::{clock::ClockControl, delay::Delay, gpio::IO, peripherals::Peripherals, prelude::*};
|
||||||
|
|
||||||
@ -24,10 +26,10 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
||||||
// loop.
|
// loop.
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
led.toggle().unwrap();
|
led.toggle().unwrap();
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@
|
|||||||
//! Additionally demonstrates passing GPIO to a function in a generic way.
|
//! Additionally demonstrates passing GPIO to a function in a generic way.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::digital::v2::{InputPin, ToggleableOutputPin};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
@ -40,11 +42,11 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Initialize the `Delay` peripheral, and use it to toggle the LED state
|
// Initialize the `Delay` peripheral, and use it to toggle the LED state
|
||||||
// in a loop:
|
// in a loop:
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
toggle_pins(&mut pins, &button);
|
toggle_pins(&mut pins, &button);
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
//! clock cycles within a given number of RTC_SLOW_CLK cycles.
|
//! clock cycles within a given number of RTC_SLOW_CLK cycles.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -10,6 +11,7 @@
|
|||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
|
use embedded_hal_02::watchdog::WatchdogEnable;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -1,12 +1,14 @@
|
|||||||
//! This shows example usage of the CRC functions in ROM
|
//! This shows example usage of the CRC functions in ROM
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
|
||||||
|
use embedded_hal_02::timer::CountDown;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -43,7 +43,7 @@ fn main() -> ! {
|
|||||||
let mut dac1 = DAC1::new(peripherals.DAC1, dac1_pin);
|
let mut dac1 = DAC1::new(peripherals.DAC1, dac1_pin);
|
||||||
let mut dac2 = DAC2::new(peripherals.DAC2, dac2_pin);
|
let mut dac2 = DAC2::new(peripherals.DAC2, dac2_pin);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
let mut voltage_dac1: u8 = 200;
|
let mut voltage_dac1: u8 = 200;
|
||||||
let mut voltage_dac2: u8 = 255;
|
let mut voltage_dac2: u8 = 255;
|
||||||
@ -54,6 +54,6 @@ fn main() -> ! {
|
|||||||
|
|
||||||
voltage_dac2 = voltage_dac2.wrapping_sub(1);
|
voltage_dac2 = voltage_dac2.wrapping_sub(1);
|
||||||
dac2.write(voltage_dac2);
|
dac2.write(voltage_dac2);
|
||||||
delay.delay_ms(50u32);
|
delay.delay_millis(50u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
//! hardware-accelerated and pure software ECC.
|
//! hardware-accelerated and pure software ECC.
|
||||||
|
|
||||||
//% CHIPS: esp32c2 esp32c6 esp32h2
|
//% CHIPS: esp32c2 esp32c6 esp32h2
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -15,6 +16,7 @@ use crypto_bigint::{
|
|||||||
U256,
|
U256,
|
||||||
};
|
};
|
||||||
use elliptic_curve::sec1::ToEncodedPoint;
|
use elliptic_curve::sec1::ToEncodedPoint;
|
||||||
|
use embedded_hal_02::blocking::rng::Read;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
ecc::{Ecc, EllipticCurve, Error, WorkMode},
|
ecc::{Ecc, EllipticCurve, Error, WorkMode},
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//! signal set by the task running on the other core.
|
//! signal set by the task running on the other core.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32s3
|
//% CHIPS: esp32 esp32s3
|
||||||
//% FEATURES: embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers
|
//% FEATURES: embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -13,6 +13,7 @@
|
|||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
||||||
use embassy_time::{Duration, Ticker};
|
use embassy_time::{Duration, Ticker};
|
||||||
|
use embedded_hal_02::digital::v2::OutputPin;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
//! signal set by the task running on the other core.
|
//! signal set by the task running on the other core.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32s3
|
//% CHIPS: esp32 esp32s3
|
||||||
//% FEATURES: embassy embassy-executor-interrupt embassy-time-timg0 embassy-generic-timers
|
//% FEATURES: embassy embassy-executor-interrupt embassy-time-timg0 embassy-generic-timers embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -12,6 +12,7 @@
|
|||||||
|
|
||||||
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
use embassy_sync::{blocking_mutex::raw::CriticalSectionRawMutex, signal::Signal};
|
||||||
use embassy_time::{Duration, Ticker};
|
use embassy_time::{Duration, Ticker};
|
||||||
|
use embedded_hal_02::digital::v2::OutputPin;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
//! Connect GPIO5 to GPIO4
|
//! Connect GPIO5 to GPIO4
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
//% FEATURES: async embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers
|
//% FEATURES: async embassy embassy-executor-thread embassy-time-timg0 embassy-generic-timers embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -10,6 +10,7 @@
|
|||||||
|
|
||||||
use embassy_executor::Spawner;
|
use embassy_executor::Spawner;
|
||||||
use embassy_time::{Duration, Timer};
|
use embassy_time::{Duration, Timer};
|
||||||
|
use embedded_hal_02::digital::v2::ToggleableOutputPin;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
//! Control LED on GPIO1 by the BOOT-BUTTON via ETM
|
//! Control LED on GPIO1 by the BOOT-BUTTON via ETM
|
||||||
|
|
||||||
//% CHIPS: esp32c6 esp32h2
|
//% CHIPS: esp32c6 esp32h2
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::digital::v2::OutputPin;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
etm::Etm,
|
etm::Etm,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
//! It also blinks an LED like the blinky example.
|
//! It also blinks an LED like the blinky example.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -11,6 +12,7 @@
|
|||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
|
use embedded_hal_02::digital::v2::{OutputPin, ToggleableOutputPin};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
@ -54,11 +56,11 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
||||||
// loop.
|
// loop.
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
led.toggle().unwrap();
|
led.toggle().unwrap();
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -67,7 +67,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
||||||
// loop.
|
// loop.
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
let mut color = Hsv {
|
let mut color = Hsv {
|
||||||
hue: 0,
|
hue: 0,
|
||||||
@ -88,7 +88,7 @@ fn main() -> ! {
|
|||||||
// that the output it's not too bright.
|
// that the output it's not too bright.
|
||||||
led.write(brightness(gamma(data.iter().cloned()), 10))
|
led.write(brightness(gamma(data.iter().cloned()), 10))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
delay.delay_ms(20u8);
|
delay.delay_millis(20);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,12 +4,14 @@
|
|||||||
//! option.
|
//! option.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
use core::fmt::Write;
|
use core::fmt::Write;
|
||||||
|
|
||||||
|
use embedded_hal_02::timer::CountDown;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -53,10 +53,12 @@
|
|||||||
//! ```
|
//! ```
|
||||||
|
|
||||||
//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::blocking::rng::Read;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -7,10 +7,12 @@
|
|||||||
//! - SCL => GPIO5
|
//! - SCL => GPIO5
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::blocking::i2c::WriteRead;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{clock::ClockControl, gpio::IO, i2c::I2C, peripherals::Peripherals, prelude::*};
|
use esp_hal::{clock::ClockControl, gpio::IO, i2c::I2C, peripherals::Peripherals, prelude::*};
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
|
@ -8,6 +8,7 @@
|
|||||||
//! - SCL => GPIO2
|
//! - SCL => GPIO2
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -21,6 +22,7 @@ use embedded_graphics::{
|
|||||||
prelude::*,
|
prelude::*,
|
||||||
text::{Alignment, Text},
|
text::{Alignment, Text},
|
||||||
};
|
};
|
||||||
|
use embedded_hal_02::timer::CountDown;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -18,10 +18,12 @@
|
|||||||
//! D7 GPIO15
|
//! D7 GPIO15
|
||||||
|
|
||||||
//% CHIPS: esp32s3
|
//% CHIPS: esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::digital::v2::OutputPin;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
@ -64,7 +66,7 @@ fn main() -> ! {
|
|||||||
DmaPriority::Priority0,
|
DmaPriority::Priority0,
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
let mut backlight = lcd_backlight.into_push_pull_output();
|
let mut backlight = lcd_backlight.into_push_pull_output();
|
||||||
let mut reset = lcd_reset.into_push_pull_output();
|
let mut reset = lcd_reset.into_push_pull_output();
|
||||||
@ -96,9 +98,9 @@ fn main() -> ! {
|
|||||||
// https://github.com/lovyan03/LovyanGFX/blob/302169a6f23e9a2a6451f03311c366d182193831/src/lgfx/v1/panel/Panel_ST7796.hpp#L28
|
// https://github.com/lovyan03/LovyanGFX/blob/302169a6f23e9a2a6451f03311c366d182193831/src/lgfx/v1/panel/Panel_ST7796.hpp#L28
|
||||||
|
|
||||||
reset.set_low().unwrap();
|
reset.set_low().unwrap();
|
||||||
delay.delay_us(8_000u32);
|
delay.delay_micros(8_000u32);
|
||||||
reset.set_high().unwrap();
|
reset.set_high().unwrap();
|
||||||
delay.delay_us(64_000u32);
|
delay.delay_micros(64_000u32);
|
||||||
|
|
||||||
// const CMD_FRMCTR1: u8 = 0xB1;
|
// const CMD_FRMCTR1: u8 = 0xB1;
|
||||||
// const CMD_FRMCTR2: u8 = 0xB2;
|
// const CMD_FRMCTR2: u8 = 0xB2;
|
||||||
@ -149,7 +151,7 @@ fn main() -> ! {
|
|||||||
i8080.send(CMD_PWCTR3, 0, &[0xA7]).unwrap(); // Power control 3 //Source driving current level=low, Gamma driving current
|
i8080.send(CMD_PWCTR3, 0, &[0xA7]).unwrap(); // Power control 3 //Source driving current level=low, Gamma driving current
|
||||||
// level=High
|
// level=High
|
||||||
i8080.send(CMD_VMCTR, 0, &[0x18]).unwrap(); // VCOM Control //VCOM=0.9
|
i8080.send(CMD_VMCTR, 0, &[0x18]).unwrap(); // VCOM Control //VCOM=0.9
|
||||||
delay.delay_us(120_000u32);
|
delay.delay_micros(120_000u32);
|
||||||
i8080
|
i8080
|
||||||
.send(
|
.send(
|
||||||
CMD_GMCTRP1,
|
CMD_GMCTRP1,
|
||||||
@ -170,13 +172,13 @@ fn main() -> ! {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
delay.delay_us(120_000u32);
|
delay.delay_micros(120_000u32);
|
||||||
i8080.send(CMD_CSCON, 0, &[0x3C]).unwrap(); // Command Set control // Disable extension command 2 partI
|
i8080.send(CMD_CSCON, 0, &[0x3C]).unwrap(); // Command Set control // Disable extension command 2 partI
|
||||||
i8080.send(CMD_CSCON, 0, &[0x69]).unwrap(); // Command Set control // Disable
|
i8080.send(CMD_CSCON, 0, &[0x69]).unwrap(); // Command Set control // Disable
|
||||||
// extension command 2 partII
|
// extension command 2 partII
|
||||||
|
|
||||||
i8080.send(0x11, 0, &[]).unwrap(); // ExitSleepMode
|
i8080.send(0x11, 0, &[]).unwrap(); // ExitSleepMode
|
||||||
delay.delay_us(130_000u32);
|
delay.delay_micros(130_000u32);
|
||||||
i8080.send(0x38, 0, &[]).unwrap(); // ExitIdleMode
|
i8080.send(0x38, 0, &[]).unwrap(); // ExitIdleMode
|
||||||
i8080.send(0x29, 0, &[]).unwrap(); // SetDisplayOn
|
i8080.send(0x29, 0, &[]).unwrap(); // SetDisplayOn
|
||||||
|
|
||||||
@ -239,10 +241,10 @@ fn main() -> ! {
|
|||||||
transfer.wait().unwrap();
|
transfer.wait().unwrap();
|
||||||
}
|
}
|
||||||
|
|
||||||
delay.delay_ms(1_000u32);
|
delay.delay_millis(1_000u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
delay.delay_ms(1_000u32);
|
delay.delay_millis(1_000u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,10 +6,12 @@
|
|||||||
//! Make sure to first compile the `esp-lp-hal/examples/uart.rs` example
|
//! Make sure to first compile the `esp-lp-hal/examples/uart.rs` example
|
||||||
|
|
||||||
//% CHIPS: esp32c6
|
//% CHIPS: esp32c6
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::serial::Read;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
//! second core.
|
//! second core.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32s3
|
//% CHIPS: esp32 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -11,6 +12,7 @@
|
|||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
|
use embedded_hal_02::timer::CountDown;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -57,13 +57,13 @@ fn main() -> ! {
|
|||||||
let mut buffer = rx_buffer;
|
let mut buffer = rx_buffer;
|
||||||
buffer.fill(0u8);
|
buffer.fill(0u8);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let transfer = parl_io_rx.read_dma(&mut buffer).unwrap();
|
let transfer = parl_io_rx.read_dma(&mut buffer).unwrap();
|
||||||
transfer.wait().unwrap();
|
transfer.wait().unwrap();
|
||||||
println!("Received: {:02x?} ...", &buffer[..30]);
|
println!("Received: {:02x?} ...", &buffer[..30]);
|
||||||
|
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -80,13 +80,13 @@ fn main() -> ! {
|
|||||||
buffer[i] = (i % 255) as u8;
|
buffer[i] = (i % 255) as u8;
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let transfer = parl_io_tx.write_dma(&buffer).unwrap();
|
let transfer = parl_io_tx.write_dma(&buffer).unwrap();
|
||||||
transfer.wait().unwrap();
|
transfer.wait().unwrap();
|
||||||
println!("Transferred {} bytes", buffer.len());
|
println!("Transferred {} bytes", buffer.len());
|
||||||
|
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,12 +13,7 @@ extern crate alloc;
|
|||||||
use alloc::{string::String, vec::Vec};
|
use alloc::{string::String, vec::Vec};
|
||||||
|
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, psram};
|
||||||
clock::{ClockControl, CpuClock},
|
|
||||||
peripherals::Peripherals,
|
|
||||||
prelude::*,
|
|
||||||
psram,
|
|
||||||
};
|
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
|
|
||||||
#[global_allocator]
|
#[global_allocator]
|
||||||
|
@ -93,7 +93,7 @@ fn main() -> ! {
|
|||||||
DmaPriority::Priority0,
|
DmaPriority::Priority0,
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
// DMA buffer require a static life-time
|
// DMA buffer require a static life-time
|
||||||
let (zero_buf, _, _, _) = dma_buffers!(0);
|
let (zero_buf, _, _, _) = dma_buffers!(0);
|
||||||
@ -111,7 +111,7 @@ fn main() -> ! {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
transfer.wait().unwrap();
|
transfer.wait().unwrap();
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// erase sector
|
// erase sector
|
||||||
let transfer = spi
|
let transfer = spi
|
||||||
@ -124,7 +124,7 @@ fn main() -> ! {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
transfer.wait().unwrap();
|
transfer.wait().unwrap();
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// write enable
|
// write enable
|
||||||
let transfer = spi
|
let transfer = spi
|
||||||
@ -137,7 +137,7 @@ fn main() -> ! {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
transfer.wait().unwrap();
|
transfer.wait().unwrap();
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// write data / program page
|
// write data / program page
|
||||||
send.fill(b'!');
|
send.fill(b'!');
|
||||||
@ -152,7 +152,7 @@ fn main() -> ! {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
transfer.wait().unwrap();
|
transfer.wait().unwrap();
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// quad fast read
|
// quad fast read
|
||||||
@ -181,6 +181,6 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
println!();
|
println!();
|
||||||
|
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,10 +12,12 @@
|
|||||||
//! We can also run code from RTC memory.
|
//! We can also run code from RTC memory.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::timer::CountDown;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -2,10 +2,12 @@
|
|||||||
//! Connect GPIO5 to GPIO4
|
//! Connect GPIO5 to GPIO4
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::digital::v2::OutputPin;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
@ -54,7 +56,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
let mut data = [PulseCode {
|
let mut data = [PulseCode {
|
||||||
level1: true,
|
level1: true,
|
||||||
@ -74,9 +76,9 @@ fn main() -> ! {
|
|||||||
// simulate input
|
// simulate input
|
||||||
for i in 0u32..5u32 {
|
for i in 0u32..5u32 {
|
||||||
out.set_high().unwrap();
|
out.set_high().unwrap();
|
||||||
delay.delay_us(i * 10 + 20);
|
delay.delay_micros(i * 10 + 20);
|
||||||
out.set_low().unwrap();
|
out.set_low().unwrap();
|
||||||
delay.delay_us(i * 20 + 20);
|
delay.delay_micros(i * 20 + 20);
|
||||||
}
|
}
|
||||||
|
|
||||||
match transaction.wait() {
|
match transaction.wait() {
|
||||||
@ -125,6 +127,6 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
delay.delay_ms(1500u32);
|
delay.delay_millis(1500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let mut channel = rmt.channel0.configure(io.pins.gpio4, tx_config).unwrap();
|
let mut channel = rmt.channel0.configure(io.pins.gpio4, tx_config).unwrap();
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
let mut data = [PulseCode {
|
let mut data = [PulseCode {
|
||||||
level1: true,
|
level1: true,
|
||||||
@ -62,6 +62,6 @@ fn main() -> ! {
|
|||||||
loop {
|
loop {
|
||||||
let transaction = channel.transmit(&data);
|
let transaction = channel.transmit(&data);
|
||||||
channel = transaction.wait().unwrap();
|
channel = transaction.wait().unwrap();
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
//! Demonstrates the use of the hardware Random Number Generator (RNG)
|
//! Demonstrates the use of the hardware Random Number Generator (RNG)
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::blocking::rng::Read;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{peripherals::Peripherals, prelude::*, rng::Rng};
|
use esp_hal::{peripherals::Peripherals, prelude::*, rng::Rng};
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
|
@ -21,10 +21,10 @@ fn main() -> ! {
|
|||||||
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
|
let clocks = ClockControl::boot_defaults(system.clock_control).freeze();
|
||||||
|
|
||||||
let rtc = Rtc::new(peripherals.LPWR);
|
let rtc = Rtc::new(peripherals.LPWR);
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
esp_println::println!("rtc time in milliseconds is {}", rtc.get_time_ms());
|
esp_println::println!("rtc time in milliseconds is {}", rtc.get_time_ms());
|
||||||
delay.delay_ms(1000u32);
|
delay.delay_millis(1000u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,6 +5,7 @@
|
|||||||
//! to reset both the main system and the RTC.
|
//! to reset both the main system and the RTC.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -12,6 +13,7 @@
|
|||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
|
use embedded_hal_02::watchdog::WatchdogEnable;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
interrupt::{self, Priority},
|
interrupt::{self, Priority},
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
//! espflash won't work)
|
//! espflash won't work)
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -10,6 +11,7 @@
|
|||||||
use core::{cell::RefCell, fmt::Write};
|
use core::{cell::RefCell, fmt::Write};
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
|
use embedded_hal_02::{serial::Read, timer::CountDown};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -36,6 +36,6 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let timer = TimerWakeupSource::new(Duration::from_secs(5));
|
let timer = TimerWakeupSource::new(Duration::from_secs(5));
|
||||||
println!("sleeping!");
|
println!("sleeping!");
|
||||||
delay.delay_ms(100u32);
|
delay.delay_millis(100u32);
|
||||||
rtc.sleep_deep(&[&timer], &mut delay);
|
rtc.sleep_deep(&[&timer], &mut delay);
|
||||||
}
|
}
|
||||||
|
@ -48,6 +48,6 @@ fn main() -> ! {
|
|||||||
let timer = TimerWakeupSource::new(Duration::from_secs(30));
|
let timer = TimerWakeupSource::new(Duration::from_secs(30));
|
||||||
let ext0 = Ext0WakeupSource::new(&mut ext0_pin, WakeupLevel::High);
|
let ext0 = Ext0WakeupSource::new(&mut ext0_pin, WakeupLevel::High);
|
||||||
println!("sleeping!");
|
println!("sleeping!");
|
||||||
delay.delay_ms(100u32);
|
delay.delay_millis(100u32);
|
||||||
rtc.sleep_deep(&[&timer, &ext0], &mut delay);
|
rtc.sleep_deep(&[&timer, &ext0], &mut delay);
|
||||||
}
|
}
|
||||||
|
@ -50,6 +50,6 @@ fn main() -> ! {
|
|||||||
let mut wakeup_pins: [&mut dyn RTCPin; 2] = [&mut pin_0, &mut pin_2];
|
let mut wakeup_pins: [&mut dyn RTCPin; 2] = [&mut pin_0, &mut pin_2];
|
||||||
let ext1 = Ext1WakeupSource::new(&mut wakeup_pins, WakeupLevel::High);
|
let ext1 = Ext1WakeupSource::new(&mut wakeup_pins, WakeupLevel::High);
|
||||||
println!("sleeping!");
|
println!("sleeping!");
|
||||||
delay.delay_ms(100u32);
|
delay.delay_millis(100u32);
|
||||||
rtc.sleep_deep(&[&timer, &ext1], &mut delay);
|
rtc.sleep_deep(&[&timer, &ext1], &mut delay);
|
||||||
}
|
}
|
||||||
|
@ -54,6 +54,6 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let rtcio = Ext1WakeupSource::new(wakeup_pins);
|
let rtcio = Ext1WakeupSource::new(wakeup_pins);
|
||||||
println!("sleeping!");
|
println!("sleeping!");
|
||||||
delay.delay_ms(100u32);
|
delay.delay_millis(100u32);
|
||||||
rtc.sleep_deep(&[&timer, &rtcio], &mut delay);
|
rtc.sleep_deep(&[&timer, &rtcio], &mut delay);
|
||||||
}
|
}
|
||||||
|
@ -58,6 +58,6 @@ fn main() -> ! {
|
|||||||
|
|
||||||
let rtcio = RtcioWakeupSource::new(wakeup_pins);
|
let rtcio = RtcioWakeupSource::new(wakeup_pins);
|
||||||
println!("sleeping!");
|
println!("sleeping!");
|
||||||
delay.delay_ms(100u32);
|
delay.delay_millis(100u32);
|
||||||
rtc.sleep_deep(&[&timer, &rtcio], &mut delay);
|
rtc.sleep_deep(&[&timer, &rtcio], &mut delay);
|
||||||
}
|
}
|
||||||
|
@ -38,11 +38,11 @@ fn main() -> ! {
|
|||||||
interrupt::enable(Interrupt::FROM_CPU_INTR2, Priority::Priority3).unwrap();
|
interrupt::enable(Interrupt::FROM_CPU_INTR2, Priority::Priority3).unwrap();
|
||||||
interrupt::enable(Interrupt::FROM_CPU_INTR3, Priority::Priority3).unwrap();
|
interrupt::enable(Interrupt::FROM_CPU_INTR3, Priority::Priority3).unwrap();
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
let mut counter = 0;
|
let mut counter = 0;
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
match counter {
|
match counter {
|
||||||
0 => critical_section::with(|cs| {
|
0 => critical_section::with(|cs| {
|
||||||
SWINT
|
SWINT
|
||||||
|
@ -24,7 +24,7 @@
|
|||||||
//! data.
|
//! data.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
//% FEATURES: eh1
|
//% FEATURES: embedded-hal
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -79,7 +79,7 @@ fn main() -> ! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
println!("=== SPI example with embedded-hal-1 traits ===");
|
println!("=== SPI example with embedded-hal-1 traits ===");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
@ -93,7 +93,7 @@ fn main() -> ! {
|
|||||||
spi_device_2.transfer(&mut read[..], &write[..]).unwrap();
|
spi_device_2.transfer(&mut read[..], &write[..]).unwrap();
|
||||||
spi_device_3.transfer(&mut read[..], &write[..]).unwrap();
|
spi_device_3.transfer(&mut read[..], &write[..]).unwrap();
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// --- Asymmetric transfer (Read more than we write) ---
|
// --- Asymmetric transfer (Read more than we write) ---
|
||||||
print!("Starting asymetric transfer (read > write)...");
|
print!("Starting asymetric transfer (read > write)...");
|
||||||
@ -111,7 +111,7 @@ fn main() -> ! {
|
|||||||
.transfer(&mut read[0..2], &write[..])
|
.transfer(&mut read[0..2], &write[..])
|
||||||
.expect("Asymmetric transfer failed");
|
.expect("Asymmetric transfer failed");
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// --- Symmetric transfer with huge buffer ---
|
// --- Symmetric transfer with huge buffer ---
|
||||||
// Only your RAM is the limit!
|
// Only your RAM is the limit!
|
||||||
@ -133,7 +133,7 @@ fn main() -> ! {
|
|||||||
.transfer(&mut read[..], &write[..])
|
.transfer(&mut read[..], &write[..])
|
||||||
.expect("Huge transfer failed");
|
.expect("Huge transfer failed");
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// --- Symmetric transfer with huge buffer in-place (No additional allocation
|
// --- Symmetric transfer with huge buffer in-place (No additional allocation
|
||||||
// needed) ---
|
// needed) ---
|
||||||
@ -156,6 +156,6 @@ fn main() -> ! {
|
|||||||
.transfer_in_place(&mut write[..])
|
.transfer_in_place(&mut write[..])
|
||||||
.expect("Huge transfer failed");
|
.expect("Huge transfer failed");
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
//! data.
|
//! data.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
//% FEATURES: eh1
|
//% FEATURES: embedded-hal
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -50,7 +50,7 @@ fn main() -> ! {
|
|||||||
Some(cs),
|
Some(cs),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
println!("=== SPI example with embedded-hal-1 traits ===");
|
println!("=== SPI example with embedded-hal-1 traits ===");
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
@ -62,7 +62,7 @@ fn main() -> ! {
|
|||||||
SpiBus::transfer(&mut spi, &mut read[..], &write[..]).expect("Symmetric transfer failed");
|
SpiBus::transfer(&mut spi, &mut read[..], &write[..]).expect("Symmetric transfer failed");
|
||||||
assert_eq!(write, read);
|
assert_eq!(write, read);
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// --- Asymmetric transfer (Read more than we write) ---
|
// --- Asymmetric transfer (Read more than we write) ---
|
||||||
print!("Starting asymetric transfer (read > write)...");
|
print!("Starting asymetric transfer (read > write)...");
|
||||||
@ -73,7 +73,7 @@ fn main() -> ! {
|
|||||||
assert_eq!(write[0], read[0]);
|
assert_eq!(write[0], read[0]);
|
||||||
assert_eq!(read[2], 0x00u8);
|
assert_eq!(read[2], 0x00u8);
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// --- Symmetric transfer with huge buffer ---
|
// --- Symmetric transfer with huge buffer ---
|
||||||
// Only your RAM is the limit!
|
// Only your RAM is the limit!
|
||||||
@ -87,7 +87,7 @@ fn main() -> ! {
|
|||||||
SpiBus::transfer(&mut spi, &mut read[..], &write[..]).expect("Huge transfer failed");
|
SpiBus::transfer(&mut spi, &mut read[..], &write[..]).expect("Huge transfer failed");
|
||||||
assert_eq!(write, read);
|
assert_eq!(write, read);
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// --- Symmetric transfer with huge buffer in-place (No additional allocation
|
// --- Symmetric transfer with huge buffer in-place (No additional allocation
|
||||||
// needed) ---
|
// needed) ---
|
||||||
@ -102,6 +102,6 @@ fn main() -> ! {
|
|||||||
assert_eq!(write[byte], byte as u8);
|
assert_eq!(write[byte], byte as u8);
|
||||||
}
|
}
|
||||||
println!(" SUCCESS");
|
println!(" SUCCESS");
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -77,7 +77,7 @@ fn main() -> ! {
|
|||||||
Some(cs),
|
Some(cs),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
// READ MANUFACTURER ID FROM FLASH CHIP
|
// READ MANUFACTURER ID FROM FLASH CHIP
|
||||||
@ -91,7 +91,7 @@ fn main() -> ! {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("Single {:x?}", data);
|
println!("Single {:x?}", data);
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// READ MANUFACTURER ID FROM FLASH CHIP
|
// READ MANUFACTURER ID FROM FLASH CHIP
|
||||||
let mut data = [0u8; 2];
|
let mut data = [0u8; 2];
|
||||||
@ -104,7 +104,7 @@ fn main() -> ! {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("Dual {:x?}", data);
|
println!("Dual {:x?}", data);
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
// READ MANUFACTURER ID FROM FLASH CHIP
|
// READ MANUFACTURER ID FROM FLASH CHIP
|
||||||
let mut data = [0u8; 2];
|
let mut data = [0u8; 2];
|
||||||
@ -117,6 +117,6 @@ fn main() -> ! {
|
|||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
println!("Quad {:x?}", data);
|
println!("Quad {:x?}", data);
|
||||||
delay.delay_ms(1500u32);
|
delay.delay_millis(1500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,10 +14,12 @@
|
|||||||
//! data.
|
//! data.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::blocking::spi::Transfer;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
@ -48,13 +50,13 @@ fn main() -> ! {
|
|||||||
Some(cs),
|
Some(cs),
|
||||||
);
|
);
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
let mut data = [0xde, 0xca, 0xfb, 0xad];
|
let mut data = [0xde, 0xca, 0xfb, 0xad];
|
||||||
spi.transfer(&mut data).unwrap();
|
spi.transfer(&mut data).unwrap();
|
||||||
println!("{:x?}", data);
|
println!("{:x?}", data);
|
||||||
|
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,7 +64,7 @@ fn main() -> ! {
|
|||||||
DmaPriority::Priority0,
|
DmaPriority::Priority0,
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
// DMA buffer require a static life-time
|
// DMA buffer require a static life-time
|
||||||
let mut send = tx_buffer;
|
let mut send = tx_buffer;
|
||||||
@ -86,7 +86,7 @@ fn main() -> ! {
|
|||||||
// Check is_done until the transfer is almost done (32000 bytes at 100kHz is
|
// Check is_done until the transfer is almost done (32000 bytes at 100kHz is
|
||||||
// 2.56 seconds), then move to wait().
|
// 2.56 seconds), then move to wait().
|
||||||
while !transfer.is_done() && n < 10 {
|
while !transfer.is_done() && n < 10 {
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
n += 1;
|
n += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,6 +97,6 @@ fn main() -> ! {
|
|||||||
&receive[receive.len() - 10..]
|
&receive[receive.len() - 10..]
|
||||||
);
|
);
|
||||||
|
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,10 +24,12 @@
|
|||||||
//! so no immediate neighbor is available.
|
//! so no immediate neighbor is available.
|
||||||
|
|
||||||
//% CHIPS: esp32c2 esp32c3 esp32c6 esp32h2 esp32s3
|
//% CHIPS: esp32c2 esp32c3 esp32c6 esp32h2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::digital::v2::{InputPin, OutputPin};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
@ -83,7 +85,7 @@ fn main() -> ! {
|
|||||||
DmaPriority::Priority0,
|
DmaPriority::Priority0,
|
||||||
));
|
));
|
||||||
|
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
// DMA buffer require a static life-time
|
// DMA buffer require a static life-time
|
||||||
let master_send = &mut [0u8; 32000];
|
let master_send = &mut [0u8; 32000];
|
||||||
@ -149,7 +151,7 @@ fn main() -> ! {
|
|||||||
&master_receive[master_receive.len() - 10..]
|
&master_receive[master_receive.len() - 10..]
|
||||||
);
|
);
|
||||||
|
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
|
|
||||||
slave_receive.fill(0xff);
|
slave_receive.fill(0xff);
|
||||||
let transfer = spi.dma_read(&mut slave_receive).unwrap();
|
let transfer = spi.dma_read(&mut slave_receive).unwrap();
|
||||||
@ -177,7 +179,7 @@ fn main() -> ! {
|
|||||||
&slave_receive[slave_receive.len() - 10..],
|
&slave_receive[slave_receive.len() - 10..],
|
||||||
);
|
);
|
||||||
|
|
||||||
delay.delay_ms(250u32);
|
delay.delay_millis(250u32);
|
||||||
let transfer = spi.dma_write(&mut slave_send).unwrap();
|
let transfer = spi.dma_write(&mut slave_send).unwrap();
|
||||||
|
|
||||||
master_receive.fill(0);
|
master_receive.fill(0);
|
||||||
|
@ -59,10 +59,10 @@ fn main() -> ! {
|
|||||||
|
|
||||||
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
// Initialize the Delay peripheral, and use it to toggle the LED state in a
|
||||||
// loop.
|
// loop.
|
||||||
let mut delay = Delay::new(&clocks);
|
let delay = Delay::new(&clocks);
|
||||||
|
|
||||||
loop {
|
loop {
|
||||||
delay.delay_ms(500u32);
|
delay.delay_millis(500u32);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
//! There is TIMG0 which contains a general purpose timer and a watchdog timer.
|
//! There is TIMG0 which contains a general purpose timer and a watchdog timer.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -10,6 +11,7 @@
|
|||||||
use core::cell::RefCell;
|
use core::cell::RefCell;
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
|
use embedded_hal_02::timer::CountDown;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -18,14 +18,14 @@
|
|||||||
|
|
||||||
const IS_FIRST_SENDER: bool = true;
|
const IS_FIRST_SENDER: bool = true;
|
||||||
|
|
||||||
// Run this example with the eh1 feature enabled to use embedded-can instead of
|
// Run this example with the embedded-hal feature enabled to use embedded-can instead of
|
||||||
// embedded-hal-0.2.7. embedded-can was split off from embedded-hal before it's
|
// embedded-hal-0.2.7. embedded-can was split off from embedded-hal before it's
|
||||||
// upgrade to 1.0.0. cargo run --example twai --features eh1 --release
|
// upgrade to 1.0.0. cargo run --example twai --features embedded-hal --release
|
||||||
#[cfg(feature = "eh1")]
|
#[cfg(feature = "embedded-hal")]
|
||||||
use embedded_can::{nb::Can, Frame, StandardId};
|
use embedded_can::{nb::Can, Frame, StandardId};
|
||||||
// Run this example without the eh1 flag to use the embedded-hal 0.2.7 CAN traits.
|
// Run this example without the embedded-hal flag to use the embedded-hal 0.2.7 CAN traits.
|
||||||
// cargo run --example twai --release
|
// cargo run --example twai --release
|
||||||
#[cfg(not(feature = "eh1"))]
|
#[cfg(not(feature = "embedded-hal"))]
|
||||||
use embedded_hal_02::can::{Can, Frame, StandardId};
|
use embedded_hal_02::can::{Can, Frame, StandardId};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
//! Most dev-kits use a USB-UART-bridge - in that case you won't see any output.
|
//! Most dev-kits use a USB-UART-bridge - in that case you won't see any output.
|
||||||
|
|
||||||
//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s3
|
//% CHIPS: esp32c3 esp32c6 esp32h2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
@ -11,6 +12,7 @@
|
|||||||
use core::{cell::RefCell, fmt::Write};
|
use core::{cell::RefCell, fmt::Write};
|
||||||
|
|
||||||
use critical_section::Mutex;
|
use critical_section::Mutex;
|
||||||
|
use embedded_hal_02::timer::CountDown;
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{
|
use esp_hal::{
|
||||||
clock::ClockControl,
|
clock::ClockControl,
|
||||||
|
@ -4,10 +4,15 @@
|
|||||||
//! `wdt.feed()` the watchdog will reset the system.
|
//! `wdt.feed()` the watchdog will reset the system.
|
||||||
|
|
||||||
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
//% CHIPS: esp32 esp32c2 esp32c3 esp32c6 esp32h2 esp32s2 esp32s3
|
||||||
|
//% FEATURES: embedded-hal-02
|
||||||
|
|
||||||
#![no_std]
|
#![no_std]
|
||||||
#![no_main]
|
#![no_main]
|
||||||
|
|
||||||
|
use embedded_hal_02::{
|
||||||
|
timer::CountDown,
|
||||||
|
watchdog::{Watchdog, WatchdogEnable},
|
||||||
|
};
|
||||||
use esp_backtrace as _;
|
use esp_backtrace as _;
|
||||||
use esp_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup};
|
use esp_hal::{clock::ClockControl, peripherals::Peripherals, prelude::*, timer::TimerGroup};
|
||||||
use esp_println::println;
|
use esp_println::println;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user