Skip to content

Commit ff86321

Browse files
author
Jonas Schievink
committed
Update PACs and nrf-usbd
1 parent e3e9b2d commit ff86321

File tree

17 files changed

+105
-101
lines changed

17 files changed

+105
-101
lines changed

examples/usb/src/bin/serial.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use panic_semihosting as _;
66
use cortex_m_rt::entry;
77
use nrf52840_hal::clocks::Clocks;
88
use nrf52840_hal::usbd::{UsbPeripheral, Usbd};
9+
use usb_device::class_prelude::UsbBusAllocator;
910
use usb_device::device::{UsbDeviceBuilder, UsbVidPid};
1011
use usbd_serial::{SerialPort, USB_CLASS_CDC};
1112

@@ -15,7 +16,7 @@ fn main() -> ! {
1516
let clocks = Clocks::new(periph.CLOCK);
1617
let clocks = clocks.enable_ext_hfosc();
1718

18-
let usb_bus = Usbd::new(UsbPeripheral::new(periph.USBD, &clocks));
19+
let usb_bus = UsbBusAllocator::new(Usbd::new(UsbPeripheral::new(periph.USBD, &clocks)));
1920
let mut serial = SerialPort::new(&usb_bus);
2021

2122
let mut usb_dev = UsbDeviceBuilder::new(&usb_bus, UsbVidPid(0x16c0, 0x27dd))

examples/usb/src/bin/test_class.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ use panic_semihosting as _;
66
use cortex_m_rt::entry;
77
use nrf52840_hal::clocks::Clocks;
88
use nrf52840_hal::usbd::{UsbPeripheral, Usbd};
9+
use usb_device::class_prelude::UsbBusAllocator;
910
use usb_device::test_class::TestClass;
1011

1112
#[entry]
@@ -14,7 +15,7 @@ fn main() -> ! {
1415
let clocks = Clocks::new(periph.CLOCK);
1516
let clocks = clocks.enable_ext_hfosc();
1617

17-
let usb_bus = Usbd::new(UsbPeripheral::new(periph.USBD, &clocks));
18+
let usb_bus = UsbBusAllocator::new(Usbd::new(UsbPeripheral::new(periph.USBD, &clocks)));
1819

1920
let mut test = TestClass::new(&usb_bus);
2021

nrf-hal-common/Cargo.toml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -38,42 +38,42 @@ version = "0.3.0"
3838

3939
[dependencies.nrf51-pac]
4040
optional = true
41-
version = "0.11.0"
41+
version = "0.12.2"
4242

4343
[dependencies.nrf52810-pac]
4444
optional = true
45-
version = "0.11.0"
45+
version = "0.12.2"
4646

4747
[dependencies.nrf52811-pac]
4848
optional = true
49-
version = "0.11.0"
49+
version = "0.12.2"
5050

5151
[dependencies.nrf52832-pac]
5252
optional = true
53-
version = "0.11.0"
53+
version = "0.12.2"
5454

5555
[dependencies.nrf52833-pac]
5656
optional = true
57-
version = "0.11.0"
57+
version = "0.12.2"
5858

5959
[dependencies.nrf52840-pac]
6060
optional = true
61-
version = "0.11.0"
61+
version = "0.12.2"
6262

6363
[dependencies.nrf5340-app-pac]
6464
optional = true
65-
version = "0.11.0"
65+
version = "0.12.2"
6666

6767
[dependencies.nrf5340-net-pac]
6868
optional = true
69-
version = "0.11.0"
69+
version = "0.12.2"
7070

7171
[dependencies.nrf9160-pac]
7272
optional = true
73-
version = "0.11.0"
73+
version = "0.12.2"
7474

7575
[dependencies.nrf-usbd]
76-
version = "0.1.0"
76+
version = "0.2.0"
7777
optional = true
7878

7979
[dependencies.embedded-hal]

nrf-hal-common/src/adc.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,26 +26,28 @@ impl Adc {
2626
};
2727

2828
let w2 = match config.input_selection {
29-
InputSelection::ANALOGINPUTNOPRESCALING => w1.inpsel().analog_input_no_prescaling(),
30-
InputSelection::ANALOGINPUTTWOTHIRDSPRESCALING => {
29+
InputSelection::ANALOG_INPUT_NO_PRESCALING => {
30+
w1.inpsel().analog_input_no_prescaling()
31+
}
32+
InputSelection::ANALOG_INPUT_TWO_THIRDS_PRESCALING => {
3133
w1.inpsel().analog_input_two_thirds_prescaling()
3234
}
33-
InputSelection::ANALOGINPUTONETHIRDPRESCALING => {
35+
InputSelection::ANALOG_INPUT_ONE_THIRD_PRESCALING => {
3436
w1.inpsel().analog_input_one_third_prescaling()
3537
}
36-
InputSelection::SUPPLYTWOTHIRDSPRESCALING => {
38+
InputSelection::SUPPLY_TWO_THIRDS_PRESCALING => {
3739
w1.inpsel().supply_two_thirds_prescaling()
3840
}
39-
InputSelection::SUPPLYONETHIRDPRESCALING => {
41+
InputSelection::SUPPLY_ONE_THIRD_PRESCALING => {
4042
w1.inpsel().supply_one_third_prescaling()
4143
}
4244
};
4345

4446
let w3 = match config.reference {
4547
Reference::VBG => w2.refsel().vbg(),
4648
Reference::EXTERNAL => w2.refsel().external(),
47-
Reference::SUPPLYONEHALFPRESCALING => w2.refsel().supply_one_half_prescaling(),
48-
Reference::SUPPLYONETHIRDPRESCALING => w2.refsel().supply_one_third_prescaling(),
49+
Reference::SUPPLY_ONE_HALF_PRESCALING => w2.refsel().supply_one_half_prescaling(),
50+
Reference::SUPPLY_ONE_THIRD_PRESCALING => w2.refsel().supply_one_third_prescaling(),
4951
};
5052

5153
w3
@@ -68,8 +70,8 @@ impl Default for AdcConfig {
6870
fn default() -> Self {
6971
Self {
7072
resolution: Resolution::_10BIT,
71-
input_selection: InputSelection::ANALOGINPUTONETHIRDPRESCALING,
72-
reference: Reference::SUPPLYONETHIRDPRESCALING,
73+
input_selection: InputSelection::ANALOG_INPUT_ONE_THIRD_PRESCALING,
74+
reference: Reference::SUPPLY_ONE_THIRD_PRESCALING,
7375
}
7476
}
7577
}

nrf-hal-common/src/comp.rs

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -285,35 +285,35 @@ macro_rules! comp_ref_pins {
285285
}
286286

287287
comp_ref_pins! {
288-
P0_02<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE0,
289-
P0_03<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE1,
290-
P0_04<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE2,
291-
P0_05<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE3,
292-
P0_28<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE4,
293-
P0_29<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE5,
294-
P0_30<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE6,
295-
P0_31<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE7,
288+
P0_02<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE0,
289+
P0_03<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE1,
290+
P0_04<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE2,
291+
P0_05<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE3,
292+
P0_28<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE4,
293+
P0_29<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE5,
294+
P0_30<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE6,
295+
P0_31<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE7,
296296
}
297297

298298
#[cfg(not(any(feature = "52811", feature = "52810")))]
299299
comp_input_pins! {
300-
P0_02<Input<Floating>> => PSEL_A::ANALOGINPUT0,
301-
P0_03<Input<Floating>> => PSEL_A::ANALOGINPUT1,
302-
P0_04<Input<Floating>> => PSEL_A::ANALOGINPUT2,
303-
P0_05<Input<Floating>> => PSEL_A::ANALOGINPUT3,
304-
P0_28<Input<Floating>> => PSEL_A::ANALOGINPUT4,
305-
P0_29<Input<Floating>> => PSEL_A::ANALOGINPUT5,
306-
P0_30<Input<Floating>> => PSEL_A::ANALOGINPUT6,
307-
P0_31<Input<Floating>> => PSEL_A::ANALOGINPUT7,
300+
P0_02<Input<Floating>> => PSEL_A::ANALOG_INPUT0,
301+
P0_03<Input<Floating>> => PSEL_A::ANALOG_INPUT1,
302+
P0_04<Input<Floating>> => PSEL_A::ANALOG_INPUT2,
303+
P0_05<Input<Floating>> => PSEL_A::ANALOG_INPUT3,
304+
P0_28<Input<Floating>> => PSEL_A::ANALOG_INPUT4,
305+
P0_29<Input<Floating>> => PSEL_A::ANALOG_INPUT5,
306+
P0_30<Input<Floating>> => PSEL_A::ANALOG_INPUT6,
307+
P0_31<Input<Floating>> => PSEL_A::ANALOG_INPUT7,
308308
}
309309

310310
#[cfg(any(feature = "52811", feature = "52810"))]
311311
comp_input_pins! {
312-
P0_02<Input<Floating>> => PSEL_A::ANALOGINPUT0,
313-
P0_03<Input<Floating>> => PSEL_A::ANALOGINPUT1,
314-
P0_04<Input<Floating>> => PSEL_A::ANALOGINPUT2,
315-
P0_05<Input<Floating>> => PSEL_A::ANALOGINPUT3,
316-
P0_28<Input<Floating>> => PSEL_A::ANALOGINPUT4,
317-
P0_29<Input<Floating>> => PSEL_A::ANALOGINPUT5,
318-
P0_30<Input<Floating>> => PSEL_A::ANALOGINPUT6,
312+
P0_02<Input<Floating>> => PSEL_A::ANALOG_INPUT0,
313+
P0_03<Input<Floating>> => PSEL_A::ANALOG_INPUT1,
314+
P0_04<Input<Floating>> => PSEL_A::ANALOG_INPUT2,
315+
P0_05<Input<Floating>> => PSEL_A::ANALOG_INPUT3,
316+
P0_28<Input<Floating>> => PSEL_A::ANALOG_INPUT4,
317+
P0_29<Input<Floating>> => PSEL_A::ANALOG_INPUT5,
318+
P0_30<Input<Floating>> => PSEL_A::ANALOG_INPUT6,
319319
}

nrf-hal-common/src/ieee802154.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,20 @@ pub enum TxPower {
129129
impl TxPower {
130130
fn _into(self) -> TXPOWER_A {
131131
match self {
132-
TxPower::Neg40dBm => TXPOWER_A::NEG40DBM,
133-
TxPower::Neg20dBm => TXPOWER_A::NEG20DBM,
134-
TxPower::Neg16dBm => TXPOWER_A::NEG16DBM,
135-
TxPower::Neg12dBm => TXPOWER_A::NEG12DBM,
136-
TxPower::Neg8dBm => TXPOWER_A::NEG8DBM,
137-
TxPower::Neg4dBm => TXPOWER_A::NEG4DBM,
138-
TxPower::_0dBm => TXPOWER_A::_0DBM,
139-
TxPower::Pos2dBm => TXPOWER_A::POS2DBM,
140-
TxPower::Pos3dBm => TXPOWER_A::POS3DBM,
141-
TxPower::Pos4dBm => TXPOWER_A::POS4DBM,
142-
TxPower::Pos5dBm => TXPOWER_A::POS5DBM,
143-
TxPower::Pos6dBm => TXPOWER_A::POS6DBM,
144-
TxPower::Pos7dBm => TXPOWER_A::POS7DBM,
145-
TxPower::Pos8dBm => TXPOWER_A::POS8DBM,
132+
TxPower::Neg40dBm => TXPOWER_A::NEG40D_BM,
133+
TxPower::Neg20dBm => TXPOWER_A::NEG20D_BM,
134+
TxPower::Neg16dBm => TXPOWER_A::NEG16D_BM,
135+
TxPower::Neg12dBm => TXPOWER_A::NEG12D_BM,
136+
TxPower::Neg8dBm => TXPOWER_A::NEG8D_BM,
137+
TxPower::Neg4dBm => TXPOWER_A::NEG4D_BM,
138+
TxPower::_0dBm => TXPOWER_A::_0D_BM,
139+
TxPower::Pos2dBm => TXPOWER_A::POS2D_BM,
140+
TxPower::Pos3dBm => TXPOWER_A::POS3D_BM,
141+
TxPower::Pos4dBm => TXPOWER_A::POS4D_BM,
142+
TxPower::Pos5dBm => TXPOWER_A::POS5D_BM,
143+
TxPower::Pos6dBm => TXPOWER_A::POS6D_BM,
144+
TxPower::Pos7dBm => TXPOWER_A::POS7D_BM,
145+
TxPower::Pos8dBm => TXPOWER_A::POS8D_BM,
146146
}
147147
}
148148
}
@@ -409,7 +409,7 @@ impl<'c> Radio<'c> {
409409

410410
fn cancel_recv(&mut self) {
411411
self.radio.tasks_stop.write(|w| w.tasks_stop().set_bit());
412-
self.wait_for_state_a(STATE_A::RXIDLE);
412+
self.wait_for_state_a(STATE_A::RX_IDLE);
413413
// DMA transfer may have been in progress so synchronize with its memory operations
414414
dma_end_fence();
415415
}
@@ -590,7 +590,7 @@ impl<'c> Radio<'c> {
590590
match self.radio.state.read().state().variant().unwrap() {
591591
STATE_A::DISABLED => return,
592592

593-
STATE_A::RXRU | STATE_A::RXIDLE | STATE_A::TXRU | STATE_A::TXIDLE => {
593+
STATE_A::RX_RU | STATE_A::RX_IDLE | STATE_A::TX_RU | STATE_A::TX_IDLE => {
594594
self.radio
595595
.tasks_disable
596596
.write(|w| w.tasks_disable().set_bit());
@@ -600,7 +600,7 @@ impl<'c> Radio<'c> {
600600
}
601601

602602
// ramping down
603-
STATE_A::RXDISABLE | STATE_A::TXDISABLE => {
603+
STATE_A::RX_DISABLE | STATE_A::TX_DISABLE => {
604604
self.wait_for_state_a(STATE_A::DISABLED);
605605
return;
606606
}
@@ -611,11 +611,11 @@ impl<'c> Radio<'c> {
611611
.tasks_ccastop
612612
.write(|w| w.tasks_ccastop().set_bit());
613613
self.radio.tasks_stop.write(|w| w.tasks_stop().set_bit());
614-
self.wait_for_state_a(STATE_A::RXIDLE);
614+
self.wait_for_state_a(STATE_A::RX_IDLE);
615615
}
616616
STATE_A::TX => {
617617
self.radio.tasks_stop.write(|w| w.tasks_stop().set_bit());
618-
self.wait_for_state_a(STATE_A::TXIDLE);
618+
self.wait_for_state_a(STATE_A::TX_IDLE);
619619
}
620620
}
621621
}
@@ -642,7 +642,7 @@ impl<'c> Radio<'c> {
642642
if enable {
643643
self.needs_enable = false;
644644
self.radio.tasks_rxen.write(|w| w.tasks_rxen().set_bit());
645-
self.wait_for_state_a(STATE_A::RXIDLE);
645+
self.wait_for_state_a(STATE_A::RX_IDLE);
646646
}
647647
}
648648

@@ -653,19 +653,19 @@ impl<'c> Radio<'c> {
653653
if state != State::TxIdle || self.needs_enable {
654654
self.needs_enable = false;
655655
self.radio.tasks_txen.write(|w| w.tasks_txen().set_bit());
656-
self.wait_for_state_a(STATE_A::TXIDLE);
656+
self.wait_for_state_a(STATE_A::TX_IDLE);
657657
}
658658
}
659659

660660
fn state(&self) -> State {
661661
match self.radio.state.read().state().variant().unwrap() {
662662
// final states
663663
STATE_A::DISABLED => State::Disabled,
664-
STATE_A::TXIDLE => State::TxIdle,
665-
STATE_A::RXIDLE => State::RxIdle,
664+
STATE_A::TX_IDLE => State::TxIdle,
665+
STATE_A::RX_IDLE => State::RxIdle,
666666

667667
// transitory states
668-
STATE_A::TXDISABLE => {
668+
STATE_A::TX_DISABLE => {
669669
self.wait_for_state_a(STATE_A::DISABLED);
670670
State::Disabled
671671
}

nrf-hal-common/src/lpcomp.rs

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -260,36 +260,36 @@ macro_rules! comp_ref_pins {
260260

261261
#[cfg(not(feature = "51"))]
262262
comp_ref_pins! {
263-
P0_02<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE0,
264-
P0_03<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE1,
263+
P0_02<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE0,
264+
P0_03<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE1,
265265
}
266266

267267
#[cfg(not(feature = "51"))]
268268
comp_input_pins! {
269-
P0_02<Input<Floating>> => PSEL_A::ANALOGINPUT0,
270-
P0_03<Input<Floating>> => PSEL_A::ANALOGINPUT1,
271-
P0_04<Input<Floating>> => PSEL_A::ANALOGINPUT2,
272-
P0_05<Input<Floating>> => PSEL_A::ANALOGINPUT3,
273-
P0_28<Input<Floating>> => PSEL_A::ANALOGINPUT4,
274-
P0_29<Input<Floating>> => PSEL_A::ANALOGINPUT5,
275-
P0_30<Input<Floating>> => PSEL_A::ANALOGINPUT6,
276-
P0_31<Input<Floating>> => PSEL_A::ANALOGINPUT7,
269+
P0_02<Input<Floating>> => PSEL_A::ANALOG_INPUT0,
270+
P0_03<Input<Floating>> => PSEL_A::ANALOG_INPUT1,
271+
P0_04<Input<Floating>> => PSEL_A::ANALOG_INPUT2,
272+
P0_05<Input<Floating>> => PSEL_A::ANALOG_INPUT3,
273+
P0_28<Input<Floating>> => PSEL_A::ANALOG_INPUT4,
274+
P0_29<Input<Floating>> => PSEL_A::ANALOG_INPUT5,
275+
P0_30<Input<Floating>> => PSEL_A::ANALOG_INPUT6,
276+
P0_31<Input<Floating>> => PSEL_A::ANALOG_INPUT7,
277277
}
278278

279279
#[cfg(feature = "51")]
280280
comp_ref_pins! {
281-
P0_00<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE0,
282-
P0_06<Input<Floating>> => EXTREFSEL_A::ANALOGREFERENCE1,
281+
P0_00<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE0,
282+
P0_06<Input<Floating>> => EXTREFSEL_A::ANALOG_REFERENCE1,
283283
}
284284

285285
#[cfg(feature = "51")]
286286
comp_input_pins! {
287-
P0_26<Input<Floating>> => PSEL_A::ANALOGINPUT0,
288-
P0_27<Input<Floating>> => PSEL_A::ANALOGINPUT1,
289-
P0_01<Input<Floating>> => PSEL_A::ANALOGINPUT2,
290-
P0_02<Input<Floating>> => PSEL_A::ANALOGINPUT3,
291-
P0_03<Input<Floating>> => PSEL_A::ANALOGINPUT4,
292-
P0_04<Input<Floating>> => PSEL_A::ANALOGINPUT5,
293-
P0_05<Input<Floating>> => PSEL_A::ANALOGINPUT6,
294-
P0_06<Input<Floating>> => PSEL_A::ANALOGINPUT7,
287+
P0_26<Input<Floating>> => PSEL_A::ANALOG_INPUT0,
288+
P0_27<Input<Floating>> => PSEL_A::ANALOG_INPUT1,
289+
P0_01<Input<Floating>> => PSEL_A::ANALOG_INPUT2,
290+
P0_02<Input<Floating>> => PSEL_A::ANALOG_INPUT3,
291+
P0_03<Input<Floating>> => PSEL_A::ANALOG_INPUT4,
292+
P0_04<Input<Floating>> => PSEL_A::ANALOG_INPUT5,
293+
P0_05<Input<Floating>> => PSEL_A::ANALOG_INPUT6,
294+
P0_06<Input<Floating>> => PSEL_A::ANALOG_INPUT7,
295295
}

nrf-hal-common/src/twis.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ where
167167
/// Returns matched address for latest command.
168168
#[inline(always)]
169169
pub fn address_match(&self) -> u8 {
170-
self.0.address[self.0.match_.read().match_().bits() as usize]
170+
self.0.address[self.0.match_.read().bits() as usize]
171171
.read()
172172
.address()
173173
.bits()
@@ -323,11 +323,11 @@ where
323323
// after all possible DMA actions have completed.
324324
compiler_fence(SeqCst);
325325

326-
if self.0.errorsrc.read().dnack().bits() {
326+
if self.0.errorsrc.read().dnack().is_received() {
327327
return Err(Error::DataNack);
328328
}
329329

330-
if self.0.errorsrc.read().overflow().bits() {
330+
if self.0.errorsrc.read().overflow().is_detected() {
331331
return Err(Error::OverFlow);
332332
}
333333

@@ -380,7 +380,7 @@ where
380380
// after all possible DMA actions have completed.
381381
compiler_fence(SeqCst);
382382

383-
if self.0.errorsrc.read().overread().bits() {
383+
if self.0.errorsrc.read().overread().is_detected() {
384384
return Err(Error::OverRead);
385385
}
386386

nrf51-hal/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ keywords = ["arm", "cortex-m", "nrf52", "hal", "nrf51"]
1919
license = "MIT OR Apache-2.0"
2020

2121
[dependencies]
22-
nrf51-pac = "0.11.0"
22+
nrf51-pac = "0.12.2"
2323

2424
[dependencies.nrf-hal-common]
2525
path = "../nrf-hal-common"

0 commit comments

Comments
 (0)