Skip to content

Commit 4297410

Browse files
authored
Merge pull request #36 from stm32-rs/tsc-in-progress-and-clear-ccr
TSC in progress & ccr reset
2 parents 8190e54 + 85ae063 commit 4297410

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/tsc.rs

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,8 +24,8 @@ pub enum Event {
2424
pub enum Error {
2525
/// Max count error
2626
MaxCountError,
27-
/// Wrong GPIO for reading
28-
InvalidPin
27+
/// Wrong GPIO for reading - returns the ioccr register
28+
InvalidPin(u32)
2929
}
3030

3131
pub trait SamplePin<TSC> {
@@ -218,7 +218,7 @@ impl<SPIN> Tsc<SPIN> {
218218
break Err(Error::MaxCountError)
219219
}
220220
};
221-
221+
self.tsc.ioccr.write(|w| unsafe { w.bits(0b0) }); // clear channel register
222222
result
223223
}
224224

@@ -233,7 +233,7 @@ impl<SPIN> Tsc<SPIN> {
233233
if channel == (1 << bit_pos) {
234234
Ok(self.read_unchecked())
235235
} else {
236-
Err(Error::InvalidPin)
236+
Err(Error::InvalidPin(channel))
237237
}
238238
}
239239

@@ -243,6 +243,11 @@ impl<SPIN> Tsc<SPIN> {
243243
self.tsc.iog2cr.read().cnt().bits()
244244
}
245245

246+
/// Is the tsc performing an aquisition
247+
pub fn in_progress(&mut self) -> bool {
248+
self.tsc.cr.read().start().bit_is_set()
249+
}
250+
246251
/// Enables an interrupt event
247252
pub fn listen(&mut self, event: Event){
248253
match event {

0 commit comments

Comments
 (0)