Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
F
firmware
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Marek
firmware
Commits
576f6755
Verified
Commit
576f6755
authored
5 years ago
by
rahix
Browse files
Options
Downloads
Patches
Plain Diff
docs: Slight adjustments to header nesting
Signed-off-by:
Rahix
<
rahix@rahix.de
>
parent
56c91922
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
Documentation/pycardium-guide.rst
+7
-13
7 additions, 13 deletions
Documentation/pycardium-guide.rst
with
7 additions
and
13 deletions
Documentation/pycardium-guide.rst
+
7
−
13
View file @
576f6755
...
...
@@ -46,16 +46,10 @@ pushing that into external flash.
.. _#11: https://git.card10.badge.events.ccc.de/card10/firmware/issues/11
C Modules
---------
C modules are quite a bit more complicated. First, this guide will show how to
create a new module and then, there will be some information related to
different aspects of writing modules.
Creating a new C module
~~~~~~~~~~~~~~~~~~~~~~~
-----------------------
Module Source
^^^^^^^^^^^^^
~~~~~~~~~~~~~
Create a new file in ``pycardium/modules``. The basic structure of a C module
looks like this:
...
...
@@ -89,13 +83,13 @@ looks like this:
MP_REGISTER_MODULE(MP_QSTR_example, example_module, MODULE_EXAMPLE_ENABLED);
Build Integration
^^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~~
Next, you need to add your module to ``pycardium/meson.build``. There is a list
of module sources at the very top called ``modsrc`` where you need to add your
file (e.g. ``modules/example.c``).
QSTR Definitions
^^^^^^^^^^^^^^^^
~~~~~~~~~~~~~~~~
If you now run ``ninja -C build/``, you will hit a few errors regarding missing
QSTR definitions. With the example module above, they will look similar to
this:
...
...
@@ -119,7 +113,7 @@ Each ``Q(...)`` will define into a corresponding ``MP_QSTR_...``. So
``Q(example)`` corresponds to ``MP_QSTR_example``.
Enable Module
^^^^^^^^^^^^^
~~~~~~~~~~~~~
The last step is to actually enable inclusion of your module into the firmware.
Do this by adding a define in ``pycardium/mpconfigport.h``:
...
...
@@ -130,7 +124,7 @@ Do this by adding a define in ``pycardium/mpconfigport.h``:
The name of the define is the one from the last line in the module source above.
Wrapping Epicardium API
~~~~~~~~~~~~~~~~~~~~~~~
-----------------------
Most modules will probably make use of the :ref:`Epicardium API
<epicardium_api_overview>`. Doing so does not require any extra work, you can
just call the API from your module code. You should check the input that your
...
...
@@ -149,7 +143,7 @@ calls. As most API calls use *errno* codes, you can just wrap them in an
}
QSTRs
~~~~~
-----
QSTRs are so called “interned strings”. This means they are not allocated like
normal python objects but instead live in flash and are indexed. This allow
MicroPython to very efficiently use them as identifiers. According to them,
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment