Skip to content

Commit

Permalink
add ptr to registerblock as associated constant
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
JOE1994 committed Jul 24, 2020
1 parent 498f9cd commit 64dc07d
Showing 1 changed file with 56 additions and 14 deletions.
70 changes: 56 additions & 14 deletions src/peripheral/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,10 @@ impl CBP {
}
}

/// Returns a pointer to the register block
/// Pointer to the register block
pub const CBP_PTR: *const self::cbp::RegisterBlock = 0xE000_EF50 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const self::cbp::RegisterBlock {
0xE000_EF50 as *const _
Expand All @@ -259,7 +262,10 @@ pub struct CPUID {
unsafe impl Send for CPUID {}

impl CPUID {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const CPUID_PTR: *const self::cpuid::RegisterBlock = 0xE000_ED00 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const self::cpuid::RegisterBlock {
0xE000_ED00 as *const _
Expand All @@ -283,7 +289,10 @@ pub struct DCB {
unsafe impl Send for DCB {}

impl DCB {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const DCB_PTR: *const dcb::RegisterBlock = 0xE000_EDF0 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const dcb::RegisterBlock {
0xE000_EDF0 as *const _
Expand All @@ -307,7 +316,10 @@ pub struct DWT {
unsafe impl Send for DWT {}

impl DWT {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const DWT_PTR: *const dwt::RegisterBlock = 0xE000_1000 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const dwt::RegisterBlock {
0xE000_1000 as *const _
Expand All @@ -332,7 +344,10 @@ unsafe impl Send for FPB {}

#[cfg(not(armv6m))]
impl FPB {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const FPB_PTR: *const fpb::RegisterBlock = 0xE000_2000 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const fpb::RegisterBlock {
0xE000_2000 as *const _
Expand All @@ -358,7 +373,10 @@ unsafe impl Send for FPU {}

#[cfg(any(has_fpu, target_arch = "x86_64"))]
impl FPU {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const FPU_PTR: *const fpu::RegisterBlock = 0xE000_EF30 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const fpu::RegisterBlock {
0xE000_EF30 as *const _
Expand Down Expand Up @@ -388,7 +406,10 @@ pub struct ICB {
unsafe impl Send for ICB {}

impl ICB {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const ICB_PTR: *mut icb::RegisterBlock = 0xE000_E004 as *mut _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *mut icb::RegisterBlock {
0xE000_E004 as *mut _
Expand Down Expand Up @@ -420,7 +441,10 @@ unsafe impl Send for ITM {}

#[cfg(all(not(armv6m), not(armv8m_base)))]
impl ITM {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const ITM_PTR: *mut itm::RegisterBlock = 0xE000_0000 as *mut _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *mut itm::RegisterBlock {
0xE000_0000 as *mut _
Expand Down Expand Up @@ -453,7 +477,10 @@ pub struct MPU {
unsafe impl Send for MPU {}

impl MPU {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const MPU_PTR: *const mpu::RegisterBlock = 0xE000_ED90 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const mpu::RegisterBlock {
0xE000_ED90 as *const _
Expand All @@ -477,7 +504,10 @@ pub struct NVIC {
unsafe impl Send for NVIC {}

impl NVIC {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const NVIC_PTR: *const nvic::RegisterBlock = 0xE000_E100 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const nvic::RegisterBlock {
0xE000_E100 as *const _
Expand All @@ -502,7 +532,10 @@ unsafe impl Send for SAU {}

#[cfg(armv8m)]
impl SAU {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const SAU_PTR: *const sau::RegisterBlock = 0xE000_EDD0 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const sau::RegisterBlock {
0xE000_EDD0 as *const _
Expand All @@ -527,7 +560,10 @@ pub struct SCB {
unsafe impl Send for SCB {}

impl SCB {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const SCB_PTR: *const scb::RegisterBlock = 0xE000_ED04 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const scb::RegisterBlock {
0xE000_ED04 as *const _
Expand All @@ -551,7 +587,10 @@ pub struct SYST {
unsafe impl Send for SYST {}

impl SYST {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const SYST_PTR: *const syst::RegisterBlock = 0xE000_E010 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const syst::RegisterBlock {
0xE000_E010 as *const _
Expand All @@ -576,7 +615,10 @@ unsafe impl Send for TPIU {}

#[cfg(not(armv6m))]
impl TPIU {
/// Returns a pointer to the register block
/// Pointer to the register block
pub const TPIU_PTR: *const tpiu::RegisterBlock = 0xE004_0000 as *const _;

/// Returns a pointer to the register block (to be deprecated in 0.7)
#[inline(always)]
pub const fn ptr() -> *const tpiu::RegisterBlock {
0xE004_0000 as *const _
Expand Down

0 comments on commit 64dc07d

Please sign in to comment.