Skip to content

Commit 880b947

Browse files
committed
Merge branch 'master' into feat/tracing
2 parents aa17958 + 6b01313 commit 880b947

File tree

8 files changed

+347
-21
lines changed

8 files changed

+347
-21
lines changed

CHANGELOG.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,34 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
### Added
11+
- Added support for additional DWT counters (#349)
12+
- CPI counter
13+
- Exception overhead counter
14+
- LSU counter
15+
- Folded-instruction counter
16+
- Added `DWT.set_cycle_count` (#347).
17+
- Added support for the Cortex-M7 TCM and cache access control registers.
18+
There is a feature `cm7` to enable access to these.
19+
20+
### Deprecated
21+
22+
- `DWT::get_cycle_count` has been deprecated in favor of `DWT::cycle_count`.
23+
This change was made for consistency with the [C-GETTER] convention. (#349)
24+
25+
[C-GETTER]: https://rust-lang.github.io/api-guidelines/naming.html#c-getter
26+
27+
## [v0.7.3] - 2021-07-03
28+
29+
### Fixed
30+
31+
- Fixed compilation for native targets on non-x86 host systems (#336, #337).
32+
33+
### Added
34+
35+
- The `Delay` struct now offers direct `delay_us()` and `delay_ms()` methods
36+
without having to go through the embedded-hal traits (#344).
37+
1038
## [v0.7.2] - 2021-03-07
1139

1240
### Fixed
@@ -689,7 +717,8 @@ fn main() {
689717
- Functions to get the vector table
690718
- Wrappers over miscellaneous instructions like `bkpt`
691719

692-
[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/v0.7.2...HEAD
720+
[Unreleased]: https://github.com/rust-embedded/cortex-m/compare/v0.7.3...HEAD
721+
[v0.7.3]: https://github.com/rust-embedded/cortex-m/compare/v0.7.2...v0.7.3
693722
[v0.7.2]: https://github.com/rust-embedded/cortex-m/compare/v0.7.1...v0.7.2
694723
[v0.7.1]: https://github.com/rust-embedded/cortex-m/compare/v0.7.0...v0.7.1
695724
[v0.7.0]: https://github.com/rust-embedded/cortex-m/compare/v0.6.4...v0.7.0

Cargo.toml

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ license = "MIT OR Apache-2.0"
1111
name = "cortex-m"
1212
readme = "README.md"
1313
repository = "https://github.com/rust-embedded/cortex-m"
14-
version = "0.7.2"
14+
version = "0.7.3"
1515
edition = "2018"
1616
links = "cortex-m" # prevent multiple versions of this crate to be linked together
1717

@@ -22,7 +22,8 @@ bitfield = "0.13.2"
2222
embedded-hal = "0.2.4"
2323

2424
[features]
25-
cm7-r0p1 = []
25+
cm7 = []
26+
cm7-r0p1 = ["cm7"]
2627
inline-asm = []
2728
linker-plugin-lto = []
2829

src/delay.rs

Lines changed: 20 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ impl Delay {
2929
self.syst
3030
}
3131

32-
fn _delay_us(&mut self, us: u32) {
33-
let ticks = (us as u64) * (self.ahb_frequency as u64) / 1_000_000;
32+
/// Delay using the Cortex-M systick for a certain duration, in µs.
33+
#[allow(clippy::missing_inline_in_public_items)]
34+
pub fn delay_us(&mut self, us: u32) {
35+
let ticks = (u64::from(us)) * (u64::from(self.ahb_frequency)) / 1_000_000;
3436

3537
let full_cycles = ticks >> 24;
3638
if full_cycles > 0 {
@@ -54,11 +56,10 @@ impl Delay {
5456

5557
self.syst.disable_counter();
5658
}
57-
}
5859

59-
impl DelayMs<u32> for Delay {
60+
/// Delay using the Cortex-M systick for a certain duration, in ms.
6061
#[inline]
61-
fn delay_ms(&mut self, mut ms: u32) {
62+
pub fn delay_ms(&mut self, mut ms: u32) {
6263
// 4294967 is the highest u32 value which you can multiply by 1000 without overflow
6364
while ms > 4294967 {
6465
self.delay_us(4294967000u32);
@@ -68,33 +69,40 @@ impl DelayMs<u32> for Delay {
6869
}
6970
}
7071

72+
impl DelayMs<u32> for Delay {
73+
#[inline]
74+
fn delay_ms(&mut self, ms: u32) {
75+
Delay::delay_ms(self, ms);
76+
}
77+
}
78+
7179
// This is a workaround to allow `delay_ms(42)` construction without specifying a type.
7280
impl DelayMs<i32> for Delay {
7381
#[inline(always)]
7482
fn delay_ms(&mut self, ms: i32) {
7583
assert!(ms >= 0);
76-
self.delay_ms(ms as u32);
84+
Delay::delay_ms(self, ms as u32);
7785
}
7886
}
7987

8088
impl DelayMs<u16> for Delay {
8189
#[inline(always)]
8290
fn delay_ms(&mut self, ms: u16) {
83-
self.delay_ms(u32::from(ms));
91+
Delay::delay_ms(self, u32::from(ms));
8492
}
8593
}
8694

8795
impl DelayMs<u8> for Delay {
8896
#[inline(always)]
8997
fn delay_ms(&mut self, ms: u8) {
90-
self.delay_ms(u32::from(ms));
98+
Delay::delay_ms(self, u32::from(ms));
9199
}
92100
}
93101

94102
impl DelayUs<u32> for Delay {
95103
#[inline]
96104
fn delay_us(&mut self, us: u32) {
97-
self._delay_us(us);
105+
Delay::delay_us(self, us);
98106
}
99107
}
100108

@@ -103,20 +111,20 @@ impl DelayUs<i32> for Delay {
103111
#[inline(always)]
104112
fn delay_us(&mut self, us: i32) {
105113
assert!(us >= 0);
106-
self.delay_us(us as u32);
114+
Delay::delay_us(self, us as u32);
107115
}
108116
}
109117

110118
impl DelayUs<u16> for Delay {
111119
#[inline(always)]
112120
fn delay_us(&mut self, us: u16) {
113-
self.delay_us(u32::from(us))
121+
Delay::delay_us(self, u32::from(us))
114122
}
115123
}
116124

117125
impl DelayUs<u8> for Delay {
118126
#[inline(always)]
119127
fn delay_us(&mut self, us: u8) {
120-
self.delay_us(u32::from(us))
128+
Delay::delay_us(self, u32::from(us))
121129
}
122130
}

src/peripheral/ac.rs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
//! Cortex-M7 TCM and Cache access control.
2+
3+
use volatile_register::RW;
4+
5+
/// Register block
6+
#[repr(C)]
7+
pub struct RegisterBlock {
8+
/// Instruction Tightly-Coupled Memory Control Register
9+
pub itcmcr: RW<u32>,
10+
/// Data Tightly-Coupled Memory Control Register
11+
pub dtcmcr: RW<u32>,
12+
/// AHBP Control Register
13+
pub ahbpcr: RW<u32>,
14+
/// L1 Cache Control Register
15+
pub cacr: RW<u32>,
16+
/// AHB Slave Control Register
17+
pub ahbscr: RW<u32>,
18+
reserved0: u32,
19+
/// Auxilary Bus Fault Status Register
20+
pub abfsr: RW<u32>,
21+
}
22+
23+
/// ITCMCR and DTCMCR TCM enable bit.
24+
pub const TCM_EN: u32 = 1;
25+
26+
/// ITCMCR and DTCMCR TCM read-modify-write bit.
27+
pub const TCM_RMW: u32 = 2;
28+
29+
/// ITCMCR and DTCMCR TCM rety phase enable bit.
30+
pub const TCM_RETEN: u32 = 4;
31+
32+
/// ITCMCR and DTCMCR TCM size mask.
33+
pub const TCM_SZ_MASK: u32 = 0x78;
34+
35+
/// ITCMCR and DTCMCR TCM shift.
36+
pub const TCM_SZ_SHIFT: usize = 3;
37+
38+
/// AHBPCR AHBP enable bit.
39+
pub const AHBPCR_EN: u32 = 1;
40+
41+
/// AHBPCR AHBP size mask.
42+
pub const AHBPCR_SZ_MASK: u32 = 0x0e;
43+
44+
/// AHBPCR AHBP size shit.
45+
pub const AHBPCR_SZ_SHIFT: usize = 1;
46+
47+
/// CACR Shared cachedable-is-WT for data cache.
48+
pub const CACR_SIWT: u32 = 1;
49+
50+
/// CACR ECC in the instruction and data cache (disable).
51+
pub const CACR_ECCDIS: u32 = 2;
52+
53+
/// CACR Force Write-Through in the data cache.
54+
pub const CACR_FORCEWT: u32 = 4;
55+
56+
/// AHBSCR AHBS prioritization control mask.
57+
pub const AHBSCR_CTL_MASK: u32 = 0x03;
58+
59+
/// AHBSCR AHBS prioritization control shift.
60+
pub const AHBSCR_CTL_SHIFT: usize = 0;
61+
62+
/// AHBSCR Threshold execution prioity for AHBS traffic demotion, mask.
63+
pub const AHBSCR_TPRI_MASK: u32 = 0x7fc;
64+
65+
/// AHBSCR Threshold execution prioity for AHBS traffic demotion, shift.
66+
pub const AHBSCR_TPRI_SHIFT: usize = 2;
67+
68+
/// AHBSCR Failness counter initialization value, mask.
69+
pub const AHBSCR_INITCOUNT_MASK: u32 = 0xf800;
70+
71+
/// AHBSCR Failness counter initialization value, shift.
72+
pub const AHBSCR_INITCOUNT_SHIFT: usize = 11;
73+
74+
/// ABFSR Async fault on ITCM interface.
75+
pub const ABFSR_ITCM: u32 = 1;
76+
77+
/// ABFSR Async fault on DTCM interface.
78+
pub const ABFSR_DTCM: u32 = 2;
79+
80+
/// ABFSR Async fault on AHBP interface.
81+
pub const ABFSR_AHBP: u32 = 4;
82+
83+
/// ABFSR Async fault on AXIM interface.
84+
pub const ABFSR_AXIM: u32 = 8;
85+
86+
/// ABFSR Async fault on EPPB interface.
87+
pub const ABFSR_EPPB: u32 = 16;
88+
89+
/// ABFSR Indicates the type of fault on the AXIM interface, mask.
90+
pub const ABFSR_AXIMTYPE_MASK: u32 = 0x300;
91+
92+
/// ABFSR Indicates the type of fault on the AXIM interface, shift.
93+
pub const ABFSR_AXIMTYPE_SHIFT: usize = 8;

0 commit comments

Comments
 (0)