aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Schwind <[email protected]>2025-10-04 13:22:35 +0900
committerBrian Schwind <[email protected]>2025-10-04 16:52:20 +0900
commit7e3ca6067be7e2361ccd75f9712a0d08fa7d2d6a (patch)
treeb6571909da4fecb31caa383350dee6f0d7926c85
parent2ecb06bf9b7d59ec85793228fefa01c70f3c432c (diff)
hspi: properly configure the transfer size
-rw-r--r--embassy-stm32/src/hspi/mod.rs18
1 files changed, 12 insertions, 6 deletions
diff --git a/embassy-stm32/src/hspi/mod.rs b/embassy-stm32/src/hspi/mod.rs
index 277f69496..b64a6b62c 100644
--- a/embassy-stm32/src/hspi/mod.rs
+++ b/embassy-stm32/src/hspi/mod.rs
@@ -498,7 +498,8 @@ impl<'d, T: Instance, M: PeriMode> Hspi<'d, T, M> {
498 w.set_dmaen(false); 498 w.set_dmaen(false);
499 }); 499 });
500 500
501 self.configure_command(&transaction, Some(buf.len()))?; 501 let transfer_size_bytes = buf.len() * W::size().bytes();
502 self.configure_command(&transaction, Some(transfer_size_bytes))?;
502 503
503 let current_address = T::REGS.ar().read().address(); 504 let current_address = T::REGS.ar().read().address();
504 let current_instruction = T::REGS.ir().read().instruction(); 505 let current_instruction = T::REGS.ir().read().instruction();
@@ -537,7 +538,8 @@ impl<'d, T: Instance, M: PeriMode> Hspi<'d, T, M> {
537 w.set_dmaen(false); 538 w.set_dmaen(false);
538 }); 539 });
539 540
540 self.configure_command(&transaction, Some(buf.len()))?; 541 let transfer_size_bytes = buf.len() * W::size().bytes();
542 self.configure_command(&transaction, Some(transfer_size_bytes))?;
541 543
542 T::REGS 544 T::REGS
543 .cr() 545 .cr()
@@ -767,7 +769,8 @@ impl<'d, T: Instance> Hspi<'d, T, Async> {
767 // Wait for peripheral to be free 769 // Wait for peripheral to be free
768 while T::REGS.sr().read().busy() {} 770 while T::REGS.sr().read().busy() {}
769 771
770 self.configure_command(&transaction, Some(buf.len()))?; 772 let transfer_size_bytes = buf.len() * W::size().bytes();
773 self.configure_command(&transaction, Some(transfer_size_bytes))?;
771 774
772 let current_address = T::REGS.ar().read().address(); 775 let current_address = T::REGS.ar().read().address();
773 let current_instruction = T::REGS.ir().read().instruction(); 776 let current_instruction = T::REGS.ir().read().instruction();
@@ -807,7 +810,8 @@ impl<'d, T: Instance> Hspi<'d, T, Async> {
807 // Wait for peripheral to be free 810 // Wait for peripheral to be free
808 while T::REGS.sr().read().busy() {} 811 while T::REGS.sr().read().busy() {}
809 812
810 self.configure_command(&transaction, Some(buf.len()))?; 813 let transfer_size_bytes = buf.len() * W::size().bytes();
814 self.configure_command(&transaction, Some(transfer_size_bytes))?;
811 T::REGS 815 T::REGS
812 .cr() 816 .cr()
813 .modify(|v| v.set_fmode(FunctionalMode::IndirectWrite.into())); 817 .modify(|v| v.set_fmode(FunctionalMode::IndirectWrite.into()));
@@ -837,7 +841,8 @@ impl<'d, T: Instance> Hspi<'d, T, Async> {
837 // Wait for peripheral to be free 841 // Wait for peripheral to be free
838 while T::REGS.sr().read().busy() {} 842 while T::REGS.sr().read().busy() {}
839 843
840 self.configure_command(&transaction, Some(buf.len()))?; 844 let transfer_size_bytes = buf.len() * W::size().bytes();
845 self.configure_command(&transaction, Some(transfer_size_bytes))?;
841 846
842 let current_address = T::REGS.ar().read().address(); 847 let current_address = T::REGS.ar().read().address();
843 let current_instruction = T::REGS.ir().read().instruction(); 848 let current_instruction = T::REGS.ir().read().instruction();
@@ -877,7 +882,8 @@ impl<'d, T: Instance> Hspi<'d, T, Async> {
877 // Wait for peripheral to be free 882 // Wait for peripheral to be free
878 while T::REGS.sr().read().busy() {} 883 while T::REGS.sr().read().busy() {}
879 884
880 self.configure_command(&transaction, Some(buf.len()))?; 885 let transfer_size_bytes = buf.len() * W::size().bytes();
886 self.configure_command(&transaction, Some(transfer_size_bytes))?;
881 T::REGS 887 T::REGS
882 .cr() 888 .cr()
883 .modify(|v| v.set_fmode(FunctionalMode::IndirectWrite.into())); 889 .modify(|v| v.set_fmode(FunctionalMode::IndirectWrite.into()));