summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Silverstone <dsilvers@digital-scurf.org>2017-08-30 16:00:47 +0100
committerDaniel Silverstone <dsilvers@digital-scurf.org>2017-08-30 16:00:59 +0100
commite39384c7b22c72c078e03e2c8b1d5a9d513bf31c (patch)
tree724a94496d0c267d4695783c7c394121b90b690e
parentd88d3365ebf7636b080dee468a5693cd6efc648c (diff)
downloadblog-e39384c7b22c72c078e03e2c8b1d5a9d513bf31c.tar.bz2
Publish pma post
-rw-r--r--posts/stm32-usb-in-rust-pma.mdwn18
1 files changed, 11 insertions, 7 deletions
diff --git a/posts/stm32-usb-in-rust-pma.mdwn b/posts/stm32-usb-in-rust-pma.mdwn
index 2a2ef5c..12b9853 100644
--- a/posts/stm32-usb-in-rust-pma.mdwn
+++ b/posts/stm32-usb-in-rust-pma.mdwn
@@ -1,7 +1,7 @@
[[!meta title="STM32 USB and Rust - Packet Memory Area"]]
[[!meta author="Daniel Silverstone"]]
[[!meta date="2017-08-30 16:00:00"]]
-[[!tag stm32 usb rust draft]]
+[[!tag stm32 usb rust]]
In this, our next exciting installment of STM32 and Rust for USB device
drivers, we're going to look at what the STM32 calls the 'packet memory area'.
@@ -35,12 +35,12 @@ the sense of the endpoint address numbering. As such there're eight
descriptors each four 16bit words long (eight bytes) making for a buffer
descriptor table which is 64 bytes in size at most.
-Byte offset | Field name | Description
-----------------|----------------|-------------
-`(EPn * 8) + 0` | `USB_ADDRn_TX` | The address (inside the PMA) of the TX buffer for EPn
-`(EPn * 8) + 2` | `USB_COUNTn_TX`| The number of bytes present in the TX buffer for EPn
-`(EPn * 8) + 4` | `USB_ADDRn_RX` | The address (inside the PMA0 of the RX buffer for EPn
-`(EPn * 8) + 6` | `USB_COUNTn_RX`| The number of bytes of space available for the RX buffer for EPn (and once received, the number of bytes received)
+Byte offset in PMA | Field name | Description
+-------------------|----------------|-------------
+`(EPn * 8) + 0` | `USB_ADDRn_TX` | The address (inside the PMA) of the TX buffer for EPn
+`(EPn * 8) + 2` | `USB_COUNTn_TX`| The number of bytes present in the TX buffer for EPn
+`(EPn * 8) + 4` | `USB_ADDRn_RX` | The address (inside the PMA0 of the RX buffer for EPn
+`(EPn * 8) + 6` | `USB_COUNTn_RX`| The number of bytes of space available for the RX buffer for EPn (and once received, the number of bytes received)
[Buffer Descriptor Table]
The TX entries are trivial to comprehend. To transmit a packet, part of the
@@ -271,8 +271,12 @@ but for now it's there.
Amazingly, despite using iterators, enumerators, high level for loops, function
calls, etc, if we pop:
+[[!format c """
+
unsafe { (&*usb::pma::PMA.get()).write_buffer(0, &[0x1000, 0x2000, 0x3000]); }
+"""]]
+
into our main function and compile it, we end up with the instruction sequence:
80001e4: f246 0000 movw r0, #24576 ; 0x6000