summaryrefslogtreecommitdiffstatshomepage
path: root/docs/library
diff options
context:
space:
mode:
authorPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-03-31 01:05:17 +0300
committerPaul Sokolovsky <pfalcon@users.sourceforge.net>2015-03-31 01:16:14 +0300
commit9d2c0c231c5b366f42071ed5880f799a4f5cc52b (patch)
treee8c711232f0bccad96c53e7270ce69f03ebd6631 /docs/library
parent1bc534247cfe585afeba41b58b25a21af158ae4e (diff)
downloadmicropython-9d2c0c231c5b366f42071ed5880f799a4f5cc52b.tar.gz
micropython-9d2c0c231c5b366f42071ed5880f799a4f5cc52b.zip
docs: uctypes: Describe how to instantiate struct objects.
Diffstat (limited to 'docs/library')
-rw-r--r--docs/library/uctypes.rst20
1 files changed, 18 insertions, 2 deletions
diff --git a/docs/library/uctypes.rst b/docs/library/uctypes.rst
index d7ebc7b7d5..e83c56b3e4 100644
--- a/docs/library/uctypes.rst
+++ b/docs/library/uctypes.rst
@@ -98,8 +98,8 @@ Module contents
.. class:: struct(descriptor, layout_type)
- Create a "foreign data structure" object based on its descriptor (encoded
- as a dictionary) and layout type.
+ Create a "foreign data structure" class based on its descriptor (encoded
+ as a dictionary) and layout type (see below).
.. data:: LITTLE_ENDIAN
@@ -140,6 +140,22 @@ Module contents
so it can be both written too, and you will access current value
at the given memory address.
+Structure classes and instantiating structure objects
+-----------------------------------------------------
+
+Given structure descriptor and layout type, you can instantiate a
+"structure class" using uctypes.struct() factory function. From it,
+you can instantiate a specific structure instance at a given
+memory address. Memory address usually comes from following sources:
+
+* Predefined address, when accessing hardware registers on a baremetal
+port. Lookup these addresses in datasheet for a particular MCU/SoC.
+* As return value from a call to some FFI (Foreign Function Interface)
+function.
+* From uctypes.addressof(), when you want to pass arguments to FFI
+function, or alternatively, to access some data for I/O (for example,
+data read from file or network socket).
+
Structure objects
-----------------