Skip to content

Commit 7e174b4

Browse files
Merge pull request #148 from blueluna/nrf52833
Adding support for Nordic nRF52833
2 parents 6190fd8 + 9997aa4 commit 7e174b4

14 files changed

Lines changed: 165 additions & 48 deletions

File tree

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ members = [
88
"boards/actinius-icarus",
99
"nrf52810-hal",
1010
"nrf52832-hal",
11+
"nrf52833-hal",
1112
"nrf52840-hal",
1213
"nrf9160-hal",
1314
"examples/rtfm-demo",

nrf-hal-common/Cargo.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ version = "0.9.0"
4444
optional = true
4545
version = "0.9.0"
4646

47+
[dependencies.nrf52833-pac]
48+
optional = true
49+
version = "0.9.0"
50+
4751
[dependencies.nrf52840-pac]
4852
optional = true
4953
version = "0.9.0"
@@ -61,5 +65,6 @@ doc = []
6165
51 = ["nrf51"]
6266
52810 = ["nrf52810-pac"]
6367
52832 = ["nrf52832-pac"]
68+
52833 = ["nrf52833-pac"]
6469
52840 = ["nrf52840-pac"]
6570
9160 = ["nrf9160-pac"]

nrf-hal-common/src/gpio.rs

Lines changed: 27 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ pub enum Level {
4545
/// Generic $PX pin
4646
pub struct Pin<MODE> {
4747
pub pin: u8,
48-
#[cfg(feature = "52840")]
48+
#[cfg(any(feature = "52833", feature = "52840"))]
4949
pub port: bool,
5050
_mode: PhantomData<MODE>,
5151
}
@@ -59,7 +59,7 @@ use crate::target::P0_NS as P0;
5959
#[cfg(not(any(feature = "9160", feature = "51")))]
6060
use crate::target::P0;
6161

62-
#[cfg(feature = "52840")]
62+
#[cfg(any(feature = "52833", feature = "52840"))]
6363
use crate::target::P1;
6464

6565
use crate::hal::digital::v2::{InputPin, OutputPin, StatefulOutputPin};
@@ -70,11 +70,11 @@ impl<MODE> Pin<MODE> {
7070
pub fn into_floating_input(self) -> Pin<Input<Floating>> {
7171
unsafe {
7272
&(*{
73-
#[cfg(not(feature = "52840"))]
73+
#[cfg(not(any(feature = "52833", feature = "52840")))]
7474
{
7575
P0::ptr()
7676
}
77-
#[cfg(feature = "52840")]
77+
#[cfg(any(feature = "52833", feature = "52840"))]
7878
{
7979
if !self.port {
8080
P0::ptr()
@@ -96,19 +96,19 @@ impl<MODE> Pin<MODE> {
9696

9797
Pin {
9898
_mode: PhantomData,
99-
#[cfg(feature = "52840")]
99+
#[cfg(any(feature = "52833", feature = "52840"))]
100100
port: self.port,
101101
pin: self.pin,
102102
}
103103
}
104104
pub fn into_pullup_input(self) -> Pin<Input<PullUp>> {
105105
unsafe {
106106
&(*{
107-
#[cfg(not(feature = "52840"))]
107+
#[cfg(not(any(feature = "52833", feature = "52840")))]
108108
{
109109
P0::ptr()
110110
}
111-
#[cfg(feature = "52840")]
111+
#[cfg(any(feature = "52833", feature = "52840"))]
112112
{
113113
if !self.port {
114114
P0::ptr()
@@ -130,19 +130,19 @@ impl<MODE> Pin<MODE> {
130130

131131
Pin {
132132
_mode: PhantomData,
133-
#[cfg(feature = "52840")]
133+
#[cfg(any(feature = "52833", feature = "52840"))]
134134
port: self.port,
135135
pin: self.pin,
136136
}
137137
}
138138
pub fn into_pulldown_input(self) -> Pin<Input<PullDown>> {
139139
unsafe {
140140
&(*{
141-
#[cfg(not(feature = "52840"))]
141+
#[cfg(not(any(feature = "52833", feature = "52840")))]
142142
{
143143
P0::ptr()
144144
}
145-
#[cfg(feature = "52840")]
145+
#[cfg(any(feature = "52833", feature = "52840"))]
146146
{
147147
if !self.port {
148148
P0::ptr()
@@ -164,7 +164,7 @@ impl<MODE> Pin<MODE> {
164164

165165
Pin {
166166
_mode: PhantomData,
167-
#[cfg(feature = "52840")]
167+
#[cfg(any(feature = "52833", feature = "52840"))]
168168
port: self.port,
169169
pin: self.pin,
170170
}
@@ -174,7 +174,7 @@ impl<MODE> Pin<MODE> {
174174
pub fn into_push_pull_output(self, initial_output: Level) -> Pin<Output<PushPull>> {
175175
let mut pin = Pin {
176176
_mode: PhantomData,
177-
#[cfg(feature = "52840")]
177+
#[cfg(any(feature = "52833", feature = "52840"))]
178178
port: self.port,
179179
pin: self.pin,
180180
};
@@ -186,11 +186,11 @@ impl<MODE> Pin<MODE> {
186186

187187
unsafe {
188188
&(*{
189-
#[cfg(not(feature = "52840"))]
189+
#[cfg(not(any(feature = "52833", feature = "52840")))]
190190
{
191191
P0::ptr()
192192
}
193-
#[cfg(feature = "52840")]
193+
#[cfg(any(feature = "52833", feature = "52840"))]
194194
{
195195
if !self.port {
196196
P0::ptr()
@@ -224,7 +224,7 @@ impl<MODE> Pin<MODE> {
224224
) -> Pin<Output<OpenDrain>> {
225225
let mut pin = Pin {
226226
_mode: PhantomData,
227-
#[cfg(feature = "52840")]
227+
#[cfg(any(feature = "52833", feature = "52840"))]
228228
port: self.port,
229229
pin: self.pin,
230230
};
@@ -238,11 +238,11 @@ impl<MODE> Pin<MODE> {
238238
// register for this pin.
239239
let pin_cnf = unsafe {
240240
&(*{
241-
#[cfg(not(feature = "52840"))]
241+
#[cfg(not(any(feature = "52833", feature = "52840")))]
242242
{
243243
P0::ptr()
244244
}
245-
#[cfg(feature = "52840")]
245+
#[cfg(any(feature = "52833", feature = "52840"))]
246246
{
247247
if !self.port {
248248
P0::ptr()
@@ -276,11 +276,11 @@ impl<MODE> InputPin for Pin<Input<MODE>> {
276276
fn is_low(&self) -> Result<bool, Self::Error> {
277277
Ok(unsafe {
278278
((*{
279-
#[cfg(not(feature = "52840"))]
279+
#[cfg(not(any(feature = "52833", feature = "52840")))]
280280
{
281281
P0::ptr()
282282
}
283-
#[cfg(feature = "52840")]
283+
#[cfg(any(feature = "52833", feature = "52840"))]
284284
{
285285
if !self.port {
286286
P0::ptr()
@@ -307,11 +307,11 @@ impl<MODE> OutputPin for Pin<Output<MODE>> {
307307
// TODO - I wish I could do something like `.pins$i()`...
308308
unsafe {
309309
(*{
310-
#[cfg(not(feature = "52840"))]
310+
#[cfg(not(any(feature = "52833", feature = "52840")))]
311311
{
312312
P0::ptr()
313313
}
314-
#[cfg(feature = "52840")]
314+
#[cfg(any(feature = "52833", feature = "52840"))]
315315
{
316316
if !self.port {
317317
P0::ptr()
@@ -332,11 +332,11 @@ impl<MODE> OutputPin for Pin<Output<MODE>> {
332332
// TODO - I wish I could do something like `.pins$i()`...
333333
unsafe {
334334
(*{
335-
#[cfg(not(feature = "52840"))]
335+
#[cfg(not(any(feature = "52833", feature = "52840")))]
336336
{
337337
P0::ptr()
338338
}
339-
#[cfg(feature = "52840")]
339+
#[cfg(any(feature = "52833", feature = "52840"))]
340340
{
341341
if !self.port {
342342
P0::ptr()
@@ -364,11 +364,11 @@ impl<MODE> StatefulOutputPin for Pin<Output<MODE>> {
364364
// TODO - I wish I could do something like `.pins$i()`...
365365
Ok(unsafe {
366366
((*{
367-
#[cfg(not(feature = "52840"))]
367+
#[cfg(not(any(feature = "52833", feature = "52840")))]
368368
{
369369
P0::ptr()
370370
}
371-
#[cfg(feature = "52840")]
371+
#[cfg(any(feature = "52833", feature = "52840"))]
372372
{
373373
if !self.port {
374374
P0::ptr()
@@ -592,7 +592,7 @@ macro_rules! gpio {
592592
pub fn degrade(self) -> Pin<MODE> {
593593
Pin {
594594
_mode: PhantomData,
595-
#[cfg(feature = "52840")]
595+
#[cfg(any(feature = "52833", feature = "52840"))]
596596
port: $port_value,
597597
pin: $i
598598
}
@@ -692,7 +692,7 @@ gpio!(P0, p0, p0, false, [
692692

693693
// The p1 types are present in the p0 module generated from the
694694
// svd, but we want to export them in a p1 module from this crate.
695-
#[cfg(feature = "52840")]
695+
#[cfg(any(feature = "52833", feature = "52840"))]
696696
gpio!(P1, p0, p1, true, [
697697
P1_00: (p1_00, 0, Input<Floating>),
698698
P1_01: (p1_01, 1, Input<Floating>),

nrf-hal-common/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ pub use nrf52810_pac as target;
1111
#[cfg(feature = "52832")]
1212
pub use nrf52832_pac as target;
1313

14+
#[cfg(feature = "52833")]
15+
pub use nrf52833_pac as target;
16+
1417
#[cfg(feature = "52840")]
1518
pub use nrf52840_pac as target;
1619

@@ -64,7 +67,7 @@ pub mod target_constants {
6467
pub const SRAM_UPPER: usize = 0x3000_0000;
6568
pub const FORCE_COPY_BUFFER_SIZE: usize = 255;
6669
}
67-
#[cfg(any(feature = "52840", feature = "9160"))]
70+
#[cfg(any(feature = "52840", feature = "52833", feature = "9160"))]
6871
pub mod target_constants {
6972
// NRF52840 and NRF9160 16 bits 1..0xFFFF
7073
pub const EASY_DMA_SIZE: usize = 65535;

nrf-hal-common/src/rtc.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ use crate::target::{rtc0_ns as rtc0, Interrupt, NVIC, RTC0_NS as RTC0, RTC1_NS a
88
#[cfg(not(feature = "9160"))]
99
use crate::target::{rtc0, Interrupt, NVIC, RTC0, RTC1};
1010

11-
#[cfg(any(feature = "52840", feature = "52832"))]
11+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
1212
use crate::target::RTC2;
1313

1414
// Zero Size Type State structs
@@ -252,5 +252,5 @@ macro_rules! impl_instance {
252252

253253
impl_instance!(RTC0, RTC1,);
254254

255-
#[cfg(any(feature = "52840", feature = "52832"))]
255+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
256256
impl_instance!(RTC2,);

nrf-hal-common/src/spim.rs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,10 @@ pub use spim0::frequency::FREQUENCY_A as Frequency;
1515

1616
use core::iter::repeat_with;
1717

18-
#[cfg(any(feature = "52832", feature = "52840"))]
18+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
1919
use crate::target::{SPIM1, SPIM2};
2020

21-
#[cfg(feature = "52840")]
21+
#[cfg(any(feature = "52833", feature = "52840"))]
2222
use crate::target::SPIM3;
2323

2424
use crate::gpio::{Floating, Input, Output, Pin, PushPull};
@@ -97,15 +97,15 @@ where
9797
// Select pins
9898
spim.psel.sck.write(|w| {
9999
let w = unsafe { w.pin().bits(pins.sck.pin) };
100-
#[cfg(feature = "52840")]
100+
#[cfg(any(feature = "52843", feature = "52840"))]
101101
let w = w.port().bit(pins.sck.port);
102102
w.connect().connected()
103103
});
104104

105105
match pins.mosi {
106106
Some(mosi) => spim.psel.mosi.write(|w| {
107107
let w = unsafe { w.pin().bits(mosi.pin) };
108-
#[cfg(feature = "52840")]
108+
#[cfg(any(feature = "52843", feature = "52840"))]
109109
let w = w.port().bit(mosi.port);
110110
w.connect().connected()
111111
}),
@@ -114,7 +114,7 @@ where
114114
match pins.miso {
115115
Some(miso) => spim.psel.miso.write(|w| {
116116
let w = unsafe { w.pin().bits(miso.pin) };
117-
#[cfg(feature = "52840")]
117+
#[cfg(any(feature = "52843", feature = "52840"))]
118118
let w = w.port().bit(miso.port);
119119
w.connect().connected()
120120
}),
@@ -407,11 +407,11 @@ pub trait Instance: Deref<Target = spim0::RegisterBlock> {}
407407

408408
impl Instance for SPIM0 {}
409409

410-
#[cfg(any(feature = "52832", feature = "52840"))]
410+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
411411
impl Instance for SPIM1 {}
412412

413-
#[cfg(any(feature = "52832", feature = "52840"))]
413+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
414414
impl Instance for SPIM2 {}
415415

416-
#[cfg(feature = "52840")]
416+
#[cfg(any(feature = "52833", feature = "52840"))]
417417
impl Instance for SPIM3 {}

nrf-hal-common/src/timer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use embedded_hal::{
1717
use nb::{self, block};
1818
use void::{unreachable, Void};
1919

20-
#[cfg(any(feature = "52832", feature = "52840"))]
20+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
2121
use crate::target::{TIMER3, TIMER4};
2222

2323
use core::marker::PhantomData;
@@ -362,5 +362,5 @@ macro_rules! impl_instance {
362362

363363
impl_instance!(TIMER0, TIMER1, TIMER2,);
364364

365-
#[cfg(any(feature = "52832", feature = "52840"))]
365+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
366366
impl_instance!(TIMER3, TIMER4,);

nrf-hal-common/src/twim.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::target::{twim0_ns as twim0, P0_NS as P0, TWIM0_NS as TWIM0};
1313
#[cfg(not(feature = "9160"))]
1414
use crate::target::{twim0, P0, TWIM0};
1515

16-
#[cfg(any(feature = "52832", feature = "52840"))]
16+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
1717
use crate::target::TWIM1;
1818

1919
use crate::{
@@ -404,5 +404,5 @@ pub trait Instance: Deref<Target = twim0::RegisterBlock> {}
404404

405405
impl Instance for TWIM0 {}
406406

407-
#[cfg(any(feature = "52832", feature = "52840"))]
407+
#[cfg(any(feature = "52832", feature = "52833", feature = "52840"))]
408408
impl Instance for TWIM1 {}

0 commit comments

Comments
 (0)