Skip to content

Commit 51880c9

Browse files
committed
add ptr to registerblock as associated constant
This commit introduces new associated constants to Core Peripherals. (pointers to the register block) This commit also adds a notice that 'ptr()' APIs will be deprecated in v0.7.
1 parent 1299137 commit 51880c9

File tree

1 file changed

+56
-14
lines changed

1 file changed

+56
-14
lines changed

src/peripheral/mod.rs

Lines changed: 56 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,10 @@ impl CBP {
237237
}
238238
}
239239

240-
/// Returns a pointer to the register block
240+
/// Pointer to the register block
241+
pub const CBP_PTR: *const self::cbp::RegisterBlock = 0xE000_EF50 as *const _;
242+
243+
/// Returns a pointer to the register block (to be deprecated in 0.7)
241244
#[inline(always)]
242245
pub const fn ptr() -> *const self::cbp::RegisterBlock {
243246
0xE000_EF50 as *const _
@@ -262,7 +265,10 @@ pub struct CPUID {
262265
unsafe impl Send for CPUID {}
263266

264267
impl CPUID {
265-
/// Returns a pointer to the register block
268+
/// Pointer to the register block
269+
pub const CPUID_PTR: *const self::cpuid::RegisterBlock = 0xE000_ED00 as *const _;
270+
271+
/// Returns a pointer to the register block (to be deprecated in 0.7)
266272
#[inline(always)]
267273
pub const fn ptr() -> *const self::cpuid::RegisterBlock {
268274
0xE000_ED00 as *const _
@@ -286,7 +292,10 @@ pub struct DCB {
286292
unsafe impl Send for DCB {}
287293

288294
impl DCB {
289-
/// Returns a pointer to the register block
295+
/// Pointer to the register block
296+
pub const DCB_PTR: *const dcb::RegisterBlock = 0xE000_EDF0 as *const _;
297+
298+
/// Returns a pointer to the register block (to be deprecated in 0.7)
290299
#[inline(always)]
291300
pub const fn ptr() -> *const dcb::RegisterBlock {
292301
0xE000_EDF0 as *const _
@@ -310,7 +319,10 @@ pub struct DWT {
310319
unsafe impl Send for DWT {}
311320

312321
impl DWT {
313-
/// Returns a pointer to the register block
322+
/// Pointer to the register block
323+
pub const DWT_PTR: *const dwt::RegisterBlock = 0xE000_1000 as *const _;
324+
325+
/// Returns a pointer to the register block (to be deprecated in 0.7)
314326
#[inline(always)]
315327
pub const fn ptr() -> *const dwt::RegisterBlock {
316328
0xE000_1000 as *const _
@@ -335,7 +347,10 @@ unsafe impl Send for FPB {}
335347

336348
#[cfg(not(armv6m))]
337349
impl FPB {
338-
/// Returns a pointer to the register block
350+
/// Pointer to the register block
351+
pub const FPB_PTR: *const fpb::RegisterBlock = 0xE000_2000 as *const _;
352+
353+
/// Returns a pointer to the register block (to be deprecated in 0.7)
339354
#[inline(always)]
340355
pub const fn ptr() -> *const fpb::RegisterBlock {
341356
0xE000_2000 as *const _
@@ -361,7 +376,10 @@ unsafe impl Send for FPU {}
361376

362377
#[cfg(any(has_fpu, target_arch = "x86_64"))]
363378
impl FPU {
364-
/// Returns a pointer to the register block
379+
/// Pointer to the register block
380+
pub const FPU_PTR: *const fpu::RegisterBlock = 0xE000_EF30 as *const _;
381+
382+
/// Returns a pointer to the register block (to be deprecated in 0.7)
365383
#[inline(always)]
366384
pub const fn ptr() -> *const fpu::RegisterBlock {
367385
0xE000_EF30 as *const _
@@ -391,7 +409,10 @@ pub struct ICB {
391409
unsafe impl Send for ICB {}
392410

393411
impl ICB {
394-
/// Returns a pointer to the register block
412+
/// Pointer to the register block
413+
pub const ICB_PTR: *mut icb::RegisterBlock = 0xE000_E004 as *mut _;
414+
415+
/// Returns a pointer to the register block (to be deprecated in 0.7)
395416
#[inline(always)]
396417
pub const fn ptr() -> *mut icb::RegisterBlock {
397418
0xE000_E004 as *mut _
@@ -423,7 +444,10 @@ unsafe impl Send for ITM {}
423444

424445
#[cfg(all(not(armv6m), not(armv8m_base)))]
425446
impl ITM {
426-
/// Returns a pointer to the register block
447+
/// Pointer to the register block
448+
pub const ITM_PTR: *mut itm::RegisterBlock = 0xE000_0000 as *mut _;
449+
450+
/// Returns a pointer to the register block (to be deprecated in 0.7)
427451
#[inline(always)]
428452
pub const fn ptr() -> *mut itm::RegisterBlock {
429453
0xE000_0000 as *mut _
@@ -456,7 +480,10 @@ pub struct MPU {
456480
unsafe impl Send for MPU {}
457481

458482
impl MPU {
459-
/// Returns a pointer to the register block
483+
/// Pointer to the register block
484+
pub const MPU_PTR: *const mpu::RegisterBlock = 0xE000_ED90 as *const _;
485+
486+
/// Returns a pointer to the register block (to be deprecated in 0.7)
460487
#[inline(always)]
461488
pub const fn ptr() -> *const mpu::RegisterBlock {
462489
0xE000_ED90 as *const _
@@ -480,7 +507,10 @@ pub struct NVIC {
480507
unsafe impl Send for NVIC {}
481508

482509
impl NVIC {
483-
/// Returns a pointer to the register block
510+
/// Pointer to the register block
511+
pub const NVIC_PTR: *const nvic::RegisterBlock = 0xE000_E100 as *const _;
512+
513+
/// Returns a pointer to the register block (to be deprecated in 0.7)
484514
#[inline(always)]
485515
pub const fn ptr() -> *const nvic::RegisterBlock {
486516
0xE000_E100 as *const _
@@ -505,7 +535,10 @@ unsafe impl Send for SAU {}
505535

506536
#[cfg(armv8m)]
507537
impl SAU {
508-
/// Returns a pointer to the register block
538+
/// Pointer to the register block
539+
pub const SAU_PTR: *const sau::RegisterBlock = 0xE000_EDD0 as *const _;
540+
541+
/// Returns a pointer to the register block (to be deprecated in 0.7)
509542
#[inline(always)]
510543
pub const fn ptr() -> *const sau::RegisterBlock {
511544
0xE000_EDD0 as *const _
@@ -530,7 +563,10 @@ pub struct SCB {
530563
unsafe impl Send for SCB {}
531564

532565
impl SCB {
533-
/// Returns a pointer to the register block
566+
/// Pointer to the register block
567+
pub const SCB_PTR: *const scb::RegisterBlock = 0xE000_ED04 as *const _;
568+
569+
/// Returns a pointer to the register block (to be deprecated in 0.7)
534570
#[inline(always)]
535571
pub const fn ptr() -> *const scb::RegisterBlock {
536572
0xE000_ED04 as *const _
@@ -554,7 +590,10 @@ pub struct SYST {
554590
unsafe impl Send for SYST {}
555591

556592
impl SYST {
557-
/// Returns a pointer to the register block
593+
/// Pointer to the register block
594+
pub const SYST_PTR: *const syst::RegisterBlock = 0xE000_E010 as *const _;
595+
596+
/// Returns a pointer to the register block (to be deprecated in 0.7)
558597
#[inline(always)]
559598
pub const fn ptr() -> *const syst::RegisterBlock {
560599
0xE000_E010 as *const _
@@ -579,7 +618,10 @@ unsafe impl Send for TPIU {}
579618

580619
#[cfg(not(armv6m))]
581620
impl TPIU {
582-
/// Returns a pointer to the register block
621+
/// Pointer to the register block
622+
pub const TPIU_PTR: *const tpiu::RegisterBlock = 0xE004_0000 as *const _;
623+
624+
/// Returns a pointer to the register block (to be deprecated in 0.7)
583625
#[inline(always)]
584626
pub const fn ptr() -> *const tpiu::RegisterBlock {
585627
0xE004_0000 as *const _

0 commit comments

Comments
 (0)