Skip to content

Commit 778241f

Browse files
committed
Fix CI, rename private feature, address comments from dirbaio.
1 parent 9dc4375 commit 778241f

File tree

15 files changed

+112
-89
lines changed

15 files changed

+112
-89
lines changed

embassy-rp/Cargo.toml

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ src_base = "https://github.com/embassy-rs/embassy/blob/embassy-rp-v$VERSION/emba
1414
src_base_git = "https://github.com/embassy-rs/embassy/blob/$COMMIT/embassy-rp/src/"
1515
features = ["defmt", "unstable-pac", "time-driver"]
1616
flavors = [
17-
{ name = "rp2040", target = "thumbv6m-none-eabi" },
18-
{ name = "rp235x", target = "thumbv8m.main-none-eabi" },
17+
{ name = "rp2040", target = "thumbv6m-none-eabi", features = ["rp2040"] },
18+
{ name = "rp235xa", target = "thumbv8m.main-none-eabi", features = ["rp235xa"] },
19+
{ name = "rp235xb", target = "thumbv8m.main-none-eabi", features = ["rp235xb"] },
1920
]
2021

2122
[package.metadata.docs.rs]
@@ -89,10 +90,13 @@ boot2-w25x10cl = []
8990
## ```
9091
boot2-none = []
9192

93+
## Configure the hal for use with the rp2040
9294
rp2040 = ["rp-pac/rp2040"]
93-
rp235x = ["rp-pac/rp235x"]
94-
rp235xa = ["rp235x"]
95-
rp235xb = ["rp235x"]
95+
_rp235x = ["rp-pac/rp235x"]
96+
## Configure the hal for use with the rp235xA
97+
rp235xa = ["_rp235x"]
98+
## Configure the hal for use with the rp235xB
99+
rp235xb = ["_rp235x"]
96100

97101
# Add a binary-info header block containing picotool-compatible metadata.
98102
#

embassy-rp/src/adc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ impl<'p> Channel<'p> {
3535
pub fn new_pin(pin: impl Peripheral<P = impl AdcPin + 'p> + 'p, pull: Pull) -> Self {
3636
into_ref!(pin);
3737
pin.pad_ctrl().modify(|w| {
38-
#[cfg(feature = "rp235x")]
38+
#[cfg(feature = "_rp235x")]
3939
w.set_iso(false);
4040
// manual says:
4141
//
@@ -234,7 +234,7 @@ impl<'d> Adc<'d, Async> {
234234
) -> Result<(), Error> {
235235
#[cfg(feature = "rp2040")]
236236
let mut rrobin = 0_u8;
237-
#[cfg(feature = "rp235x")]
237+
#[cfg(feature = "_rp235x")]
238238
let mut rrobin = 0_u16;
239239
for c in channels {
240240
rrobin |= 1 << c;

embassy-rp/src/binary_info/mod.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,12 @@
44
//! and "rt" features:
55
//!
66
//! ```
7-
//! # use rp235x_hal as hal;
87
//! #[link_section = ".bi_entries"]
98
//! #[used]
10-
//! pub static PICOTOOL_ENTRIES: [hal::binary_info::EntryAddr; 3] = [
11-
//! hal::binary_info_rp_program_name!(c"Program Name Here"),
12-
//! hal::binary_info_rp_cargo_version!(),
13-
//! hal::binary_info_int!(hal::binary_info::make_tag(b"JP"), 0x0000_0001, 0x12345678),
9+
//! pub static PICOTOOL_ENTRIES: [embassy_rp::binary_info::EntryAddr; 3] = [
10+
//! embassy_rp::binary_info_rp_program_name!(c"Program Name Here"),
11+
//! embassy_rp::binary_info_rp_cargo_version!(),
12+
//! embassy_rp::binary_info_int!(embassy_rp::binary_info::make_tag(b"JP"), 0x0000_0001, 0x12345678),
1413
//! ];
1514
//! ```
1615
@@ -163,8 +162,7 @@ pub const fn rp_boot2_name(value: &'static core::ffi::CStr) -> StringEntry {
163162
/// Create a tag from two ASCII letters.
164163
///
165164
/// ```
166-
/// # use rp235x_hal as hal;
167-
/// let tag = hal::binary_info::make_tag(b"RP");
165+
/// let tag = embassy_rp::binary_info::make_tag(b"RP");
168166
/// assert_eq!(tag, 0x5052);
169167
/// ```
170168
pub const fn make_tag(c: &[u8; 2]) -> u16 {

embassy-rp/src/clocks.rs

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,10 +311,10 @@ pub struct SysClkConfig {
311311
#[cfg(feature = "rp2040")]
312312
pub div_frac: u8,
313313
/// SYS clock divider.
314-
#[cfg(feature = "rp235x")]
314+
#[cfg(feature = "_rp235x")]
315315
pub div_int: u16,
316316
/// SYS clock fraction.
317-
#[cfg(feature = "rp235x")]
317+
#[cfg(feature = "_rp235x")]
318318
pub div_frac: u16,
319319
}
320320

@@ -430,12 +430,12 @@ pub(crate) unsafe fn init(config: ClockConfig) {
430430
c.clk_sys_ctrl().modify(|w| w.set_src(ClkSysCtrlSrc::CLK_REF));
431431
#[cfg(feature = "rp2040")]
432432
while c.clk_sys_selected().read() != 1 {}
433-
#[cfg(feature = "rp235x")]
433+
#[cfg(feature = "_rp235x")]
434434
while c.clk_sys_selected().read() != pac::clocks::regs::ClkSysSelected(1) {}
435435
c.clk_ref_ctrl().modify(|w| w.set_src(ClkRefCtrlSrc::ROSC_CLKSRC_PH));
436436
#[cfg(feature = "rp2040")]
437437
while c.clk_ref_selected().read() != 1 {}
438-
#[cfg(feature = "rp235x")]
438+
#[cfg(feature = "_rp235x")]
439439
while c.clk_ref_selected().read() != pac::clocks::regs::ClkRefSelected(1) {}
440440

441441
// Reset the PLLs
@@ -506,7 +506,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
506506
});
507507
#[cfg(feature = "rp2040")]
508508
while c.clk_ref_selected().read() != (1 << ref_src as u32) {}
509-
#[cfg(feature = "rp235x")]
509+
#[cfg(feature = "_rp235x")]
510510
while c.clk_ref_selected().read() != pac::clocks::regs::ClkRefSelected(1 << ref_src as u32) {}
511511
c.clk_ref_div().write(|w| {
512512
w.set_int(config.ref_clk.div);
@@ -539,7 +539,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
539539
c.clk_sys_ctrl().write(|w| w.set_src(ClkSysCtrlSrc::CLK_REF));
540540
#[cfg(feature = "rp2040")]
541541
while c.clk_sys_selected().read() != (1 << ClkSysCtrlSrc::CLK_REF as u32) {}
542-
#[cfg(feature = "rp235x")]
542+
#[cfg(feature = "_rp235x")]
543543
while c.clk_sys_selected().read() != pac::clocks::regs::ClkSysSelected(1 << ClkSysCtrlSrc::CLK_REF as u32) {}
544544
}
545545
c.clk_sys_ctrl().write(|w| {
@@ -549,7 +549,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
549549

550550
#[cfg(feature = "rp2040")]
551551
while c.clk_sys_selected().read() != (1 << sys_src as u32) {}
552-
#[cfg(feature = "rp235x")]
552+
#[cfg(feature = "_rp235x")]
553553
while c.clk_sys_selected().read() != pac::clocks::regs::ClkSysSelected(1 << sys_src as u32) {}
554554

555555
c.clk_sys_div().write(|w| {
@@ -661,7 +661,7 @@ pub(crate) unsafe fn init(config: ClockConfig) {
661661
}
662662

663663
// rp235x specific clocks
664-
#[cfg(feature = "rp235x")]
664+
#[cfg(feature = "_rp235x")]
665665
{
666666
// TODO hstx clock
667667
peris.set_hstx(false);
@@ -903,7 +903,8 @@ pub enum GpoutSrc {
903903
/// ADC.
904904
Adc = ClkGpoutCtrlAuxsrc::CLK_ADC as _,
905905
// RTC.
906-
//Rtc = ClkGpoutCtrlAuxsrc::CLK_RTC as _,
906+
#[cfg(feature = "rp2040")]
907+
Rtc = ClkGpoutCtrlAuxsrc::CLK_RTC as _,
907908
/// REF.
908909
Ref = ClkGpoutCtrlAuxsrc::CLK_REF as _,
909910
}
@@ -934,7 +935,7 @@ impl<'d, T: GpoutPin> Gpout<'d, T> {
934935
}
935936

936937
/// Set clock divider.
937-
#[cfg(feature = "rp235x")]
938+
#[cfg(feature = "_rp235x")]
938939
pub fn set_div(&self, int: u16, frac: u16) {
939940
let c = pac::CLOCKS;
940941
c.clk_gpout_div(self.gpout.number()).write(|w| {

embassy-rp/src/dma.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ fn copy_inner<'a, C: Channel>(
147147
p.trans_count().write(|w| {
148148
*w = len as u32;
149149
});
150-
#[cfg(feature = "rp235x")]
150+
#[cfg(feature = "_rp235x")]
151151
p.trans_count().write(|w| {
152152
w.set_mode(0.into());
153153
w.set_count(len as u32);
@@ -208,7 +208,10 @@ impl<'a, C: Channel> Future for Transfer<'a, C> {
208208
}
209209
}
210210

211+
#[cfg(feature = "rp2040")]
211212
pub(crate) const CHANNEL_COUNT: usize = 12;
213+
#[cfg(feature = "_rp235x")]
214+
pub(crate) const CHANNEL_COUNT: usize = 16;
212215
const NEW_AW: AtomicWaker = AtomicWaker::new();
213216
static CHANNEL_WAKERS: [AtomicWaker; CHANNEL_COUNT] = [NEW_AW; CHANNEL_COUNT];
214217

@@ -303,11 +306,11 @@ channel!(DMA_CH8, 8);
303306
channel!(DMA_CH9, 9);
304307
channel!(DMA_CH10, 10);
305308
channel!(DMA_CH11, 11);
306-
#[cfg(feature = "rp235x")]
309+
#[cfg(feature = "_rp235x")]
307310
channel!(DMA_CH12, 12);
308-
#[cfg(feature = "rp235x")]
311+
#[cfg(feature = "_rp235x")]
309312
channel!(DMA_CH13, 13);
310-
#[cfg(feature = "rp235x")]
313+
#[cfg(feature = "_rp235x")]
311314
channel!(DMA_CH14, 14);
312-
#[cfg(feature = "rp235x")]
315+
#[cfg(feature = "_rp235x")]
313316
channel!(DMA_CH15, 15);

embassy-rp/src/flash.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -669,8 +669,10 @@ mod ram_helpers {
669669

670670
#[inline(never)]
671671
#[link_section = ".data.ram_func"]
672-
#[cfg(feature = "rp235x")]
673-
unsafe fn write_flash_inner(_addr: u32, _len: u32, _data: Option<&[u8]>, _ptrs: *const FlashFunctionPointers) {}
672+
#[cfg(feature = "_rp235x")]
673+
unsafe fn write_flash_inner(_addr: u32, _len: u32, _data: Option<&[u8]>, _ptrs: *const FlashFunctionPointers) {
674+
todo!();
675+
}
674676

675677
#[repr(C)]
676678
struct FlashCommand {
@@ -891,8 +893,10 @@ mod ram_helpers {
891893

892894
#[inline(never)]
893895
#[link_section = ".data.ram_func"]
894-
#[cfg(feature = "rp235x")]
895-
unsafe fn read_flash_inner(_cmd: FlashCommand, _ptrs: *const FlashFunctionPointers) {}
896+
#[cfg(feature = "_rp235x")]
897+
unsafe fn read_flash_inner(_cmd: FlashCommand, _ptrs: *const FlashFunctionPointers) {
898+
todo!();
899+
}
896900
}
897901

898902
/// Make sure to uphold the contract points with rp2040-flash.
@@ -906,7 +910,7 @@ pub(crate) unsafe fn in_ram(operation: impl FnOnce()) -> Result<(), Error> {
906910
}
907911

908912
// Make sure CORE1 is paused during the entire duration of the RAM function
909-
//crate::multicore::pause_core1();
913+
crate::multicore::pause_core1();
910914

911915
critical_section::with(|_| {
912916
// Wait for all DMA channels in flash to finish before ram operation

embassy-rp/src/gpio.rs

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,12 @@ use crate::pac::SIO;
1414
use crate::{interrupt, pac, peripherals, Peripheral, RegExt};
1515

1616
const NEW_AW: AtomicWaker = AtomicWaker::new();
17+
18+
#[cfg(any(feature = "rp2040", feature = "rp235xa"))]
1719
const BANK0_PIN_COUNT: usize = 30;
20+
#[cfg(feature = "rp235xb")]
21+
const BANK0_PIN_COUNT: usize = 48;
22+
1823
static BANK0_WAKERS: [AtomicWaker; BANK0_PIN_COUNT] = [NEW_AW; BANK0_PIN_COUNT];
1924
#[cfg(feature = "qspi-as-gpio")]
2025
const QSPI_PIN_COUNT: usize = 6;
@@ -180,7 +185,7 @@ impl<'d> Input<'d> {
180185
}
181186

182187
/// Set the pin's pad isolation
183-
#[cfg(feature = "rp235x")]
188+
#[cfg(feature = "_rp235x")]
184189
#[inline]
185190
pub fn set_pad_isolation(&mut self, isolate: bool) {
186191
self.pin.set_pad_isolation(isolate)
@@ -422,7 +427,7 @@ impl<'d> Output<'d> {
422427
}
423428

424429
/// Set the pin's pad isolation
425-
#[cfg(feature = "rp235x")]
430+
#[cfg(feature = "_rp235x")]
426431
#[inline]
427432
pub fn set_pad_isolation(&mut self, isolate: bool) {
428433
self.pin.set_pad_isolation(isolate)
@@ -555,7 +560,7 @@ impl<'d> OutputOpenDrain<'d> {
555560
}
556561

557562
/// Set the pin's pad isolation
558-
#[cfg(feature = "rp235x")]
563+
#[cfg(feature = "_rp235x")]
559564
#[inline]
560565
pub fn set_pad_isolation(&mut self, isolate: bool) {
561566
self.pin.set_pad_isolation(isolate)
@@ -581,15 +586,15 @@ impl<'d> Flex<'d> {
581586
into_ref!(pin);
582587

583588
pin.pad_ctrl().write(|w| {
584-
#[cfg(feature = "rp235x")]
589+
#[cfg(feature = "_rp235x")]
585590
w.set_iso(false);
586591
w.set_ie(true);
587592
});
588593

589594
pin.gpio().ctrl().write(|w| {
590595
#[cfg(feature = "rp2040")]
591596
w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIO_0 as _);
592-
#[cfg(feature = "rp235x")]
597+
#[cfg(feature = "_rp235x")]
593598
w.set_funcsel(pac::io::vals::Gpio0ctrlFuncsel::SIOB_PROC_0 as _);
594599
});
595600

@@ -788,7 +793,7 @@ impl<'d> Flex<'d> {
788793
}
789794

790795
/// Set the pin's pad isolation
791-
#[cfg(feature = "rp235x")]
796+
#[cfg(feature = "_rp235x")]
792797
#[inline]
793798
pub fn set_pad_isolation(&mut self, isolate: bool) {
794799
self.pin.pad_ctrl().modify(|w| {

embassy-rp/src/i2c.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ where
363363
{
364364
pin.gpio().ctrl().write(|w| w.set_funcsel(3));
365365
pin.pad_ctrl().write(|w| {
366-
#[cfg(feature = "rp235x")]
366+
#[cfg(feature = "_rp235x")]
367367
w.set_iso(false);
368368
w.set_schmitt(true);
369369
w.set_slewfast(false);

embassy-rp/src/lib.rs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ mod critical_section_impl;
1515
mod intrinsics;
1616

1717
pub mod adc;
18-
#[cfg(feature = "rp235x")]
18+
#[cfg(feature = "_rp235x")]
1919
pub mod binary_info;
20-
#[cfg(feature = "rp235x")]
20+
#[cfg(feature = "_rp235x")]
2121
pub mod block;
2222
#[cfg(feature = "rp2040")]
2323
pub mod bootsel;
@@ -92,7 +92,7 @@ embassy_hal_internal::interrupt_mod!(
9292
SWI_IRQ_5,
9393
);
9494

95-
#[cfg(feature = "rp235x")]
95+
#[cfg(feature = "_rp235x")]
9696
embassy_hal_internal::interrupt_mod!(
9797
TIMER0_IRQ_0,
9898
TIMER0_IRQ_1,
@@ -267,7 +267,7 @@ embassy_hal_internal::peripherals! {
267267
BOOTSEL,
268268
}
269269

270-
#[cfg(feature = "rp235x")]
270+
#[cfg(feature = "_rp235x")]
271271
embassy_hal_internal::peripherals! {
272272
PIN_0,
273273
PIN_1,
@@ -497,7 +497,7 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
497497
Ok(())
498498
}
499499

500-
#[cfg(feature = "rp235x")]
500+
#[cfg(all(feature = "_rp235x", armv8m))]
501501
#[inline(always)]
502502
fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
503503
let core = unsafe { cortex_m::Peripherals::steal() };
@@ -515,6 +515,14 @@ fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
515515
Ok(())
516516
}
517517

518+
// This is to hack around cortex_m defaulting to ARMv7 when building tests,
519+
// so the compile fails when we try to use ARMv8 peripherals.
520+
#[cfg(all(feature = "_rp235x", not(armv8m)))]
521+
#[inline(always)]
522+
fn install_stack_guard(stack_bottom: *mut usize) -> Result<(), ()> {
523+
Ok(())
524+
}
525+
518526
/// HAL configuration for RP.
519527
pub mod config {
520528
use crate::clocks::ClockConfig;

embassy-rp/src/multicore.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ unsafe fn SIO_IRQ_PROC1() {
109109
}
110110
}
111111

112-
#[cfg(all(feature = "rt", feature = "rp235x"))]
112+
#[cfg(all(feature = "rt", feature = "_rp235x"))]
113113
#[interrupt]
114114
#[link_section = ".data.ram_func"]
115115
unsafe fn SIO_IRQ_FIFO() {
@@ -164,7 +164,7 @@ where
164164
unsafe {
165165
interrupt::SIO_IRQ_PROC1.enable()
166166
};
167-
#[cfg(feature = "rp235x")]
167+
#[cfg(feature = "_rp235x")]
168168
unsafe {
169169
interrupt::SIO_IRQ_FIFO.enable()
170170
};

0 commit comments

Comments
 (0)