diff options
author | 2018-01-11 15:26:18 +0100 | |
---|---|---|
committer | 2018-01-11 15:26:18 +0100 | |
commit | ee21e7d66a2975aa358f9a69185defa9fa5e4e85 (patch) | |
tree | 166503af50042e80b3f044caac4be587689dc5da /src/exception.rs | |
parent | bdc7ca96c5593e410c8f49025d2b0fced7607a4d (diff) | |
download | cortex-m-ee21e7d66a2975aa358f9a69185defa9fa5e4e85.tar.gz cortex-m-ee21e7d66a2975aa358f9a69185defa9fa5e4e85.tar.zst cortex-m-ee21e7d66a2975aa358f9a69185defa9fa5e4e85.zip |
make `Stim::write_*` methods take `&mut self` instead of `&self`
this prevents people from overlapping non-atomic write operations on the same stimulus port when
working with generators (cooperative tasks).
For example, with this change the following code won't compile
``` rust
let stim = &mut ITM.stim[0];
let a = || {
loop {
// ..
for byte in b"Hello, world!".iter() {
while !stim.is_fifo_ready() { yield }
stim.write_u8(*byte);
}
// ..
}
};
let b = || {
loop {
// ..
for byte in b"The quick brown fox jumps over the lazy dog".iter() {
while !stim.is_fifo_ready() { yield }
stim.write_u8(*byte);
}
// ..
}
};
```
A possible fix for the above code is to use different stimulus ports in each task (generator).
Diffstat (limited to 'src/exception.rs')
0 files changed, 0 insertions, 0 deletions