aboutsummaryrefslogtreecommitdiffstats
path: root/docs
diff options
context:
space:
mode:
authorMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:43:27 -0400
committerMarti Bolivar <mbolivar@leaflabs.com>2011-05-09 16:49:08 -0400
commit19ea6ba4ea3f1ecb9830cf4d3e1366513f4f96e3 (patch)
treea43f7e0fb3650ca54f245b750a078a0e8c356504 /docs
parent868fb1c273e562a1140abfa948022c9d4f55bccf (diff)
parent1e2e177f6dae62e040c674b617744c73be187062 (diff)
downloadlibrambutan-19ea6ba4ea3f1ecb9830cf4d3e1366513f4f96e3.tar.gz
librambutan-19ea6ba4ea3f1ecb9830cf4d3e1366513f4f96e3.zip
Merge branch 'refactor'
This merges the libmaple refactor work into master. The contents of libmaple proper (/libmaple/) are almost completely incompatible with previous APIs in master. See /docs/source/libmaple/overview.rst for more information on the new design. Wirish incompatibilities are limited to the HardwareTimer class; however, there are several new deprecations, most likely to be removed in 0.1.0.
Diffstat (limited to 'docs')
-rw-r--r--docs/Doxyfile13
-rw-r--r--docs/README73
-rw-r--r--docs/source/_static/img/libmaple-screenshot-small.pngbin38023 -> 0 bytes
-rw-r--r--docs/source/adc.rst66
-rw-r--r--docs/source/arduino-cc-attribution.txt (renamed from docs/source/lang/api/cc-attribution.txt)6
-rw-r--r--docs/source/arduino-compatibility.rst (renamed from docs/source/compatibility.rst)30
-rw-r--r--docs/source/arm-gcc.rst53
-rw-r--r--docs/source/bootloader.rst178
-rw-r--r--docs/source/conf.py40
-rw-r--r--docs/source/errata.rst140
-rw-r--r--docs/source/external-interrupts.rst119
-rw-r--r--docs/source/gpio.rst114
-rw-r--r--docs/source/hardware/maple-ret6.rst276
-rw-r--r--docs/source/hardware/maple.rst345
-rw-r--r--docs/source/i2c.rst54
-rw-r--r--docs/source/index.rst29
-rw-r--r--docs/source/jtag.rst55
-rw-r--r--docs/source/lang/api/abs.rst3
-rw-r--r--docs/source/lang/api/analogread.rst78
-rw-r--r--docs/source/lang/api/analogwrite.rst43
-rw-r--r--docs/source/lang/api/attachinterrupt.rst57
-rw-r--r--docs/source/lang/api/bit.rst12
-rw-r--r--docs/source/lang/api/bitclear.rst13
-rw-r--r--docs/source/lang/api/bitread.rst11
-rw-r--r--docs/source/lang/api/bitset.rst9
-rw-r--r--docs/source/lang/api/bitwrite.rst7
-rw-r--r--docs/source/lang/api/board-values.rst180
-rw-r--r--docs/source/lang/api/boardusespin.rst27
-rw-r--r--docs/source/lang/api/constants.rst36
-rw-r--r--docs/source/lang/api/constrain.rst5
-rw-r--r--docs/source/lang/api/cos.rst6
-rw-r--r--docs/source/lang/api/delay.rst6
-rw-r--r--docs/source/lang/api/delaymicroseconds.rst11
-rw-r--r--docs/source/lang/api/detachinterrupt.rst8
-rw-r--r--docs/source/lang/api/digitalread.rst39
-rw-r--r--docs/source/lang/api/digitalwrite.rst39
-rw-r--r--docs/source/lang/api/disabledebugports.rst31
-rw-r--r--docs/source/lang/api/enabledebugports.rst31
-rw-r--r--docs/source/lang/api/hardwarespi.rst215
-rw-r--r--docs/source/lang/api/hardwaretimer.rst548
-rw-r--r--docs/source/lang/api/highbyte.rst6
-rw-r--r--docs/source/lang/api/isbuttonpressed.rst5
-rw-r--r--docs/source/lang/api/loop.rst3
-rw-r--r--docs/source/lang/api/lowbyte.rst2
-rw-r--r--docs/source/lang/api/map.rst2
-rw-r--r--docs/source/lang/api/max.rst5
-rw-r--r--docs/source/lang/api/micros.rst2
-rw-r--r--docs/source/lang/api/millis.rst2
-rw-r--r--docs/source/lang/api/min.rst3
-rw-r--r--docs/source/lang/api/pinmode.rst8
-rw-r--r--docs/source/lang/api/pow.rst5
-rw-r--r--docs/source/lang/api/pwmwrite.rst12
-rw-r--r--docs/source/lang/api/random.rst6
-rw-r--r--docs/source/lang/api/randomseed.rst2
-rw-r--r--docs/source/lang/api/serial.rst86
-rw-r--r--docs/source/lang/api/serialusb.rst72
-rw-r--r--docs/source/lang/api/setup.rst2
-rw-r--r--docs/source/lang/api/shiftout.rst99
-rw-r--r--docs/source/lang/api/sin.rst3
-rw-r--r--docs/source/lang/api/sq.rst3
-rw-r--r--docs/source/lang/api/tan.rst3
-rw-r--r--docs/source/lang/api/toggleled.rst2
-rw-r--r--docs/source/lang/api/volatile.rst8
-rw-r--r--docs/source/lang/api/waitforbuttonpress.rst2
-rw-r--r--docs/source/lang/cc-attribution.txt9
-rw-r--r--docs/source/lang/cpp/arithmetic.rst7
-rw-r--r--docs/source/lang/cpp/array.rst6
-rw-r--r--docs/source/lang/cpp/assignment.rst2
-rw-r--r--docs/source/lang/cpp/bitshift.rst3
-rw-r--r--docs/source/lang/cpp/bitwisemath.rst3
-rw-r--r--docs/source/lang/cpp/boolean.rst3
-rw-r--r--docs/source/lang/cpp/booleanvariables.rst6
-rw-r--r--docs/source/lang/cpp/break.rst5
-rw-r--r--docs/source/lang/cpp/built-in-types.rst31
-rw-r--r--docs/source/lang/cpp/byte.rst3
-rw-r--r--docs/source/lang/cpp/bytecast.rst8
-rw-r--r--docs/source/lang/cpp/char.rst10
-rw-r--r--docs/source/lang/cpp/charcast.rst6
-rw-r--r--docs/source/lang/cpp/comments.rst5
-rw-r--r--docs/source/lang/cpp/comparison.rst3
-rw-r--r--docs/source/lang/cpp/compoundarithmetic.rst3
-rw-r--r--docs/source/lang/cpp/compoundbitwise.rst1
-rw-r--r--docs/source/lang/cpp/const.rst6
-rw-r--r--docs/source/lang/cpp/continue.rst4
-rw-r--r--docs/source/lang/cpp/curly-braces.rst5
-rw-r--r--docs/source/lang/cpp/define.rst6
-rw-r--r--docs/source/lang/cpp/double.rst4
-rw-r--r--docs/source/lang/cpp/doublecast.rst2
-rw-r--r--docs/source/lang/cpp/dowhile.rst3
-rw-r--r--docs/source/lang/cpp/float.rst2
-rw-r--r--docs/source/lang/cpp/floatcast.rst2
-rw-r--r--docs/source/lang/cpp/for.rst4
-rw-r--r--docs/source/lang/cpp/goto.rst3
-rw-r--r--docs/source/lang/cpp/if.rst2
-rw-r--r--docs/source/lang/cpp/include.rst4
-rw-r--r--docs/source/lang/cpp/increment.rst2
-rw-r--r--docs/source/lang/cpp/intcast.rst5
-rw-r--r--docs/source/lang/cpp/longcast.rst2
-rw-r--r--docs/source/lang/cpp/longlong.rst2
-rw-r--r--docs/source/lang/cpp/modulo.rst2
-rw-r--r--docs/source/lang/cpp/pointer.rst2
-rw-r--r--docs/source/lang/cpp/return.rst3
-rw-r--r--docs/source/lang/cpp/scope.rst2
-rw-r--r--docs/source/lang/cpp/semicolon.rst5
-rw-r--r--docs/source/lang/cpp/sizeof.rst2
-rw-r--r--docs/source/lang/cpp/sqrt.rst3
-rw-r--r--docs/source/lang/cpp/static.rst3
-rw-r--r--docs/source/lang/cpp/string.rst3
-rw-r--r--docs/source/lang/cpp/switchcase.rst4
-rw-r--r--docs/source/lang/cpp/unsignedchar.rst5
-rw-r--r--docs/source/lang/cpp/unsignedint.rst2
-rw-r--r--docs/source/lang/cpp/unsignedlonglong.rst2
-rw-r--r--docs/source/lang/cpp/variables.rst3
-rw-r--r--docs/source/lang/cpp/void.rst4
-rw-r--r--docs/source/lang/cpp/while.rst2
-rw-r--r--docs/source/lang/unimplemented/notone.rst17
-rw-r--r--docs/source/lang/unimplemented/shiftout.rst136
-rw-r--r--docs/source/lang/unimplemented/tone.rst27
-rw-r--r--docs/source/language-index.rst21
-rw-r--r--docs/source/language.rst190
-rw-r--r--docs/source/libmaple.rst58
-rw-r--r--docs/source/libmaple/api/adc.rst12
-rw-r--r--docs/source/libmaple/api/bitband.rst12
-rw-r--r--docs/source/libmaple/api/bkp.rst12
-rw-r--r--docs/source/libmaple/api/dac.rst12
-rw-r--r--docs/source/libmaple/api/delay.rst12
-rw-r--r--docs/source/libmaple/api/dma.rst12
-rw-r--r--docs/source/libmaple/api/exti.rst12
-rw-r--r--docs/source/libmaple/api/flash.rst12
-rw-r--r--docs/source/libmaple/api/fsmc.rst12
-rw-r--r--docs/source/libmaple/api/gpio.rst12
-rw-r--r--docs/source/libmaple/api/i2c.rst12
-rw-r--r--docs/source/libmaple/api/iwdg.rst12
-rw-r--r--docs/source/libmaple/api/libmaple.rst12
-rw-r--r--docs/source/libmaple/api/libmaple_types.rst12
-rw-r--r--docs/source/libmaple/api/nvic.rst12
-rw-r--r--docs/source/libmaple/api/pwr.rst12
-rw-r--r--docs/source/libmaple/api/rcc.rst12
-rw-r--r--docs/source/libmaple/api/ring_buffer.rst12
-rw-r--r--docs/source/libmaple/api/scb.rst12
-rw-r--r--docs/source/libmaple/api/spi.rst12
-rw-r--r--docs/source/libmaple/api/stm32.rst12
-rw-r--r--docs/source/libmaple/api/systick.rst20
-rw-r--r--docs/source/libmaple/api/timer.rst12
-rw-r--r--docs/source/libmaple/api/usart.rst12
-rw-r--r--docs/source/libmaple/api/util.rst12
-rw-r--r--docs/source/libmaple/apis.rst14
-rw-r--r--docs/source/libmaple/coding-standard.rst412
-rw-r--r--docs/source/libmaple/contributing.rst113
-rw-r--r--docs/source/libmaple/overview.rst342
-rw-r--r--docs/source/libraries.rst176
-rw-r--r--docs/source/libs/servo.rst61
-rw-r--r--docs/source/libs/wire.rst104
-rw-r--r--docs/source/maple-ide-install.rst23
-rw-r--r--docs/source/maple-quickstart.rst14
-rw-r--r--docs/source/pwm.rst31
-rw-r--r--docs/source/specs.rst29
-rw-r--r--docs/source/spi.rst16
-rw-r--r--docs/source/timers.rst216
-rw-r--r--docs/source/troubleshooting.rst18
-rw-r--r--docs/source/unix-toolchain.rst324
-rw-r--r--docs/source/usart.rst19
-rw-r--r--docs/source/usb.rst59
163 files changed, 3934 insertions, 2362 deletions
diff --git a/docs/Doxyfile b/docs/Doxyfile
index 3290843..5fbb079 100644
--- a/docs/Doxyfile
+++ b/docs/Doxyfile
@@ -608,7 +608,7 @@ INPUT_ENCODING = UTF-8
# *.c *.cc *.cxx *.cpp *.c++ *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh *.hxx
# *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.py *.f90
-FILE_PATTERNS = *.h
+FILE_PATTERNS = *.h *.c
# The RECURSIVE tag can be used to turn specify whether or not subdirectories
# should be searched for input files as well. Possible values are YES and NO.
@@ -620,7 +620,9 @@ RECURSIVE = YES
# excluded from the INPUT source files. This way you can easily exclude a
# subdirectory from a directory tree whose root is specified with the INPUT tag.
-EXCLUDE =
+# FIXME The USB thing needs to get redone (ST code stripped out,
+# etc.). Until then, just ignore it.
+EXCLUDE = ../libmaple/usb/
# The EXCLUDE_SYMLINKS tag can be used select whether or not files or
# directories that are symbolic links (a Unix filesystem feature) are excluded
@@ -1369,8 +1371,11 @@ INCLUDE_FILE_PATTERNS =
# undefined via #undef or recursively expanded use the := operator
# instead of the = operator.
-PREDEFINED = ALWAYS_INLINE= \
- __cplusplus
+PREDEFINED = __attribute__()= \
+ __cplusplus \
+ STM32_MEDIUM_DENSITY
+ STM32_HIGH_DENSITY
+ STM32_XL_DENSITY
# If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then
# this tag can be used to specify a list of macro names that should be expanded.
diff --git a/docs/README b/docs/README
index 326d278..7a50a54 100644
--- a/docs/README
+++ b/docs/README
@@ -1,16 +1,42 @@
-This directory contains the Sphinx documentation for libmaple, as well
-as a Doxygen configuration file; we turn Doxygen XML output into
-Sphinx documentation. You can generate HTML documentation using the
-Makefile if you have make, or using make.bat from Windows.
+This directory contains source files used to generate libmaple's
+documentation.
+
+The generated documentation for the latest libmaple release is
+available online in HTML form at http://leaflabs.com/docs/. The web
+interface is the recommended way for users to read the documentation.
+
+This file contains instructions for generating the HTML files.
+
+About the Documentation
+-----------------------
+
+The docs are written in Sphinx's extensions to reStructuredText
+(reST). You can read more about Sphinx here:
+
+ http://sphinx.pocoo.org/tutorial.html
+
+Much of the documentation is pulled out of the libmaple source code;
+we use Doxygen XML output into Sphinx documentation. You can read
+more about Doxygen here:
+
+ http://doxygen.org
+
+We use a Sphinx plugin called Breathe to parse Doxygen's XML output
+into a form usable by Sphinx. You can read more about Breathe here:
+
+ http://michaeljones.github.com/breathe/
Documentation Build Steps
-------------------------
+You first need to produce Doxygen XML output, then you can generate
+the HTML documentation.
+
1. You need a recent-ish version of Doxygen in your PATH:
http://www.stack.nl/~dimitri/doxygen/download.html#latestsrc
-2. Install breathe, which does Doxygen-to-Sphinx conversion:
+2. Install Breathe, which does Doxygen-to-Sphinx conversion:
Read/write version (for LeafLabs developers):
@@ -37,9 +63,11 @@ Documentation Build Steps
$ sudo easy_install -U Sphinx
+ You need Sphinx version >= 1.0.6.
+
4. Before the first time you run Sphinx (and any time the Doxygen
comments in the libmaple source code are changed), you'll need to
- rebuild the Doxygen XML output:
+ build the Doxygen XML output:
$ cd libmaple/docs/source
$ doxygen
@@ -48,36 +76,23 @@ Documentation Build Steps
$ make html
- (Read the Makefile for more targets).
+ On Windows, use the batch file make.bat instead.
Reading and Modifying the Documentation
---------------------------------------
-The net effect of the above is to produce Doxygen XML output (ignore
-this) in libmaple/docs/doxygen/xml, and HTML documentation (this is
-what you want) in libmaple/docs/build/html.
-
Just point your web browser at the file
- libmaple/docs/build/html/index.html
+ /docs/build/html/index.html
-it corresponds to the Sphinx file
+It corresponds to the Sphinx file
- libmaple/docs/source/index.rst
-
-All of the documentation itself lives in libmaple/docs/source/. The
-directory source/_static/ is for static content (like style sheets);
-source/_templates/ contains Sphinx templates (or, it would, if we had
-any).
-
-The docs are written in Sphinx's version of reStructuredText (reST);
-it's a Python thing that they use to produce the docs at
-http://python.org. You can read more about Sphinx here:
-
- http://sphinx.pocoo.org/tutorial.html
+ /docs/source/index.rst
-You can view the source for any generated page of documentation by
-clicking the "Show Source" link in the sidebar.
+The file /docs/source/conf.py is the Sphinx configuration file; you
+can go read it for more information about our setup.
-The file libmaple/docs/source/conf.py is the Sphinx configuration
-file; you can go read it for more information about our setup.
+All of the documentation which isn't pulled out of source code
+comments lives in /docs/source/. The directory /docs/source/_static/
+is for static content (like style sheets); /docs/source/_templates/
+contains Sphinx templates.
diff --git a/docs/source/_static/img/libmaple-screenshot-small.png b/docs/source/_static/img/libmaple-screenshot-small.png
deleted file mode 100644
index f2be783..0000000
--- a/docs/source/_static/img/libmaple-screenshot-small.png
+++ /dev/null
Binary files differ
diff --git a/docs/source/adc.rst b/docs/source/adc.rst
index 6bbbac2..af613cc 100644
--- a/docs/source/adc.rst
+++ b/docs/source/adc.rst
@@ -6,23 +6,12 @@
Analog-Digital Conversion is the process of reading a physical voltage
as a number. The Maple has a large number of pins which are capable of
-taking 12-bit ADC measurements, which means that voltages from ground
-to +3.3v are read as numbers from 0 to 4095; this corresponds to a
+taking 12-bit ADC measurements, which means that voltages from 0 to
+3.3V are read as numbers from 0 to 4095. This corresponds to a
theoretical sensitivity of just under 1 millivolt. In reality, a
-number of factors introduce noise and bias into this reading and a
+number of factors introduce noise and bias into this reading, and a
number of techniques must be used to get good precision and accuracy.
-.. compound::
-
- The header pins with ADC functionality (marked as "AIN" on the
- silkscreen) are:
-
- D0, D1, D2, D3, D10, D11, D12, D13, D15, D16, D17, D18, D19, D20, D27, D28
-
- Note that pins 3, 27, and 28 are not marked AIN on the silkscreen
- for Maple revisions through Rev 5, however, they **do work** as
- analog input pins.
-
.. contents:: Contents
:local:
@@ -31,13 +20,15 @@ number of techniques must be used to get good precision and accuracy.
Noise and Bias
--------------
+.. FIXME [0.0.10, Maple-specific]
+
The biggest issues with analog-digital conversion are noise and bias.
With the Maple, we have tried to isolate the ADC pins and traces from
-strong noise sources but there are always trade--offs between noise,
+strong noise sources, but there are always trade--offs between noise,
additional functionality, cost, and package size.
The 6 ADC pins in a bank (D15--D20) generally have the least
-noise and should be used for fine measurements. If the input voltage
+noise, and should be used for fine measurements. If the input voltage
changes relatively slowly, a number of samples can be taken in
succession and averaged together, or the same voltage can even be
sampled by multiple ADC pins at the same time.
@@ -47,35 +38,40 @@ voltages that the sample is being compared against. In the case of the
Maple, the high reference is |vcc| and the low reference is ground.
This means that noise or fluctuations on either |vcc| or ground will
affect the measurement. It also means that the voltage you are trying
-to sample must be between ground and 3.3V. In the case of a variable
-reading, it is best if the voltage varies over the entire range of
-0--3.3V; otherwise, only a fraction of the sensitivity is being
-leveraged. Resistor dividers and constant voltage diodes are basic
-tools which can help bring a given voltage signal into the appropriate
-range; opamps and other powered components can also be used.
+to sample must be between ground and 3.3V.
+
+.. _adc-range:
+
+In the case of a variable reading, it is best if the voltage varies
+over the entire range of 0--3.3V; otherwise, only a fraction of the
+sensitivity is being leveraged. Some basic tools to accomplish this
+are `resistor dividers
+<http://en.wikipedia.org/wiki/Voltage_divider>`_ and `Zener diodes
+<http://en.wikipedia.org/wiki/Voltage_source#Zener_voltage_source>`_\
+. However, `operational amplifiers
+<http://en.wikipedia.org/wiki/Operational_amplifier>`_ and other
+powered components can also be used if greater precision is required.
.. _adc-function-reference:
Function Reference
------------------
-.. doxygenfunction:: analogRead
-
-.. doxygenfunction:: pinMode
-
-.. doxygenenum:: WiringPinMode
+* :ref:`lang-analogread`
+* :ref:`lang-pinmode`
.. _adc-recommended-reading:
Recommended Reading
-------------------
-* `Wikipedia article on Analog-to-digital converter <http://en.wikipedia.org/wiki/Analog-to-digital_converter>`_
-* `Arduino Analog Input Tutorial <http://arduino.cc/en/Tutorial/AnalogInputPins>`_
-* STMicro documentation for STM32F103RB microcontroller:
+* `Wikipedia: Analog-to-Digital Converter
+ <http://en.wikipedia.org/wiki/Analog-to-digital_converter>`_
+* `Arduino Analog Input Tutorial
+ <http://arduino.cc/en/Tutorial/AnalogInputPins>`_
+* ST documentation:
- * `All <http://www.st.com/mcu/devicedocs-STM32F103RB-110.html>`_
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
- * `Application Note on ADC Modes (pdf) <http://www.st.com/stonline/products/literature/an/16840.pdf>`_
- * `Application Note on ADC Oversampling (pdf) <http://www.st.com/stonline/products/literature/an/14183.pdf>`_
+ * `Application Note on ADC Modes
+ <http://www.st.com/stonline/products/literature/an/16840.pdf>`_ (PDF)
+ * `Application Note on ADC Oversampling
+ <http://www.st.com/stonline/products/literature/an/14183.pdf>`_ (PDF)
diff --git a/docs/source/lang/api/cc-attribution.txt b/docs/source/arduino-cc-attribution.txt
index e100140..ad1c1e0 100644
--- a/docs/source/lang/api/cc-attribution.txt
+++ b/docs/source/arduino-cc-attribution.txt
@@ -1,9 +1,9 @@
-.. Included in all this directory's files in order to satisfy the
-.. Arduino CC Attribution-ShareAlike 3.0 License
+.. Included in all relevant files in order to satisfy the Arduino
+.. CC Attribution-ShareAlike 3.0 License
.. admonition:: License and Attribution
- This documentation page was adapted from the `Arduino Reference
+ Portions of this page were adapted from the `Arduino Reference
Documentation <http://arduino.cc/en/Reference/HomePage>`_\ , which
is released under a `Creative Commons Attribution-ShareAlike 3.0
License <http://creativecommons.org/licenses/by-sa/3.0/>`_.
diff --git a/docs/source/compatibility.rst b/docs/source/arduino-compatibility.rst
index 0d6319f..e6852a0 100644
--- a/docs/source/compatibility.rst
+++ b/docs/source/arduino-compatibility.rst
@@ -1,6 +1,6 @@
.. highlight:: cpp
-.. _compatibility:
+.. _arduino-compatibility:
=============================
Maple-Arduino Compatibility
@@ -41,16 +41,19 @@ means that programs aren't much larger (or are even smaller).
Header Numbering and Incompatibilities
--------------------------------------
+.. FIXME [Maple-specific values]
+
The numbering of headers is different; on the Maple each GPIO has a
-unique number: D0, D1, D2, all the way up to D37 (actually, there are
+unique number: 0, 1, 2, all the way up to 37 (actually, there are
:ref:`a few more <jtag>`...). On the Arduino, the analog pins are
numbered separately (A0-A5) from the digital pins (D0\ -D13).
The incompatible hardware differences are:
-* **I2C port**: on most Arduinos, the |i2c| port is Analog Input 4
- (SDA) and Analog Input 5 (SCL); on the Maple, |i2c| port 1 is D5
- (SCL) and D9 (SDA), and |i2c| port 2 is D29 (SCL) and D30 (SDA).
+* :ref:`I2C <i2c>` **port**: on most Arduinos, the |i2c| port is Analog
+ Input 4 (SDA) and Analog Input 5 (SCL); on the Maple, |i2c| port 1
+ is D5 (SCL) and D9 (SDA), and |i2c| port 2 is D29 (SCL) and D30
+ (SDA).
It should be possible to skywire, sacrificing signal quality (due to
increased capacitance). Alternatively, |i2c| can be bit-banged
@@ -59,9 +62,7 @@ The incompatible hardware differences are:
* :ref:`PWM <pwm>` **on D10**: all the other standard Arduino PWM
headers have PWM functionality on the Maple (D2,D3,D6,D9,D11), but
- not D10. We did our best! It may be possible to reroute this
- peripheral internally using low level configuration, but we haven't
- looked in to it.
+ not D10.
* **No External Voltage Reference**: The Arduino has an AREF pin which
allows the use of an external ADC voltage reference; the Maple has
@@ -96,15 +97,15 @@ differences, most of which are improvements:
modes with a single call to ``pinMode()``: ``OUTPUT``,
``OUTPUT_OPEN_DRAIN``, ``INPUT_FLOATING``, ``INPUT_PULLUP``,
``INPUT_PULLDOWN``. Additionally, the PWM pins (labeled "PWM" on the
- Maple's silkscreen) can be configured in ``PWM`` and
- ``PWM_OPEN_DRAIN`` modes, and the analog input pins (labeled "AIN")
- can be configured in ``INPUT_ANALOG`` mode. See the :ref:`GPIO
- documentation <gpio>` for more information.
+ silkscreen) can be configured in ``PWM`` and ``PWM_OPEN_DRAIN``
+ modes, and the analog input pins (labeled "AIN") can be configured
+ in ``INPUT_ANALOG`` mode. See the :ref:`GPIO documentation <gpio>`
+ for more information.
* :ref:`Serial port <lang-serial>` **syntax**: like the `Arduino Mega
<http://arduino.cc/en/Main/ArduinoBoardMega>`_, the Maple has
multiple :ref:`USART ports <lang-serial>`. By default, ``Serial``
- is not mapped to any of them, use ``Serial1`` through ``Serial3``
+ is not mapped to any of them. Use ``Serial1`` through ``Serial3``
instead.
* **16-bit** :ref:`PWM <pwm>`: Arduino boards support 8-bit PWM, which
@@ -227,7 +228,8 @@ function.
- Check for ported library functionality. We intend to port all of the
core and popular libraries (like Wire, Ethernet, and the LCD screen
- driver), but this task is not yet finished. (Patches are welcome!)
+ driver), but this task is not yet finished. (:ref:`Patches are
+ welcome! <libmaple-contributing>`).
- Check for peripheral conflicts; changing the configuration of timers
and bus speeds for a feature on one header may impact all the
diff --git a/docs/source/arm-gcc.rst b/docs/source/arm-gcc.rst
index ef745f5..e97bb2f 100644
--- a/docs/source/arm-gcc.rst
+++ b/docs/source/arm-gcc.rst
@@ -4,12 +4,11 @@
GCC for Maple
=============
-This document provides notes on the current usage of
-``arm-none-eabi-gcc``, the `CodeSourcery <http://codesourcery.com>`_
-version of the GNU `GCC <http://gcc.gnu.org/>`_ compilers used to
-compile programs for the Maple. It is not intended as a reference
-manual for GCC; such manuals are available `elsewhere
-<http://gcc.gnu.org/>`_.
+This document provides notes on using of ``arm-none-eabi-gcc``, the
+`CodeSourcery <http://www.codesourcery.com/>`_ version of the GNU `GCC
+<http://gcc.gnu.org/>`_ compilers used for the Maple boards. It is
+not intended as a reference manual for GCC; such manuals are available
+`elsewhere <http://gcc.gnu.org/>`_.
Obtaining ``arm-none-eabi-gcc``
-------------------------------
@@ -17,21 +16,24 @@ Obtaining ``arm-none-eabi-gcc``
Recent versions of ``arm-none-eabi-gcc`` and associated tools are
included with the :ref:`Maple IDE <ide>`.
-Users who wish to use ``arm-none-eabi-gcc`` in concert with a standard
-Unix toolchain are referred to our :ref:`unix-toolchain` reference,
-which describes how to set up such an environment.
+Users who wish to use ``arm-none-eabi-gcc`` directly, along with a
+standard Unix Make-based toolchain, should read the
+:ref:`unix-toolchain`, which describes how to set up such an
+environment.
-LeafLabs mirrors some of the more recent versions of the compiler
-under http://static.leaflabs.com/pub/codesourcery/\ , including
-versions for OS X, win32, and 32-bit Linux.
+LeafLabs maintains `mirrors
+<http://static.leaflabs.com/pub/codesourcery/>`_ for some of the more
+recent versions of the compiler, including versions for OS X, Win32,
+and 32-bit Linux.
Compiler Flags Used by libmaple
-------------------------------
This section documents the flags passed to ``arm-none-eabi-gcc`` by
-the :ref:`Maple IDE <ide>` and the default Makefile provided with
-:ref:`libmaple <unix-toolchain>`. The information in this section is
-subject to change without notice.
+the :ref:`Maple IDE <ide>` and the default Makefile provided with the
+:ref:`Unix toolchain <unix-toolchain>`. The information in this
+section is subject to change between :ref:`libmaple <libmaple>`
+releases.
.. highlight:: sh
@@ -40,7 +42,8 @@ The following flags are among those passed to the C compiler::
-Os -g -mcpu=cortex-m3 -mthumb -march=armv7-m -nostdlib
-ffunction-sections -fdata-sections -Wl,--gc-sections
-The following flags are among those passed to the C++ compiler::
+In addition to those flags just given for the C compiler, the
+following flags are among those passed to the C++ compiler::
-fno-rtti -fno-exceptions -Wall
@@ -52,6 +55,15 @@ The following flags are among those passed to the assembler::
.. _arm-gcc-avr-gcc:
+Using the C Standard Library
+----------------------------
+
+By default (under both the :ref:`Maple IDE <ide>` and the :ref:`Unix
+toolchain <unix-toolchain>`), ``arm-none-eabi-gcc`` is configured to
+link against `newlib <http://sourceware.org/newlib/>`_, a C standard
+library intended for use with embedded applications. You are free to
+include of any of its headers.
+
Switching from AVR-GCC
----------------------
@@ -63,8 +75,11 @@ including Arduino) for use on the Maple.
.. _arm-gcc-attribute-flash:
- Replacing ``PROGMEM``: You can direct the linker script provided
- with libmaple to store a variable in flash by using
- ``__attribute__((section (".USER_FLASH")))``, like so::
+ with libmaple to store a variable in Flash (instead of RAM) by using
+ the libmaple macro ``__FLASH__``, like so::
- uint32 arr[] __attribute__((section (".USER_FLASH"))) = {...};
+ uint32 array[] __FLASH__ = {0, 1, 2};
+ Be aware, however, that if you do that, you can only store values
+ which are compile-time constants, and that if you attempt to change
+ a variable stored in Flash, your program will crash.
diff --git a/docs/source/bootloader.rst b/docs/source/bootloader.rst
index 57833ed..ec4fe73 100644
--- a/docs/source/bootloader.rst
+++ b/docs/source/bootloader.rst
@@ -1,10 +1,9 @@
.. highlight:: sh
-=====================
- Maple Bootloader(s)
-=====================
+.. _bootloader:
-.. TODO: add a section on flashing your own bootloader
+Maple Bootloader(s)
+===================
The firmware which allows the Maple to be reprogrammed via a USB
connection. Every Maple board comes programmed with this by default,
@@ -15,7 +14,7 @@ Flash memory and only runs when the chip is reset).
git clone git://github.com/leaflabs/maple-bootloader.git
-**Visit the github development project**: http://github.com/leaflabs/maple-bootloader
+**Visit the github development project**: https://github.com/leaflabs/maple-bootloader
.. contents:: Contents
:local:
@@ -36,7 +35,7 @@ likely only interesting to a few. If you just want to get the rough
idea, skim this article. If you want to start hacking on the
bootloader, get in touch with us to get even more info on how this all
works. And finally, you can always `check out the code at github
-<http://github.com/leaflabs/libmaple>`_!
+<https://github.com/leaflabs/libmaple>`_!
Arduino
-------
@@ -66,7 +65,7 @@ have embedded USB support. Thus, Maple doesn’t need the extra FTDI
chip. Firmware is uploaded via the standard DFU protocol (also used by
iPhone and openMoko). Since DFU is a standard, there is no need for
custom software running on the host to upload the firmware. Any DFU
-compliant program will work. The maple ide is based around
+compliant program will work. The Maple IDE is based around
:command:`dfu-util`, openMoko’s DFU utility. Using DFU came at a cost,
however. The USB port must additionally implement a separate serial
port at the same time (we use the CDC ACM class for serial
@@ -87,11 +86,11 @@ important what this means, except for two things.
1. Four drivers were necessary to make everything work.
2. IAD is not supported by OS X.
-Mac, on the other hand, only supported Compound USB, a different trick
-that is not supported by Windows. While a perpetual background
+Mac OS X, on the other hand, only supported Compound USB, a different
+trick that is not supported by Windows. While a perpetual background
bootloader was attractive, it became clear, after much toiling, we
-were going to have to write some custom drivers across several
-platforms to make everything work this way.
+were going to have to write custom drivers across several platforms to
+make everything work this way.
.. _bootloader-rev3:
@@ -103,22 +102,21 @@ Arduino. In Rev 3, the device resets into bootloader mode, which
stays alive for a few moments to receive commands, and then jumps to
user code. The bootloader is implemented as a DFU device -- just a DFU
device, no serial port. This requires one driver for Windows
-(:file:`drivers/mapleDrv/dfu` in the Windows IDE directory). As part
-of the :ref:`libmaple <libmaple>` library, user code is automatically
-supplied with serial support via some behind the scenes work that
-happens automatically when you compile (``setupUSB()`` is appended to
-``setup()``). This user mode code only implements a CDC ACM class USB
-device, giving you functions like ``Usb.print()``. Separating these
-two modes fixed the driver issue, required no complicated compound USB
-device nonsense, and works well across platforms, requiring only two
-drivers (serial and DFU) on Windows.
+(:file:`drivers/mapleDrv/dfu` in the Windows IDE directory).
+
+As part of the :ref:`libmaple <libmaple>` library, user code is
+automatically supplied with serial support via some behind the scenes
+work (``setupUSB()`` is called from ``init()``). This user mode code
+only implements a CDC ACM class USB device, giving you functions like
+:ref:`SerialUSB.read() <lang-serialusb-read>`. Separating these two
+modes fixed the driver issues and works well across platforms,
+requiring only two drivers (serial and DFU) on Windows.
However, it is no longer possible to upload code at will, since there
-is no bootloader quietly listening in the background. Instead you have
-to reset the board, then initiate a DFU transaction. This reset is
-performed automatically by the IDE by sending a command over the USB
-serial port. You can generate this reset on your own using a Python
-script or some other scheme. All you need do is:
+is no bootloader quietly listening in the background. Instead, you
+must reset the board, then initiate a DFU transaction. The IDE
+performs this reset automatically by performing a special sequence of
+changes on the USB serial port:
1. Pulse DTR (high and then low, so that you've created a negative
edge)
@@ -128,15 +126,16 @@ script or some other scheme. All you need do is:
negative edge, rather than just ensuring DTR is low.
After the reset, the host OS takes a few moments (.5-2 seconds) to
-re-enumerate the device as DFU. This delay is unpredictable, and its
-the reason the bootloader on Maple Rev3 stays alive for so
-long. Sometimes the bootloader was exiting before the OS had even
-enumerated the device! Once in bootloader mode, however,
-:command:`dfu-util` uploads your sketch into either flash or RAM (DFU
-alternate setting 0 or 1, respectively) and resets the board again.
-This time, however, no DFU transaction is initiated, and the
-bootloader gives way to user code, closing down the DFU pipe and
-bringing up the USB serial.
+re-enumerate the device as DFU. This delay is unpredictable, and is
+the reason the bootloader on Maple Rev 3/Rev 5 stays alive for so
+long. (Sometimes, the bootloader was exiting before the OS had even
+enumerated the device.)
+
+Once in bootloader mode, :command:`dfu-util` uploads your sketch into
+either flash or RAM (DFU alternate setting 0 or 1, respectively) and
+resets the board again. This time, however, no DFU transaction is
+initiated, and the bootloader gives way to user code, closing down the
+DFU pipe and bringing up the USB serial port.
.. .. _bootloader-rev6:
@@ -585,20 +584,25 @@ bringing up the USB serial.
Flashing A Custom Bootloader
----------------------------
-The STM32 microprocessor on the Maple comes with a built-in hardware
+.. warning:: This section is for users who want to put a fresh or
+ custom bootloader on their board. It's possible to make a mistake
+ in this process and e.g. render your Maple unable to communicate
+ with the IDE. Know what you're doing, and proceed with caution.
+
+The STM32 microprocessor on the Maple comes with a built-in serial
bootloader that can be used to flash a new (software) bootloader onto
-the chip. This section describes how to go about this, using a Maple
-Rev 3 or higher (if you have a Maple Rev 1; you don't have a BUT
-button, and won't be able to follow these directions. A workaround is
-detailed in `this forum posting
-<http://forums.leaflabs.com/topic.php?id=32#post-126>`_).
-
-.. warning:: This section is directed at users wishing to write a
- custom bootloader for the Maple, or update their bootloader to a
- more recent version. It's generally not necessary to do so, and it
- is possible to make a mistake and e.g. render your Maple unable to
- communicate with the IDE. Know what you're doing, and proceed with
- caution.
+the chip. While the Maple bootloader is just a program, the built-in
+serial bootloader is part of the STM32 hardware, so it's always
+available.
+
+This means that you can **always** follow these instructions to put a
+new bootloader program on your board; it **doesn't matter** if there's
+already a copy of the Maple bootloader on it or not.
+
+This section applies to Maple Rev 3 or higher. If you have a Maple
+Rev 1; you don't have a BUT button, and won't be able to follow these
+directions. A workaround is detailed in `this forum posting
+<http://forums.leaflabs.com/topic.php?id=32#post-126>`_.
.. highlight:: sh
@@ -615,10 +619,20 @@ In order to follow these instructions, you will need:
**Step 1: Obtain a bootloader binary**. The first thing you'll need to
do is to compile your bootloader binary. Note that an ASCII
-representation of the binary, such as the Intel .hex format, will not
-suffice. For example, you can run (on a :ref:`suitably configured
-system <unix-toolchain>`) the following to obtain a binary of the
-bootloader currently used on the Maple::
+representation of the binary, such as the Intel .hex format, won't
+work.
+
+.. FIXME [Mini, Native] links to precompiled bootloaders
+
+If you just want to flash the default Maple bootloader (the one that
+was installed on your Maple when it arrived), we host a `pre-compiled
+copy
+<http://static.leaflabs.com/pub/leaflabs/maple-bootloader/maple_boot-rev3-9c5f8e.bin>`_,
+which works on all Maple Revs.
+
+To obtain the latest development version, you can run (on a
+:ref:`suitably configured system <unix-toolchain>`) the following to
+obtain a binary of the bootloader currently used on the Maple::
$ git checkout git://github.com/leaflabs/maple-bootloader.git
$ cd maple-bootloader
@@ -632,15 +646,20 @@ could use another Maple, an Arduino, etc. -- anything that allows your
computer to communicate with the Maple you want to reprogram over a
serial interface.
+.. FIXME [Maple-specific values]
+
If you do use an FTDI breakout board, first make sure your Maple is
disconnected from an external power source, be it battery, USB, or
barrel jack. Then, connect the FTDI board's TX pin to ``Serial1``\ 's
RX pin (pin 8), FTDI RX to ``Serial1`` TX (pin 7), FTDI ground to
Maple's GND, and its 3.3V pin to Maple's Vin (use the Maple's
-silkscreen for help locating these pins). At this point, you're ready
-to plug the FTDI board into your computer (via USB).
+silkscreen for help locating these pins).
+
+More information on ``Serial1`` is available :ref:`here
+<lang-serial>`.
-The ``Serial1`` pins are documented :ref:`here <lang-serial>`.
+At this point, you're ready to plug the FTDI board into your computer
+(via USB).
**Step 3: Put your Maple into serial bootloader mode**. Do this by
pressing the RESET button, then *while RESET is held down*, pressing
@@ -648,35 +667,50 @@ and holding the BUT button. Next, *making sure to keep BUT held
down*, release the RESET button and wait for a few seconds before
releasing BUT.
-**Step 4: Obtain stm32loader.py**. The
-script ``stm32loader.py`` is provided with libmaple. If you have set
-up the :ref:`Unix toolchain <unix-toolchain>`, it is available in
-libmaple/support/stm32loader.py. Otherwise, you can download it
-directly from `github
+**Step 4: Get stm32loader.py**. You can download it directly from
+`libmaple's github page
<https://github.com/leaflabs/libmaple/raw/master/support/stm32loader.py>`_
-(click the link, then save the file somewhere on your system).
+(click the link, then save the file somewhere on your system). If you
+have set up the :ref:`Unix toolchain <unix-toolchain>`, it's the file
+libmaple/support/stm32loader.py.
Flashing the new Bootloader
^^^^^^^^^^^^^^^^^^^^^^^^^^^
-We'll use ``new-boot.bin``, ``ser-port``, and ``stm32loader.py`` to
-respectively refer to the absolute paths to the bootloader binary
-(from Step 1), the serial port device file or COMM port (from Steps 2
-and 3), and the stm32loader.py script.
+We'll use ``maple_boot.bin`` as the path to the bootloader binary from
+Step 1, and ``ser-port`` as the Maple's serial port device file or COM
+port.
+
+* On **Linux**, ``ser-port`` will probably be something like
+ ``/dev/ttyUSB0``, although the exact number could be different (it
+ could be ``/dev/ttyUSB1``, ``/dev/ttyUSB2``, etc.).
+
+* On **OS X**, ``ser-port`` will probably look like
+ ``/dev/tty.usbserialXXXX``, where ``XXXX`` is some random string of
+ characters.
+
+* On **Windows**, ``ser-port`` will be something like ``COM1``, ``COM2``, etc.
.. highlight:: sh
-You can run ::
+To upload a bootloader binary, run this command from the Unix shell::
+
+ python stm32loader.py -p ser-port -evw maple_boot.bin
+
+Or this command from the Windows command prompt::
+
+ python.exe stm32loader.py -p ser-port -evw maple_boot.bin
- $ python stm32loader.py -h
+You can also run the following to get usage information::
-to obtain usage information. The incantation for uploading a
-bootloader binary ``new-bootloader.bin`` is ::
+ # Unix:
+ python stm32loader.py -h
- $ python stm32loader.py -p ser-port -evw new-boot.bin
+ # Windows:
+ python.exe stm32loader.py -h
If all goes well, you'll see a bunch of output, then "Verification
OK". If something goes wrong, the `forum`_ is probably your best bet
-for obtaining help, with IRC (irc.freenode.net, #leafblowers) being
-another option. If all else fails, you can always `contact us
-directly`_!
+for obtaining help, with IRC (server irc.freenode.net, channel
+#leafblowers) being another option. If all else fails, you can always
+`contact us directly`_!
diff --git a/docs/source/conf.py b/docs/source/conf.py
index 1ad4e57..baadccb 100644
--- a/docs/source/conf.py
+++ b/docs/source/conf.py
@@ -59,7 +59,7 @@ copyright = u'2010, LeafLabs, LLC'
# The short X.Y version.
version = '0.0'
# The full version, including alpha/beta/rc tags.
-release = '0.0.9'
+release = '0.0.10'
# The language for content autogenerated by Sphinx. Refer to documentation
# for a list of supported languages.
@@ -117,25 +117,25 @@ html_theme = 'default'
# further. For a list of options available for each theme, see the
# documentation.
html_theme_options = {
- ## Sidebar placement options
- #'stickysidebar' : 'true',
- 'rightsidebar' : 'true',
- #'collapsiblesidebar' : 'true',
-
- ## Color
- 'sidebarbgcolor' : '#C8C8C8',
- 'sidebarlinkcolor' : 'green',
- 'sidebartextcolor' : 'black',
+ ## Sidebar placement options
+ #'stickysidebar' : 'true',
+ 'rightsidebar' : 'true',
+ #'collapsiblesidebar' : 'true',
+
+ ## Color
+ 'sidebarbgcolor' : '#C8C8C8',
+ 'sidebarlinkcolor' : 'green',
+ 'sidebartextcolor' : 'black',
#'sidebarbtncolor' : 'black',
- 'footerbgcolor' : 'green',
- 'relbarbgcolor' : 'green',
- 'headlinkcolor' : '#000000',
- 'linkcolor' : 'green',
- 'visitedlinkcolor' : 'green',
-
- ## Font
- 'headfont' : 'Georgia',
- 'bodyfont' : 'Lucidia'
+ 'footerbgcolor' : 'green',
+ 'relbarbgcolor' : 'green',
+ 'headlinkcolor' : '#000000',
+ 'linkcolor' : 'green',
+ 'visitedlinkcolor' : 'green',
+
+ ## Font
+ 'headfont' : 'Georgia',
+ 'bodyfont' : 'Lucidia'
}
# Add any paths that contain custom themes here, relative to this directory.
@@ -174,7 +174,7 @@ html_last_updated_fmt = '%b %d, %Y'
# re-add commented line when custom template for api finished
html_sidebars = {
'**': ['globaltoc.html', 'searchbox.html'],
- #'lang/api**':['searchbox.html', 'apilist.html'],
+ #'lang/api**':['searchbox.html', 'apilist.html'],
}
diff --git a/docs/source/errata.rst b/docs/source/errata.rst
deleted file mode 100644
index 657abd9..0000000
--- a/docs/source/errata.rst
+++ /dev/null
@@ -1,140 +0,0 @@
-.. _errata:
-
-========
- Errata
-========
-
-This page is a collection of known issues and warnings for each
-revision of the Maple board. The failure modes aren't design errors,
-but are easy ways to break or damage your board permanently. For a
-list of differences between the Maple and Arduinos, see the
-:ref:`compatibility reference <compatibility>`.
-
-The errata are grouped by Maple version ("Rev"). Rev 5 is currently
-on sale. If you are unsure which version you own, the :ref:`Maple
-hardware page <maple-hardware-identify-rev>` has pictures and
-descriptions of each version.
-
-.. contents:: Contents
- :local:
-
-Maple Rev 5
------------
-
-Known issues:
-
-* **Pin 3 AIN missing**: Pin 3 is capable of analog input, but the
- corresponding "AIN" is missing from its silkscreen.
-
-* **GPIO 39-43 not configured**: this is really more of a software
- "TODO" item. Some of the JTAG header pins are numbered 39-43. These
- STM32 pins are indeed fully functional :ref:`GPIO <gpio>` when a
- :ref:`JTAG <jtag>` device is not connected, but we have not enabled
- them in software and thus they can not be accessed with the regular
- :ref:`lang-pinmode` or :ref:`lang-digitalwrite` functions.
-
-Potential failure modes:
-
-* **High voltage on non-tolerant pins**: not all header pins are 5V
- compatible; so e.g. connecting certain serial devices in the wrong
- way could over-voltage the pins. The :ref:`Pin-Mapping Mega Table
- <pin-mapping-mega-table>` details which pins are 5V-tolerant.
-
-Maple Rev 3
------------
-
-Known issues:
-
-* **Bad/Sticky Buttons**: a number of Rev 3 boards sold in May-June 2010
- have questionable RESET and BUT buttons.
-
- What seems to have happened is that the flux remover we used to
- clean the boards before shipping eroded the plastic internals, which
- resulted in intermittent functionality. All buttons on all shipped
- boards did function in testing, but some may have been unreliable in
- regular use.
-
- If you have this problem, we will be happy to ship you new buttons
- if you think you can re-solder them yourself, or you can ship us
- your board and we will swap out that part.
-
- For reference, the button part number is KMR211GLFS and the flux
- remover we used is "Precision Electronics Cleaner" from RadioShack,
- which is "Safe on most plastics" and contains Dipropylene glycol
- monomethyl ether, hydrotreated heavy naphtha, dipropylene glycol
- methyl ether acetate (really?), and carbon dioxide.
-
-* **Resistors on pins 0 and 1**: these header pins, which are RX/TX on
- USART2 (:ref:`Serial2 <lang-serial>`), have resistors in-line
- between the STM32 and the headers. These resistors increase the
- impedance of the lines for ADC reads and affect the open drain GPIO
- functionality of the pins.
-
- These resistors were accidentally copied over from older Arduino USB
- designs, where they appear to protect the USB-Serial converter from
- TTL voltage on the headers.
-
-* **GPIO 39-43 not configured**: this is really more of a software
- "TODO" item. Some of the JTAG header pins are numbered 39-43. These
- STM32 pins are indeed fully functional :ref:`GPIO <gpio>` when the a
- :ref:`JTAG <jtag>` device is not connected, but we have not enabled
- them in software and thus they can not be accessed with the regular
- :ref:`lang-pinmode` or :ref:`lang-digitalwrite` functions.
-
-* **Silkscreen Errors**: the silkscreen on the bottom indicated PWM
- functionality on pin 25 and listen the external header GND pin as
- number 38 (actually 38 is connected to the BUT button). We manually
- sharpied over both of these mistakes.
-
-* **PWM Marketing Mistake**: We originally sold the Maple advertising
- 22 channels of 16-bit hardware PWM; actually the Maple only has 15.
-
-Potential failure modes:
-
-* **TTL voltage on non-tolerant pins**: not all header pins are 5V
- compatible; connecting certain serial devices in the wrong way could
- over voltage the pins. The :ref:`Pin-Mapping Mega Table
- <pin-mapping-mega-table>` details which pins are 5V-tolerant.
-
-Maple Rev 1
------------
-
-Known issues:
-
-* **ADC noise**: generally very high, in particular when the USB port
- is being used for communications (including keep-alive pings when
- connected to a computer).
-
- This issue was resolved in Rev 3 with a 4-layer design and a
- geometrically isolated ADC V\ :sub:`ref` plane.
-
-* **Resistors on pins 0 and 1**: these header pins, which are RX/TX on
- USART2 (:ref:`Serial2 <lang-serial>`), have resistors in-line
- between the STM32 and the headers. These resistors increase the
- impedance of the lines for ADC reads and affect the open drain GPIO
- functionality of the pins.
-
- These resistors were accidentally copied over from older Arduino USB
- designs, where they appear to protect the USB-Serial converter from
- TTL voltage on the headers.
-
-* **Silkscreen Differences**: the pin numbering scheme on Rev 1 is
- different from Rev 3, and thus Rev 3 software is difficult to use
- with Rev 1 boards. Notably, the analog input bank is labeled A0-A4
- on Rev 1 but 15-20 on Rev 3, and the extra header bank does not have
- a pinout table on the bottom.
-
-* **No BUT Button**: the BUT button, useful for serial bootloading,
- was only added in Rev 3. As a workaround, you can directly short the
- appropriate MCU pin to Vcc; see `this forum posting
- <http://forums.leaflabs.com/topic.php?id=32#post-126>`_.
-
-* **PWM Marketing Mistake**: We originally sold the Maple advertising
- 22 channels of 16-bit hardware PWM; actually the Maple only has 15.
-
-Potential failure modes:
-
-* **TTL voltage on non-tolerant pins**: not all header pins are 5v
- compatible; connecting certain serial devices in the wrong way could
- over voltage the pins. The :ref:`Pin-Mapping Mega Table
- <pin-mapping-mega-table>` details which pins are 5V-tolerant.
diff --git a/docs/source/external-interrupts.rst b/docs/source/external-interrupts.rst
index b2cbbb1..ac065a4 100644
--- a/docs/source/external-interrupts.rst
+++ b/docs/source/external-interrupts.rst
@@ -6,73 +6,42 @@ External Interrupts
===================
External interrupts can be used to trigger routines to run in response
-to changes in voltage on a pin. Each GPIO pin on the Maple can be used
-to detect transitions such as when the voltage goes from low to high,
-or from high to low. This technique can be used to avoid unnecessary
-polling of the state of a pin.
+to changes in voltage on a pin. Each :ref:`GPIO pin <gpio>` can be
+used to detect transitions, such as when the voltage goes from
+:ref:`LOW <lang-constants-low>` to :ref:`HIGH <lang-constants-high>`,
+or from ``HIGH`` to ``LOW``. This can be used to avoid checking for
+changes on a pin "manually" by waiting in a loop until the pin
+changes.
.. _contents: Contents
:local:
-
Overview
--------
External interrupts are often used to detect when events happen
-outside of the microcontroller. These can be used to tell the Maple
-when events happen, such as when a sensor has data ready to be read,
-or when a button has been pushed. When such an event happens, an
-interrupt is raised and the Maple can react to it with a preset
-*interrupt handler*.
-
-Every GPIO pin on the Maple can be used as an external interrupt,
-subject to certain constraints; there can be a maximum of 16 different
-external interrupts set up at a time on the Maple. This is because the
-external interrupt lines on the STM32 are multiplexed between GPIO
-ports. In effect, this means that every pin on the Maple maps to a
-certain EXTI line, and within that EXTI line, only one of the pins
-that maps to it can be used as an external interrupt at a time.
-
-The following table shows which pins can be used on which lines.
-
-.. list-table::
- :widths: 1 1
- :header-rows: 1
-
- * - EXTI Line
- - Maple pins
- * - EXTI0
- - 2, 15, 27
- * - EXTI1
- - 3, 16, 28
- * - EXTI2
- - 1, 17, 25
- * - EXTI3
- - 0, 18
- * - EXTI4
- - 10, 19
- * - EXTI5
- - 4, 13, 20
- * - EXTI6
- - 5, 12, 35
- * - EXTI7
- - 9, 11, 36
- * - EXTI8
- - 6, 14, 37
- * - EXTI9
- - 7, 25, 28
- * - EXTI10
- - 8, 26, 29
- * - EXTI11
- - 30
- * - EXTI12
- - 31
- * - EXTI13
- - 21, 32
- * - EXTI14
- - 22, 33
- * - EXTI15
- - 23, 34
+outside of the microcontroller. These can be used to tell Maple when
+events happen, such as when a sensor has data ready to be read, or
+when a button has been pushed. When such an event happens, an
+interrupt is raised, and the Maple can react to it with a preset
+*interrupt handler*, which is a function that gets called whenever the
+event occurs.
+
+.. _external-interrupts-exti-line:
+
+Every GPIO pin can generate an external interrupt, subject to certain
+constraints. There can be a maximum of 16 different external
+interrupts set up at a time. This is because the external interrupt
+lines on the STM32 are shared between GPIO ports. In effect, this
+means that every pin on the Maple connects to what is called an *EXTI
+line*, and within an EXTI line, only one of the pins that connects to
+it can be used to detect external interrupts at a time.
+
+The EXTI Line Pin Map for your board lists which pins connect to which
+EXTI lines:
+
+* :ref:`Maple <maple-exti-map>`
+* :ref:`Maple RET6 Edition <maple-ret6-exti-map>`
.. note::
@@ -80,40 +49,16 @@ The following table shows which pins can be used on which lines.
desired pin to an input mode (e.g ``INPUT`` or ``INPUT_FLOATING``,
``INPUT_PULLUP``, ``INPUT_PULLDOWN``).
-
Function Reference
------------------
- :ref:`attachInterrupt() <lang-attachinterrupt>`
- :ref:`detachInterrupt() <lang-detachinterrupt>`
-Code example
-------------
-
-Blink the LED on every transition::
-
- int pin = 13;
- volatile int state = LOW;
-
- void setup() {
- pinMode(pin, OUTPUT);
- pinMode(0, INPUT_FLOATING);
- attachInterrupt(0, blink, CHANGE);
- }
-
- void loop() {
- digitalWrite(pin, state);
- }
-
- void blink() {
- state = !state;
- }
-
-
Recommended Reading
-------------------
-* STMicro documentation for STM32F103RB microcontroller:
-
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
+* ST manual `RM0008
+ <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_
+ (PDF), Chapter 9, "General-purpose and alternate-function I/Os", and
+ Chapter 10, "Interrupts and Events".
diff --git a/docs/source/gpio.rst b/docs/source/gpio.rst
index cebb402..74be3d4 100644
--- a/docs/source/gpio.rst
+++ b/docs/source/gpio.rst
@@ -3,84 +3,54 @@
GPIO
====
-The Maple features 38 ready-to-use general purpose input/output (GPIO)
-pins for digital input/output, numbered D0 through D37. These numbers
-correspond to the numeric values next to each header on the Maple
-silkscreen.
-
-Many of these pins may additionally be used for special features or
-peripheral functions. This page documents those capabilities, by pin.
-
-The current and voltage limitations have been copied over from the
-STM32 datasheet (see the :ref:`Recommended Reading
-<gpio-recommended-reading>` for a link). In particular, a number of
-GPIO pins are 5V tolerant (which means that applying 5 volts to a pin
-and reading it as input or allowing it to drain to ground will not
-damage that pin), while some are not.
+Each LeafLabs board comes with ready-to-use General Purpose
+Input/Output (GPIO) pins, which are numbered starting from zero.
+These numbers are listed on your board's silkscreen, next to where the
+pin is broken out to a header. Many pins may additionally be used for
+special features or peripheral functions.
.. contents:: Contents
:local:
-.. _pin-mapping-mega-table:
-
-Pin Mapping Mega Table
-----------------------
-
-This table shows the available functionality on every GPIO pin, by
-peripheral type. The "STM32" column refers to the port and number that
-the header is connected to on the microcontroller. The "5V?" column
-documents whether or not the pin is 5 volt tolerant (see above).
-
-.. TODO silkscreen pictures which let you know what each abbreviation
-.. means, with links to the relevant documentation.
-
-.. csv-table::
- :header: "Pin", "STM32", ":ref:`ADC <adc>`", ":ref:`Timer <timers>`", ":ref:`I2C <i2c>`", ":ref:`UART <usart>`", ":ref:`SPI <spi>`", "5v?"
-
- "D0", "PA3", "ADC3", "TIM2_CH4", "-", "USART2_RX", "-", "No"
- "D1", "PA2", "ADC2", "TIM2_CH3", "-", "USART2_TX", "-", "No"
- "D2", "PA0", "ADC0", "TIM2_CH1_ETR", "-", "USART2_CTS", "-", "No"
- "D3", "PA1", "ADC1", "TIM2_CH2", "-", "USART2_RTS", "-", "No"
- "D4", "PB5", "-", "-", "ISC1_SMBA", "-", "-", "No"
- "D5", "PB6", "-", "TIM4_CH1", "I2C1_SCL", "-", "-", "Yes"
- "D6", "PA8", "-", "TIM1_CH1", "-", "USART1_CK", "-", "Yes"
- "D7", "PA9", "-", "TIM1_CH2", "-", "USART1_TX", "-", "Yes"
- "D8", "PA10", "-", "TIM1_CH3", "-", "USART1_RX", "-", "Yes"
- "D9", "PB7", "-", "TIM4_CH2", "I2C1_SDA", "-", "-", "Yes"
- "D10", "PA4", "ADC4", "-", "-", "USART2_CK", "SPI1_NSS", "No"
- "D11", "PA7", "ADC7", "TIM3_CH2", "-", "-", "SPI1_MOSI", "No"
- "D12", "PA6", "ADC6", "TIM3_CH1", "-", "-", "SPI1_MISO", "No"
- "D13", "PA5", "ADC5", "-", "-", "-", "SPI1_SCK", "No"
- "D14", "PB8", "-", "TIM4_CH3", "-", "-", "-", "Yes"
- "D15", "PC0", "ADC10", "-", "-", "-", "-", "No"
- "D16", "PC1", "ADC11", "-", "-", "-", "-", "No"
- "D17", "PC2", "ADC12", "-", "-", "-", "-", "No"
- "D18", "PC3", "ADC13", "-", "-", "-", "-", "No"
- "D19", "PC4", "ADC14", "-", "-", "-", "-", "No"
- "D20", "PC5", "ADC15", "-", "-", "-", "-", "No"
- "D21", "PC13", "-", "-", "-", "-", "-", "No"
- "D22", "PC14", "-", "-", "-", "-", "-", "No"
- "D23", "PC15", "-", "-", "-", "-", "-", "No"
- "D24", "PB9", "-", "TIM4_CH4", "-", "-", "-", "Yes"
- "D25", "PD2", "-", "TIM3_ETR", "-", "-", "-", "Yes"
- "D26", "PC10", "-", "-", "-", "-", "-", "Yes"
- "D27", "PB0", "ADC8", "TIM3_CH3", "-", "-", "-", "No"
- "D28", "PB1", "ADC9", "TIM3_CH4", "-", "-", "-", "No"
- "D29", "PB10", "-", "-", "I2C2_SCL", "USART3_TX", "-", "Yes"
- "D30", "PB11", "-", "-", "I2C2_SDA", "USART3_RX", "-", "Yes"
- "D31", "PB12", "-", "TIM1_BKIN", "I2C2_SMBAL", "USART3_CK", "SPI2_NSS", "Yes"
- "D32", "PB13", "-", "TIM1_CH1N", "-", "USART3_CTS", "SPI2_SCK", "Yes"
- "D33", "PB14", "-", "TIM1_CH2N", "-", "USART3_RTS", "SPI2_MISO", "Yes"
- "D34", "PB15", "-", "TIM1_CH3N", "-", "-", "SPI2_MOSI", "Yes"
- "D35", "PC6", "-", "-", "-", "-", "-", "Yes"
- "D36", "PC7", "-", "-", "-", "-", "-", "Yes"
- "D37", "PC8", "-", "-", "-", "-", "-", "Yes"
+.. _gpio-pin-maps:
+
+Pin Maps
+--------
+
+The hardware documentation for your board lists each pin's
+capabilities, by pin number:
+
+.. TODO [0.1.0] Uncomment Mini and Native GPIO links
+
+* :ref:`Maple <maple-gpios>`
+* :ref:`Maple RET6 Edition <maple-ret6-gpios>`
+
+.. * :ref:`Maple Mini <maple-mini-gpios>`
+.. * :ref:`Maple Native <maple-native-gpios>`
+
+The current and voltage limitations were determined using the STM32
+datasheets. In particular, only some GPIO pins are **5V tolerant**,
+which means that applying 5 volts to a pin and reading it as input or
+allowing it to drain to ground will not damage that pin. Connecting a
+voltage higher than 3.3V to a non-5V tolerant pin may damage your
+board.
.. _gpio-modes:
GPIO Modes
----------
+Each of the GPIO pins on a Maple board may be configured using
+pinMode() to behave in a number of ways: as a digital output pin,
+or as an analog input pin, etc., depending on the particular pin.
+
+A ``WiringPinMode`` value specifies the complete set of possible
+configurations; not every pin can have all of these modes. For
+example, on the Maple, pin 15 may have mode ``INPUT_ANALOG``, but not
+``PWM``. See your :ref:`board's pin maps <gpio-pin-maps>` and its
+silkscreen for more information on what functionality is available on
+each pin.
+
.. doxygenenum:: WiringPinMode
Function Reference
@@ -103,7 +73,11 @@ Function Reference
Recommended Reading
-------------------
-STMicro documentation for STM32F103RB microcontroller:
+* ST Documentation for the STM32F103 series of microcontrollers:
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
* `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
+
+ * `Programming Manual
+ <http://www.st.com/stonline/products/literature/pm/15491.pdf>`_
+ (PDF; assembly language and register reference)
+
diff --git a/docs/source/hardware/maple-ret6.rst b/docs/source/hardware/maple-ret6.rst
new file mode 100644
index 0000000..06dcaff
--- /dev/null
+++ b/docs/source/hardware/maple-ret6.rst
@@ -0,0 +1,276 @@
+.. highlight:: sh
+
+.. _maple-ret6:
+
+Maple RET6 Edition
+==================
+
+.. contents:: Contents
+ :local:
+
+Technical Specifications
+------------------------
+
+ * MCU: **STM32F103RET6**, a 32-bit ARM Cortex M3 microprocessor
+ * Clock Speed: **72 MHz**
+ * Operating Voltage: 3.3V
+ * Input Voltage (recommended): 3V-12V
+ * 39 Digital I/O Pins (:ref:`GPIO <gpio>`)
+ * 16 Analog Input pins, 12 bit **ADC** resolution (:ref:`ADC <adc>`)
+ * 15 **PWM** pins at 16-bit resolution (:ref:`PWM <pwm>`)
+ * Dedicated **USB** port for programming and communications (:ref:`USB<usb>`)
+ * External **JTAG** interface (:ref:`JTAG <jtag>`)
+ * **512KB Flash** and **64KB SRAM**
+ * 64 Channel nested vector interrupt handler (including external interrupt on GPIOs)
+ * Integrated **SPI** (:ref:`SPI <spi>`)
+ * Integrated **I2C** (:ref:`I2C <i2c>`)
+ * 12 Channels of Direct Memory Access (**DMA**)
+ * 3 **USART** and 2 **UART** devices (:ref:`USART <usart>`)
+ * Six 4-channel and two basic **timers** (:ref:`Timers <timers>`)
+ * Supplies up to 800mA @ 3.3v
+ * Support for low power and sleep modes (<500uA)
+ * Dimensions are 2.05″x2.1″
+
+.. _maple-ret6-powering:
+
+Powering the Maple RET6 Edition
+-------------------------------
+
+The Maple RET6 Edition's power source is determined by the header to
+the left of the "LeafLabs" label on the silkscreen. The RET6 Edition
+can be powered from the barrel jack connector, USB, or a LiPo battery.
+We ship the RET6 Edition with a jumper on the USB selector. In order
+to power it off of an alternative source, unplug the board, then move
+the jumper to the desired selector before reconnecting power.
+
+You can also power the Maple via the pin labeled "Vin" on the lower
+header. However, don't do this while simultaneously powering the
+board from another source, or you could damage the it.
+
+Using the Built-in Battery Charger
+----------------------------------
+
+The RET6 Edition has a built-in LiPo battery charger. In order to use
+it, put a jumper across the CHRG header on the power selection header
+and across the USB, or EXT selectors, depending on whether you're
+charging the battery via USB cable or barrel jack connector. The LED
+labeled CHRG will light up while the battery is being charged. When
+the battery is finished charging, the LED labeled DONE will also light
+up.
+
+.. _maple-ret6-gpios:
+
+GPIO Information
+----------------
+
+The RET6 Edition features 38 ready-to-use general purpose input/output
+(GPIO) pins for digital input/output, numbered ``D0`` through ``D37``.
+These numbers correspond to the numeric values next to each header on
+the Maple silkscreen. More GPIOs (numbered ``D39``\ --``43``) are
+available through use in combination with the
+:ref:`lang-disabledebugports` function; see the :ref:`board-specific
+debug pin constants <lang-board-values-debug>` for more information.
+
+.. TODO [0.1.0] silkscreen pictures which expand abbreviations
+
+.. _maple-ret6-pin-map-master:
+
+Master Pin Map
+^^^^^^^^^^^^^^
+
+.. TODO [0.0.10] Update from base Maple information
+
+This table shows the available functionality on every GPIO pin, by
+peripheral type. The "STM32" column refers to the port and number that
+the header is connected to on the microcontroller. The "5V?" column
+documents whether or not the pin is 5 volt tolerant.
+
+.. csv-table::
+ :header: "Pin", "STM32", ":ref:`ADC <adc>`", ":ref:`Timer <timers>`", ":ref:`I2C <i2c>`", ":ref:`UART <usart>`", ":ref:`SPI <spi>`", "5v?"
+
+ "D0", "PA3", "ADC3", "TIM2_CH4", "-", "USART2_RX", "-", "No"
+ "D1", "PA2", "ADC2", "TIM2_CH3", "-", "USART2_TX", "-", "No"
+ "D2", "PA0", "ADC0", "TIM2_CH1_ETR", "-", "USART2_CTS", "-", "No"
+ "D3", "PA1", "ADC1", "TIM2_CH2", "-", "USART2_RTS", "-", "No"
+ "D4", "PB5", "-", "-", "ISC1_SMBA", "-", "-", "No"
+ "D5", "PB6", "-", "TIM4_CH1", "I2C1_SCL", "-", "-", "Yes"
+ "D6", "PA8", "-", "TIM1_CH1", "-", "USART1_CK", "-", "Yes"
+ "D7", "PA9", "-", "TIM1_CH2", "-", "USART1_TX", "-", "Yes"
+ "D8", "PA10", "-", "TIM1_CH3", "-", "USART1_RX", "-", "Yes"
+ "D9", "PB7", "-", "TIM4_CH2", "I2C1_SDA", "-", "-", "Yes"
+ "D10", "PA4", "ADC4", "-", "-", "USART2_CK", "SPI1_NSS", "No"
+ "D11", "PA7", "ADC7", "TIM3_CH2", "-", "-", "SPI1_MOSI", "No"
+ "D12", "PA6", "ADC6", "TIM3_CH1", "-", "-", "SPI1_MISO", "No"
+ "D13", "PA5", "ADC5", "-", "-", "-", "SPI1_SCK", "No"
+ "D14", "PB8", "-", "TIM4_CH3", "-", "-", "-", "Yes"
+ "D15", "PC0", "ADC10", "-", "-", "-", "-", "No"
+ "D16", "PC1", "ADC11", "-", "-", "-", "-", "No"
+ "D17", "PC2", "ADC12", "-", "-", "-", "-", "No"
+ "D18", "PC3", "ADC13", "-", "-", "-", "-", "No"
+ "D19", "PC4", "ADC14", "-", "-", "-", "-", "No"
+ "D20", "PC5", "ADC15", "-", "-", "-", "-", "No"
+ "D21", "PC13", "-", "-", "-", "-", "-", "No"
+ "D22", "PC14", "-", "-", "-", "-", "-", "No"
+ "D23", "PC15", "-", "-", "-", "-", "-", "No"
+ "D24", "PB9", "-", "TIM4_CH4", "-", "-", "-", "Yes"
+ "D25", "PD2", "-", "TIM3_ETR", "-", "-", "-", "Yes"
+ "D26", "PC10", "-", "-", "-", "-", "-", "Yes"
+ "D27", "PB0", "ADC8", "TIM3_CH3", "-", "-", "-", "No"
+ "D28", "PB1", "ADC9", "TIM3_CH4", "-", "-", "-", "No"
+ "D29", "PB10", "-", "-", "I2C2_SCL", "USART3_TX", "-", "Yes"
+ "D30", "PB11", "-", "-", "I2C2_SDA", "USART3_RX", "-", "Yes"
+ "D31", "PB12", "-", "TIM1_BKIN", "I2C2_SMBA", "USART3_CK", "SPI2_NSS", "Yes"
+ "D32", "PB13", "-", "TIM1_CH1N", "-", "USART3_CTS", "SPI2_SCK", "Yes"
+ "D33", "PB14", "-", "TIM1_CH2N", "-", "USART3_RTS", "SPI2_MISO", "Yes"
+ "D34", "PB15", "-", "TIM1_CH3N", "-", "-", "SPI2_MOSI", "Yes"
+ "D35", "PC6", "-", "-", "-", "-", "-", "Yes"
+ "D36", "PC7", "-", "-", "-", "-", "-", "Yes"
+ "D37", "PC8", "-", "-", "-", "-", "-", "Yes"
+
+.. TODO [0.0.10] Another table for the JTAG pins
+
+Timer Pin Map
+^^^^^^^^^^^^^
+
+.. TODO [0.0.10] Add Timer 5,6,7,8 information
+
+The following table shows what pins are associated with a particular
+timer's capture/compare channels.
+
+.. csv-table::
+ :header: Timer, Ch. 1, Ch. 2, Ch. 3, Ch. 4
+ :delim: |
+
+ 1 | D6 | D7 | D8 | -
+ 2 | D2 | D3 | D1 | D0
+ 3 | D12 | D11 | D27 | D28
+ 4 | D5 | D9 | D14 | D24
+
+.. _maple-ret6-exti-map:
+
+EXTI Line Pin Map
+^^^^^^^^^^^^^^^^^
+
+The following table shows which pins connect to which :ref:`EXTI lines
+<external-interrupts-exti-line>` on the Maple RET6 Edition.
+
+.. list-table::
+ :widths: 1 1
+ :header-rows: 1
+
+ * - EXTI Line
+ - Pins
+ * - EXTI0
+ - 2, 15, 27
+ * - EXTI1
+ - 3, 16, 28
+ * - EXTI2
+ - 1, 17, 25
+ * - EXTI3
+ - 0, 18
+ * - EXTI4
+ - 10, 19
+ * - EXTI5
+ - 4, 13, 20
+ * - EXTI6
+ - 5, 12, 35
+ * - EXTI7
+ - 9, 11, 36
+ * - EXTI8
+ - 6, 14, 37
+ * - EXTI9
+ - 7, 25, 28
+ * - EXTI10
+ - 8, 26, 29
+ * - EXTI11
+ - 30
+ * - EXTI12
+ - 31
+ * - EXTI13
+ - 21, 32
+ * - EXTI14
+ - 22, 33
+ * - EXTI15
+ - 23, 34
+
+.. _maple-ret6-usart-map:
+
+USART Pin Map
+^^^^^^^^^^^^^
+
+.. FIXME [0.0.10] UART4 and UART5 information
+
+The Maple RET6 Edition has three serial ports (also known as a UARTs
+or USARTs): ``Serial1``, ``Serial2``, and ``Serial3``. They
+communicate using the pins summarized in the following table:
+
+.. csv-table::
+ :header: Serial Port, TX, RX, CK, CTS, RTS
+ :delim: |
+
+ ``Serial1`` | 7 | 8 | 6 | - | -
+ ``Serial2`` | 1 | 0 | 10 | 2 | 3
+ ``Serial3`` | 29 | 30 | 31 | 32 | 33
+
+Board-Specific Values
+---------------------
+
+.. TODO [0.0.10]
+
+Stub.
+
+Hardware Design Files
+---------------------
+
+The hardware schematics and board layout files are available in the
+`Maple Github repository <https://github.com/leaflabs/maple>`_. Other
+than the processor used, the design files for the Maple RET6 edition
+are identical to the Maple Rev 5, which are in the ``maple-r5``
+subdirectory of the Maple repository. A schematic for a JTAG adapter
+suitable for use with Maple is available in the ``jtagadapter``
+directory.
+
+From the Github repository main page, you can download the entire
+repository by clicking the "Download" button. If you are familiar
+with `git <http://git-scm.com/>`_, you can also clone the repository
+at the command line with ::
+
+ $ git clone git://github.com/leaflabs/maple.git
+
+.. _maple-ret6-failure-modes:
+
+Failure Modes
+-------------
+
+The following known failure modes apply to all Maple boards. The
+failure modes aren't design errors, but are easy ways to break or
+damage your board permanently.
+
+* **High voltage on non-tolerant pins**: not all header pins are 5V
+ compatible; so e.g. connecting certain serial devices in the wrong
+ way could over-voltage the pins. The :ref:`pin-mapping master table
+ <maple-ret6-pin-map-master>` details which pins are 5V-tolerant.
+
+Errata
+------
+
+This section lists known issues and warnings for the Maple RET6 Edition.
+
+* **DAC, UART4, UART5 GPIOs unavailable**: Pins related to the digital
+ to analog converter (DAC) and UARTs 4 and 5 are not broken out to
+ headers. The RET6 Edition's hardware layout is identical to that of
+ the Maple Rev 5, which wasn't designed for use with these
+ STM32F103RET6-only peripherals.
+
+Recommended Reading
+-------------------
+
+* STMicro documentation for STM32F103RE microcontroller:
+
+ * `Datasheet
+ <http://www.st.com/internet/com/TECHNICAL_RESOURCES/TECHNICAL_LITERATURE/DATASHEET/CD00191185.pdf>`_ (PDF)
+ * `Reference Manual
+ <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (PDF)
+ * `Programming Manual
+ <http://www.st.com/stonline/products/literature/pm/15491.pdf>`_
+ (PDF; assembly language and register reference)
diff --git a/docs/source/hardware/maple.rst b/docs/source/hardware/maple.rst
index 874ee82..f4fcaf4 100644
--- a/docs/source/hardware/maple.rst
+++ b/docs/source/hardware/maple.rst
@@ -1,6 +1,6 @@
.. highlight:: sh
-.. _hardware-maple:
+.. _maple:
Maple
=====
@@ -8,7 +8,30 @@ Maple
.. contents:: Contents
:local:
-.. _maple-hardware-identify-rev:
+Technical Specifications
+------------------------
+
+ * MCU: **STM32F103RBT6**, a 32-bit ARM Cortex M3 microprocessor
+ * Clock Speed: **72 MHz**
+ * Operating Voltage: 3.3V
+ * Input Voltage (recommended): 3V-12V
+ * 39 Digital I/O Pins (:ref:`GPIO <gpio>`)
+ * 16 Analog Input Pins, 12-bit **ADC** resolution (:ref:`ADC <adc>`)
+ * 15 **PWM** pins at 16-bit resolution (:ref:`PWM <pwm>`)
+ * Dedicated **USB** port for programming and communications (:ref:`USB <usb>`)
+ * External **JTAG** interface (:ref:`JTAG <jtag>`)
+ * **128KB Flash** and **20KB SRAM**
+ * 64 Channel nested vector interrupt handler (including external interrupt on GPIOs)
+ * Integrated **SPI** (:ref:`SPI <spi>`)
+ * Integrated **I2C** (:ref:`I2C <i2c>`)
+ * 7 Channels of Direct Memory Access (**DMA**)
+ * 3 **USART** divices (:ref:`USART <usart>`)
+ * Four 4-channel **timers** (:ref:`Timers <timers>`)
+ * Supplies up to 800mA @ 3.3v
+ * Support for low power and sleep modes (<500uA)
+ * Dimensions are 2.05″x2.1″
+
+.. _maple-identify-rev:
Identifying your Rev
--------------------
@@ -16,17 +39,22 @@ Identifying your Rev
We went through three versions ("Revs") of the Maple hardware: Rev 1,
Rev 3, and Rev 5 [#frev2_4]_; Rev 5, the final design, is currently on
sale. The following sections will help you to help you identify your
-Rev. Known issues are listed in the :ref:`errata <errata>`.
+Rev.
-Rev 1
+Rev 5
^^^^^
-A small number of Maple Rev 1 boards went on sale in late 2009. They
-have a light red silkscreen and a single pixelated leaf as a logo.
+These boards went on sale in November 2010. They have white buttons,
+and "r5" in small print near the "LeafLabs Maple" text next to the
+"infinity leaf" logo. The Maple Rev 5 repositioned the double header
+on the right hand side to better fit 0.1 inch pitch breadboard. This
+necessitated the removal of pins 21 and 22 from the double header;
+they are still available, but don't have any headers installed on
+them.
-.. figure:: /_static/img/maple_rev1.png
+.. figure:: /_static/img/maple_rev5.png
:align: center
- :alt: Maple Rev 1
+ :alt: Maple Rev 5
Rev 3
^^^^^
@@ -40,22 +68,17 @@ It also includes a built-in LiPo battery charger.
:align: center
:alt: Maple Rev 3
-Rev 5
+Rev 1
^^^^^
-These boards went on sale in November 2010. They have white buttons,
-and "r5" in small print near the "LeafLabs Maple" text next to the
-"infinity leaf" logo. The Maple Rev 5 repositioned the double header
-on the right hand side to better fit 0.1 inch pitch breadboard. This
-necessitated the removal of pins 21 and 22 from the double header;
-they are still available, but don't have any headers installed on
-them.
+A small number of Maple Rev 1 boards went on sale in late 2009. They
+have a light red silkscreen and a single pixelated leaf as a logo.
-.. figure:: /_static/img/maple_rev5.png
+.. figure:: /_static/img/maple_rev1.png
:align: center
- :alt: Maple Rev 5
+ :alt: Maple Rev 1
-.. _hardware-maple-powering:
+.. _maple-powering:
Powering the Maple
------------------
@@ -82,25 +105,303 @@ connector. The LED labeled CHRG will light up while the battery is
being charged. When the battery is finished charging, the LED labeled
DONE will also light up.
+.. _maple-gpios:
+
+GPIO Information
+----------------
+
+The Maple features 38 ready-to-use general purpose input/output (GPIO)
+pins for digital input/output, numbered ``D0`` through ``D37``. These
+numbers correspond to the numeric values next to each header on the
+Maple silkscreen. More GPIOs (numbered ``D39``\ --``43``) are
+available through use in combination with the
+:ref:`lang-disabledebugports` function; see the :ref:`board-specific
+debug pin constants <lang-board-values-debug>` for more information.
+
+.. TODO [0.1.0] silkscreen pictures which expand abbreviations
+
+.. _maple-pin-map-master:
+
+Master Pin Map
+^^^^^^^^^^^^^^
+
+This table shows the available functionality on every GPIO pin, by
+peripheral type. The "STM32" column refers to the port and number that
+the header is connected to on the microcontroller. The "5V?" column
+documents whether or not the pin is 5 volt tolerant.
+
+.. csv-table::
+ :header: "Pin", "STM32", ":ref:`ADC <adc>`", ":ref:`Timer <timers>`", ":ref:`I2C <i2c>`", ":ref:`UART <usart>`", ":ref:`SPI <spi>`", "5v?"
+
+ "D0", "PA3", "ADC3", "TIM2_CH4", "-", "USART2_RX", "-", "No"
+ "D1", "PA2", "ADC2", "TIM2_CH3", "-", "USART2_TX", "-", "No"
+ "D2", "PA0", "ADC0", "TIM2_CH1_ETR", "-", "USART2_CTS", "-", "No"
+ "D3", "PA1", "ADC1", "TIM2_CH2", "-", "USART2_RTS", "-", "No"
+ "D4", "PB5", "-", "-", "ISC1_SMBA", "-", "-", "No"
+ "D5", "PB6", "-", "TIM4_CH1", "I2C1_SCL", "-", "-", "Yes"
+ "D6", "PA8", "-", "TIM1_CH1", "-", "USART1_CK", "-", "Yes"
+ "D7", "PA9", "-", "TIM1_CH2", "-", "USART1_TX", "-", "Yes"
+ "D8", "PA10", "-", "TIM1_CH3", "-", "USART1_RX", "-", "Yes"
+ "D9", "PB7", "-", "TIM4_CH2", "I2C1_SDA", "-", "-", "Yes"
+ "D10", "PA4", "ADC4", "-", "-", "USART2_CK", "SPI1_NSS", "No"
+ "D11", "PA7", "ADC7", "TIM3_CH2", "-", "-", "SPI1_MOSI", "No"
+ "D12", "PA6", "ADC6", "TIM3_CH1", "-", "-", "SPI1_MISO", "No"
+ "D13", "PA5", "ADC5", "-", "-", "-", "SPI1_SCK", "No"
+ "D14", "PB8", "-", "TIM4_CH3", "-", "-", "-", "Yes"
+ "D15", "PC0", "ADC10", "-", "-", "-", "-", "No"
+ "D16", "PC1", "ADC11", "-", "-", "-", "-", "No"
+ "D17", "PC2", "ADC12", "-", "-", "-", "-", "No"
+ "D18", "PC3", "ADC13", "-", "-", "-", "-", "No"
+ "D19", "PC4", "ADC14", "-", "-", "-", "-", "No"
+ "D20", "PC5", "ADC15", "-", "-", "-", "-", "No"
+ "D21", "PC13", "-", "-", "-", "-", "-", "No"
+ "D22", "PC14", "-", "-", "-", "-", "-", "No"
+ "D23", "PC15", "-", "-", "-", "-", "-", "No"
+ "D24", "PB9", "-", "TIM4_CH4", "-", "-", "-", "Yes"
+ "D25", "PD2", "-", "TIM3_ETR", "-", "-", "-", "Yes"
+ "D26", "PC10", "-", "-", "-", "-", "-", "Yes"
+ "D27", "PB0", "ADC8", "TIM3_CH3", "-", "-", "-", "No"
+ "D28", "PB1", "ADC9", "TIM3_CH4", "-", "-", "-", "No"
+ "D29", "PB10", "-", "-", "I2C2_SCL", "USART3_TX", "-", "Yes"
+ "D30", "PB11", "-", "-", "I2C2_SDA", "USART3_RX", "-", "Yes"
+ "D31", "PB12", "-", "TIM1_BKIN", "I2C2_SMBA", "USART3_CK", "SPI2_NSS", "Yes"
+ "D32", "PB13", "-", "TIM1_CH1N", "-", "USART3_CTS", "SPI2_SCK", "Yes"
+ "D33", "PB14", "-", "TIM1_CH2N", "-", "USART3_RTS", "SPI2_MISO", "Yes"
+ "D34", "PB15", "-", "TIM1_CH3N", "-", "-", "SPI2_MOSI", "Yes"
+ "D35", "PC6", "-", "-", "-", "-", "-", "Yes"
+ "D36", "PC7", "-", "-", "-", "-", "-", "Yes"
+ "D37", "PC8", "-", "-", "-", "-", "-", "Yes"
+
+.. TODO [0.0.10] JTAG pins
+
+Timer Pin Map
+^^^^^^^^^^^^^
+
+The following table shows what pins are associated with a particular
+timer's capture/compare channels.
+
+.. csv-table::
+ :header: Timer, Ch. 1, Ch. 2, Ch. 3, Ch. 4
+ :delim: |
+
+ 1 | D6 | D7 | D8 | -
+ 2 | D2 | D3 | D1 | D0
+ 3 | D12 | D11 | D27 | D28
+ 4 | D5 | D9 | D14 | D24
+
+.. _maple-exti-map:
+
+EXTI Line Pin Map
+^^^^^^^^^^^^^^^^^
+
+The following table shows which pins connect to which :ref:`EXTI lines
+<external-interrupts-exti-line>` on the Maple.
+
+.. list-table::
+ :widths: 1 1
+ :header-rows: 1
+
+ * - EXTI Line
+ - Pins
+ * - EXTI0
+ - 2, 15, 27
+ * - EXTI1
+ - 3, 16, 28
+ * - EXTI2
+ - 1, 17, 25
+ * - EXTI3
+ - 0, 18
+ * - EXTI4
+ - 10, 19
+ * - EXTI5
+ - 4, 13, 20
+ * - EXTI6
+ - 5, 12, 35
+ * - EXTI7
+ - 9, 11, 36
+ * - EXTI8
+ - 6, 14, 37
+ * - EXTI9
+ - 7, 25, 28
+ * - EXTI10
+ - 8, 26, 29
+ * - EXTI11
+ - 30
+ * - EXTI12
+ - 31
+ * - EXTI13
+ - 21, 32
+ * - EXTI14
+ - 22, 33
+ * - EXTI15
+ - 23, 34
+
+.. _maple-usart-map:
+
+USART Pin Map
+^^^^^^^^^^^^^
+
+.. FIXME [0.0.10] UART4, UART5
+
+The Maple has three serial ports (also known as a UARTs or USARTs):
+``Serial1``, ``Serial2``, and ``Serial3``. They communicate using the
+pins summarized in the following table:
+
+.. csv-table::
+ :header: Serial Port, TX, RX, CK, CTS, RTS
+ :delim: |
+
+ ``Serial1`` | 7 | 8 | 6 | - | -
+ ``Serial2`` | 1 | 0 | 10 | 2 | 3
+ ``Serial3`` | 29 | 30 | 31 | 32 | 33
+
+Board-Specific Values
+---------------------
+
+.. TODO [0.0.10]
+
+Stub.
+
Hardware Design Files
---------------------
The hardware schematics and board layout files are available in the
-`Maple github repository <https://github.com/leaflabs/maple>`_. The
+`Maple Github repository <https://github.com/leaflabs/maple>`_. The
design files for Rev 1, Rev 3, and Rev 5 are respectively in the
``maple-r1``, ``maple-r3``, and ``maple-r5`` subdirectories. A
schematic for a JTAG adapter suitable for use with Maple is available
in the ``jtagadapter`` directory.
-From the github repository main page, you can download the entire
+From the Github repository main page, you can download the entire
repository by clicking the "Download" button. If you are familiar
with `git <http://git-scm.com/>`_, you can also clone the repository
at the command line with ::
$ git clone git://github.com/leaflabs/maple.git
+.. _maple-failure-modes:
+
+Failure Modes
+-------------
+
+The following are known failure modes. The failure modes aren't
+design errors, but are easy ways to break or damage your board
+permanently.
+
+* **High voltage on non-tolerant pins**: not all header pins are 5V
+ compatible; so e.g. connecting certain serial devices in the wrong
+ way could over-voltage the pins. The :ref:`pin-mapping master table
+ <maple-pin-map-master>` details which pins are 5V-tolerant.
+
+Errata
+------
+
+This section lists known issues and warnings for each revision of the
+Maple board.
+
+Rev 5
+^^^^^
+
+* **Pin 3 AIN missing**: Pin 3 is capable of analog input, but on Rev
+ 5s manufactured during Fall 2010, the corresponding "AIN" is missing
+ from its silkscreen. This mistake was fixed in later manufacturing
+ runs.
+
+Rev 3
+^^^^^
+
+* **Pin 3 AIN missing**: Pin 3 is capable of analog input, but the
+ corresponding "AIN" is missing from the Rev 3 silkscreen.
+
+.. _maple-rev3-bad-buttons:
+
+* **Bad/Sticky Buttons**: a number of Rev 3 boards sold in May-June 2010
+ have questionable RESET and BUT buttons.
+
+ What seems to have happened is that the flux remover we used to
+ clean the boards before shipping eroded the plastic internals, which
+ resulted in intermittent functionality. All buttons on all shipped
+ boards did function in testing, but some may have been unreliable in
+ regular use.
+
+ If you have this problem, we will be happy to ship you new buttons
+ if you think you can re-solder them yourself, or you can ship us
+ your board and we will swap out that part.
+
+ For reference, the button part number is KMR211GLFS and the flux
+ remover we used is "Precision Electronics Cleaner" from RadioShack,
+ which is "Safe on most plastics" and contains Dipropylene glycol
+ monomethyl ether, hydrotreated heavy naphtha, dipropylene glycol
+ methyl ether acetate, and carbon dioxide.
+
+* **Resistors on pins 0 and 1**: these header pins, which are RX/TX on
+ USART2 (:ref:`Serial2 <lang-serial>`), have resistors in-line
+ between the STM32 and the headers. These resistors increase the
+ impedance of the lines for ADC reads and affect the open drain GPIO
+ functionality of the pins.
+
+ These resistors were accidentally copied over from older Arduino USB
+ designs, where they appear to protect the USB-Serial converter from
+ TTL voltage on the headers.
+
+* **Silkscreen Errors**: the silkscreen on the bottom indicated PWM
+ functionality on pin 25 and listen the external header GND pin as
+ number 38 (actually 38 is connected to the BUT button). We manually
+ sharpied over both of these mistakes.
+
+* **PWM Marketing Mistake**: We originally sold the Maple advertising
+ 22 channels of 16-bit hardware PWM; actually the Maple only has 15.
+
+Rev 1
+^^^^^
+
+* **ADC noise**: generally very high, in particular when the USB port
+ is being used for communications (including keep-alive pings when
+ connected to a computer).
+
+ This issue was resolved in Rev 3 with a 4-layer design and a
+ geometrically isolated ADC V\ :sub:`ref` plane.
+
+* **Resistors on pins 0 and 1**: these header pins, which are RX/TX on
+ USART2 (:ref:`Serial2 <lang-serial>`), have resistors in-line
+ between the STM32 and the headers. These resistors increase the
+ impedance of the lines for ADC reads and affect the open drain GPIO
+ functionality of the pins.
+
+ These resistors were accidentally copied over from older Arduino USB
+ designs, where they appear to protect the USB-Serial converter from
+ TTL voltage on the headers.
+
+* **Silkscreen Differences**: the pin numbering scheme on Rev 1 is
+ different from Rev 3, and thus Rev 3 software is difficult to use
+ with Rev 1 boards. Notably, the analog input bank is labeled A0-A4
+ on Rev 1 but 15-20 on Rev 3, and the extra header bank does not have
+ a pinout table on the bottom.
+
+* **No BUT Button**: the BUT button, useful for serial bootloading,
+ was only added in Rev 3. As a workaround, you can directly short the
+ appropriate MCU pin to Vcc; see `this forum posting
+ <http://forums.leaflabs.com/topic.php?id=32#post-126>`_.
+
+* **PWM Marketing Mistake**: We originally sold the Maple advertising
+ 22 channels of 16-bit hardware PWM; the correct number is 15.
+
+Recommended Reading
+-------------------
+
+* STMicro documentation for STM32F103RB microcontroller:
+
+ * `Datasheet
+ <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_
+ (PDF)
+ * `Reference Manual
+ <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_
+ (PDF)
+ * `Programming Manual
+ <http://www.st.com/stonline/products/literature/pm/15491.pdf>`_
+ (PDF; assembly language and register reference)
+
.. rubric:: Footnotes
.. [#frev2_4] Revs 2 and 4 were prototypes that didn't pass internal
testing.
-
diff --git a/docs/source/i2c.rst b/docs/source/i2c.rst
index b4a996b..e3d68c0 100644
--- a/docs/source/i2c.rst
+++ b/docs/source/i2c.rst
@@ -1,15 +1,8 @@
.. _i2c:
-=====
|i2c|
=====
-.. note::
-
- The |i2c| interface is currently only available from the 'i2c' branch
- of the github `libmaple <http://github.com/leaflabs/libmaple>`_
- repository.
-
|i2c| is a crude and easy-to-hack serial protocol that requires only
two wires/channels for communication between many devices. Every
message passed on the bus is between a *master* (who initiates the
@@ -22,7 +15,7 @@ value, is achieved by writing to set the memory location then reading
to pull out the data.
Note that the master/slave designation is on a message-by-message
-basis. The Maple can act as both a master (messages initiated by user
+basis. Maple can act as both a master (messages initiated by user
code) and slave device (responding to requests via configurable
interrupt handlers) at the same time.
@@ -32,15 +25,15 @@ interrupt handlers) at the same time.
Hardware/Circuit Design
-----------------------
-The Maple has two |i2c| ports. Port 1 (i2c1) has SDA on header D9 and
-SCL on D5; Port 2 (i2c2) has SDA on D30 and SCL on D29.
+.. FIXME [0.0.10 add links to board-specific values]
-The Maple reliably communicates with up to a 400kHz clock speed; this
-doesn't translate into a 400kbps data rate except in extreme cases
-because of addressing and protocol overhead. We have tested clock
-speeds up to a megahertz and have had mixed results; in theory it
-could be possible to achieve even higher rates, but signal quality
-degrades rapidly and the bus becomes unreliable.
+Maple boards have two |i2c| ports. Maples reliably communicate with
+up to a 400kHz clock speed; this doesn't translate into a 400kbps data
+rate except in extreme cases because of addressing and protocol
+overhead. We have tested clock speeds up to a megahertz and have had
+mixed results; in theory it could be possible to achieve even higher
+rates, but signal quality degrades rapidly, and the bus becomes
+unreliable.
Proper wiring and pull-up resistor selection are essential when
incorporating |i2c| into a circuit, especially with data rates above
@@ -55,33 +48,22 @@ oscilloscope to debug any issues.
Function Reference
------------------
-The function API for |i2c| is not finished! See the `source code
-<http://github.com/leaflabs/libmaple/blob/i2c/libmaple/i2c.h>`_ for
-now.
-
-.. TODO link to libmaple I2C docs once (1) finished, (2) in master
+Currently, only low-level support in :ref:`libmaple-i2c` exists. A
+Wiring-style library is planned for a future release.
SMBus
-----
-The STM32 microcontroller has hardware support for SMBus; we simply
-have not written software for it. The SMBAL line for i2c1 is on header
-D4 and for i2c2 is on D31.
-
-.. TODO link to libmaple SMBus docs once (1) finished, (2) in master
+The STM32 microcontroller has hardware support for SMBus, but software
+for it is not yet implemented.
.. _i2c-recommended-reading:
Recommended Reading
-------------------
-* `i2c-bus.org <http://www.i2c-bus.org/>`_
-* `Wikipedia Article on i2c <http://en.wikipedia.org/wiki/I%C2%B2C>`_
-* `Arduino i2c/TWI reference <http://www.arduino.cc/playground/Learning/I2C>`_
-* STMicro documentation for STM32F103RB microcontroller:
-
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
- * `Application Note on Advanced I2C Usage
- <http://www.st.com/stonline/products/literature/an/15021.pdf>`_
- (pdf)
+* `I2C Bus <http://www.i2c-bus.org/>`_
+* `Wikipedia: I2C <http://en.wikipedia.org/wiki/I%C2%B2C>`_
+* `Arduino I2C/TWI reference <http://www.arduino.cc/playground/Learning/I2C>`_
+* ST `Application Note on Advanced I2C Usage
+ <http://www.st.com/stonline/products/literature/an/15021.pdf>`_ (PDF)
diff --git a/docs/source/index.rst b/docs/source/index.rst
index 4369fbd..8c7ac84 100644
--- a/docs/source/index.rst
+++ b/docs/source/index.rst
@@ -1,13 +1,12 @@
.. _index:
-Maple Documentation Contents
+LeafLabs Documentation Index
============================
Welcome! This is the Maple documentation index. If you just bought a
-Maple, you probably want to head to the :ref:`quickstart
+Maple board, you probably want to head to the :ref:`quickstart
<maple-quickstart>`. If you're having problems, check out the
-:ref:`troubleshooting <troubleshooting>` and :ref:`known problems
-<errata>` pages.
+:ref:`troubleshooting <troubleshooting>` page.
Have fun!
@@ -32,12 +31,12 @@ Have fun!
Language <language>
Libraries <libraries>
- Arduino Compatibility <compatibility>
+ Arduino Compatibility <arduino-compatibility>
libmaple <libmaple>
- External Interrupts <external-interrupts>
Bootloader <bootloader>
Troubleshooting <troubleshooting>
- Known Problems <errata>
+ Notes on GCC's ARM target <arm-gcc>
+ Complete Language Index <language-index>
.. _index-hardware:
@@ -47,6 +46,7 @@ Have fun!
:maxdepth: 1
adc
+ external-interrupts
gpio
i2c
jtag
@@ -56,7 +56,7 @@ Have fun!
usb
usart
-.. _index-schematics:
+.. _index-boards:
**Board Hardware Documentation:**
@@ -64,6 +64,7 @@ Have fun!
:maxdepth: 1
hardware/maple.rst
+ hardware/maple-ret6.rst
.. TODO write/include these upon Mini and Native release
@@ -72,15 +73,3 @@ Have fun!
.. hardware/maple-mini.rst
.. hardware/maple-native.rst
-
-.. _index-reference:
-
-**Reference:**
-
-.. toctree::
- :maxdepth: 1
-
- Technical Specifications <specs>
- Complete Language Index <language-index>
-
-
diff --git a/docs/source/jtag.rst b/docs/source/jtag.rst
index 858021e..4151a53 100644
--- a/docs/source/jtag.rst
+++ b/docs/source/jtag.rst
@@ -1,11 +1,12 @@
+.. highlight:: cpp
+
.. _jtag:
======
JTAG
======
-.. TODO update adapter schematic, add information on using it with our
-.. devices.
+.. FIXME [0.1.0] Updated adapter schematic, better information
JTAG is an interface for low-level debugging of digital devices. It
gives instruction by instruction control over the microprocessor and
@@ -37,32 +38,46 @@ Wiring Diagram
to connect a standard 20-pin ARM JTAG device to the 8-pin JTAG port
on the Maple.
-The Maple has holes for a 8-pin JTAG header but that header is not
-soldered on by default. If you know ahead of time that you'll be
-needing it, and you order `straight from LeafLabs
-<http://leaflabs.com/store/>`_, add a comment to your order and we can
-probably solder one on for no charge. Otherwise, you can simply
-attach standard 0.1" pitch male header pins (either the exact 4x2
-block or two 4-pin pieces of breakaway straight header). For a one-off
-usage hack, the header can be jammed in the holes and twisted to
-ensure electrical contact.
+The Maple has holes for a 8-pin JTAG header, but that header is not
+soldered on. To use JTAG, simply solder on standard 0.1" pitch male
+header pins (either the exact 4 by 2 block, or two 4-pin pieces of
+straight breakaway header).
Compatible Devices
------------------
We have had good experience with the `Olimex ARM-USB-OCD
<http://www.olimex.com/dev/arm-usb-ocd.html>`_ device, which costs
-about 55 euro plus shipping (as of November 2010).
+about €55 plus shipping (as of April 2011).
+
+Function Reference
+------------------
+
+You can disable or enable the JTAG and Serial Wire debugging ports in
+software using the ``disableDebugPorts()`` and ``enableDebugPorts()``
+functions.
+
+* :ref:`lang-disabledebugports`
+* :ref:`lang-enabledebugports`
Recommended Reading
-------------------
-* `Wikipedia Article on Joint Test Action Group (JTAG) <http://en.wikipedia.org/wiki/Joint_Test_Action_Group>`_
-* `STM32/gdb/OpenOCD HOWTO <http://fun-tech.se/stm32/OpenOCD/gdb.php>`_
-* STMicro documentation for STM32F103RB microcontroller:
+* `Wikipedia Article on Joint Test Action Group (JTAG)
+ <http://en.wikipedia.org/wiki/Joint_Test_Action_Group>`_
+
+* `STM32, GDB, OpenOCD How To
+ <http://fun-tech.se/stm32/OpenOCD/gdb.php>`_
+
+* `LeafLabs Wiki JTAG How To
+ <http://wiki.leaflabs.com/index.php?title=Maple_JTAG_How_To>`_
+
+* `LeafLabs forum thread on JTAG
+ <http://forums.leaflabs.com/topic.php?id=536>`_
+
+* ST documentation:
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
-* There's a `thread on JTAG
- <http://forums.leaflabs.com/topic.php?id=536>`_ in our `forum`_
- which you may find useful.
+ * Reference Manual `RM0008
+ <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_
+ (PDF), Chapter 31, "Debug support", and Chapter 9,
+ "General-purpose and alternate function I/Os".
diff --git a/docs/source/lang/api/abs.rst b/docs/source/lang/api/abs.rst
index 0cc6c23..d9f1ca3 100644
--- a/docs/source/lang/api/abs.rst
+++ b/docs/source/lang/api/abs.rst
@@ -45,5 +45,4 @@ Arduino Compatibility
Maple's implementation of ``abs()`` is compatible with Arduino.
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/analogread.rst b/docs/source/lang/api/analogread.rst
index 35c6fbc..6665a94 100644
--- a/docs/source/lang/api/analogread.rst
+++ b/docs/source/lang/api/analogread.rst
@@ -20,53 +20,56 @@ Library Documentation
Discussion
----------
-Reads the value from the specified analog pin. The Maple board
-contains a 16-channel, 12-bit analog to digital converter. This means
-that it will map input voltages between 0 and 3.3 volts into integer
-values between 0 and 4095. This yields a resolution between readings
-of 3.3V / 4096 units, or 0.8 millivolts. However, a number of factors
+Reads the value from the specified analog pin. The Maple boards
+contain 16-channel, 12-bit analog to digital converters. This means
+that a converter will map input voltages between 0 and 3.3 volts into
+integer values between 0 and 4095. However, a number of factors
interfere with getting full accuracy and precision. For more
information, see :ref:`adc`.
Before calling analogRead() on a pin, that pin must first be
-configured for analog input, using :ref:`lang-pinMode` (you only
-have to do this once, so it's usually done in :ref:`lang-setup`\ ).
+configured for analog input, using :ref:`lang-pinMode`. You only have
+to do this once, so it's usually done in :ref:`lang-setup`\ .
Parameter Discussion
--------------------
The pin parameter is the number of the analog input pin to read from.
-Header pins on the Maple with ADC functionality (marked as "AIN" on
-the silkscreen) are:
-
- 0, 1, 2, 3, 10, 11, 12, 13, 15, 16, 17, 18, 19, 20, 27, 28
-
-Note that pins 3, 27, and 28 are not marked AIN on the silkscreen
-for Maple revisions through Rev 5, however, they **do work** as
-analog input pins.
+The pins which support analog to digital conversion have ``AIN``
+listed underneath their number on your board's silkscreen. These pin
+numbers are available to your program in the :ref:`boardADCPins
+<lang-board-values-adc-pins>` board-specific array. The number of
+pins which are capable of analog to digital conversion on your board
+is given by the ``BOARD_NR_ADC_PINS`` constant. These values are
+documented for each board in the :ref:`Board Hardware Documentation
+<index-boards>` pages.
+
+.. note:: Pin 3 is not marked ``AIN`` on the silkscreen for Maple
+ revisions through Rev 5; however **it does work** as an analog
+ input pin.
Note
----
If the analog input pin is not connected to anything, the value
-returned by analogRead() will fluctuate based on a number of factors
-(e.g. the values of the other analog inputs, how close your hand is to
-the board, etc.) in a seemingly random way.
-
+returned by ``analogRead()`` will fluctuate due to a number of reasons
+(like the values of the other analog inputs, how close your hand is to
+the board, etc.) in a "random" way.
Example
-------
- ::
+::
+ int analogPin = 3; // Potentiometer wiper (middle terminal) connected
+ // to analog pin 3. outside leads to ground and +3.3V.
+ // You may have to change this value if your board
+ // cannot perform ADC conversion on pin 3.
- int analogPin = 3; // potentiometer wiper (middle terminal) connected
- // to analog pin 3. outside leads to ground and +3.3V
int val = 0; // variable to store the value read
void setup() {
pinMode(analogPin, INPUT_ANALOG); // set up pin for analog input
- SerialUSB.begin(); // set up usb virtual COM port
}
void loop() {
@@ -75,7 +78,6 @@ Example
// a serial monitor
}
-
Arduino Compatibility
---------------------
@@ -97,23 +99,21 @@ shift <lang-bitshift>` the value of a Maple readout by 2, like so::
// be aware that you're losing a lot of precision if you do this
int adc_reading = analogRead(pin) >> 2;
+.. FIXME [0.1.0] Mention that Native can do analogReference()
+
On the Arduino, the input range and resolution can be changed using
-their implementation of `analogReference()
-<http://arduino.cc/en/Reference/AnalogReference>`_\ . Because of the
-way its hardware (as of Rev 5) was designed, it's not possible to
-implement analogReference on the Maple, so this function doesn't
-exist. If your inputs lie in a different voltage range than 0V--3.3V,
-you'll need to bring them into that range before using analogRead.
-Some basic tools to accomplish this are `resistor dividers
-<http://en.wikipedia.org/wiki/Voltage_divider>`_ and `Zener diodes
-<http://en.wikipedia.org/wiki/Voltage_source#Zener_voltage_source>`_\
-. However, opamps and other powered components can also be used if
-greater precision is required.
-
-See also
+the `analogReference()
+<http://arduino.cc/en/Reference/AnalogReference>`_ function. Because
+of hardware restrictions, this function is not available on the Maple
+and Maple RET6 Edition. If your inputs lie in a different voltage
+range than 0V--3.3V, you'll need to bring them into that range before
+using ``analogRead()``. See the :ref:`ADC reference <adc-range>` for
+more information.
+
+See Also
--------
-- :ref:`ADC note <adc>`
+- :ref:`ADC tutorial <adc>`
- `(Arduino) Tutorial: Analog Input Pins <http://arduino.cc/en/Tutorial/AnalogInputPins>`_
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/analogwrite.rst b/docs/source/lang/api/analogwrite.rst
index 9147b96..dd2192a 100644
--- a/docs/source/lang/api/analogwrite.rst
+++ b/docs/source/lang/api/analogwrite.rst
@@ -52,7 +52,7 @@ you much more precise control over the duty cycle of your PWM output.
If you're porting code from the Arduino and want a quick-and-dirty
fix, one solution is to :ref:`map <lang-map>` the argument to
-analogWrite into the right range::
+analogWrite() into the right range::
// Arduino code:
analogWrite(pin, duty);
@@ -65,14 +65,14 @@ This will convert values in the range 0-255 to values in the range
which control PWM output. See the :ref:`timers reference <timers>`
for more information.
-Another fix is to consult the :ref:`pin mapping mega table
-<pin-mapping-mega-table>` to find the timer which controls PWM on the
-pin you're using, then set that Timer's overflow to 255. Subsequent
-calls to analogWrite() should work as on the Arduino (with the same
-loss of precision). Note, however, that that affects the overflow for
-the **entire timer**, so other code relying on that timer (such as any
-:ref:`interrupts <lang-attachinterrupt>` the timer controls) will
-likely need to be modified as well.
+Another fix is to consult your board's :ref:`pin maps <gpio-pin-maps>`
+to find the timer which controls PWM on the pin you're using, then set
+that Timer's overflow to 255. Subsequent calls to analogWrite()
+should work as on the Arduino (with the same loss of precision).
+Note, however, that that affects the overflow for the **entire
+timer**, so other code relying on that timer (such as any
+:ref:`interrupts <lang-hardwaretimer-interrupts>` the timer controls)
+will likely need to be modified as well.
Difference 2: You must use pinMode() to set up PWM
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -140,24 +140,28 @@ If your application definitely requires Arduino's PWM frequency, then
the steps are:
1. Figure out which :ref:`timer <lang-hardwaretimer>` controls PWM
- output on your pin (\ :ref:`this table <pwm-timer-table>` is your
- friend here). Let's say it's ``Timern``\ , where ``n`` is some
- number 1, 2, 3, or 4.
+ output on your pin (\ :ref:`your board's Timer Pin Map
+ <gpio-pin-maps>` is your friend here).
-2. Call ``Timern.setPeriod(2041)``\ . This will set the timer's
- period to approximately 2041 microseconds, which is a frequency of
- approximately 490 Hz.
+2. Let's say it's timer ``n``, where ``n`` is some number. You'll
+ then need to put "``HardwareTimer timer(n);``" with your variables,
+ as described in the :ref:`HardwareTimer
+ <lang-hardwaretimer-getting-started>` reference.
+
+3. In your :ref:`lang-setup`, put "``timer.setPeriod(2041);``". This
+ will set the timer's period to approximately 2041 microseconds,
+ which is a frequency of approximately 490 Hz.
Be aware that this will change the period for the **entire timer**\ ,
and will affect anything else in your program that depends on that
timer. The important examples are :ref:`timer interrupts
-<lang-hardwaretimer-attachinterrupt>` and :ref:`PWM
+<lang-hardwaretimer-interrupts>` and :ref:`PWM
<timers-pwm-conflicts>`\ .
-See also
+See Also
--------
-- :ref:`Maple PWM tutorial <pwm>`
+- :ref:`pwm`
.. rubric:: Footnotes
@@ -169,5 +173,4 @@ See also
Maple uses 2 bytes of memory, and an unsigned (i.e., nonnegative)
integer with size 2 bytes can hold the values between 0 and 65,535.
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/attachinterrupt.rst b/docs/source/lang/api/attachinterrupt.rst
index 7c5a6c7..39902ac 100644
--- a/docs/source/lang/api/attachinterrupt.rst
+++ b/docs/source/lang/api/attachinterrupt.rst
@@ -5,9 +5,8 @@
attachInterrupt()
=================
-Used to specify a function to call when an external interrupt (like an
-GPIO changing from LOW to HIGH, a button getting pressed, etc.)
-occurs.
+Used to specify a function to call when an :ref:`external interrupt
+<external-interrupts>` occurs.
.. contents:: Contents
:local:
@@ -15,9 +14,9 @@ occurs.
Library Documentation
---------------------
-.. FIXME once breathe knows how to get the correct attachInterupt
-.. (right now it's copying from HardwareTimer), replace with a
-.. doxygenfunction directive
+.. FIXME [doxygenfunction] once Breathe knows how to get the correct
+.. attachInterupt (right now it's copying from HardwareTimer), replace
+.. with a doxygenfunction directive
.. cpp:function:: void attachInterrupt(uint8 pin, voidFuncPtr handler, ExtIntTriggerMode mode)
@@ -47,49 +46,29 @@ Discussion
Because the function will run in interrupt context, inside of it,
:ref:`lang-delay` won't work, and the value returned by
-:ref:`lang-millis` will not increment. Serial data received while
-in the function may be lost. You should declare as ``volatile`` any
+:ref:`lang-millis` will not increment. Serial data received while in
+the function may be lost. You should declare as ``volatile`` any
global variables that you modify within the attached function.
-There are a few constraints you should be aware of if you're using
-more than one interrupt at a time; the :ref:`external-interrupts` page
-has the details.
-
-Using Interrupts
-----------------
-
-Interrupts are useful for making things happen automatically in
-microcontroller programs, and can help solve timing problems. A
-good task for using an interrupt might be reading a rotary encoder,
-or monitoring user input.
-
-If you wanted to insure that a program always caught the pulses
-from a rotary encoder, never missing a pulse, it would make it very
-tricky to write a program to do anything else, because the program
-would need to constantly poll the sensor lines for the encoder, in
-order to catch pulses when they occurred. Other sensors have a
-similar interface dynamic too, such as trying to read a sound
-sensor that is trying to catch a click, or an infrared slot sensor
-(photo-interrupter) trying to catch a coin drop. In all of these
-situations, using an interrupt can free the microcontroller to get
-some other work done while not missing the doorbell.
+There are a few limits you should be aware of if you're using more
+than one interrupt at a time; the :ref:`External Interrupts
+<external-interrupts-exti-line>` page has more information.
Example
-------
-::
+ ::
- int maple_led_pin = 13;
volatile int state = LOW; // must declare volatile, since it's
- // modified within the blink handler
+ // modified within the blink() handler
void setup() {
- pinMode(maple_led_pin, OUTPUT);
+ pinMode(BOARD_LED_PIN, OUTPUT);
attachInterrupt(0, blink, CHANGE);
}
void loop() {
- digitalWrite(maple_led_pin, state);
+ digitalWrite(BOARD_LED_PIN, state);
}
void blink() {
@@ -106,10 +85,10 @@ additional four: numbers 2 (pin 21), 3 (pin 20), 4 (pin 19), and 5
number goes with which pin -- just tell ``attachInterrupt()`` the pin
you want.
-See also
+See Also
--------
-- :ref:`detachInterrupt <lang-detachinterrupt>`
-- :ref:`external-interrupts`
+- :ref:`lang-detachinterrupt`
+- :ref:`external-interrupts`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/bit.rst b/docs/source/lang/api/bit.rst
index dd5c050..3df042c 100644
--- a/docs/source/lang/api/bit.rst
+++ b/docs/source/lang/api/bit.rst
@@ -12,33 +12,27 @@ Syntax
``bit(n)``
-
Parameters
----------
* **n** the bit to set.
-
Value
-----
The value of an integer with the given bit set.
-
Arduino Compatibility
---------------------
-The Maple implementation of bit is compatible with Arduino.
+The Maple implementation of ``bit()`` is compatible with Arduino.
-
-See also
+See Also
--------
-
- :ref:`lang-bitread`
- :ref:`lang-bitwrite`
- :ref:`lang-bitset`
- :ref:`lang-bitclear`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/bitclear.rst b/docs/source/lang/api/bitclear.rst
index 941f912..f487059 100644
--- a/docs/source/lang/api/bitclear.rst
+++ b/docs/source/lang/api/bitclear.rst
@@ -10,7 +10,6 @@ Syntax
``bitClear(x, n)``
-
Parameters
----------
@@ -19,20 +18,17 @@ Parameters
* **n** which bit to clear, starting at 0 for the least-significant
(rightmost) bit
-
Returns
-------
-None.
-
+Nothing.
Arduino Compatibility
---------------------
-This implementation is compatible with that of Arduino.
+The Maple implementation of ``bitClear()`` is compatible with Arduino.
-
-See also
+See Also
--------
- :ref:`bit <lang-bit>`\ ()
@@ -40,5 +36,4 @@ See also
- :ref:`bitWrite <lang-bitwrite>`\ ()
- :ref:`bitSet <lang-bitset>`\ ()
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/bitread.rst b/docs/source/lang/api/bitread.rst
index 46b4478..fd9fbbe 100644
--- a/docs/source/lang/api/bitread.rst
+++ b/docs/source/lang/api/bitread.rst
@@ -5,13 +5,11 @@ bitRead()
(Macro) Gets the value of a bit in a number.
-
Syntax
------
``bitRead(x, n)``
-
Parameters
----------
@@ -20,27 +18,22 @@ Parameters
* **n** which bit to read, starting at 0 for the least-significant
(rightmost) bit
-
Value
-----
The value of the bit (0 or 1).
-
Arduino Compatibility
---------------------
The Maple implementation of ``bitRead`` is compatible with Arduino.
-
-See also
+See Also
--------
-
- :ref:`lang-bit`
- :ref:`lang-bitwrite`
- :ref:`lang-bitset`
- :ref:`lang-bitclear`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/bitset.rst b/docs/source/lang/api/bitset.rst
index ccd76de..83ab5f8 100644
--- a/docs/source/lang/api/bitset.rst
+++ b/docs/source/lang/api/bitset.rst
@@ -5,13 +5,11 @@ bitSet()
(Macro) Sets (writes a 1 to) a bit of a numeric variable.
-
Syntax
------
``bitSet(x, n)``
-
Parameters
----------
@@ -20,19 +18,16 @@ Parameters
* **n** which bit to set, starting at 0 for the least-significant
(rightmost) bit
-
Value
-----
None.
-
Arduino Compatibility
---------------------
The Maple implementation of bitSet is compatible with Arduino.
-
See Also
--------
@@ -41,6 +36,4 @@ See Also
- :ref:`lang-bitwrite`
- :ref:`lang-bitclear`
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/bitwrite.rst b/docs/source/lang/api/bitwrite.rst
index b3feff2..6106545 100644
--- a/docs/source/lang/api/bitwrite.rst
+++ b/docs/source/lang/api/bitwrite.rst
@@ -32,9 +32,9 @@ Nothing.
Arduino Compatibility
---------------------
-Maple's version of ``bitWrite()`` is compatible with Arduino.
+Maple's implementation of ``bitWrite()`` is compatible with Arduino.
-See also
+See Also
--------
- :ref:`bit() <lang-bit>`
@@ -42,5 +42,4 @@ See also
- :ref:`bitSet() <lang-bitSet>`
- :ref:`bitClear() <lang-bitClear>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/board-values.rst b/docs/source/lang/api/board-values.rst
new file mode 100644
index 0000000..05e3837
--- /dev/null
+++ b/docs/source/lang/api/board-values.rst
@@ -0,0 +1,180 @@
+.. _lang-board-values:
+
+Board-Specific Constants
+========================
+
+There are a number of board-specific values: constants or variables
+which are different depending on which LeafLabs board you have.
+
+This page lists and documents the board-specific values. You should
+use these when appropriate in your own programs. This will help make
+it easier to share your code with other people who have different
+boards. Some example usages are given :ref:`below
+<lang-board-values-examples>`.
+
+The actual values for each board are given in the :ref:`Board Hardware
+Documentation <index-boards>`.
+
+.. contents:: Contents
+ :local:
+
+Constants
+---------
+
+- ``CLOCK_SPEED_MHZ``: Clock speed of your board, in megahertz
+ (MHz). This is the same as ``CYCLES_PER_MICROSECOND``.
+
+- ``CLOCK_SPEED_HZ``: Clock speed of your board, in hertz (Hz). This
+ is the same as ``CLOCK_SPEED_MHZ * 1000000``.
+
+- ``CYCLES_PER_MICROSECOND``: Number of CPU cycles per microsecond on
+ your board.
+
+.. _lang-board-values-but:
+
+- ``BOARD_BUTTON_PIN``: Pin connected to the built-in button (labeled
+ "BUT" on your board's silkscreen).
+
+.. _lang-board-values-led:
+
+- ``BOARD_LED_PIN``: Pin connected to the built-in LED.
+
+- ``BOARD_NR_GPIO_PINS``: Total number of :ref:`GPIO pins <gpio>` that
+ are broken out to headers. Some of these might already be connected
+ to external hardware (like the built-in LED and button). To find
+ out if a pin is in use, see :ref:`boardUsesPin()
+ <lang-boardusespin>` (and also :ref:`boardUsedPins
+ <lang-board-values-used-pins>`).
+
+.. _lang-board-values-nr-pwm-pins:
+
+- ``BOARD_NR_PWM_PINS``: Total *number* of GPIO pins that can be used
+ for :ref:`PWM <pwm>`. The actual *pins* that can do PWM are in the
+ :ref:`boardPWMPins <lang-board-values-pwm-pins>` array.
+
+.. _lang-board-values-nr-adc-pins:
+
+- ``BOARD_NR_ADC_PINS``: Total number of GPIO pins that can be used
+ for :ref:`analog-to-digital conversion <adc>`. The actual pins that
+ can do ADC conversion are in the :ref:`boardADCPins
+ <lang-board-values-adc-pins>` array.
+
+.. _lang-board-values-nr-used-pins:
+
+- ``BOARD_NR_USED_PINS``: Total number of GPIO pins that are already
+ connected to some external hardware (like a built-in LED) on the
+ board. The actual pins that that are already used are in the
+ :ref:`boardUsedPins <lang-board-values-used-pins>` array. To see if
+ a pin is already in use, use the :ref:`boardUsesPin()
+ <lang-boardusespin>` function.
+
+.. _lang-board-values-usart:
+
+- USART (serial port) related constants:
+
+ * ``BOARD_USART1_TX_PIN``, ``BOARD_USART2_TX_PIN``, ``BOARD_USART3_TX_PIN``:
+ TX pins for the 3 USARTS.
+
+ * ``BOARD_USART1_RX_PIN``, ``BOARD_USART2_RX_PIN``, ``BOARD_USART3_RX_PIN``:
+ RX pins for the 3 USARTS.
+
+ * ``BOARD_UART4_TX_PIN``, ``BOARD_UART5_TX_PIN``: TX pins for
+ UARTs 4 and 5 (high-density boards like Maple Native only).
+
+ * ``BOARD_UART4_RX_PIN``, ``BOARD_UART5_RX_PIN``: RX pins for
+ UARTs 4 and 5 (high-density boards like Maple Native only).
+
+ * ``BOARD_NR_USARTS``: Number of serial ports on the board. This
+ number includes UARTs 4 and 5 if they are available.
+
+.. _lang-board-values-debug:
+
+- Debug (JTAG, SW-Debug) related constants: ``BOARD_JTMS_SWDIO_PIN``,
+ ``BOARD_JTCK_SWCLK_PIN``, ``BOARD_JTDI_PIN``, ``BOARD_JTDO_PIN``,
+ and ``BOARD_NJTRST_PIN``.
+
+ These constants are the pin numbers for :ref:`GPIOs <gpio>` used by
+ the :ref:`jtag` and Serial-Wire Debug peripherals. Except for the
+ Maple Mini, these pins are usually reserved for special purposes by
+ default (i.e., they are in :ref:`boardUsedPins
+ <lang-board-values-used-pins>`). However, they can be used as
+ ordinary GPIOs if you call the :ref:`lang-disabledebugports`
+ function. (Be careful with this on the Maple, as writing to
+ ``BOARD_NJTRST_PIN`` may cause your board to reset!).
+
+.. _lang-board-values-pwm-pins:
+
+.. _lang-board-values-adc-pins:
+
+.. _lang-board-values-used-pins:
+
+Pin Arrays
+----------
+
+Some :ref:`arrays <lang-array>` of pin numbers are available which you
+can use to find out certain important information about a given pin.
+
+- ``boardPWMPins``: Pin numbers of each pin capable of :ref:`PWM
+ <pwm>` output, using :ref:`pwmWrite() <lang-pwmwrite>`. The total
+ number of these pins is :ref:`BOARD_NR_PWM_PINS
+ <lang-board-values-nr-pwm-pins>`.
+
+- ``boardADCPins``: Pin numbers of each pin capable of :ref:`ADC
+ <adc>` conversion, using :ref:`analogRead() <lang-analogread>`. The
+ total number of these pins is :ref:`BOARD_NR_ADC_PINS
+ <lang-board-values-nr-adc-pins>`.
+
+- ``boardUsedPins``: Pin numbers of each pin that, by default, is used
+ for some special purpose by the board. The total number of these
+ pins is :ref:`BOARD_NR_USED_PINS <lang-board-values-nr-used-pins>`.
+ To check if a pin is used for a special purpose, use
+ :ref:`boardUsesPin() <lang-boardusespin>`.
+
+.. _lang-board-values-examples:
+
+Examples
+--------
+
+:ref:`BOARD_LED_PIN <lang-board-values-led>` On the Maple, the
+built-in LED is connected to pin 13. On the Maple Mini, however, it
+is connected to pin 33. You can write a "blinky" program that works
+on all LeafLabs boards using ``BOARD_LED_PIN`` and :ref:`toggleLED()
+<lang-toggleled>`::
+
+ void setup() {
+ pinMode(BOARD_LED_PIN, OUTPUT);
+ }
+
+ void loop() {
+ toggleLED();
+ delay(100);
+ }
+
+:ref:`BOARD_BUTTON_PIN <lang-board-values-but>`: Similarly, you can
+write a single program that prints a message whenever the button is
+pressed which will work on all LeafLabs boards using
+``BOARD_BUTTON_PIN`` and :ref:`isButtonPressed()
+<lang-isbuttonpressed>`::
+
+ void setup() {
+ pinMode(BOARD_BUTTON_PIN, INPUT);
+ }
+
+ void loop() {
+ if (isButtonPressed()) {
+ SerialUSB.println("You pressed the button!");
+ }
+ }
+
+See Also
+--------
+
+- :ref:`lang-boardusespin`
+- :ref:`lang-isbuttonpressed`
+- :ref:`lang-waitforbuttonpress`
+- :ref:`lang-pinmode`
+- :ref:`lang-toggleled`
+- :ref:`lang-analogread`
+- :ref:`lang-pwmwrite`
+- :ref:`lang-enabledebugports`
+- :ref:`lang-disabledebugports`
diff --git a/docs/source/lang/api/boardusespin.rst b/docs/source/lang/api/boardusespin.rst
new file mode 100644
index 0000000..126c4a0
--- /dev/null
+++ b/docs/source/lang/api/boardusespin.rst
@@ -0,0 +1,27 @@
+.. highlight:: cpp
+
+.. _lang-boardusespin:
+
+boardUsesPin()
+==============
+
+Each LeafLabs board connects some pins to external hardware. The most
+important examples of this are the pins connected to the built-in LED
+and button. You can check if a board uses a particular pin using this
+function.
+
+Library Documentation
+---------------------
+
+.. doxygenfunction:: boardUsesPin
+
+See Also
+--------
+
+- :ref:`Board-specific values <lang-board-values>`
+- :ref:`boardUsedPins <lang-board-values-used-pins>`
+- :ref:`BOARD_LED_PIN <lang-board-values-led>`
+- :ref:`toggleLED() <lang-toggleled>`
+- :ref:`BOARD_BUTTON_PIN <lang-board-values-but>`
+- :ref:`isButtonPressed() <lang-isbuttonpressed>`
+- :ref:`waitForButtonPress() <lang-waitforbuttonpress>`
diff --git a/docs/source/lang/api/constants.rst b/docs/source/lang/api/constants.rst
index 72738b8..00c1a5c 100644
--- a/docs/source/lang/api/constants.rst
+++ b/docs/source/lang/api/constants.rst
@@ -61,14 +61,6 @@ pin is configured as an ``INPUT`` (using :ref:`pinMode()
<lang-digitalread>`, the microcontroller will report ``HIGH`` if a
voltage of 3 volts or more is present at the pin.
-.. TODO? Following seems false; check it out sometime, leave out for now:
-
-.. A pin may also be configured as an ``INPUT`` with ``pinMode()``, and
-.. subsequently made ``HIGH`` with :ref:`digitalWrite()
-.. <lang-digitalwrite>`, this will set the internal pullup resistors,
-.. which will *steer* the input pin to a HIGH reading unless it is pulled
-.. LOW by external circuitry.
-
When a pin is configured to ``OUTPUT`` with pinMode, and set to
``HIGH`` with :ref:`digitalWrite() <lang-digitalwrite>`, the pin is at
3.3 volts. In this state it can *source* current, e.g. light an LED
@@ -301,23 +293,16 @@ exponent indicators. Some examples are given in the following table:
Board-Specific Constants
------------------------
-This section documents constants whose value might change across
-different LeafLabs boards. You can use these constants to help ensure
-that your code will be portable across different boards.
-
-.. TODO replace "upcoming" when Mini, Native come out
-
-.. _lang-constants-led:
-
-- ``BOARD_LED_PIN``: the number of the pin which connects to the
- built-in LED. On the Maple, this is pin 13, but it's not guaranteed
- to be the same in upcoming boards like the Maple Mini.
-
-.. _lang-constants-but:
+There are several :ref:`board-specific constants <lang-board-values>`
+whose value depends on which LeafLabs board you have. If you use
+them, it will help make sure that your code will work well on all
+LeafLabs boards, not just the one you have. This will make it much
+easier to share your code with others.
-- ``BOARD_BUTTON_PIN``: the number of the pin which connects to the
- built-in button (labeled "BUT"). On the Maple, this is pin 38, but
- it's not guaranteed to be the same in other boards.
+For example, the pin number connected to the board's built-in LED is
+different on the different boards, but the board-specific constant
+:ref:`BOARD_LED_PIN <lang-board-values-led>` will always be the
+correct value for each board.
See Also
--------
@@ -333,5 +318,6 @@ See Also
- :ref:`unsigned long long <lang-unsignedlonglong>`
- :ref:`float <lang-float>`
- :ref:`double <lang-double>`
+- :ref:`Board-Specific Values <lang-board-values>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/constrain.rst b/docs/source/lang/api/constrain.rst
index d19b61c..28af1e3 100644
--- a/docs/source/lang/api/constrain.rst
+++ b/docs/source/lang/api/constrain.rst
@@ -59,11 +59,10 @@ Arduino Compatibility
Maple's implementation of ``constrain()`` is compatible with Arduino.
-See also
+See Also
--------
- :ref:`min() <lang-min>`
- :ref:`max() <lang-max>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/cos.rst b/docs/source/lang/api/cos.rst
index 3fbb0af..c340f09 100644
--- a/docs/source/lang/api/cos.rst
+++ b/docs/source/lang/api/cos.rst
@@ -19,14 +19,12 @@ Note that the Maple implementation comes from `newlib
<http://sourceware.org/newlib/>`_\ , while Arduino's is that of
`avr-libc <http://avr-libc.nongnu.org/>`_\ .
-See also
+See Also
--------
-
- :ref:`sin() <lang-sin>`
- :ref:`tan() <lang-tan>`
- :ref:`float <lang-float>`
- :ref:`double <lang-double>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/delay.rst b/docs/source/lang/api/delay.rst
index 90ca268..9ef06a0 100644
--- a/docs/source/lang/api/delay.rst
+++ b/docs/source/lang/api/delay.rst
@@ -57,10 +57,9 @@ Example
.. _lang-delay-seealso:
-See also
+See Also
--------
-
- :ref:`millis() <lang-millis>`
- :ref:`micros() <lang-micros>`
- :ref:`delayMicroseconds() <lang-delayMicroseconds>`
@@ -68,5 +67,4 @@ See also
<http://arduino.cc/en/Tutorial/BlinkWithoutDelay>`_ example (works
unmodified on Maple)
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/delaymicroseconds.rst b/docs/source/lang/api/delaymicroseconds.rst
index 24a8286..7078660 100644
--- a/docs/source/lang/api/delaymicroseconds.rst
+++ b/docs/source/lang/api/delaymicroseconds.rst
@@ -48,9 +48,9 @@ Arduino Compatibility
---------------------
While we have made every effort we could to ensure that the timing of
-delayMicroseconds is as accurate as possible, we cannot guarantee it
-will behave as the Arduino implementation down to the microsecond,
-especially for smaller values of ``us``.
+``delayMicroseconds()`` is as accurate as possible, we cannot
+guarantee it will behave as the Arduino implementation down to the
+microsecond, especially for smaller values of ``us``.
See Also
--------
@@ -59,7 +59,4 @@ See Also
- :ref:`micros <lang-micros>`
- :ref:`delay <lang-delay>`
-
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/detachinterrupt.rst b/docs/source/lang/api/detachinterrupt.rst
index 41642a7..82ce974 100644
--- a/docs/source/lang/api/detachinterrupt.rst
+++ b/docs/source/lang/api/detachinterrupt.rst
@@ -9,9 +9,8 @@ Used to disable an interrupt specified with
Library Documentation
---------------------
-.. FIXME once breathe knows how to get the correct detachInterupt
-.. (right now it's copying from HardwareTimer), replace with a
-.. doxygenfunction directive
+.. FIXME [Breathe] once we can get the correct detachInterupt(),
+.. replace with doxygenfunction.
.. cpp:function:: void detachInterrupt(uint8 pin)
@@ -39,5 +38,6 @@ See Also
--------
- :ref:`attachInterrupt() <lang-attachInterrupt>`
+- :ref:`external-interrupts`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/digitalread.rst b/docs/source/lang/api/digitalread.rst
index 3502587..ccf4a4c 100644
--- a/docs/source/lang/api/digitalread.rst
+++ b/docs/source/lang/api/digitalread.rst
@@ -8,51 +8,44 @@ digitalRead()
Reads the value from a specified digital pin, either :ref:`HIGH
<lang-constants-high>` or :ref:`LOW <lang-constants-low>`.
-
Library Documentation
---------------------
.. doxygenfunction:: digitalRead
+Discussion
+----------
+
+If the pin isn't connected to anything, ``digitalRead()`` can return
+either HIGH or LOW (and this will change in a way that seems random).
Example
-------
-The following example turns the LED on when the button is pressed::
-
- int ledPin = 13; // LED connected to Maple pin 13
- int buttonPin = 38; // BUT connected to Maple pin 38
+The following example turns the LED on or off when the button is pressed::
void setup() {
- pinMode(ledPin, OUTPUT);
- pinMode(buttonPin, INPUT);
+ pinMode(BOARD_LED_PIN, OUTPUT);
+ pinMode(BOARD_BUTTON_PIN, INPUT);
}
void loop() {
- int val = digitalRead(buttonPin); // reads the input pin
- digitalWrite(ledPin, val);
+ int val = digitalRead(BOARD_BUTTON_PIN); // reads the input pin
+ togglePin(BOARD_LED_PIN, val);
}
-Note
-----
-
-If the pin isn't connected to anything, ``digitalRead()`` can return
-either HIGH or LOW (and this can change in a way that seems random).
-
Arduino Compatibility
---------------------
The Maple version of ``digitalRead()`` is compatible with Arduino.
-
See Also
--------
-- :ref:`pinMode <lang-pinMode>`
-- :ref:`digitalWrite <lang-digitalWrite>`
-
-
-
-
+- :ref:`BOARD_BUTTON_PIN <lang-board-values-but>`
+- :ref:`lang-isButtonPressed`
+- :ref:`lang-pinmode`
+- :ref:`lang-digitalWrite`
+- :ref:`lang-togglepin`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/digitalwrite.rst b/docs/source/lang/api/digitalwrite.rst
index 6124d5f..376cbc3 100644
--- a/docs/source/lang/api/digitalwrite.rst
+++ b/docs/source/lang/api/digitalwrite.rst
@@ -21,42 +21,26 @@ If the pin has been configured as an ``OUTPUT`` with :ref:`pinMode()
<lang-pinmode>` its voltage will be set to the corresponding value:
3.3V for ``HIGH``, and 0V (ground) for ``LOW``.
-.. TODO make the following paragraphs true, but refer the reader to
-.. INPUT_PULLUP and INPUT_PULLDOWN:
-
-If the pin is configured as an ``INPUT``, writing a ``HIGH`` value
-with ``digitalWrite()`` will enable an internal pullup resistor.
-Writing ``LOW`` will disable the pullup. The pullup resistor is enough
-to light an LED dimly, so if LEDs appear to work, but very dimly, this
-is a likely cause. The remedy is to set the pin to an output with the
-:ref:`pinMode() <lang-pinmode>` function.
-
-.. note:: Pin 13 is harder to use as an input than the other pins
- because it has an LED and resistor soldered to it in series. If you
- enable its internal pull-up resistor, it will likely hang at around
- 1.1V instead of the expected 3.3V because the onboard LED and
- series resistor pull the voltage level down. If you must use pin 13
- as a digital input, use an external pull-down resistor.
+Because it is soldered to an LED and resistor in series, your board's
+:ref:`BOARD_LED_PIN <lang-board-values-led>` will respond slightly
+more slowly as an output than the other pins.
Example
-------
The following example sets pin 13 to ``HIGH``, makes a one-second-long
delay, sets the pin back to ``LOW``, and delays again, causing a
-blinking pattern::
-
-
- int ledPin = 13; // LED connected to digital pin 13
+blinking pattern (you could also use :ref:`lang-toggleled`)::
void setup() {
- pinMode(ledPin, OUTPUT); // sets the digital pin as output
+ pinMode(BOARD_LED_PIN, OUTPUT); // sets the digital pin as output
}
void loop() {
- digitalWrite(ledPin, HIGH); // sets the LED on
- delay(1000); // waits for a second
- digitalWrite(ledPin, LOW); // sets the LED off
- delay(1000); // waits for a second
+ digitalWrite(BOARD_LED_PIN, HIGH); // sets the LED on
+ delay(1000); // waits for a second
+ digitalWrite(BOARD_LED_PIN, LOW); // sets the LED off
+ delay(1000); // waits for a second
}
See Also
@@ -64,5 +48,8 @@ See Also
- :ref:`pinMode <lang-pinmode>`
- :ref:`digitalRead <lang-digitalread>`
+- :ref:`BOARD_LED_PIN <lang-board-values-led>`
+- :ref:`lang-toggleled`
+- :ref:`lang-togglepin`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/disabledebugports.rst b/docs/source/lang/api/disabledebugports.rst
new file mode 100644
index 0000000..43ac337
--- /dev/null
+++ b/docs/source/lang/api/disabledebugports.rst
@@ -0,0 +1,31 @@
+.. highlight:: cpp
+
+.. _lang-disabledebugports:
+
+disableDebugPorts()
+===================
+
+Used to disable the JTAG and Serial Wire debugging ports.
+
+Library Documentation
+---------------------
+
+.. doxygenfunction:: disableDebugPorts
+
+Example
+-------
+
+ ::
+
+ void setup() {
+ disableDebugPorts();
+ }
+
+ void loop() {
+ // Now you can use the debug port pins as ordinary pins
+ }
+
+See Also
+--------
+
+* :ref:`lang-enabledebugports`
diff --git a/docs/source/lang/api/enabledebugports.rst b/docs/source/lang/api/enabledebugports.rst
new file mode 100644
index 0000000..bee2b0a
--- /dev/null
+++ b/docs/source/lang/api/enabledebugports.rst
@@ -0,0 +1,31 @@
+.. highlight:: cpp
+
+.. _lang-enabledebugports:
+
+enableDebugPorts()
+==================
+
+Used to enable the JTAG and Serial Wire debugging ports.
+
+Library Documentation
+---------------------
+
+.. doxygenfunction:: enableDebugPorts
+
+Example
+-------
+
+ ::
+
+ void setup() {
+ enableDebugPorts();
+ // Now you can debug using JTAG and SW-Debug
+ }
+
+ void loop() {
+ }
+
+See Also
+--------
+
+* :ref:`lang-disabledebugports`
diff --git a/docs/source/lang/api/hardwarespi.rst b/docs/source/lang/api/hardwarespi.rst
index 53a225d..289ded5 100644
--- a/docs/source/lang/api/hardwarespi.rst
+++ b/docs/source/lang/api/hardwarespi.rst
@@ -5,160 +5,161 @@
HardwareSPI
===========
-This class is used for creating objects to manage the Maple's built-in
-SPI ports. The Maple has two SPI ports. The relevant pins
-corresponding to each port's logic signals are documented in the
-following table (and on the Maple silkscreen):
+This page describes how to use the built-in SPI ports. It does not
+describe the SPI protocol itself. For more information about SPI, see
+the :ref:`SPI reference <spi>`.
-.. _lang-hardwarespi-pinout:
+.. contents:: Contents
+ :local:
-.. list-table::
- :header-rows: 1
+Getting Started
+---------------
- * - Port number
- - NSS
- - MOSI
- - MISO
- - SCK
+.. TODO [0.1.0] Add a note about calling disableDebugPorts() when
+.. using SPI3 on Maple Native
- * - 1
- - 10
- - 11
- - 12
- - 13
+In order to get started, you'll first need to define a ``HardwareSPI``
+variable, which you'll use to control the SPI port. Do this by
+putting the line "``HardwareSPI spi(number);``" with your variables,
+where ``number`` is the SPI port's number.
- * - 2
- - 31
- - 32
- - 33
- - 34
+Here's an example (we'll fill in :ref:`setup() <lang-setup>` and
+:ref:`loop() <lang-loop>` later)::
-If you use a SPI port, you cannot simultaneously use its associated
-pins for other purposes.
+ // Use SPI port number 1
+ HardwareSPI spi(1);
-Library Documentation
----------------------
+ void setup() {
+ // Your setup code
+ }
+
+ void loop() {
+ // Do stuff with SPI
+ }
-Using the SPI Class
-^^^^^^^^^^^^^^^^^^^
+Turning the SPI Port On
+-----------------------
-You can declare that you want to use SPI in your sketch by putting
-``HardwareSPI Spi(number);`` with your variables, where ``number`` is
-1 or 2, depending on which SPI you want to use. Then you can use the
-functions described in the next section. For example::
+Now it's time to turn your SPI port on. Do this with the ``begin()``
+function (an example is given below).
- // Use SPI 1
- HardwareSpi Spi(1);
+.. FIXME [0.0.10] Breathe doesn't include the class; fix & submit pull req
+
+.. doxygenfunction:: HardwareSPI::begin
+
+The speed at which the SPI port communicates is configured using a
+``SPIFrequency`` value:
+
+.. FIXME [0.1.0] Breathe's enum output is enormous; shrink & submit pull req
+
+.. doxygenenum:: SPIFrequency
+
+.. note:: Due to hardware issues, you can't use the frequency
+ ``SPI_140_625KHz`` with SPI port 1.
+
+You'll need to determine the correct values for ``frequency``,
+``bitOrder``, and ``mode`` yourself, by consulting the datasheet for
+the device you're communicating with. Continuing our example from
+before, we'll add a call to ``begin()`` to our ``setup()``::
+
+ // Use SPI port number 1
+ HardwareSPI spi(1);
void setup() {
- Spi.begin(SPI_18MHZ);
+ // Turn on the SPI port
+ spi.begin(SPI_18MHZ, MSBFIRST, 0);
}
void loop() {
- // Get the next byte from the peripheral
- uint8 byte = Spi.recv();
+ // Do stuff with SPI
}
-HardwareSPI Class Reference
-^^^^^^^^^^^^^^^^^^^^^^^^^^^
+If you call ``begin()`` with no arguments (as in "``spi.begin();``"),
+it's the same as if you wrote "``spi.begin(SPI_1_125MHZ, MSBFIRST,
+0);``".
-.. cpp:class:: HardwareSPI
+Communicating Over SPI
+----------------------
- Class for interacting with SPI.
+Now that you've got your SPI port set up, it's time to start
+communicating. You can send data using ``HardwareSPI::write()``,
+receive data using ``HardwareSPI::read()``, and do both using
+``HardwareSPI::transfer()``.
-.. cpp:function:: HardwareSPI::HardwareSPI(uint32 spi_num)
+.. cpp:function:: void HardwareSPI::write(byte data)
- Construct an object for managing a SPI peripheral. ``spi_num``
- must be 1 or 2; see the :ref:`table above
- <lang-hardwarespi-pinout>` for pinout information.
+ Send a single byte of data.
-.. cpp:function:: void HardwareSPI::begin(SPIFrequency freq, uint32 endianness, uint32 mode)
+ **Parameters**:
- Configure the baudrate of the given SPI port and set up the header
- pins appropriately.
+ - ``data``: Byte to send
- Parameters:
+.. cpp:function:: byte HardwareSPI::read()
- - ``freq``: one of the ``SPIFrequency`` values, given :ref:`below
- <lang-hardwarespi-spifrequency>`.
+ Get the next available, unread byte. If there aren't any unread
+ bytes, this function will wait until one is received.
- - ``endianness``: either ``LSBFIRST`` (little-endian) or
- ``MSBFIRST`` (big-endian).
+.. cpp:function:: byte HardwareSPI::transmit(byte data)
- - ``mode``: one of 0, 1, 2, or 3, and specifies which SPI mode is
- used. The mode number determines a combination of polarity and
- phase according to the following table:
+ Send a byte, then return the next byte received.
- .. list-table::
- :header-rows: 1
+ **Parameters:**
- * - Mode
- - Polarity
- - Phase
+ - ``data``: Byte to send
- * - 0
- - 0
- - 0
+ **Returns:** Next unread byte
- * - 1
- - 0
- - 1
+Continuing our example from before, let's send a number over SPI and
+print out whatever we get back over :ref:`lang-serialusb`::
- * - 2
- - 1
- - 0
+ // Use SPI port number 1
+ HardwareSPI spi(1);
- * - 3
- - 1
- - 1
+ void setup() {
+ // Turn on the SPI port
+ spi.begin(SPI_18MHZ, MSBFIRST, 0);
+ }
- For more information on polarity and phase, see the
- :ref:`external references, below <lang-hardwarespi-seealso>`.
+ void loop() {
+ // Send 245 over SPI, and wait for a response.
+ spi.write(245);
+ byte response = spi.read();
+ // Print out the response received.
+ SerialUSB.print("response: ");
+ SerialUSB.println(response, DEC);
+ }
+
+HardwareSPI Class Reference
+---------------------------
+
+There are a number of other things you can accomplish with your
+``spi`` object. A full function listing follows.
-.. cpp:function:: void HardwareSPI::begin()
+.. doxygenclass:: HardwareSPI
+ :members: HardwareSPI, begin, beginSlave, end, read, write, transfer
- A convenience ``begin()``, equivalent to ``begin(SPI_1_125MHZ,
- MSBFIRST, 0)``.
+Deprecated Functions
+--------------------
-.. cpp:function:: uint8 HardwareSpi::send(uint8 *data, uint32 length)
+The following functions are defined for now, but they have been
+deprecated, and will be removed in a future Maple IDE release. You
+shouldn't use them in new programs, and you should change any of your
+programs which do use them to the up-to-date functions discussed
+above.
+
+.. cpp:function:: uint8 HardwareSPI::send(uint8 *data, uint32 length)
Writes ``data`` into the port buffer to be transmitted as soon as
possible, where ``length`` is the number of bytes to send from
``data``. Returns the last byte shifted back from slave.
-.. cpp:function:: uint8 HardwareSpi::send(uint8 data)
+.. cpp:function:: uint8 HardwareSPI::send(uint8 data)
Writes the single byte ``data`` into the port buffer to be
transmitted as soon as possible. Returns the data byte shifted
back from the slave.
-.. cpp:function:: uint8 HardwareSpi::recv()
+.. cpp:function:: uint8 HardwareSPI::recv()
Reads a byte from the peripheral. Returns the next byte in the
buffer.
-
-SPI Speeds
-^^^^^^^^^^
-
-.. _lang-hardwarespi-spifrequency:
-
-The possible SPI speeds are configured using the ``SPIFrequency`` enum:
-
-.. doxygenenum:: SPIFrequency
-
-.. _lang-hardwarespi-seealso:
-
-See Also
---------
-
-* `Wikipedia Article on Serial Peripheral Interface Bus (SPI)
- <http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus>`_
-* `Arduino reference on SPI
- <http://www.arduino.cc/playground/Code/Spi>`_
-* `Hardcore SPI on Arduino <http://klk64.com/arduino-spi/>`_ by kik64
-* STMicro documentation for STM32F103RB microcontroller:
-
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
-
-
diff --git a/docs/source/lang/api/hardwaretimer.rst b/docs/source/lang/api/hardwaretimer.rst
index c7a630d..09245f0 100644
--- a/docs/source/lang/api/hardwaretimer.rst
+++ b/docs/source/lang/api/hardwaretimer.rst
@@ -5,369 +5,341 @@
HardwareTimer
=============
-This class defines the public API for interfacing with the STM32's
-built-in timer peripherals. More information on these peripherals
-(including code examples) is available in the :ref:`timers reference
-<timers>`.
+This page describes how to control the built-in timers. It does not
+describe how the timers work on your board. For more information on
+that, the :ref:`timers reference <timers>`.
-Library Documentation
----------------------
+.. warning:: The timer interface is still taking shape, and is
+ expected to change significantly between releases. Because of
+ that, the functionality described in this page shouldn't be
+ considered stable.
-HardwareTimer Class Reference
-^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+ If you want a timer API that will be consistent between releases of
+ the Maple IDE, your best bet for now is to use the low-level
+ support in :ref:`libmaple-timer`.
-To interact with a particular timer, call one of the methods
-documented below on one of the predefined ``HardwareTimer`` instances.
-For example, to set the prescale factor on timer 1 to 5, call
-``Timer1.setPrescaleFactor(5)``.
+.. contents:: Contents
+ :local:
-.. TODO add code examples that people can copy and paste in case
-.. they're unfamiliar with namespace syntax
+.. _lang-hardwaretimer-getting-started:
-.. cpp:class:: HardwareTimer
+Getting Started
+---------------
- Class for interacting with a timer. There are four predefined
- instances available on the Maple: ``Timer1``, ``Timer2``,
- ``Timer3``, and ``Timer4``.
+You'll first need to define a ``HardwareTimer`` variable, which you'll
+use to control the timer. Do this by putting the line
+"``HardwareTimer timer(number);``" with your variables, where
+``number`` is the timer's number.
-.. _lang-hardwaretimer-attachinterrupt:
+Here's an example (we'll fill in :ref:`setup() <lang-setup>` and
+:ref:`loop() <lang-loop>` later)::
-.. cpp:function:: void HardwareTimer::attachInterrupt(int channel, voidFuncPtr handler)
+ // Use timer 1
+ HardwareTimer timer(1);
- Attach an interrupt handler to the given ``channel``. This
- interrupt handler will be called when the timer's counter reaches
- the given channel :ref:`compare <lang-hardwaretimer-setcompare>`
- value.
+ void setup() {
+ // Your setup code
+ }
- ``handler`` should be a function which takes no arguments and has
- :ref:`void <lang-void>` value; i.e. it should have signature ::
+ void loop() {
+ // ...
+ }
- void handler(void);
+Configuring the Prescaler and Overflow
+--------------------------------------
- You can later detach the interrupt using :ref:`detachInterrupt()
- <lang-hardwaretimer-detachinterrupt>`.
+After defining your ``timer`` variable, you'll probably want to
+configure how fast your timer's counter changes (using the prescaler)
+and when it gets reset to zero (using the overflow value). You can do
+that with the ``setPrescaleFactor()`` and ``setOverflow()`` functions.
- .. note:: The function (often called an *interrupt service
- routine*, or ISR) should attempt to return as quickly as
- possible. :ref:`Blinking the LED <lang-toggleled>`, some
- logic, :ref:`PWM <pwm>` updates, and :ref:`Serial
- <lang-serial>` writes are fine; writing to
- :ref:`SerialUSB <lang-serialusb>` or :ref:`waiting
- <lang-waitforbuttonpress>` for user input can take a long
- time and prevent other interrupts from firing on time.
-
- Tip: if you have a :ref:`delay() <lang-delay>` in your
- ISR, you're probably doing it wrong.
-
-.. cpp:function:: void HardwareTimer::attachCompare1Interrupt(voidFuncPtr handler)
-
- Equivalent to :ref:`attachInterrupt
- <lang-hardwaretimer-attachinterrupt>`\ ``(1, handler)``.
-
-.. cpp:function:: void HardwareTimer::attachCompare2Interrupt(voidFuncPtr handler)
-
- Equivalent to :ref:`attachInterrupt
- <lang-hardwaretimer-attachinterrupt>`\ ``(2, handler)``.
-
-.. cpp:function:: void HardwareTimer::attachCompare3Interrupt(voidFuncPtr handler)
+.. _lang-hardwaretimer-setprescalefactor:
- Equivalent to :ref:`attachInterrupt
- <lang-hardwaretimer-attachinterrupt>`\ ``(3, handler)``.
+.. doxygenfunction:: HardwareTimer::setPrescaleFactor
+ :no-link:
-.. cpp:function:: void HardwareTimer::attachCompare4Interrupt(voidFuncPtr handler)
+.. _lang-hardwaretimer-setoverflow:
- Equivalent to :ref:`attachInterrupt
- <lang-hardwaretimer-attachinterrupt>`\ ``(4, handler)``.
+.. doxygenfunction:: HardwareTimer::setOverflow
+ :no-link:
-.. _lang-hardwaretimer-setchannelmode:
+For example::
-.. cpp:function:: void HardwareTimer::setChannelMode(int channel, TimerMode mode)
+ // Use timer 1
+ HardwareTimer timer(1);
- Set the given channel of this timer to the given :ref:`mode
- <lang-hardwaretimer-modes>`. The parameter ``channel`` is one of
- 1, 2, 3, and 4, and corresponds to the compare channel you would
- like to set. Refer to the full :ref:`pin mapping table
- <pin-mapping-mega-table>` to match up timer channels and pin
- numbers.
+ void setup() {
+ timer.setPrescaleFactor(5);
+ timer.setOverflow(255);
+ }
-.. cpp:function:: void HardwareTimer::setChannel1Mode(TimerMode mode)
+ void loop() {
+ // ...
+ }
- Equivalent to :ref:`setChannelMode <lang-hardwaretimer-setchannelmode>`\
- ``(1, mode)``.
+You may also find the ``setPeriod()`` function useful:
-.. cpp:function:: void HardwareTimer::setChannel2Mode(TimerMode mode)
+.. _lang-hardwaretimer-setperiod:
- Equivalent to :ref:`setChannelMode <lang-hardwaretimer-setchannelmode>`\
- ``(2, mode)``.
+.. doxygenfunction:: HardwareTimer::setPeriod
+ :no-link:
-.. cpp:function:: void HardwareTimer::setChannel3Mode(TimerMode mode)
+For example::
- Equivalent to :ref:`setChannelMode <lang-hardwaretimer-setchannelmode>`\
- ``(3, mode)``.
+ // Use timer 1
+ HardwareTimer timer(1);
-.. cpp:function:: void HardwareTimer::setChannel4Mode(TimerMode mode)
+ void setup() {
+ // Have the timer repeat every 20 milliseconds
+ int microseconds_per_millisecond = 1000;
+ timer.setPeriod(20 * microseconds_per_millisecond);
+ }
- Equivalent to :ref:`setChannelMode <lang-hardwaretimer-setchannelmode>`\
- ``(4, mode)``.
+ void loop() {
+ // ...
+ }
+
+.. _lang-hardwaretimer-interrupts:
+
+Using Timer Interrupts
+----------------------
+
+.. TODO [0.2.0] Improve the interrupts section, here or in timers.rst
+
+In order to use timer interrupts, we recommend the following sequence:
+
+* Pause the timer.
+* Configure the prescaler and overflow.
+* Pick a timer channel to handle the interrupt and set the channel's
+ :ref:`mode <lang-hardwaretimer-timermode>` to ``TIMER_OUTPUT_COMPARE``.
+* Set the channel compare value appropriately (this controls what counter value,
+ from 0 to overflow - 1). If you just want to make the interrupt fire once
+ every time the timer overflows, and you don't care what the timer count is,
+ the channel compare value can just be 1.
+* Attach an interrupt handler to the channel.
+* Refresh the timer.
+* Resume the timer.
+
+Here are two complete examples.
+
+**LED blink**: This example blinks the built-in LED without doing
+anything in ``loop()``. ::
+
+ #define LED_RATE 500000 // in microseconds; should give 0.5Hz toggles
+
+ // We'll use timer 2
+ HardwareTimer timer(2);
+
+ void setup() {
+ // Set up the LED to blink
+ pinMode(BOARD_LED_PIN, OUTPUT);
+
+ // Pause the timer while we're configuring it
+ timer.pause();
+
+ // Set up period
+ timer.setPeriod(LED_RATE); // in microseconds
+
+ // Set up an interrupt on channel 1
+ timer.setChannel1Mode(TIMER_OUTPUT_COMPARE);
+ timer.setCompare(TIMER_CH1, 1); // Interrupt 1 count after each update
+ timer.attachCompare1Interrupt(handler_led);
+
+ // Refresh the timer's count, prescale, and overflow
+ timer.refresh();
+
+ // Start the timer counting
+ timer.resume();
+ }
+
+ void loop() {
+ // Nothing! It's all in the handler_led() interrupt:
+ }
+
+ void handler_led(void) {
+ toggleLED();
+ }
+
+**Racing Counters**: This example shows how to use multiple timers at
+the same time. ::
+
+ int count3 = 0;
+ int count4 = 0;
+
+ // We'll use timers 3 and 4
+ HardwareTimer timer3(3);
+ HardwareTimer timer4(4);
+
+ void setup() {
+ // Set up the button for input
+ pinMode(BOARD_BUTTON_PIN, INPUT_PULLUP);
+
+ // Set up timers to add 1 to their counts each time
+ // their interrupts fire.
+ timer3.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE);
+ timer4.setMode(TIMER_CH1, TIMER_OUTPUT_COMPARE);
+ timer3.pause();
+ timer4.pause();
+ timer3.setCount(0);
+ timer4.setCount(0);
+ timer3.setOverflow(30000);
+ timer4.setOverflow(30000);
+ timer3.setCompare(TIMER_CH1, 1000); // somewhere in the middle
+ timer4.setCompare(TIMER_CH1, 1000);
+ timer3.attachCompare1Interrupt(handler3);
+ timer4.attachCompare1Interrupt(handler4);
+ timer3.refresh();
+ timer4.refresh();
+ timer3.resume();
+ timer4.resume();
+ }
+
+ void loop() {
+ // Display the running counts
+ SerialUSB.print("Count 3: ");
+ SerialUSB.print(count3);
+ SerialUSB.print("\t\tCount 4: ");
+ SerialUSB.println(count4);
+
+ // While the button is held down, pause timer 4
+ for (int i = 0; i < 1000; i++) {
+ if (digitalRead(BOARD_BUTTON_PIN)) {
+ timer4.pause();
+ } else {
+ timer4.resume();
+ }
+ delay(1);
+ }
+ }
+
+ void handler3(void) {
+ count3++;
+ }
+
+ void handler4(void) {
+ count4++;
+ }
+
+``HardwareTimer`` Class Reference
+---------------------------------
+
+This section gives a full listing of the capabilities of a
+``HardwareTimer``.
+
+.. doxygenclass:: HardwareTimer
+ :members: HardwareTimer, pause, resume, getPrescaleFactor, setPrescaleFactor, getOverflow, setOverflow, getCount, setCount, setPeriod, setMode, getCompare, setCompare, attachInterrupt, detachInterrupt, refresh
+
+.. _lang-hardwaretimer-timermode:
+
+.. doxygenenum:: timer_mode
+
+Deprecated Functionality
+------------------------
+
+The following functionality exists for now, but it has been
+deprecated, and will be removed in a future Maple IDE release. You
+shouldn't use it in new programs, and you should change any of your
+programs which do use them to use the up-to-date features described
+above.
+
+The ``TimerMode`` type from previous releases has been renamed
+``timer_mode``. The mode ``TIMER_OUTPUTCOMPARE`` is still present,
+but will be removed in a future release. Use ``TIMER_OUTPUT_COMPARE``
+instead.
-.. _lang-hardwaretimer-getcompare:
+.. cpp:function:: void HardwareTimer::attachCompare1Interrupt(voidFuncPtr handler)
-.. cpp:function:: uint16 HardwareTimer::getCompare(int channel)
+ Use ``attachInterrupt(1, handler)`` instead.
- Gets the compare value for the given ``channel``, from 1 to 4. See
- :ref:`setCompare() <lang-hardwaretimer-setcompare>`.
+.. cpp:function:: void HardwareTimer::attachCompare2Interrupt(voidFuncPtr handler)
-.. cpp:function:: uint16 HardwareTimer::getCompare1()
+ Use ``attachInterrupt(2, handler)`` instead.
- Equivalent to :ref:`getCompare <lang-hardwaretimer-getcompare>`\
- ``(1, mode)``.
+.. cpp:function:: void HardwareTimer::attachCompare3Interrupt(voidFuncPtr handler)
-.. cpp:function:: uint16 HardwareTimer::getCompare2()
+ Use ``attachInterrupt(3, handler)`` instead.
- Equivalent to :ref:`getCompare <lang-hardwaretimer-getcompare>`\
- ``(2, mode)``.
+.. cpp:function:: void HardwareTimer::attachCompare4Interrupt(voidFuncPtr handler)
-.. cpp:function:: uint16 HardwareTimer::getCompare3()
+ Use ``attachInterrupt(4, handler)`` instead.
- Equivalent to :ref:`getCompare <lang-hardwaretimer-getcompare>`\
- ``(3, mode)``.
+.. _lang-hardwaretimer-setchannelmode:
-.. cpp:function:: uint16 HardwareTimer::getCompare4()
+.. cpp:function:: void HardwareTimer::setChannelMode(int channel, timer_mode mode)
- Equivalent to :ref:`getCompare <lang-hardwaretimer-getcompare>`\
- ``(4, mode)``.
+ Use ``setMode(channel, mode)`` instead.
-.. _lang-hardwaretimer-setcompare:
+.. cpp:function:: void HardwareTimer::setChannel1Mode(timer_mode mode)
-.. cpp:function:: void HardwareTimer::setCompare(int channel, uint16 compare)
+ Use ``setMode(1, mode)`` instead.
- Sets the compare value for the given ``channel`` to ``compare``.
- If ``compare`` is greater than this timer's overflow value, it will
- be truncated to the overflow value. The default compare value is
- 65,535 (the largest unsigned 16-bit integer value).
+.. cpp:function:: void HardwareTimer::setChannel2Mode(timer_mode mode)
- When the counter reaches this value the interrupt for this channel
- will fire if the given ``channel`` :ref:`mode
- <lang-hardwaretimer-setchannelmode>` is ``TIMER_OUTPUTCOMPARE`` and
- an interrupt is :ref:`attached
- <lang-hardwaretimer-attachinterrupt>`.
+ Use ``setMode(2, mode)`` instead.
- By default, this only changes the relative offsets between events
- on a single timer ("phase"); they don't control the frequency with
- which they occur. However, a common trick is to increment the
- compare value manually in the interrupt handler so that the event
- will fire again after the increment period. There can be a
- different increment value for each channel, so this trick allows
- events to be programmed at 4 different rates on a single
- timer. Note that function call overheads mean that the smallest
- increment rate is at least a few microseconds.
+.. cpp:function:: void HardwareTimer::setChannel3Mode(timer_mode mode)
-.. cpp:function:: void HardwareTimer::setCompare1(uint16 compare)
+ Use ``setMode(3, mode)`` instead.
- Equivalent to :ref:`setCompare <lang-hardwaretimer-setcompare>`\
- ``(1, compare)``.
+.. cpp:function:: void HardwareTimer::setChannel4Mode(timer_mode mode)
-.. cpp:function:: void HardwareTimer::setCompare2(uint16 compare)
+ Use ``setMode(4, mode)`` instead.
- Equivalent to :ref:`setCompare <lang-hardwaretimer-setcompare>`\
- ``(2, compare)``.
+.. cpp:function:: uint16 HardwareTimer::getCompare1()
-.. cpp:function:: void HardwareTimer::setCompare3(uint16 compare)
+ Use ``getCompare(1, mode)`` instead.
- Equivalent to :ref:`setCompare <lang-hardwaretimer-setcompare>`\
- ``(3, compare)``.
+.. cpp:function:: uint16 HardwareTimer::getCompare2()
-.. cpp:function:: void HardwareTimer::setCompare4(uint16 compare)
+ Use ``getCompare(2, mode)`` instead.
- Equivalent to :ref:`setCompare <lang-hardwaretimer-setcompare>`\
- ``(4, compare)``.
+.. cpp:function:: uint16 HardwareTimer::getCompare3()
-.. cpp:function:: uint16 HardwareTimer::getCount()
+ Use ``getCompare(3, mode)`` instead.
- Gets the current timer count. Due to function call overhead, the
- return value will be increasingly accurate with smaller prescale
- values. Also see :ref:`setCount() <lang-hardwaretimer-setcount>`.
+.. cpp:function:: uint16 HardwareTimer::getCompare4()
-.. _lang-hardwaretimer-setcount:
+ Use ``getCompare(4, mode)`` instead.
-.. cpp:function:: void HardwareTimer::setCount(uint16 val)
+.. cpp:function:: void HardwareTimer::setCompare1(uint16 compare)
- Set the timer's current count to ``val``.
+ Use ``setCompare(1, compare)`` instead.
- Note that there is some function call overhead associated with
- calling this method, so using it is not a robust way to get
- multiple timers to share a count value.
+.. cpp:function:: void HardwareTimer::setCompare2(uint16 compare)
- If ``val`` exceeds the timer's :ref:`overflow value
- <lang-hardwaretimer-getoverflow>`, it is truncated to the overflow
- value.
+ Use ``setCompare(2, compare)`` instead.
+.. cpp:function:: void HardwareTimer::setCompare3(uint16 compare)
-.. _lang-hardwaretimer-detachinterrupt:
+ Use ``setCompare(3, compare)`` instead.
-.. cpp:function:: void HardwareTimer::detachInterrupt(int channel)
+.. cpp:function:: void HardwareTimer::setCompare4(uint16 compare)
- Remove the interrupt handler attached to the given ``channel``, if
- any. The handler will no longer be called by this timer.
+ Use ``setCompare(4, compare)`` instead.
.. cpp:function:: void HardwareTimer::detachCompare1Interrupt()
- Equivalent to :ref:`detachInterrupt
- <lang-hardwaretimer-detachinterrupt>`\ ``(1)``.
+ Use ``detachInterrupt(1)`` instead.
.. cpp:function:: void HardwareTimer::detachCompare2Interrupt()
- Equivalent to :ref:`detachInterrupt
- <lang-hardwaretimer-detachinterrupt>`\ ``(2)``.
+ Use ``detachInterrupt(2)`` instead.
.. cpp:function:: void HardwareTimer::detachCompare3Interrupt()
- Equivalent to :ref:`detachInterrupt
- <lang-hardwaretimer-detachinterrupt>`\ ``(3)``.
+ Use ``detachInterrupt(3)`` instead.
.. cpp:function:: void HardwareTimer::detachCompare4Interrupt()
- Equivalent to :ref:`detachInterrupt
- <lang-hardwaretimer-detachinterrupt>`\ ``(4)``.
-
-.. _lang-hardwaretimer-generateupdate:
+ Use ``detachInterrupt(4)`` instead.
.. cpp:function:: void HardwareTimer::generateUpdate()
- Re-initializes the counter (to 0 in upcounting mode, which is the
- default), and generates an update of the prescale and overflow
- registers.
-
-.. _lang-hardwaretimer-getoverflow:
-
-.. cpp:function:: uint16 HardwareTimer::getOverflow()
-
- Gets the timer's overflow value. See :ref:`setOverflow()
- <lang-hardwaretimer-setoverflow>`.
-
-.. _lang-hardwaretimer-setoverflow:
-
-.. cpp:function:: void HardwareTimer::setOverflow(uint16 val)
-
- Sets the timer overflow (or "reload") value to ``val``.
-
- When the timer's counter reaches this, value it resets to
- zero. Its default value is 65535 (the largest unsigned 16-bit
- integer); setting the overflow to anything lower will cause
- interrupts to be called more frequently (see :ref:`setPeriod()
- <lang-hardwaretimer-setperiod>` function for a shortcut).
-
- After the next :ref:`timer update
- <lang-hardwaretimer-generateupdate>`, this number will be the
- maximum value for the timer's channel compare values.
-
-.. _lang-hardwaretimer-pause:
-
-.. cpp:function:: void HardwareTimer::pause()
-
- Stop the timer's counter, without affecting its configuration.
-
- The timer will no longer count or fire interrupts after this
- function is called, until it is resumed. This function is useful
- during timer setup periods, in order to prevent interrupts from
- firing before the timer is fully configured.
-
- Note that there is some function call overhead associated with this
- method, so using it in concert with :ref:`resume()
- <lang-hardwaretimer-resume>` is not a robust way to align multiple
- timers to the same count value.
-
-.. _lang-hardwaretimer-setperiod:
-
-.. cpp:function:: uint16 HardwareTimer::setPeriod(uint32 microseconds)
-
- Configure the :ref:`prescaler
- <lang-hardwaretimer-getprescalefactor>` and :ref:`overflow
- <lang-hardwaretimer-getoverflow>` values to generate a timer reload
- with a period as close to the given number of ``microseconds`` as
- possible.
-
- The return value is the new overflow value, which may be used to
- set channel compare values. However, if a clock that fires an
- interrupt every given number of microseconds is all that is
- desired, and the relative "phases" are unimportant, channel compare
- values may all be set to 1.
-
-.. _lang-hardwaretimer-getprescalefactor:
-
-.. cpp:function:: uint16 HardwareTimer::getPrescaleFactor()
-
- Returns the timer's prescale factor. See
- :ref:`setPrescaleFactor() <lang-hardwaretimer-setprescalefactor>`.
-
-.. _lang-hardwaretimer-setprescalefactor:
-
-.. cpp:function:: void HardwareTimer::setPrescaleFactor(uint16 factor)
-
- Set the timer's prescale factor to ``factor``.
-
- The prescaler acts as a clock divider to slow down the rate at
- which the counter increments.
-
- For example, the system clock rate is 72MHz, so the counter will
- reach 65535 in (13.89 nanoseconds) × (65535 counts) = (910.22
- microseconds), or about a thousand times a second. If the
- prescaler equals 1098, then the clock rate is effectively 72MHz /
- 1098 = 65.56KHz, and the counter will reach 65536 in (15.25
- microseconds) × (65536 counts) = (0.999 seconds), or about once
- per second.
-
- The :ref:`setPeriod() <lang-hardwaretimer-setperiod>` method may
- also be used as a convenient alternative.
-
-.. _lang-hardwaretimer-resume:
-
-.. cpp:function:: void HardwareTimer::resume()
-
- Resume a paused timer, without affecting its configuration.
-
- The timer will resume counting and firing interrupts as
- appropriate.
-
- Note that there is some function call overhead associated with
- using this method, so using it in concert with :ref:`pause()
- <lang-hardwaretimer-pause>` is not a robust way to align multiple
- timers to the same count value.
-
-.. cpp:function:: timer_dev_num HardwareTimer::getTimerNum()
-
- Returns the :ref:`timer device number
- <lang-hardwaretimer-timer-dev-num>` associated with the timer. For
- example, ``Timer1.getTimerNum()`` would return ``TIMER1``.
-
- In most cases, you should not need to use this function. If you do
- use it, be careful; the constant ``TIMER1`` is *not equal* to the
- number 1; similarly, ``TIMER2`` is *not* the number 2, etc. Be
- sure to refer to the timer device number by name.
-
-.. _lang-hardwaretimer-modes:
-
-Timer Modes
-^^^^^^^^^^^
-.. doxygenenum:: TimerMode
-
-.. _lang-hardwaretimer-timer-dev-num:
-
-Timer Device Numbers
-^^^^^^^^^^^^^^^^^^^^
-
-These provide a lower-level interface for interacting with timers.
-They are mostly useful in context with the :ref:`getTimer()
-<lang-hardwaretimer-gettimer>` function. **Be careful** when using
-these not to confuse e.g. ``TIMER1`` with the number 1; they are
-different.
-
-.. doxygenenum:: timer_dev_num
-
-.. _lang-hardwaretimer-convenience:
-
-.. _lang-hardwaretimer-gettimer:
+ Use ``refresh()`` instead.
-Other Functions
-^^^^^^^^^^^^^^^
-.. doxygenfunction:: getTimer
+In previous releases, to interact with a particular timers, you would
+use one of the predefined ``HardwareTimer`` instances ``Timer1``,
+``Timer2``, ``Timer3``, and ``Timer4``. These are still available for
+now, but they are also deprecated, and will be removed in a future
+release. As detailed in :ref:`lang-hardwaretimer-getting-started`,
+you should define your own ``HardwareTimer`` variables.
diff --git a/docs/source/lang/api/highbyte.rst b/docs/source/lang/api/highbyte.rst
index 50a1fa6..4cb6f9b 100644
--- a/docs/source/lang/api/highbyte.rst
+++ b/docs/source/lang/api/highbyte.rst
@@ -52,8 +52,4 @@ See Also
- :ref:`lowByte() <lang-lowbyte>`
-
-
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/isbuttonpressed.rst b/docs/source/lang/api/isbuttonpressed.rst
index dbff0c9..8c350b9 100644
--- a/docs/source/lang/api/isbuttonpressed.rst
+++ b/docs/source/lang/api/isbuttonpressed.rst
@@ -4,7 +4,8 @@ isButtonPressed()
=================
Check whether the board's built-in button (labeled BUT on the
-silkscreen) is pressed.
+silkscreen) is pressed. The pin number of the built-in button is
+given by the constant ``BOARD_BUTTON_PIN``.
Library Documentation
---------------------
@@ -14,4 +15,6 @@ Library Documentation
See Also
--------
+- :ref:`Board-specific values <lang-board-values>`
+- :ref:`BOARD_BUTTON_PIN <lang-board-values-but>`
- :ref:`lang-waitforbuttonpress`
diff --git a/docs/source/lang/api/loop.rst b/docs/source/lang/api/loop.rst
index d8f6183..c2a5097 100644
--- a/docs/source/lang/api/loop.rst
+++ b/docs/source/lang/api/loop.rst
@@ -15,7 +15,6 @@ Example
::
-
int buttonPin = 38;
// setup initializes serial and the button pin
@@ -42,4 +41,4 @@ See Also
- :ref:`setup() <lang-setup>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/lowbyte.rst b/docs/source/lang/api/lowbyte.rst
index 58e622f..c513711 100644
--- a/docs/source/lang/api/lowbyte.rst
+++ b/docs/source/lang/api/lowbyte.rst
@@ -22,4 +22,4 @@ Returns
The low byte's value (this will be between 0 and 255).
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/map.rst b/docs/source/lang/api/map.rst
index 79122b3..69661a0 100644
--- a/docs/source/lang/api/map.rst
+++ b/docs/source/lang/api/map.rst
@@ -65,4 +65,4 @@ See Also
- :ref:`constrain() <lang-constrain>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/max.rst b/docs/source/lang/api/max.rst
index d38eebe..d356f08 100644
--- a/docs/source/lang/api/max.rst
+++ b/docs/source/lang/api/max.rst
@@ -53,7 +53,7 @@ functions inside the parentheses. It may lead to incorrect results::
Arduino Compatibility
---------------------
-The Maple version of ``max()`` is compatible with Arduino.
+The Maple implementation of ``max()`` is compatible with Arduino.
See Also
--------
@@ -61,5 +61,4 @@ See Also
- :ref:`min() <lang-min>`
- :ref:`constrain() <lang-constrain>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/micros.rst b/docs/source/lang/api/micros.rst
index f12976b..de85303 100644
--- a/docs/source/lang/api/micros.rst
+++ b/docs/source/lang/api/micros.rst
@@ -43,4 +43,4 @@ See Also
- :ref:`delay() <lang-delay>`
- :ref:`delayMicroseconds() <lang-delaymicroseconds>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/millis.rst b/docs/source/lang/api/millis.rst
index 0288c56..db0531c 100644
--- a/docs/source/lang/api/millis.rst
+++ b/docs/source/lang/api/millis.rst
@@ -49,4 +49,4 @@ See Also
- :ref:`delay <lang-delay>`
- :ref:`delayMicroseconds <lang-delaymicroseconds>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/min.rst b/docs/source/lang/api/min.rst
index 1245f6f..3307105 100644
--- a/docs/source/lang/api/min.rst
+++ b/docs/source/lang/api/min.rst
@@ -62,5 +62,4 @@ See Also
- :ref:`max() <lang-max>`
- :ref:`constrain() <lang-constrain>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/pinmode.rst b/docs/source/lang/api/pinmode.rst
index 03cbcfa..8cee3e5 100644
--- a/docs/source/lang/api/pinmode.rst
+++ b/docs/source/lang/api/pinmode.rst
@@ -60,13 +60,13 @@ set up a pin for these purposes before a call to, e.g.,
:ref:`lang-analogRead`. In practice, this should only add a few lines
to your :ref:`lang-setup` function.
-.. TODO verify following before putting it in:
+.. TODO [0.1.0] verify following before putting it in:
.. ``OUTPUT_OPEN_DRAIN``, ``INPUT_PULLUP``, ``INPUT_PULLDOWN``, and
.. ``PWM_OPEN_DRAIN`` modes represent functionality not currently
.. available on Arduino boards.
-See also
+See Also
--------
- :ref:`lang-constants`
@@ -74,6 +74,4 @@ See also
- :ref:`lang-digitalread`
- Maple :ref:`GPIO <gpio>` reference page
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/pow.rst b/docs/source/lang/api/pow.rst
index 4280400..219a866 100644
--- a/docs/source/lang/api/pow.rst
+++ b/docs/source/lang/api/pow.rst
@@ -10,8 +10,6 @@ Library Documentation
.. doxygenfunction:: pow
-.. TODO LATER some examples
-
See Also
--------
@@ -19,5 +17,4 @@ See Also
- :ref:`float <lang-float>`
- :ref:`double <lang-double>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/pwmwrite.rst b/docs/source/lang/api/pwmwrite.rst
index 9d50077..5cc112e 100644
--- a/docs/source/lang/api/pwmwrite.rst
+++ b/docs/source/lang/api/pwmwrite.rst
@@ -11,8 +11,13 @@ pwmWrite(), the pin will output a steady square wave with the given
duty cycle. You can change the duty cycle later by calling pwmWrite()
again with the same pin and a different duty.
-On the Maple, the pins which support PWM are: 0, 1, 2, 3, 5, 6, 7, 8,
-9, 11, 12, 14, 24, 27, and 28.
+The pins which support PWM have ``PWM`` listed underneath their number
+on your board's silkscreen. These pin numbers are available to your
+program in the :ref:`boardPWMPins <lang-board-values-pwm-pins>`
+board-specific array. The number of pins which are capable of PWM on
+your board is given by the ``BOARD_NR_PWM_PINS`` constant. These
+values are documented for each board in the :ref:`Board Hardware
+Documentation <index-boards>` pages.
The Arduino function :ref:`analogWrite() <lang-analogwrite>` is an
alias for ``pwmWrite()``, but it is badly named, and its use is
@@ -52,4 +57,5 @@ potentiometer::
See Also
--------
-- :ref:`Maple PWM tutorial <pwm>`
+- :ref:`Maple PWM tutorial <pwm>`
+- :ref:`boardPWMPins <lang-board-values-pwm-pins>`
diff --git a/docs/source/lang/api/random.rst b/docs/source/lang/api/random.rst
index dd8871d..9875ee6 100644
--- a/docs/source/lang/api/random.rst
+++ b/docs/source/lang/api/random.rst
@@ -10,9 +10,7 @@ The ``random()`` function generates pseudo-random numbers.
Library Documentation
---------------------
-.. FIXME keep tracking Sphinx/Breathe's ability to reference
-.. overloaded functions so we can use doxygenfunction instead of
-.. manually documenting.
+.. FIXME [Breathe] use doxygenfunction when possible
.. cpp:function:: random(long max)
@@ -70,4 +68,4 @@ See Also
- :ref:`randomSeed() <lang-randomseed>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/randomseed.rst b/docs/source/lang/api/randomseed.rst
index d0a15b7..ca7b75f 100644
--- a/docs/source/lang/api/randomseed.rst
+++ b/docs/source/lang/api/randomseed.rst
@@ -57,4 +57,4 @@ See Also
- :ref:`random() <lang-random>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/serial.rst b/docs/source/lang/api/serial.rst
index 58002e3..0821f43 100644
--- a/docs/source/lang/api/serial.rst
+++ b/docs/source/lang/api/serial.rst
@@ -12,46 +12,20 @@ devices.
Introduction
------------
-The Maple has three serial ports (also known as a UARTs or USARTs):
-``Serial1``, ``Serial2``, and ``Serial3``. They communicate using the
-pins summarized in the following table:
+.. FIXME [0.0.10] UART4, UART5
-.. list-table::
- :header-rows: 1
-
- * - Serial port
- - TX, RX, CK
- - CTS, RTS (if present)
-
- * - ``Serial1``
- - 7, 8, 6
- -
-
- * - ``Serial2``
- - 1, 0, 10
- - 2, 3
-
- * - ``Serial3``
- - 29, 30, 31
- - 32, 33
-
-Thus, if you use a particular serial port, you cannot also use its
-communication pins for other purposes at the same time.
-
-If you want to communicate with the Maple using the provided USB port,
-use :ref:`SerialUSB <lang-serialusb>` instead.
-
-To use them to communicate with an external TTL serial device, connect
-the TX pin to your device's RX pin, the RX to your device's TX pin,
-and the ground of your Maple to your device's ground.
+To use a serial port to communicate with an external serial device,
+connect the TX pin to your device's RX pin, the RX to your device's TX
+pin, and your Maple board's ground to your device's ground.
.. warning:: Don't connect these pins directly to an RS232 serial
port; they operate at +/- 12V and can damage your board.
-
Library Documentation
---------------------
+.. FIXME [0.1.0] Tutorial-style usage introduction
+
All of the ``Serial[1,2,3]`` objects are instances of the
``HardwareSerial`` class, which is documented in this section. (This
means that you can use any of these functions on any of ``Serial1``,
@@ -87,7 +61,7 @@ means that you can use any of these functions on any of ``Serial1``,
.. cpp:function:: HardwareSerial::flush()
- Removes the contents of the Serial's associated USART RX FIFO.
+ Throw away the contents of the serial port's receiver (RX) buffer.
That is, clears any buffered characters, so that the next character
read is guaranteed to be new.
@@ -113,34 +87,25 @@ means that you can use any of these functions on any of ``Serial1``,
Print the argument's digits over the USART, in decimal format.
-.. cpp:function:: HardwareSerial::print(long long n)
+.. cpp:function:: HardwareSerial::print(long n)
Print the argument's digits over the USART, in decimal format.
Negative values will be prefixed with a ``'-'`` character.
-.. cpp:function:: HardwareSerial::print(unsigned long long n)
+.. cpp:function:: HardwareSerial::print(unsigned long n)
Print the argument's digits over the USART, in decimal format.
-.. _lang-serial-print-n-base:
-
-.. cpp:function:: HardwareSerial::print(int n, int base)
-
- Print the digits of ``n`` over the USART, in base ``base``. The
- ``base`` value 2 corresponds to binary, 8 to octal, 10 to decimal,
- and 16 to hexadecimal (you can also use the symbolic constants
- ``BIN``, ``OCT``, ``DEC``, ``HEX``). If ``base`` is 10, negative
- values will be prefixed with a ``'-'`` character (otherwise, ``n``
- will be interpreted as an unsigned quantity).
-
-.. cpp:function:: HardwareSerial::print(long long n, int base)
+.. cpp:function:: HardwareSerial::print(long n, int base)
- Same behavior as the above :ref:`print(int n, int base)
- <lang-serial-print-n-base>`, except with 64-bit values.
+ Print the digits of ``n`` over the USART, in base ``base`` (which
+ may be between 2 and 16). The ``base`` value 2 corresponds to
+ binary, 8 to octal, 10 to decimal, and 16 to hexadecimal. Negative
+ values will be prefixed with a ``'-'`` character.
.. cpp:function:: HardwareSerial::print(double n)
- Print ``n``, accurate to 6 digits after the decimal point.
+ Print ``n``, accurate to 2 digits after the decimal point.
.. _lang-serial-println:
@@ -164,19 +129,15 @@ means that you can use any of these functions on any of ``Serial1``,
Like ``print(n)``, followed by ``"\r\n"``.
-.. cpp:function:: HardwareSerial::println(long long n)
+.. cpp:function:: HardwareSerial::println(long n)
Like ``print(n)``, followed by ``"\r\n"``.
-.. cpp:function:: HardwareSerial::println(unsigned long long n)
+.. cpp:function:: HardwareSerial::println(unsigned long n)
Like ``print(n)``, followed by ``"\r\n"``.
-.. cpp:function:: HardwareSerial::println(int n, int base)
-
- Like ``print(n, b)``, followed by ``"\r\n"``.
-
-.. cpp:function:: HardwareSerial::println(long long n, int base)
+.. cpp:function:: HardwareSerial::println(long n, int base)
Like ``print(n, b)``, followed by ``"\r\n"``.
@@ -219,11 +180,12 @@ Arduino Compatibility Note
--------------------------
Unlike the Arduino, none of the Maple's serial ports is connected to
-the USB port on the Maple board (for that, use :ref:`SerialUSB
-<lang-serialusb>`). Thus, to use these pins to communicate with your
-personal computer, you will need an additional USB-to-serial adaptor.
+the USB port on the Maple board. If you want to communicate using the
+built-in USB port, use :ref:`SerialUSB <lang-serialusb>` instead. You
+will need an additional USB-to-serial adapter to communicate between a
+USART and your computer.
-.. TODO LATER port these examples over
+.. FIXME [0.1.0] port these examples over
.. Examples
.. --------
@@ -236,4 +198,4 @@ personal computer, you will need an additional USB-to-serial adaptor.
.. - `Serial Call Response <http://arduino.cc/en/Tutorial/SerialCallResponse>`_
.. - `Serial Call Response ASCII <http://arduino.cc/en/Tutorial/SerialCallResponseASCII>`_
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/serialusb.rst b/docs/source/lang/api/serialusb.rst
index 87fa641..ed466f2 100644
--- a/docs/source/lang/api/serialusb.rst
+++ b/docs/source/lang/api/serialusb.rst
@@ -16,9 +16,8 @@ Introduction
In addition to three :ref:`serial ports <lang-serial>`, the Maple's
STM32 microprocessor includes a dedicated USB peripheral. This
peripheral is used to emulate a regular serial port for use as a
-terminal (text read/write). The emulated terminal is relatively slow
-and inefficient; it is best for transferring data at regular serial
-speeds (kilobaud).
+terminal. The emulated terminal is relatively slow; it is best for
+transferring data at regular serial speeds (kilobaud).
Library access to the emulated serial port is provided through the
``SerialUSB`` object. You can mostly use ``SerialUSB`` as a drop-in
@@ -30,14 +29,14 @@ replacement for ``Serial1``, ``Serial2``, and ``Serial3``.
This means that if you have a number of calls to one of the
``SerialUSB`` ``write()`` or ``print()`` functions in your code,
- and you are not monitoring the emulated on a computer, your program
- will run much, much slower than if it is being monitored or totally
- disconnected (run off of a battery).
+ and you are not monitoring ``SerialUSB`` on a computer, your
+ program will run much slower than if it is being monitored or
+ totally disconnected (run off of a battery).
You can avoid this behavior by :ref:`deciphering the port status
- using the DTR and RTS line status <lang-serialusb-safe-print>`; the
+ using the DTR and RTS line status <lang-serialusb-safe-print>` (the
behavior of these control lines is platform dependent and we no
- longer interpret them by default.
+ longer interpret them by default).
Library Documentation
---------------------
@@ -109,35 +108,26 @@ world!")``.
Print the argument's digits over the USB connection, in decimal format.
-.. cpp:function:: USBSerial::print(long long n)
+.. cpp:function:: USBSerial::print(long n)
Print the argument's digits over the USB connection, in decimal
format. Negative values will be prefixed with a ``'-'`` character.
-.. cpp:function:: USBSerial::print(unsigned long long n)
+.. cpp:function:: USBSerial::print(unsigned long n)
Print the argument's digits over the USB connection, in decimal
format.
-.. _lang-serial-print-n-base:
+.. cpp:function:: USBSerial::print(long n, int base)
-.. cpp:function:: USBSerial::print(int n, int base)
-
- Print the digits of ``n`` over USB, in base ``base``. The ``base``
- value 2 corresponds to binary, 8 to octal, 10 to decimal, and 16 to
- hexadecimal (you can also use the symbolic constants ``BIN``,
- ``OCT``, ``DEC``, ``HEX``). If ``base`` is 10, negative values
- will be prefixed with a ``'-'`` character (otherwise, ``n`` will be
- interpreted as an unsigned quantity).
-
-.. cpp:function:: HardwareSerial::print(long long n, int base)
-
- Same behavior as the above :ref:`print(int n, int base)
- <lang-serialusb-print-n-base>`, except with 64-bit values.
+ Print the digits of ``n`` over the USB connection, in base ``base``
+ (which may be between 2 and 16). The ``base`` value 2 corresponds
+ to binary, 8 to octal, 10 to decimal, and 16 to hexadecimal.
+ Negative values will be prefixed with a ``'-'`` character.
.. cpp:function:: USBSerial::print(double n)
- Print ``n``, accurate to 6 digits after the decimal point.
+ Print ``n``, accurate to 2 digits after the decimal point.
.. _lang-serialusb-println:
@@ -161,19 +151,15 @@ world!")``.
Like ``print(n)``, followed by ``"\r\n"``.
-.. cpp:function:: USBSerial::println(long long n)
+.. cpp:function:: USBSerial::println(long n)
Like ``print(n)``, followed by ``"\r\n"``.
-.. cpp:function:: USBSerial::println(unsigned long long n)
+.. cpp:function:: USBSerial::println(unsigned long n)
Like ``print(n)``, followed by ``"\r\n"``.
-.. cpp:function:: USBSerial::println(int n, int base)
-
- Like ``print(n, b)``, followed by ``"\r\n"``.
-
-.. cpp:function:: USBSerial::println(long long n, int base)
+.. cpp:function:: USBSerial::println(long n, int base)
Like ``print(n, b)``, followed by ``"\r\n"``.
@@ -224,7 +210,7 @@ running from battery, or connected but not monitored. You may need to
experiment with the DTR/RTS logic for your platform and device
configuration. ::
- #define LED_PIN 13
+ #define LED_PIN BOARD_LED_PIN
void setup() {
/* Set up the LED to blink */
@@ -232,22 +218,22 @@ configuration. ::
}
void loop() {
- // LED will stay off if we are disconnected;
- // will blink quickly if USB is unplugged (battery etc)
+ // LED will stay off if we are disconnected, and will blink
+ // quickly if USB is unplugged (battery power, etc.).
if(SerialUSB.isConnected()) {
digitalWrite(LED_PIN, 1);
}
delay(100);
- // If this logic fails to detect if bytes are going to
- // be read by the USB host, then the println() will fully
- // many times, causing a very slow LED blink.
- // If the characters are printed and read, the blink will
- // only slow a small amount when "really" connected, and fast
- // when the virtual port is only configured.
+ // If this logic fails to detect if bytes are going to be read
+ // by the USB host, then the println() take a long time,
+ // causing a very slow LED blink. If the characters are
+ // printed and read, the blink will only slow a small amount
+ // when "really" connected, and will be fast fast when the
+ // virtual port is only configured.
if(SerialUSB.isConnected() && (SerialUSB.getDTR() || SerialUSB.getRTS())) {
- for(int i=0; i<10; i++) {
- SerialUSB.println(123456,BIN);
+ for(int i = 0; i < 10; i++) {
+ SerialUSB.println(123456, BIN);
}
}
digitalWrite(LED_PIN, 0);
diff --git a/docs/source/lang/api/setup.rst b/docs/source/lang/api/setup.rst
index 837ddd6..1e8e3b8 100644
--- a/docs/source/lang/api/setup.rst
+++ b/docs/source/lang/api/setup.rst
@@ -26,4 +26,4 @@ Example
// ...
}
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/shiftout.rst b/docs/source/lang/api/shiftout.rst
new file mode 100644
index 0000000..1d9ba12
--- /dev/null
+++ b/docs/source/lang/api/shiftout.rst
@@ -0,0 +1,99 @@
+.. highlight:: cpp
+
+.. _lang-shiftout:
+
+shiftOut()
+==========
+
+Shift out a byte of data, one bit at a time.
+
+.. contents:: Contents
+ :local:
+
+Library Documentation
+---------------------
+
+.. doxygenfunction:: shiftOut
+
+Discussion
+----------
+
+This is a software implementation. There is also a hardware :ref:`SPI
+<spi>` library available which will be faster and consume less CPU
+cycles than this function.
+
+Note that the ``dataPin`` and ``clockPin`` must already be configured
+to :ref:`OUTPUT <lang-constants-output>` mode by a call to
+:ref:`pinMode() <lang-pinmode>`.
+
+Also note that since shiftOut() outputs 1 byte (8 bits) at a time, it
+requires multiple steps to output values larger than 255.
+
+Examples
+--------
+
+To use these examples, replace ``dataPin`` and ``clockPin`` with the
+numbers of the pins you want to use::
+
+ /* MSBFIRST example */
+
+ uint16 data = 500;
+ // shift out high byte
+ shiftOut(dataPin, clockPin, MSBFIRST, (data >> 8));
+ // shift out low byte
+ shiftOut(dataPin, clockPin, MSBFIRST, data);
+
+ /* LSBFIRST serial */
+
+ data = 500;
+ // shift out low byte
+ shiftOut(dataPin, clockPin, LSBFIRST, data);
+ // shift out high byte
+ shiftOut(dataPin, clockPin, LSBFIRST, (data >> 8));
+
+Arduino Tutorial Example
+------------------------
+
+This Arduino example runs unmodified on the Maple. For accompanying
+circuit, see the `tutorial on controlling a 74HC595 shift register
+<http://arduino.cc/en/Tutorial/ShiftOut>`_.
+
+::
+
+ //**************************************************************//
+ // Name : shiftOutCode, Hello World //
+ // Author : Carlyn Maw, Tom Igoe //
+ // Date : 25 Oct, 2006 //
+ // Version : 1.0 //
+ // Notes : Code for using a 74HC595 Shift Register //
+ // : to count from 0 to 255 //
+ //**************************************************************//
+
+ // Pin connected to ST_CP of 74HC595
+ int latchPin = 8;
+ // Pin connected to SH_CP of 74HC595
+ int clockPin = 12;
+ // Pin connected to DS of 74HC595
+ int dataPin = 11;
+
+ void setup() {
+ // Set pins to output because they are addressed in the main loop
+ pinMode(latchPin, OUTPUT);
+ pinMode(clockPin, OUTPUT);
+ pinMode(dataPin, OUTPUT);
+ }
+
+ void loop() {
+ // Count up routine
+ for (int j = 0; j < 256; j++) {
+ // Ground latchPin and hold low for as long as you are transmitting
+ digitalWrite(latchPin, LOW);
+ shiftOut(dataPin, clockPin, LSBFIRST, j);
+ // Return the latch pin high to signal chip that it
+ // no longer needs to listen for information
+ digitalWrite(latchPin, HIGH);
+ delay(1000);
+ }
+ }
+
+.. include:: /lang/cc-attribution.txt
diff --git a/docs/source/lang/api/sin.rst b/docs/source/lang/api/sin.rst
index 398b8f3..3e28c0b 100644
--- a/docs/source/lang/api/sin.rst
+++ b/docs/source/lang/api/sin.rst
@@ -28,5 +28,4 @@ See Also
- :ref:`float <lang-float>`
- :ref:`double <lang-double>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/sq.rst b/docs/source/lang/api/sq.rst
index bd32648..96724d3 100644
--- a/docs/source/lang/api/sq.rst
+++ b/docs/source/lang/api/sq.rst
@@ -42,5 +42,4 @@ Arduino Compatibility
Maple's implementation of ``sq()`` is compatible with Arduino.
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/tan.rst b/docs/source/lang/api/tan.rst
index 4bbe0db..b1aed31 100644
--- a/docs/source/lang/api/tan.rst
+++ b/docs/source/lang/api/tan.rst
@@ -22,10 +22,9 @@ Note that the Maple implementation comes from `newlib
See Also
--------
-
- :ref:`sin <lang-sin>`
- :ref:`cos <lang-cos>`
- :ref:`float <lang-float>`
- :ref:`double <lang-double>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/toggleled.rst b/docs/source/lang/api/toggleled.rst
index 0cc20c2..54a7d64 100644
--- a/docs/source/lang/api/toggleled.rst
+++ b/docs/source/lang/api/toggleled.rst
@@ -13,5 +13,5 @@ Library Documentation
See Also
--------
-- :ref:`BOARD_LED_PIN <lang-constants-led>`
+- :ref:`BOARD_LED_PIN <lang-board-values-led>`
- :ref:`togglePin() <lang-togglepin>`
diff --git a/docs/source/lang/api/volatile.rst b/docs/source/lang/api/volatile.rst
index 276bb6a..1b72897 100644
--- a/docs/source/lang/api/volatile.rst
+++ b/docs/source/lang/api/volatile.rst
@@ -24,8 +24,8 @@ for efficiency).
A variable should be declared ``volatile`` whenever its value can be
changed by something beyond the control of the code section in which
it appears, such as an :ref:`external interrupt
-<external-interrupts>`. On the Maple, the only place that this is
-likely to occur is in sections of code associated with interrupts.
+<external-interrupts>`. (The only place that this is likely to occur
+in most programs is inside of code called by interrupts).
Example
-------
@@ -55,11 +55,11 @@ Example
}
}
-See also
+See Also
--------
- :ref:`External Interrupts <external-interrupts>`
- :ref:`lang-attachinterrupt`
- :ref:`lang-detachinterrupt`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/api/waitforbuttonpress.rst b/docs/source/lang/api/waitforbuttonpress.rst
index 34c5066..a5bd45c 100644
--- a/docs/source/lang/api/waitforbuttonpress.rst
+++ b/docs/source/lang/api/waitforbuttonpress.rst
@@ -14,4 +14,6 @@ Library Documentation
See Also
--------
+- :ref:`Board-specific values <lang-board-values>`
+- :ref:`BOARD_BUTTON_PIN <lang-board-values-but>`
- :ref:`lang-isbuttonpressed`
diff --git a/docs/source/lang/cc-attribution.txt b/docs/source/lang/cc-attribution.txt
index e100140..11302b2 100644
--- a/docs/source/lang/cc-attribution.txt
+++ b/docs/source/lang/cc-attribution.txt
@@ -3,7 +3,8 @@
.. admonition:: License and Attribution
- This documentation page was adapted from the `Arduino Reference
- Documentation <http://arduino.cc/en/Reference/HomePage>`_\ , which
- is released under a `Creative Commons Attribution-ShareAlike 3.0
- License <http://creativecommons.org/licenses/by-sa/3.0/>`_.
+ Some information in this page was adapted from the `Arduino
+ Reference Documentation
+ <http://arduino.cc/en/Reference/HomePage>`_\ , which is released
+ under a `Creative Commons Attribution-ShareAlike 3.0 License
+ <http://creativecommons.org/licenses/by-sa/3.0/>`_.
diff --git a/docs/source/lang/cpp/arithmetic.rst b/docs/source/lang/cpp/arithmetic.rst
index 7e8c3fc..cef3954 100644
--- a/docs/source/lang/cpp/arithmetic.rst
+++ b/docs/source/lang/cpp/arithmetic.rst
@@ -117,11 +117,8 @@ See Also
--------
- The individual sizes (in bits) of various available types are
- defined in `libmaple_types.h
- <http://github.com/leaflabs/libmaple/blob/master/libmaple/libmaple_types.h>`_\
- .
+ defined in :ref:`libmaple_types.h <libmaple-libmaple_types>`.
- :ref:`sizeof <lang-sizeof>`\ ()
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/array.rst b/docs/source/lang/cpp/array.rst
index 30a818f..39d4d91 100644
--- a/docs/source/lang/cpp/array.rst
+++ b/docs/source/lang/cpp/array.rst
@@ -113,11 +113,9 @@ Arduino Compatibility
Arrays on Maple are identical those on Arduino.
-See also
+See Also
--------
- :ref:`Storing arrays in FLASH memory <arm-gcc-attribute-flash>`
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/assignment.rst b/docs/source/lang/cpp/assignment.rst
index f9430b4..6379298 100644
--- a/docs/source/lang/cpp/assignment.rst
+++ b/docs/source/lang/cpp/assignment.rst
@@ -57,4 +57,4 @@ See Also
<http://icu-project.org/docs/papers/cpp_report/the_anatomy_of_the_assignment_operator.html>`_
for more information.
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/bitshift.rst b/docs/source/lang/cpp/bitshift.rst
index e1c8de0..47413f2 100644
--- a/docs/source/lang/cpp/bitshift.rst
+++ b/docs/source/lang/cpp/bitshift.rst
@@ -140,5 +140,4 @@ See Also
- :ref:`lang-bitwrite`
- :ref:`lang-bitclear`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/bitwisemath.rst b/docs/source/lang/cpp/bitwisemath.rst
index 28fe6bf..59794ba 100644
--- a/docs/source/lang/cpp/bitwisemath.rst
+++ b/docs/source/lang/cpp/bitwisemath.rst
@@ -182,5 +182,4 @@ See Also
- :ref:`Compound bitwise operations <lang-compoundbitwise>` (``&=``,
``|=``, ``^=``).
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/boolean.rst b/docs/source/lang/cpp/boolean.rst
index 8d6aa5c..f09345e 100644
--- a/docs/source/lang/cpp/boolean.rst
+++ b/docs/source/lang/cpp/boolean.rst
@@ -87,5 +87,4 @@ See Also
``|=``, ``^=``).
- :ref:`if statement <lang-if>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/booleanvariables.rst b/docs/source/lang/cpp/booleanvariables.rst
index 6051b8c..0d76a12 100644
--- a/docs/source/lang/cpp/booleanvariables.rst
+++ b/docs/source/lang/cpp/booleanvariables.rst
@@ -42,13 +42,11 @@ Example
}
}
-See also
+See Also
--------
-
- :ref:`Boolean constants <lang-constants-bool>`
- :ref:`Boolean operators <lang-boolean>`
- :ref:`Variables <lang-variables>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/break.rst b/docs/source/lang/cpp/break.rst
index ce8ac17..f367b99 100644
--- a/docs/source/lang/cpp/break.rst
+++ b/docs/source/lang/cpp/break.rst
@@ -29,7 +29,4 @@ Example
delay(50);
}
-
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/built-in-types.rst b/docs/source/lang/cpp/built-in-types.rst
index a7349e6..28e8cdc 100644
--- a/docs/source/lang/cpp/built-in-types.rst
+++ b/docs/source/lang/cpp/built-in-types.rst
@@ -41,55 +41,60 @@ Integral types
.. cpp:type:: int8
- Synonym for ``char``.
+ 8-bit integer value. Synonym for ``signed char``.
.. cpp:type:: uint8
- Synonym for ``unsigned char``.
+ 8-bit unsigned integer value. Synonym for ``unsigned char``.
+
+.. cpp:type:: byte
+
+ 8-bit unsigned integer value. Synonym for ``unsigned char``.
.. cpp:type:: int16
- Synonym for ``short``.
+ 16-bit integer value. Synonym for ``short``.
.. cpp:type:: uint16
- Synonym for ``unsigned short``.
+ 16-bit unsigned integer value. Synonym for ``unsigned short``.
.. cpp:type:: int32
- Synonym for ``int``.
+ 32-bit integer value. Synonym for ``int``.
.. cpp:type:: uint32
- Synonym for ``unsigned int``
+ Unsigned 32-bit integer value. Synonym for ``unsigned int``
.. cpp:type:: int64
- Synonym for ``long long``
+ 64-bit integer value. Synonym for ``long long``
.. cpp:type:: uint64
- Synonym for ``unsigned long long``.
+ Unsigned 64-bit integer value. Synonym for ``unsigned long long``.
Floating-Point Types
--------------------
.. cpp:type:: float
- 32-bit, IEEE 754 single-precision floating-point type.
+ 32-bit, IEEE-754 single-precision floating-point type.
.. cpp:type:: double
- 64-bit, IEEE 754 double-precision floating-point type.
+ 64-bit, IEEE-754 double-precision floating-point type.
Other Types
-----------
.. cpp:type:: voidFuncPtr
- Pointer to a function that takes no arguments and returns nothing, i.e.
-
- ::
+ Pointer to a function that takes no arguments and returns nothing, i.e. ::
typedef void (*voidFuncPtr)(void);
+.. cpp:type:: bool
+
+ Boolean type.
diff --git a/docs/source/lang/cpp/byte.rst b/docs/source/lang/cpp/byte.rst
index 45c9d5f..4634594 100644
--- a/docs/source/lang/cpp/byte.rst
+++ b/docs/source/lang/cpp/byte.rst
@@ -30,5 +30,4 @@ See Also
- :ref:`byte() <lang-bytecast>` (casting a value to a byte)
- :ref:`Variables <lang-variables>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/bytecast.rst b/docs/source/lang/cpp/bytecast.rst
index b3f0de2..24c3b9e 100644
--- a/docs/source/lang/cpp/bytecast.rst
+++ b/docs/source/lang/cpp/bytecast.rst
@@ -24,13 +24,11 @@ Syntax
``byte(x)``
-
Parameters
----------
**x**: a value of any integer type
-
Returns
-------
@@ -38,13 +36,9 @@ The value, converted to a ``byte``. Note, however, that if the value
is larger than the maximum value you can store in a byte (255), then
the results might be strange and unexpected.
-
See Also
--------
- :ref:`lang-byte`
-
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/char.rst b/docs/source/lang/cpp/char.rst
index b8747f3..686c0d1 100644
--- a/docs/source/lang/cpp/char.rst
+++ b/docs/source/lang/cpp/char.rst
@@ -10,7 +10,6 @@ value from -128 to 127). Character literals are written in single
quotes, like this: ``'A'`` (for multiple characters - strings - use
double quotes: ``"ABC"``).
-
Just like everything else on a computer, characters are stored as
numbers. You can see the specific encoding in the `ASCII chart
<http://en.wikipedia.org/wiki/ASCII#ASCII_printable_characters>`_\
@@ -25,26 +24,21 @@ The ``char`` datatype is a signed type, meaning that it encodes
numbers from -128 to 127. For an unsigned type, which stores values
from 0 to 255, just use the type ``unsigned char`` (two words).
-
Example
-------
::
- // the following two lines are equivalent, using the ASCII
+ // The following two lines are equivalent, using the ASCII
// character encoding:
char c = 'A';
char c = 65;
-
-See also
+See Also
--------
-
- :ref:`lang-int`
- :ref:`lang-array` (a string is just an array of ``char``\ s)
- :ref:`Serial.println() <lang-serial-println>`
-
-
.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/charcast.rst b/docs/source/lang/cpp/charcast.rst
index a480dec..640ad85 100644
--- a/docs/source/lang/cpp/charcast.rst
+++ b/docs/source/lang/cpp/charcast.rst
@@ -12,13 +12,11 @@ Syntax
``char(x)``
-
Parameters
----------
**x**: a value of any type
-
Returns
-------
@@ -26,11 +24,9 @@ The value, converted to a ``char``. Note, however, that if the value
is outside the range of a ``char`` (-128 to 127), then the results
might be strange and unexpected.
-
See Also
--------
- :ref:`char <lang-char>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/comments.rst b/docs/source/lang/cpp/comments.rst
index c5f118a..1428dc3 100644
--- a/docs/source/lang/cpp/comments.rst
+++ b/docs/source/lang/cpp/comments.rst
@@ -61,7 +61,4 @@ just ignores them. This can be especially useful when trying to locate
a problem, or when a program refuses to compile and the compiler error
is cryptic or unhelpful.
-
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/comparison.rst b/docs/source/lang/cpp/comparison.rst
index b24355f..9cd0a9f 100644
--- a/docs/source/lang/cpp/comparison.rst
+++ b/docs/source/lang/cpp/comparison.rst
@@ -83,5 +83,4 @@ Comparison operators, along with :ref:`boolean operators
appears within a conditional doesn't mean it's automatically wrong.
Be careful to know what you mean.)
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/compoundarithmetic.rst b/docs/source/lang/cpp/compoundarithmetic.rst
index 420f1db..d70a43c 100644
--- a/docs/source/lang/cpp/compoundarithmetic.rst
+++ b/docs/source/lang/cpp/compoundarithmetic.rst
@@ -40,5 +40,4 @@ See Also
- :ref:`Arithmetic operators <lang-arithmetic>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/compoundbitwise.rst b/docs/source/lang/cpp/compoundbitwise.rst
index 8231130..4efe5df 100644
--- a/docs/source/lang/cpp/compoundbitwise.rst
+++ b/docs/source/lang/cpp/compoundbitwise.rst
@@ -226,5 +226,4 @@ See Also
- :ref:`Boolean operations <lang-boolean>` (``&&``, ``||``)
- :ref:`Bitwise operators <lang-bitwisemath>` (``&``, ``|``, ``^``, ``~``)
-
.. include:: cc-attribution.txt
diff --git a/docs/source/lang/cpp/const.rst b/docs/source/lang/cpp/const.rst
index 52de85f..ad0c580 100644
--- a/docs/source/lang/cpp/const.rst
+++ b/docs/source/lang/cpp/const.rst
@@ -21,7 +21,7 @@ method for defining constants than ``#define``.
Example
-------
-::
+ ::
// this defines a variable called "pi", which cannot be changed:
const float pi = 3.14;
@@ -33,7 +33,6 @@ Example
pi = 7; // illegal - you can't write to (modify) a constant
-
**#define** or **const**
------------------------
@@ -48,5 +47,4 @@ See Also
- :ref:`#define <lang-define>`
- :ref:`volatile <lang-volatile>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/continue.rst b/docs/source/lang/cpp/continue.rst
index 13d1815..2a694f6 100644
--- a/docs/source/lang/cpp/continue.rst
+++ b/docs/source/lang/cpp/continue.rst
@@ -27,6 +27,4 @@ Example
delay(50);
}
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/curly-braces.rst b/docs/source/lang/cpp/curly-braces.rst
index a4bd3dc..df2fe2a 100644
--- a/docs/source/lang/cpp/curly-braces.rst
+++ b/docs/source/lang/cpp/curly-braces.rst
@@ -99,11 +99,8 @@ reference page for more information)::
.. rubric:: Footnotes
-.. TODO remove this once IDE 0.1.0 released
-
.. [#fbug] At present this feature is slightly buggy as the IDE will
often find (incorrectly) a brace in text that has been commented
out.
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/define.rst b/docs/source/lang/cpp/define.rst
index 677390d..bdf7283 100644
--- a/docs/source/lang/cpp/define.rst
+++ b/docs/source/lang/cpp/define.rst
@@ -13,7 +13,6 @@ defined value at compile time.
This can have some unwanted side effects. In general, the :ref:`const
<lang-const>` keyword is preferred for defining constants.
-
Syntax
------
@@ -42,7 +41,7 @@ is, **don't do this, either**::
Example
-------
-::
+ ::
#define LED_PIN 13
// The compiler will replace any mention of LED_PIN with
@@ -52,5 +51,4 @@ See Also
--------
- :ref:`const <lang-const>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/double.rst b/docs/source/lang/cpp/double.rst
index 1527778..59422eb 100644
--- a/docs/source/lang/cpp/double.rst
+++ b/docs/source/lang/cpp/double.rst
@@ -43,6 +43,4 @@ See Also
- :ref:`float <lang-float>`
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/doublecast.rst b/docs/source/lang/cpp/doublecast.rst
index 16a9907..d3f32ce 100644
--- a/docs/source/lang/cpp/doublecast.rst
+++ b/docs/source/lang/cpp/doublecast.rst
@@ -24,4 +24,4 @@ See Also
- :ref:`float <lang-float>`
- :ref:`float() <lang-floatcast>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/dowhile.rst b/docs/source/lang/cpp/dowhile.rst
index fe92226..d229122 100644
--- a/docs/source/lang/cpp/dowhile.rst
+++ b/docs/source/lang/cpp/dowhile.rst
@@ -23,5 +23,4 @@ Example::
x = readSensors(); // check the sensors
} while (x < 100);
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/float.rst b/docs/source/lang/cpp/float.rst
index 6937c8c..5195fac 100644
--- a/docs/source/lang/cpp/float.rst
+++ b/docs/source/lang/cpp/float.rst
@@ -47,4 +47,4 @@ See Also
- :ref:`double <lang-double>`
- :ref:`Variables <lang-variables>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/floatcast.rst b/docs/source/lang/cpp/floatcast.rst
index 4766478..af92543 100644
--- a/docs/source/lang/cpp/floatcast.rst
+++ b/docs/source/lang/cpp/floatcast.rst
@@ -25,4 +25,4 @@ See Also
- :ref:`double <lang-double>`
- :ref:`double() <lang-doublecast>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/for.rst b/docs/source/lang/cpp/for.rst
index 71c5aca..78ea562 100644
--- a/docs/source/lang/cpp/for.rst
+++ b/docs/source/lang/cpp/for.rst
@@ -123,7 +123,7 @@ questions (answers are in footnote [#fanswers]_\ ):
2. Why does it stop at 64?
-See also
+See Also
--------
- :ref:`while <lang-while>` loops
@@ -139,4 +139,4 @@ See also
false, and the loop stops.
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/goto.rst b/docs/source/lang/cpp/goto.rst
index ff2f248..2c0b3b0 100644
--- a/docs/source/lang/cpp/goto.rst
+++ b/docs/source/lang/cpp/goto.rst
@@ -126,5 +126,4 @@ See Also
- Knuth, Donald. `Structured Programming with go to Statements <http://pplab.snu.ac.kr/courses/adv_pl05/papers/p261-knuth.pdf>`_ (PDF)
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/if.rst b/docs/source/lang/cpp/if.rst
index bef89e2..d57b9f1 100644
--- a/docs/source/lang/cpp/if.rst
+++ b/docs/source/lang/cpp/if.rst
@@ -118,4 +118,4 @@ See Also
- :ref:`boolean operators <lang-boolean>`
- :ref:`comparison operators <lang-comparison>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/include.rst b/docs/source/lang/cpp/include.rst
index 74fe7af..163509d 100644
--- a/docs/source/lang/cpp/include.rst
+++ b/docs/source/lang/cpp/include.rst
@@ -67,6 +67,4 @@ root <http://en.wikipedia.org/wiki/Cube_root>`_ of a number::
SerialUSB.println(cubeRootOf3);
}
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/increment.rst b/docs/source/lang/cpp/increment.rst
index 6dffa80..c423d1a 100644
--- a/docs/source/lang/cpp/increment.rst
+++ b/docs/source/lang/cpp/increment.rst
@@ -34,4 +34,4 @@ See Also
- :ref:`lang-compoundarithmetic`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/intcast.rst b/docs/source/lang/cpp/intcast.rst
index 386fe14..da838c7 100644
--- a/docs/source/lang/cpp/intcast.rst
+++ b/docs/source/lang/cpp/intcast.rst
@@ -23,7 +23,4 @@ See Also
- :ref:`int <lang-int>`
-
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/longcast.rst b/docs/source/lang/cpp/longcast.rst
index f588fc6..493ad67 100644
--- a/docs/source/lang/cpp/longcast.rst
+++ b/docs/source/lang/cpp/longcast.rst
@@ -24,4 +24,4 @@ See Also
- :ref:`long <lang-long>`
- :ref:`long long <lang-longlong>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/longlong.rst b/docs/source/lang/cpp/longlong.rst
index 0ba56ed..d942cb4 100644
--- a/docs/source/lang/cpp/longlong.rst
+++ b/docs/source/lang/cpp/longlong.rst
@@ -53,4 +53,4 @@ See Also
- :ref:`Integer Constants <lang-constants-integers>`
- :ref:`Variables <lang-variables>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/modulo.rst b/docs/source/lang/cpp/modulo.rst
index 289fba0..013d07e 100644
--- a/docs/source/lang/cpp/modulo.rst
+++ b/docs/source/lang/cpp/modulo.rst
@@ -67,4 +67,4 @@ See Also
- :ref:`Arithmetic <lang-arithmetic>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/pointer.rst b/docs/source/lang/cpp/pointer.rst
index 0a42270..ff4ec32 100644
--- a/docs/source/lang/cpp/pointer.rst
+++ b/docs/source/lang/cpp/pointer.rst
@@ -28,4 +28,4 @@ See Also
- http://xkcd.com/138/
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/return.rst b/docs/source/lang/cpp/return.rst
index b4ef5fd..d9aecbe 100644
--- a/docs/source/lang/cpp/return.rst
+++ b/docs/source/lang/cpp/return.rst
@@ -57,5 +57,4 @@ See Also
- :ref:`comments <lang-comments>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/scope.rst b/docs/source/lang/cpp/scope.rst
index 7b65bab..a270428 100644
--- a/docs/source/lang/cpp/scope.rst
+++ b/docs/source/lang/cpp/scope.rst
@@ -117,4 +117,4 @@ See Also
- `C++ programming Wikibook <http://en.wikibooks.org/wiki/C%2B%2B_Programming/Programming_Languages/C%2B%2B/Code/Statements/Scope>`_.
- Wikipedia article on `scope <http://en.wikipedia.org/wiki/Scope_%28programming%29>`_
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/semicolon.rst b/docs/source/lang/cpp/semicolon.rst
index 8164616..05e6218 100644
--- a/docs/source/lang/cpp/semicolon.rst
+++ b/docs/source/lang/cpp/semicolon.rst
@@ -19,7 +19,4 @@ compiler error comes up, one of the first things to check is a
missing semicolon, in the immediate vicinity, preceding the line at
which the compiler complained.
-
-
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/sizeof.rst b/docs/source/lang/cpp/sizeof.rst
index eae509c..ec2dea6 100644
--- a/docs/source/lang/cpp/sizeof.rst
+++ b/docs/source/lang/cpp/sizeof.rst
@@ -60,5 +60,5 @@ would look something like this::
standard guarantees, however, is that a ``char`` occupies at
*least* 8 bits.
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/sqrt.rst b/docs/source/lang/cpp/sqrt.rst
index 956a754..fbabf82 100644
--- a/docs/source/lang/cpp/sqrt.rst
+++ b/docs/source/lang/cpp/sqrt.rst
@@ -21,5 +21,4 @@ See Also
- :ref:`pow <lang-pow>`
- :ref:`sq <lang-sq>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/static.rst b/docs/source/lang/cpp/static.rst
index 5d1802e..8c52ba0 100644
--- a/docs/source/lang/cpp/static.rst
+++ b/docs/source/lang/cpp/static.rst
@@ -53,5 +53,4 @@ then incremented, so it starts out at one. Subsequent calls to
it was declared ``static``. Thus, ``numSensorReadings`` is a count of
the number of times that ``readSensors()`` has been called.
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/string.rst b/docs/source/lang/cpp/string.rst
index 0a270da..84917c1 100644
--- a/docs/source/lang/cpp/string.rst
+++ b/docs/source/lang/cpp/string.rst
@@ -124,5 +124,4 @@ See Also
- :ref:`__attribute__ <arm-gcc-attribute-flash>`
- :ref:`Variables <lang-variables>`
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/switchcase.rst b/docs/source/lang/cpp/switchcase.rst
index b484bc5..e31ccf3 100644
--- a/docs/source/lang/cpp/switchcase.rst
+++ b/docs/source/lang/cpp/switchcase.rst
@@ -110,9 +110,9 @@ value as the variable to compare. In this case, you can write down
all of the values the ``enum`` takes as ``case`` statements, and be
sure you've covered all the possibilities.
-See also:
+See Also:
---------
- :ref:`if/else <lang-if>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/unsignedchar.rst b/docs/source/lang/cpp/unsignedchar.rst
index 5b946ed..45fedeb 100644
--- a/docs/source/lang/cpp/unsignedchar.rst
+++ b/docs/source/lang/cpp/unsignedchar.rst
@@ -16,18 +16,17 @@ won't store negative numbers; it is also subject to the same
Example
-------
-::
+ ::
unsigned char c = 240;
See Also
--------
-
- :ref:`byte <lang-byte>`
- :ref:`int <lang-int>`
- :ref:`array <lang-array>`
- :ref:`SerialUSB.println() <lang-serialusb-println>`
- :ref:`Serial.println() <lang-serial-println>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/unsignedint.rst b/docs/source/lang/cpp/unsignedint.rst
index ad3e2f2..b7d9716 100644
--- a/docs/source/lang/cpp/unsignedint.rst
+++ b/docs/source/lang/cpp/unsignedint.rst
@@ -56,4 +56,4 @@ See Also
- :ref:`Integer Constants <lang-constants-integers>`
- :ref:`Variables <lang-variables>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/unsignedlonglong.rst b/docs/source/lang/cpp/unsignedlonglong.rst
index 910b7e4..a1143f0 100644
--- a/docs/source/lang/cpp/unsignedlonglong.rst
+++ b/docs/source/lang/cpp/unsignedlonglong.rst
@@ -40,4 +40,4 @@ See Also
- :ref:`Integer Constants <lang-constants-integers>`
- :ref:`Variables <lang-variables>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/variables.rst b/docs/source/lang/cpp/variables.rst
index 336d5ab..9ffdd1d 100644
--- a/docs/source/lang/cpp/variables.rst
+++ b/docs/source/lang/cpp/variables.rst
@@ -165,6 +165,5 @@ See Also
(usually) stored
<http://en.wikipedia.org/wiki/Two%27s_complement>`_ on computers.
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/void.rst b/docs/source/lang/cpp/void.rst
index 88c9c64..7af0acd 100644
--- a/docs/source/lang/cpp/void.rst
+++ b/docs/source/lang/cpp/void.rst
@@ -28,6 +28,4 @@ Example
// ...
}
-.. TODO doc page on function declaration?
-
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/cpp/while.rst b/docs/source/lang/cpp/while.rst
index 9047d05..e66e0aa 100644
--- a/docs/source/lang/cpp/while.rst
+++ b/docs/source/lang/cpp/while.rst
@@ -35,4 +35,4 @@ Example
var++;
}
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/lang/unimplemented/notone.rst b/docs/source/lang/unimplemented/notone.rst
index 485c9c5..8af878b 100644
--- a/docs/source/lang/unimplemented/notone.rst
+++ b/docs/source/lang/unimplemented/notone.rst
@@ -10,41 +10,28 @@ Stops the generation of a square wave triggered by
`tone <http://arduino.cc/en/Reference/Tone>`_\ (). Has no effect if
no tone is being generated.
-
-
**NOTE:** if you want to play different pitches on multiple pins,
you need to call noTone() on one pin before calling tone() on the
next pin.
-
-
Syntax
------
noTone(pin)
-
-
Parameters
----------
pin: the pin on which to stop generating the tone
-
-
Returns
-------
-nothing
-
-
+Nothing.
-See also
+See Also
--------
-
- `tone <http://arduino.cc/en/Reference/Tone>`_ ()
-
-
.. include:: /lang/cc-attribution.txt
diff --git a/docs/source/lang/unimplemented/shiftout.rst b/docs/source/lang/unimplemented/shiftout.rst
deleted file mode 100644
index ff3852f..0000000
--- a/docs/source/lang/unimplemented/shiftout.rst
+++ /dev/null
@@ -1,136 +0,0 @@
-.. _lang-shiftout:
-
-shiftOut()
-==========
-
-Description
------------
-
-Shifts out a byte of data one bit at a time. Starts from either the
-most (i.e. the leftmost) or least (rightmost) significant bit. Each
-bit is written in turn to a data pin, after which a clock pin is
-pulsed to indicate that the bit is available.
-
-
-
-This is a software implementation; Arduino (as of 0019) also
-provides an `SPI library <http://arduino.cc/en/Reference/SPI>`_
-that uses the hardware implementation.
-
-
-
-Syntax
-------
-
-shiftOut(dataPin, clockPin, bitOrder, value)
-
-
-
-Parameters
-----------
-
-dataPin: the pin on which to output each bit (*int*)
-
-
-
-clockPin: the pin to toggle once the **dataPin** has been set to
-the correct value (*int*)
-
-
-
-bitOrder: which order to shift out the bits; either **MSBFIRST** or
-**LSBFIRST**.
-(Most Significant Bit First, or, Least Significant Bit First)
-
-
-
-value: the data to shift out. (*byte*)
-
-
-
-Returns
--------
-
-None
-
-
-
-Note
-----
-
-The **dataPin** and **clockPin** must already be configured as
-outputs by a call to
-`pinMode <http://arduino.cc/en/Reference/PinMode>`_\ ().
-
-
-
-**shiftOut** is currently written to output 1 byte (8 bits) so it
-requires a two step operation to output values larger than 255.
-
-::
-
- // Do this for MSBFIRST serial
- int data = 500;
- // shift out highbyte
- shiftOut(dataPin, clock, MSBFIRST, (data >> 8));
- // shift out lowbyte
- shiftOut(data, clock, MSBFIRST, data);
-
- // Or do this for LSBFIRST serial
- data = 500;
- // shift out lowbyte
- shiftOut(dataPin, clock, LSBFIRST, data);
- // shift out highbyte
- shiftOut(dataPin, clock, LSBFIRST, (data >> 8));
-
-
-
-Example
--------
-
-*For accompanying circuit, see the `tutorial on controlling a 74HC595 shift register <http://arduino.cc/en/Tutorial/ShiftOut>`_.*
-
-
-
-::
-
- //**************************************************************//
- // Name : shiftOutCode, Hello World //
- // Author : Carlyn Maw,Tom Igoe //
- // Date : 25 Oct, 2006 //
- // Version : 1.0 //
- // Notes : Code for using a 74HC595 Shift Register //
- // : to count from 0 to 255 //
- //****************************************************************
-
- //Pin connected to ST_CP of 74HC595
- int latchPin = 8;
- //Pin connected to SH_CP of 74HC595
- int clockPin = 12;
- ////Pin connected to DS of 74HC595
- int dataPin = 11;
-
- void setup() {
- //set pins to output because they are addressed in the main loop
- pinMode(latchPin, OUTPUT);
- pinMode(clockPin, OUTPUT);
- pinMode(dataPin, OUTPUT);
- }
-
- void loop() {
- //count up routine
- for (int j = 0; j < 256; j++) {
- //ground latchPin and hold low for as long as you are transmitting
- digitalWrite(latchPin, LOW);
- shiftOut(dataPin, clockPin, LSBFIRST, j);
- //return the latch pin high to signal chip that it
- //no longer needs to listen for information
- digitalWrite(latchPin, HIGH);
- delay(1000);
- }
- }
-
-
-
-
-.. include:: /lang/cc-attribution.txt
diff --git a/docs/source/lang/unimplemented/tone.rst b/docs/source/lang/unimplemented/tone.rst
index f83bf6b..13d581e 100644
--- a/docs/source/lang/unimplemented/tone.rst
+++ b/docs/source/lang/unimplemented/tone.rst
@@ -12,70 +12,47 @@ continues until a call to
`noTone <http://arduino.cc/en/Reference/NoTone>`_\ (). The pin can be
connected to a piezo buzzer or other speaker to play tones.
-
-
Only one tone can be generated at a time. If a tone is already
playing on a different pin, the call to tone() will have no effect.
If the tone is playing on the same pin, the call will set its
frequency.
-
-
Use of the tone() function will interfere with PWM output on pins 3
and 11 (on boards other than the Mega).
-
-
**NOTE:** if you want to play different pitches on multiple pins,
you need to call noTone() on one pin before calling tone() on the
next pin.
-
-
Syntax
------
tone(pin, frequency)
tone(pin, frequency, duration)
-
-
Parameters
----------
pin: the pin on which to generate the tone
-
-
frequency: the frequency of the tone in hertz
-
-
duration: the duration of the tone in milliseconds (optional)
-
-
Returns
-------
nothing
-
-
-See also
+See Also
--------
-
- `noTone <http://arduino.cc/en/Reference/NoTone>`_\ ()
- `analogWrite <http://arduino.cc/en/Reference/AnalogWrite>`_\ ()
- `Tutorial:Tone <http://arduino.cc/en/Tutorial/Tone>`_
- `Tutorial:Pitch follower <http://arduino.cc/en/Tutorial/Tone2>`_
- `Tutorial:Simple Keyboard <http://arduino.cc/en/Tutorial/Tone3>`_
- `Tutorial: multiple tones <http://arduino.cc/en/Tutorial/Tone4>`_
-
-
- `Tutorial: PWM <http://arduino.cc/en/Tutorial/PWM>`_
-
-
-.. include:: /lang/cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/docs/source/language-index.rst b/docs/source/language-index.rst
index 3c55c33..225a9ae 100644
--- a/docs/source/language-index.rst
+++ b/docs/source/language-index.rst
@@ -10,6 +10,22 @@ API references for documented libmaple functionality. The "C++ for
Maple" pages are intended as a minimal reference/refresher for
programmers familiar with the Arduino language.
+.. admonition:: **Looking for Something Else?**
+
+ - See the :ref:`libraries` for extra built-in libraries for dealing
+ with different kinds of hardware.
+
+ - If you're looking for something from the C standard library (like
+ ``atoi()``, for instance): the :ref:`CodeSourcery GCC compiler
+ <arm-gcc>` used to compile your programs is configured to link
+ against `newlib <http://sourceware.org/newlib/>`_, and allows the
+ use of any of its header files. However, dynamic memory allocation
+ (``malloc()``, etc.) is not available.
+
+ - If you're looking for pointers to low-level details, see the
+ :ref:`Language Recommended Reading
+ <language-recommended-reading>`.
+
.. _index-language-index-cpp:
.. _index-language-index-api:
@@ -26,14 +42,13 @@ programmers familiar with the Arduino language.
| | |
+----------------------------------+------------------------------------+
-.. Unimplemented in libmaple or not part of current release:
+.. Unimplemented or not part of current release:
.. toctree::
:hidden:
+ lang/unimplemented/tone.rst
lang/unimplemented/notone.rst
lang/unimplemented/pulsein.rst
- lang/unimplemented/shiftout.rst
lang/unimplemented/stringclass.rst
lang/unimplemented/stringobject.rst
- lang/unimplemented/tone.rst
diff --git a/docs/source/language.rst b/docs/source/language.rst
index 2ebe03c..3ecbe43 100644
--- a/docs/source/language.rst
+++ b/docs/source/language.rst
@@ -10,6 +10,8 @@ The Maple can be programmed in the `Wiring
<http://www.wiring.org.co/reference/>`_ language, which is the same
language used to program the `Arduino <http://arduino.cc/>`_ boards.
+.. TODO [0.2.0?] Wiring tutorial
+
C or C++ programmers curious about the differences between the Wiring
language and C++ may wish to skip to the
:ref:`arduino_c_for_c_hackers`.
@@ -17,43 +19,29 @@ language and C++ may wish to skip to the
.. contents:: Contents
:local:
-Unique Maple Additions
-----------------------
-
-.. _language-assert:
-
-``ASSERT(...)``
- The ``ASSERT()`` function can be very useful for basic program
- debugging. The function accepts a boolean; for example::
-
- ASSERT(state == WAIT);
+.. admonition:: **Looking for Something Else?**
- zero is false and any other number is true. If the boolean is true
- the assertion passes and the program continues as usual. If it is
- false, the assertion fails: the program is halted, debug
- information is printed to USART2, and the status LED begins to
- throb in intensity (it's noticeably different from blinking). The
- debug information is printed at 9600 baud and consists of the
- filename and line number where the particular assertion failed.
+ - See the :ref:`libraries` for extra built-in libraries for dealing
+ with different kinds of hardware.
- Including assertions in a program increases the program size. When
- using libmaple **from the command line only**, they can be
- disabled by making the definition ::
+ - If you're looking for something from the C standard library (like
+ ``atoi()``, for instance): the :ref:`CodeSourcery GCC compiler
+ <arm-gcc>` used to compile your programs is configured to link
+ against `newlib <http://sourceware.org/newlib/>`_, and allows the
+ use of any of its header files. However, dynamic memory allocation
+ (``malloc()``, etc.) is not available.
- #define DEBUG_LEVEL DEBUG_NONE
-
- before including either wirish.h or libmaple.h. In this case, all
- assertions will pass without any lost clock cycles. Note that
- this will **not work in the IDE**; even with this definition,
- assertions will still be enabled.
+ - If you're looking for pointers to low-level details, see this page's
+ :ref:`Recommended Reading <language-recommended-reading>`.
.. _language-lang-docs:
Maple Language Reference
------------------------
-The following table summarizes the available core language features.
-A more exhaustive index is available at the :ref:`language-index`.
+The following table summarizes the most important core language
+features. An exhaustive index is available at the
+:ref:`language-index`.
+--------------------------------------------+----------------------------------------------+---------------------------------------------------+
| Structure | Variables | Functions |
@@ -70,13 +58,13 @@ A more exhaustive index is available at the :ref:`language-index`.
| |* :ref:`true <lang-constants-true>` | |* :ref:`togglePin() <lang-togglepin>` |
|* :ref:`for <lang-for>` | :ref:`false <lang-constants-false>` | |
| | |* :ref:`toggleLED() <lang-toggleled>` |
-|* :ref:`switch/case <lang-switchcase>` |* :ref:`BOARD_LED_PIN <lang-constants-led>` | | |
-| | :ref:`BOARD_BUTTON_PIN <lang-constants-but>`|* :ref:`isButtonPressed() <lang-isbuttonpressed>` |
-|* :ref:`while <lang-while>` | | |
-| |* :ref:`Constants |* :ref:`waitForButtonPress() |
-|* :ref:`do...while <lang-dowhile>` | <lang-constants>` (:ref:`integers | <lang-waitforbuttonpress>` |
-| | <lang-constants-integers>`, :ref:`floating | |
-|* :ref:`break <lang-break>` | point <lang-constants-fp>`) |**Analog I/O** |
+|* :ref:`switch/case <lang-switchcase>` |* :ref:`Constants | |
+| | <lang-constants>` (:ref:`integers |* :ref:`isButtonPressed() <lang-isbuttonpressed>` |
+|* :ref:`while <lang-while>` | <lang-constants-integers>`, :ref:`floating | |
+| | point <lang-constants-fp>`) |* :ref:`waitForButtonPress() |
+|* :ref:`do...while <lang-dowhile>` | | <lang-waitforbuttonpress>` |
+| |* :ref:`Board-specific values | |
+|* :ref:`break <lang-break>` | <lang-board-values>` |**Analog I/O** |
| | | |
|* :ref:`continue <lang-continue>` |**Data Types** |* :ref:`analogRead() <lang-analogread>` |
| | | |
@@ -91,7 +79,7 @@ A more exhaustive index is available at the :ref:`language-index`.
| |* :ref:`boolean <lang-boolean>` (1 byte) | |
|* :ref:`{} (curly braces) | |* noTone(): TODO |
| <lang-curly-braces>` |* :ref:`char <lang-char>` (1 byte) | |
-| | |* shiftOut(): TODO |
+| | |* :ref:`shiftOut() <lang-shiftout>` |
|* :ref:`// (single-line comment) |* :ref:`unsigned char | |
| <lang-comments-singleline>` | <lang-unsignedchar>` (1 byte) |* pulseIn(): TODO |
| | | |
@@ -106,7 +94,7 @@ A more exhaustive index is available at the :ref:`language-index`.
|**Arithmetic Operators** | <lang-int>` | |
| | |* :ref:`delayMicroseconds() |
|* :ref:`= <lang-assignment>` |* ``unsigned long`` (4 bytes), synonym for | <lang-delaymicroseconds>` |
-| (assignment operator) | :ref:`unsigned int <lang-unsignedint>` | |
+| (assignment) | :ref:`unsigned int <lang-unsignedint>` | |
| | | |
|* :ref:`+ <lang-arithmetic>` (addition) |* :ref:`long long <lang-longlong>` (8 bytes) |**Math** |
| | | |
@@ -183,13 +171,13 @@ A more exhaustive index is available at the :ref:`language-index`.
| | | |
|* :ref:`++ <lang-increment>` | |* :ref:`Serial <lang-serial>` |
| (increment) | | |
-| | |**Looking for something else?** |
+| | | |
|* :ref:`- - <lang-increment>` | | |
-| (decrement) | | See the :ref:`libraries` page for interfacing with|
-| | | particular types of hardware. Maple links |
-|* :ref:`+= <lang-compoundarithmetic>` | | against `newlib <http://sourceware.org/newlib/>`_ |
-| (compound add) | | and allows the use of any of its functions; see |
-| | | its documentation for more details. |
+| (decrement) | | |
+| | | |
+|* :ref:`+= <lang-compoundarithmetic>` | | |
+| (compound add) | | |
+| | | |
|* :ref:`-= | | |
| <lang-compoundarithmetic>` (compound | | |
| subtract) | | |
@@ -217,6 +205,35 @@ A more exhaustive index is available at the :ref:`language-index`.
| | | |
+--------------------------------------------+----------------------------------------------+---------------------------------------------------+
+.. _language-assert:
+
+``ASSERT(...)``
+---------------
+
+The ``ASSERT()`` function can be very useful for basic program
+debugging. It accepts a boolean; for example::
+
+ ASSERT(state == WAIT);
+
+Zero is false and any other number is true. If the boolean is true, the
+assertion passes and the program continues as usual. If it is false,
+the assertion fails: the program is halted, debug information is
+printed to USART2, and the status LED begins to throb in intensity
+(it's noticeably different from blinking). The debug information is
+printed at 9600 baud and consists of the filename and line number
+where the particular assertion failed.
+
+Including assertions in a program increases the program size. When
+using libmaple **from the command line only**, they can be disabled by
+making the definition ::
+
+ #define DEBUG_LEVEL DEBUG_NONE
+
+before including either wirish.h or libmaple.h. In this case, all
+assertions will pass without any lost clock cycles. Note that this
+will **not work in the IDE**; even with this definition, assertions
+will still be enabled.
+
.. _language-missing-features:
Missing Arduino Features
@@ -256,13 +273,12 @@ Unimplemented Arduino Features
------------------------------
The following Wiring/Arduino features are currently unimplemented on
-the Maple. However, they will be present in future versions:
+the Maple.
+- `tone() <http://www.arduino.cc/en/Reference/Tone>`_
- `noTone() <http://www.arduino.cc/en/Reference/NoTone>`_
- `pulseIn() <http://www.arduino.cc/en/Reference/PulseIn>`_
-- `shiftOut() <http://www.arduino.cc/en/Reference/ShiftOut>`_
- `String <http://arduino.cc/en/Reference/StringObject>`_
-- `tone() <http://www.arduino.cc/en/Reference/Tone>`_
.. _our reference page: http://leaflabs.com/docs/external-interrupts/
@@ -283,16 +299,18 @@ programming ideas and C++.
Note for C/C++ Hackers
----------------------
-This is a note for programmers comfortable with C or C++ (although,
-you C programmers should remember that `C++ is not a superset of C
-<http://en.wikipedia.org/wiki/Compatibility_of_C_and_C%2B%2B>`_) who
-want a better understanding of the differences between C++ and the
-Wiring language. The good news is that the differences are relatively
-few; Wiring is just a thin wrapper around C++.
+This is a note for programmers comfortable with C or C++ who want a
+better understanding of the differences between C++ and the Wiring
+language.
-Some potentially better news is that the Maple can be programmed using
-a :ref:`standard Unix toolchain <unix-toolchain>`, so if you'd rather
-stick with :command:`gcc`, :command:`make`, and friends, you can.
+The good news is that the differences are relatively few; Wiring is
+just a thin wrapper around C++. Some potentially better news is that
+the Maple can be programmed using a :ref:`standard Unix toolchain
+<unix-toolchain>`, so if you'd rather stick with :command:`gcc`,
+:command:`make`, and friends, you can. If you're using the Unix
+toolchain and want to skip past the Wiring conveniences and get
+straight to registers, you are encouraged to move on to the
+:ref:`libmaple` documentation.
A *sketch* is the IDE's notion of a project; it consists of one or
more files written in the Wiring language, which is mostly the same as
@@ -318,9 +336,9 @@ work. As of |today|, Maple only has 20 KB RAM, anyway, so it's
doubtful that static allocation is not what you want.
The Wiring language also does not require you to define your own
-``main`` method (in fact, it forbids you from doing so). Instead, you
-are required to define two functions, ``setup`` and ``loop``, with
-type signatures ::
+``main`` method (in fact, we currently forbid you from doing so).
+Instead, you are required to define two functions, ``setup`` and
+``loop``, with type signatures ::
void setup(void);
void loop(void);
@@ -335,26 +353,33 @@ parses the result to produce a list of all functions defined in the
global scope. (We borrow this stage from the Arduino IDE, which in
turn borrows it from Wiring. It uses regular expressions to parse
C++, which is, of course, `Bad and Wrong
-<http://www.retrologic.com/jargon/B/Bad-and-Wrong.html>`_. An
-upcoming rewrite of the IDE performs this preprocessing step
-correctly, using a real parser. Until then, you have our apologies.)
-The order in which the individual sketch files are concatenated is not
-defined; it is unwise to write code that depends on a particular
-ordering.
+<http://www.retrologic.com/jargon/B/Bad-and-Wrong.html>`_. In the
+future, we'll do this correctly, using a better parser. Until then,
+you have our apologies.) The order in which the individual sketch
+files are concatenated is not defined; it is unwise to write code that
+depends on a particular ordering.
The concatenated sketch files are then appended onto a file which
includes `WProgram.h
-<http://github.com/leaflabs/libmaple/blob/master/wirish/WProgram.h>`_
+<https://github.com/leaflabs/libmaple/blob/master/wirish/WProgram.h>`_
(which includes the wirish and libmaple libraries, and declares
``setup()`` and ``loop()``), and then provides declarations for all
the function definitions found in the previous step. At this point,
-we have a file that is a valid C++ translation unit, but lacks a
-``main()`` method. The final step of compilation provides this
-method, which behaves roughly like::
+we have a file that is a valid C++ translation unit, but lacks
+``main()``. The final step of compilation provides ``main()``, which
+behaves roughly like::
int main(void) {
+ // Call libmaple's built-in initialization routines
+ init();
+
+ // Perform the user's initialization
setup();
- while (true) loop();
+
+ // Call user loop() forever.
+ while (true) {
+ loop();
+ }
}
(The truth is a little bit more complicated, but not by much).
@@ -425,20 +450,31 @@ Which could plausibly be turned into the final source file ::
}
int main() {
+ init();
setup();
while (true) loop();
}
-(Recall that it's legal C++ for a function to be declared multiple
-times, as long as it's defined exactly once).
-
+.. _language-recommended-reading:
Recommended Reading
-------------------
+* :ref:`libmaple Documentation <libmaple>`
+* Your board's :ref:`Board Hardware Documentation <index-boards>` page
+* ST Documentation:
+ * Reference Manual `RM0008
+ <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_
+ (PDF). This is the most important reference work on the STM32
+ line, and covers the low-level hardware capabilities and
+ interfaces in great detail.
+ * `Programming Manual
+ <http://www.st.com/stonline/products/literature/pm/15491.pdf>`_
+ (PDF). This is an assembly language and register reference for
+ the STM32 line.
+* ARM Documentation:
+ * `Cortex-M3 Technical Reference Manual, Revision r1p1
+ <http://infocenter.arm.com/help/topic/com.arm.doc.ddi0337e/DDI0337E_cortex_m3_r1p1_trm.pdf>`_
+ (PDF). This ARM manual specifies much of the the Cortex M3
+ Architecture, including instruction timings.
* `newlib Documentation <http://sourceware.org/newlib/>`_
-* STMicro documentation for STM32F103RB microcontroller:
-
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
- * `Programming Manual <http://www.st.com/stonline/products/literature/pm/15491.pdf>`_ (assembly language and register reference)
diff --git a/docs/source/libmaple.rst b/docs/source/libmaple.rst
index 8cc39a3..375e821 100644
--- a/docs/source/libmaple.rst
+++ b/docs/source/libmaple.rst
@@ -5,37 +5,35 @@
``libmaple``
============
-.. image:: /_static/img/libmaple-screenshot-small.png
- :align: center
- :alt: libmaple screenshot
-
-`LeafLabs libmaple <libmaple-libmaple>`_ is the low level library we
-have developed for for the ARM Cortex-M3 chips manufactured by
-STMicroelectronics used in the Maple boards (the `STM32F103x`_
-series). We found the generic peripheral libraries too painful to
-build on top of, and reimplemented the functionality we needed in a
-simpler (and less general) form.
-
-.. _libmaple-libmaple: http://github.com/leaflabs/libmaple
-.. _STM32F103x: http://www.st.com/stonline/stappl/productcatalog/app?path=/pages/stcom/PcStComPartNumberSearch.searchPartNumber&search=stm32f103
-
-This library is transparently included in the `Maple IDE
-<http://leaflabs.com/docs/maple-ide/>`_, but we develop it separately
-using good old Unix command line tools and release it for advanced
-users who might chafe at the "sketch" programming model of the
-IDE. Included are some examples, a Makefile, and the compatibility
-wrappers and code to imitate the Arduino programming library.
-
-**Check out the latest source**::
-
- git clone git://github.com/leaflabs/libmaple.git
-
-**Table of contents:**
+LeafLabs' libmaple (`source code on Github
+<https://github.com/leaflabs/libmaple>`_) is the library we have
+developed for the `STM32 <http://www.st.com/stonline>`_ line of ARM Cortex M3
+microcontrollers. Its high-level interfaces are :ref:`largely
+compatible <arduino-compatibility>` with the AVR libraries written for
+the `Arduino <http://arduino.cc>`_ and `Wiring
+<http://wiring.org.co/>`_ development boards.
+
+libmaple is split into two pieces: a lower level layer written in pure
+C, which we call *libmaple proper* (in the `libmaple/
+<https://github.com/leaflabs/libmaple/tree/master/libmaple>`_
+directory of the source repository), and the Wiring-style C++ API
+written on top of it, called *Wirish* (in `wirish/
+<https://github.com/leaflabs/libmaple/tree/master/wirish>`_).
+
+libmaple is bundled with the :ref:`Maple IDE <ide>`. However, we
+develop it separately, and :ref:`release it standalone
+<unix-toolchain>` for advanced users who might chafe at the "sketch"
+programming model of the IDE.
+
+As always, :ref:`patches are welcome <libmaple-contributing>`.
+
+**Contents:**
.. toctree::
- :maxdepth: 2
+ :maxdepth: 1
- Guide to using GCC's ARM target <arm-gcc>
+ libmaple/overview
+ libmaple/apis
+ libmaple/contributing
+ libmaple/coding-standard
-.. TODO LATER create, style, and host a pure Doxygen libmaple
-.. reference docs. This implies determining a stable API.
diff --git a/docs/source/libmaple/api/adc.rst b/docs/source/libmaple/api/adc.rst
new file mode 100644
index 0000000..8817055
--- /dev/null
+++ b/docs/source/libmaple/api/adc.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-adc:
+
+``adc.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: adc.h
diff --git a/docs/source/libmaple/api/bitband.rst b/docs/source/libmaple/api/bitband.rst
new file mode 100644
index 0000000..fd57944
--- /dev/null
+++ b/docs/source/libmaple/api/bitband.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-bitband:
+
+``bitband.h``
+=============
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: bitband.h
diff --git a/docs/source/libmaple/api/bkp.rst b/docs/source/libmaple/api/bkp.rst
new file mode 100644
index 0000000..9a697c7
--- /dev/null
+++ b/docs/source/libmaple/api/bkp.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-bkp:
+
+``bkp.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: bkp.h
diff --git a/docs/source/libmaple/api/dac.rst b/docs/source/libmaple/api/dac.rst
new file mode 100644
index 0000000..038753b
--- /dev/null
+++ b/docs/source/libmaple/api/dac.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-dac:
+
+``dac.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: dac.h
diff --git a/docs/source/libmaple/api/delay.rst b/docs/source/libmaple/api/delay.rst
new file mode 100644
index 0000000..a0d013a
--- /dev/null
+++ b/docs/source/libmaple/api/delay.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-delay:
+
+``delay.h``
+===========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: delay.h
diff --git a/docs/source/libmaple/api/dma.rst b/docs/source/libmaple/api/dma.rst
new file mode 100644
index 0000000..1512d0c
--- /dev/null
+++ b/docs/source/libmaple/api/dma.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-dma:
+
+``dma.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: dma.h
diff --git a/docs/source/libmaple/api/exti.rst b/docs/source/libmaple/api/exti.rst
new file mode 100644
index 0000000..2909aa7
--- /dev/null
+++ b/docs/source/libmaple/api/exti.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-exti:
+
+``exti.h``
+==========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: exti.h
diff --git a/docs/source/libmaple/api/flash.rst b/docs/source/libmaple/api/flash.rst
new file mode 100644
index 0000000..6f2f9d3
--- /dev/null
+++ b/docs/source/libmaple/api/flash.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-flash:
+
+``flash.h``
+===========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: flash.h
diff --git a/docs/source/libmaple/api/fsmc.rst b/docs/source/libmaple/api/fsmc.rst
new file mode 100644
index 0000000..cecfc99
--- /dev/null
+++ b/docs/source/libmaple/api/fsmc.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-fsmc:
+
+``fsmc.h``
+==========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: fsmc.h
diff --git a/docs/source/libmaple/api/gpio.rst b/docs/source/libmaple/api/gpio.rst
new file mode 100644
index 0000000..2cfec23
--- /dev/null
+++ b/docs/source/libmaple/api/gpio.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-gpio:
+
+``gpio.h``
+==========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: gpio.h
diff --git a/docs/source/libmaple/api/i2c.rst b/docs/source/libmaple/api/i2c.rst
new file mode 100644
index 0000000..14dd304
--- /dev/null
+++ b/docs/source/libmaple/api/i2c.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-i2c:
+
+``i2c.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: i2c.h
diff --git a/docs/source/libmaple/api/iwdg.rst b/docs/source/libmaple/api/iwdg.rst
new file mode 100644
index 0000000..3911ece
--- /dev/null
+++ b/docs/source/libmaple/api/iwdg.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-iwdg:
+
+``iwdg.h``
+==========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: iwdg.h
diff --git a/docs/source/libmaple/api/libmaple.rst b/docs/source/libmaple/api/libmaple.rst
new file mode 100644
index 0000000..d4f28f0
--- /dev/null
+++ b/docs/source/libmaple/api/libmaple.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-libmaple:
+
+``libmaple.h``
+==============
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: libmaple.h
diff --git a/docs/source/libmaple/api/libmaple_types.rst b/docs/source/libmaple/api/libmaple_types.rst
new file mode 100644
index 0000000..bbea2c1
--- /dev/null
+++ b/docs/source/libmaple/api/libmaple_types.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-libmaple_types:
+
+``libmaple_types.h``
+====================
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: libmaple_types.h
diff --git a/docs/source/libmaple/api/nvic.rst b/docs/source/libmaple/api/nvic.rst
new file mode 100644
index 0000000..b94dc31
--- /dev/null
+++ b/docs/source/libmaple/api/nvic.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-nvic:
+
+``nvic.h``
+==========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: nvic.h
diff --git a/docs/source/libmaple/api/pwr.rst b/docs/source/libmaple/api/pwr.rst
new file mode 100644
index 0000000..82e4864
--- /dev/null
+++ b/docs/source/libmaple/api/pwr.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-pwr:
+
+``pwr.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: pwr.h
diff --git a/docs/source/libmaple/api/rcc.rst b/docs/source/libmaple/api/rcc.rst
new file mode 100644
index 0000000..81dc604
--- /dev/null
+++ b/docs/source/libmaple/api/rcc.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-rcc:
+
+``rcc.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: rcc.h
diff --git a/docs/source/libmaple/api/ring_buffer.rst b/docs/source/libmaple/api/ring_buffer.rst
new file mode 100644
index 0000000..a014fa4
--- /dev/null
+++ b/docs/source/libmaple/api/ring_buffer.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-ring_buffer:
+
+``ring_buffer.h``
+=================
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: ring_buffer.h
diff --git a/docs/source/libmaple/api/scb.rst b/docs/source/libmaple/api/scb.rst
new file mode 100644
index 0000000..78cc7eb
--- /dev/null
+++ b/docs/source/libmaple/api/scb.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-scb:
+
+``scb.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: scb.h
diff --git a/docs/source/libmaple/api/spi.rst b/docs/source/libmaple/api/spi.rst
new file mode 100644
index 0000000..b0c7e86
--- /dev/null
+++ b/docs/source/libmaple/api/spi.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-spi:
+
+``spi.h``
+=========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: spi.h
diff --git a/docs/source/libmaple/api/stm32.rst b/docs/source/libmaple/api/stm32.rst
new file mode 100644
index 0000000..2784540
--- /dev/null
+++ b/docs/source/libmaple/api/stm32.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-stm32:
+
+``stm32.h``
+===========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: stm32.h
diff --git a/docs/source/libmaple/api/systick.rst b/docs/source/libmaple/api/systick.rst
new file mode 100644
index 0000000..a02b8e4
--- /dev/null
+++ b/docs/source/libmaple/api/systick.rst
@@ -0,0 +1,20 @@
+.. highlight:: c
+
+
+.. _libmaple-systick:
+
+.. FIXME [0.0.10] move these to the right places:
+
+.. _libmaple-systick_disable:
+
+.. _libmaple-systick_resume:
+
+``systick.h``
+=============
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: systick.h
diff --git a/docs/source/libmaple/api/timer.rst b/docs/source/libmaple/api/timer.rst
new file mode 100644
index 0000000..3acbf4f
--- /dev/null
+++ b/docs/source/libmaple/api/timer.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-timer:
+
+``timer.h``
+===========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: timer.h
diff --git a/docs/source/libmaple/api/usart.rst b/docs/source/libmaple/api/usart.rst
new file mode 100644
index 0000000..26e6b9c
--- /dev/null
+++ b/docs/source/libmaple/api/usart.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-usart:
+
+``usart.h``
+===========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: usart.h
diff --git a/docs/source/libmaple/api/util.rst b/docs/source/libmaple/api/util.rst
new file mode 100644
index 0000000..50ffe76
--- /dev/null
+++ b/docs/source/libmaple/api/util.rst
@@ -0,0 +1,12 @@
+.. highlight:: c
+.. _libmaple-util:
+
+``util.h``
+==========
+
+[Stub] support.
+
+Library Documentation
+---------------------
+
+.. doxygenfile:: util.h
diff --git a/docs/source/libmaple/apis.rst b/docs/source/libmaple/apis.rst
new file mode 100644
index 0000000..f493406
--- /dev/null
+++ b/docs/source/libmaple/apis.rst
@@ -0,0 +1,14 @@
+.. _libmaple-apis:
+
+APIs
+====
+
+This is the master index for libmaple proper's APIs.
+
+**Contents**
+
+.. toctree::
+ :maxdepth: 1
+ :glob:
+
+ api/*
diff --git a/docs/source/libmaple/coding-standard.rst b/docs/source/libmaple/coding-standard.rst
new file mode 100644
index 0000000..23d20f8
--- /dev/null
+++ b/docs/source/libmaple/coding-standard.rst
@@ -0,0 +1,412 @@
+.. _libmaple-coding-standard:
+
+Coding Standard
+===============
+
+This page documents the coding standard for :ref:`libmaple`. It's
+intended as a guide for how you should structure any code you would
+like included into the LeafLabs releases of libmaple.
+
+LeafLabs team members are required to follow these when producing new
+code. Community contributors to libmaple are strongly encouraged to
+do so; following these rules will greatly increase the probability
+that your patches will be folded in.
+
+In general, follow this guide unless there's a very good reason not
+to. Laziness doesn't count as a good reason. Most, if not all, of
+these decisions are entirely arbitrary, but it's important for
+readability that we be consistent. (If you notice an inconsistency,
+you should fix it).
+
+Note that the file ``.dir-locals.el`` in the libmaple root directory
+already ensures that many of these standards are followed by default
+in Emacs (but not on Windows, where it would need to be named
+``_dir_locals.el``, and no way, man). There's also some elisp
+scattered about this file which will provide you additional help.
+
+Vim customizations to do the same thing would be nice!
+
+.. contents:: Contents
+ :local:
+
+License
+-------
+
+.. highlight:: scheme
+
+Put an MIT license at the beginning of the file (look at any of our
+source files for an example). Copyright should go either to you or to
+LeafLabs, LLC.
+
+Emacs: if you don't like seeing the license, you should use elide-head
+(which will hide it for you). You can use the following::
+
+ (require 'elide-head)
+ (setq programming-mode-hooks '(c-mode-hook c++-mode-hook))
+ (add-to-list 'elide-head-headers-to-hide
+ '("The MIT License" . "DEALINGS IN\n [*] THE SOFTWARE"))
+ (add-to-list 'elide-head-headers-to-hide
+ '("The MIT License" . "DEALINGS IN THE\n...SOFTWARE"))
+ (dolist (hook programming-mode-hooks)
+ (add-hook hook (lambda () (elide-head))))
+
+Whitespace
+----------
+
+- 4 space indents (set in ``.dir-locals.el``).
+
+- Unix newlines. Some exceptions are currently grandfathered in; these
+ will go away in time.
+
+- No tab characters (set in ``.dir-locals.el``).
+
+- No trailing whitespace. For help getting this (and no tab
+ characters) done automatically in Emacs, you can use
+ `code-fascism.el <https://github.com/mbolivar/code-fascism>`_.
+
+- Files end in exactly one newline. The presence of a newline at EOF
+ is already done by ``c-require-final-newline`` in recent versions of
+ Emacs.
+
+- Exactly two newlines separate source paragraphs (you do separate
+ your code into paragraphs, don't you?).
+
+- The first line in a function is non-blank.
+
+.. highlight:: cpp
+
+- Exactly one space after ``if``, ``else``, ``for``, and ``while``,
+ before the following ``{`` or ``(``. One space before ``else``,
+ after the preceding ``}``. For example::
+
+ // This is good; we like this:
+ if (foo) {
+ while (quux) {
+ bar();
+ }
+ } else {
+ baz();
+ }
+
+ // THIS IS BAD! DON'T DO THIS:
+ if(foo){
+ while(quux){
+ bar();
+ }
+ }else{
+ baz();
+ }
+
+- Exactly one space in between binary arithmetic, logical, and
+ comparison operators and their operands. Examples::
+
+ // This is good:
+ int x = a + b * (c - d);
+ if (x != 0 && a > 7) {
+ SerialUSB.println(x);
+ }
+
+ // THIS IS BAD!
+ int x = a+b*(c-d);
+ if (x!=0 && a>7) {
+ SerialUSB.println(x);
+ }
+
+ // This is good:
+ uint32 adc_data = ADC1_BASE->DR;
+ SerialUSB.println(adc_data);
+
+ // THIS IS BAD!
+ uint32 adc_data = ADC1_BASE -> DR;
+ SerialUSB . println(adc_data);
+
+- No space between a unary operator and its operand. Examples::
+
+ // Good:
+ x++;
+
+ // BAD!
+ x ++;
+
+ // Good:
+ y = -x;
+
+ // BAD!
+ y = - x;
+
+- If you need to break up a long line:
+
+ * Prefer to break up long expressions after a binary operator. Example::
+
+ // Good:
+ if (some_really_long_conditional_wow_this_really_goes_on_forever ||
+ maybe_something_else_could_happen_too) {
+ ...
+ }
+
+ // BAD!
+ if (some_really_long_conditional_wow_this_really_goes_on_forever
+ || maybe_something_else_could_happen_too) {
+ ...
+ }
+
+ * When breaking up a function's arguments over multiple lines, align
+ the arguments on subsequent lines with the first argument.
+ Example::
+
+ // Good:
+ return_type value_i_got = function_with_a_really_long_name(argument1,
+ argument2,
+ argument3);
+
+ // BAD!
+ return_type value_i_got = function_with_a_really_long_name(argument1,
+ argument2,
+ argument3);
+
+ // BAD!
+ return_type value_i_got = function_with_a_really_long_name(argument1,
+ argument2,
+ argument3);
+
+- In function invocations, no space in between the function name and
+ the opening parenthesis. Example::
+
+ // Good:
+ SerialUSB.println("Hello, world!");
+
+ // BAD!
+ SerialUSB.println ("Hello, world!");
+
+- Don't indent C code within a conditionally-compiled ``extern "C"``
+ block. Example::
+
+ // Good:
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+
+ void some_c_function(void);
+
+ #ifdef __cplusplus
+ } // extern "C"
+ #endif
+
+ // BAD!
+ #ifdef __cplusplus
+ extern "C"{
+ #endif
+
+ void some_c_function(void);
+
+ #ifdef __cplusplus
+ } // extern "C"
+ #endif
+
+ Emacs does the "bad" behavior by default, which can be very
+ annoying. You can turn this off with ::
+
+ (defun c-mode-inextern-lang-hook ()
+ (setcdr (assq 'inextern-lang c-offsets-alist) '-))
+ (add-hook 'c-mode-hook c-mode-inextern-lang-hook)
+
+Comments
+--------
+
+.. highlight:: c++
+
+- Multi-line comments are pretty flexible. Any of these is fine::
+
+ /* Comment starts here.
+ * Continued lines have a '*' before them.
+ * The comment can end after the last line.
+ */
+
+ /* Comment starts here.
+ * The comment can end on the same line. */
+
+ /*
+ * You can also place a newline after the opening "/*".
+ */
+
+- Doxygen comments are multi-line comments that begin with ``/**``
+ instead.
+
+- Single-line comments are up to you.
+
+Braces
+------
+
+- Mostly `1TBS
+ <http://en.wikipedia.org/wiki/Indent_style#Variant:_1TBS>`_. The
+ only difference is that the opening brace of a function's definition
+ occurs exactly one space character after the closing parenthesis in
+ that function's parameter list. Example::
+
+ void func(void) {
+ ...
+ }
+
+Naming conventions
+------------------
+
+We'll handle the usual casing/underscore debate as follows.
+
+- First, ``Dont_Mix_Like_This``, because ``It_Looks_Really_Ugly``, ok?
+ [There's been some debate about this, and some exceptions are
+ already grandfathered in, so in order to settle it, let's call this
+ a "recommendation" instead of "requirement".]
+
+- Variables: Use underscores to separate words in C identifiers::
+
+ int some_example_name;
+
+ User-facing C++ variables should be camel cased
+ (``thisIsAnExample``, ``boardPWMPins``, etc.), for consistency with
+ the Arduino style. It's probably a good idea for you to case
+ non-user facing C++ variables in the C style; this will help
+ disambiguate what's part of the Wirish API and what's not.
+
+- Classes: Pascal case. So ``ThisIsAClassName``, but ``thisIsNot``,
+ ``this_is_not``, and ``Dont_You_DareTryANYTHING_STUPID``.
+
+- Functions: C functions are all lowercase, and words are separated by
+ underscores. C++ method names are camel cased.
+
+- Structs: Usually like variables (``adc_dev``, ``adc_reg_map``,
+ etc.), but it's not crucial. Don't feel obliged to put ``_t`` at
+ the end of the type name; we don't.
+
+- Macros and constants: all caps, separated by underscores. C++
+ variables with the ``const`` qualifier generally aren't considered
+ "constants" for the purposes of this rule; i.e., they are cased
+ according to the rules for variables. We make an exception for
+ ``PIN_MAP``, because it's the central Wirish data structure.
+
+- foo.h gets ``#ifdef``\ 'ed to ``_FOO_H_``.
+
+- Acronyms: The case of letters in an acronym is determined by the
+ case of the first letter in the acronym, which is determined by
+ following the above rules. Examples::
+
+ // Good:
+ void usb_func() { ... }
+ void frob_usb_disc() { ... }
+ class SomethingUSB {
+ void usbInit();
+ void initUSB();
+ };
+
+ // BAD:
+ class BadUsb { ... }; // say "GoodUSB" instead
+ void swizzle_USB_disc() { ... } // say "swizzle_usb_disc" instead
+
+Documentation
+-------------
+
+- Doxygen comments on every user-facing function and type.
+ Additionally, individually document the fields and enumerator values
+ of nontrivial user-facing structs and enums. See any register map
+ type's definition for an example.
+
+- For libmaple proper, you don't need comments for each register bit
+ definition, since that's just repeating information better obtained
+ by reading ST RM0008.
+
+- Doxygen comments generally only belong on types, functions,
+ etc. that are part of the public user-facing API. This generally
+ means that if there's ReST documentation for it under libmaple's
+ ``docs/source/``, it needs Doxygen comments, and that ReST should
+ use Breathe to pull that Doxygen comment out. (For more information
+ on this, see libmaple file ``docs/README``).
+
+ There are some exceptions to this rule since Breathe isn't totally
+ mature yet and Sphinx's C++ domain is still in flux. In these
+ cases, document the code "manually" in ReST.
+
+ This should be avoided if at all possible, since it creates a
+ maintenance burden of documenting things in two places at once, and
+ makes it easier for documentation to go stale.
+
+ If you do have to document something manually, put a comment in the
+ source file informing future maintainers about it, so they'll pay
+ extra attention when making changes.
+
+- When adding peripheral support, it would be nice if you put
+ longer-form comments into the libmaple ``notes/`` directory, with a
+ comment in the corresponding .h file referring to it. See the
+ :ref:`dac.h <libmaple-dac>` source for an example.
+
+ This lets us keep the source files relatively free of "introductory"
+ material, while allowing new readers a convenient starting point.
+ These longer-form notes also have a habit of turning into official,
+ user-facing documentation.
+
+- **For libmaple proper**, the convention is to document any
+ user-facing function at the point where it is defined. In
+ particular, this means you should document an externally-linked
+ function defined in a .c file in that .c file, not in the header
+ file where it is declared to the user.
+
+ **For Wirish**, the convention is to put the documentation in the
+ header file where the function is declared.
+
+General Formatting
+------------------
+
+.. highlight:: scheme
+
+- Keep it 80-column clean.
+
+ Emacs users: this means that the largest column number is 79. You
+ should turn on column number mode to help you out::
+
+ (column-number-mode 1)
+
+ You can get more help from `lineker-mode
+ <http://www.helsinki.fi/~sjpaavol/programs/lineker.el>`_. Just put
+ lineker.el somewhere in your load-path, and::
+
+ (require 'lineker)
+ (dolist (hook '(c-mode-hook c++-mode-hook))
+ (add-hook hook (lambda () (lineker-mode 1))))
+
+.. highlight:: cpp
+
+Language Features
+-----------------
+
+In libmaple proper, aim for C99 compatibility. Some GCC extensions
+are OK, but `don't get crazy <http://www.youtube.com/watch?v=jZkdcYlOn5M>`_.
+
+Explicitly approved GCC extensions:
+
+ * `asm volatile <http://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html>`_
+
+ * `Nested functions <http://gcc.gnu.org/onlinedocs/gcc/Nested-Functions.html>`_
+
+In Wirish, generally be very conservative when using C++ features that
+aren't part of C. We are forced to use C++ for Arduino compatibility
+(and the general Arduino style of conflating objects and libraries),
+but it's an angry beast, and we don't want to provoke it. **The
+mantra is "C with classes"**.
+
+Explicitly approved C++ features:
+
+ * Initializers that aren't constant; e.g. the ``gpio_dev*`` values
+ in a ``PIN_MAP``.
+
+ * Default arguments: e.g., the timeout argument in
+ :ref:`lang-waitforbuttonpress`.
+
+Explicitly forbidden C++ features:
+
+ * Templates
+
+Conditionally allowed C++ features:
+
+ * Operator overloading: Never allowed when it's just for style.
+ Probably fine when you're implementing a class that models a
+ mathematical structure, and you'd like to implement
+ e.g. ``operator+()``.
+
diff --git a/docs/source/libmaple/contributing.rst b/docs/source/libmaple/contributing.rst
new file mode 100644
index 0000000..724605b
--- /dev/null
+++ b/docs/source/libmaple/contributing.rst
@@ -0,0 +1,113 @@
+.. _libmaple-contributing:
+
+Contributing to libmaple
+========================
+
+First of all, thanks! Community contributions are what makes open
+source great.
+
+If your patch is minor (you've found a typo, you've added a new
+function, etc.), feel free to just make a `forum post
+<http://forums.leaflabs.com>`_ describing your changes.
+
+If your changes are larger (you wrote a new library, you added support
+for a new peripheral, etc.), we'd prefer you submit a pull request on
+Github or send us a nicely-formatted patch via email.
+
+.. contents:: Contents
+ :local:
+
+.. _libmaple-faq-patches-preparing:
+
+Preparing Your Patch
+--------------------
+
+Before submitting a patch, please make sure it complies with the
+:ref:`coding standard <libmaple-coding-standard>`. Consistent style throughout
+the source tree is an important implementation objective for us, and a
+patch that doesn't comply with the coding standard we've set forth is
+likely to be sent back until it follows the standard.
+
+We would prefer if you release each new file you submit under the `MIT
+license <http://www.opensource.org/licenses/mit-license.php>`_. See
+e.g. `bkp.h
+<https://github.com/leaflabs/libmaple/blob/master/libmaple/bkp.h#L1>`_
+for an example, and the coding standard for more details. Code
+released under the `Lesser GPL
+<http://www.gnu.org/copyleft/lesser.html>`_ may be accepted for
+Wirish, but will almost certainly be rejected for libmaple proper. We
+will not accept patches released under the `GPL
+<http://www.gnu.org/licenses/gpl.html>`_.
+
+**We're not against the GPL**! It just doesn't suit our purposes for
+libmaple. If you're interested in a GPLed library for ST
+microcontrollers, check out `libopenstm32
+<http://www.hermann-uwe.de/blog/libopenstm32-a-free-software-firmware-library-for-stm32-arm-cortex-m3-microcontrollers>`_.
+Also note that :ref:`libraries <libraries>` released under the GPL are
+fine, we just don't want any core libmaple or Wirish code to be GPLed.
+
+.. _libmaple-faq-patches-github:
+
+Submitting Via Github Pull Request (Preferred)
+----------------------------------------------
+
+The most convenient way for you to contribute patches is to submit a
+pull request on `Github <https://github.com>`_. Github provides
+excellent code review interfaces, which will make it easy for us at
+LeafLabs to communicate with you (and each other) about your patch.
+It also makes it easy for us to merge your patch into the libmaple
+source tree when the time comes.
+
+The steps to submit a pull request are as follows:
+
+1. If you don't already have one, get a `Github account
+ <https://github.com/plans>`_ (free).
+
+2. Fork libmaple, then clone your fork to the computer you code on.
+ Github provides detailed instructions on `forking and cloning a
+ repository <http://help.github.com/fork-a-repo/>`_.
+
+3. Push your commits to your Github libmaple fork (see instructions
+ linked in Step 2 for a step-by-step walkthrough on how to do this).
+
+4. `Submit a pull request <http://help.github.com/pull-requests/>`_ to
+ the LeafLabs version of libmaple.
+
+.. _libmaple-faq-patches-email:
+
+Submitting Via Email
+--------------------
+
+If you're unfamiliar with Git or would prefer not to use Github, you
+can always send us a patch via email at info@leaflabs.com. We'd love
+it if you used the `Linux kernel patch format
+<http://linux.yyz.us/patch-format.html>`_, but please at least include
+the following information in your email:
+
+1. How you generated your patch (arguments to ``diff``, etc.)
+
+2. What git branch/commit or libmaple version your patch applies to
+
+3. A one-line summary of your changes, along with any other details
+ you think we should know.
+
+4. A sign-off line certifying your `developer certificate of origin
+ <http://elinux.org/Developer_Certificate_Of_Origin>`_.
+
+That said, we'd really prefer a pull request. If you'd like to learn
+more about Git, we recommend the following resources:
+
+* `The Git Community Book <http://book.git-scm.com/index.html>`_: A
+ collaboratively edited book on Git.
+
+* `Pro Git <http://progit.org/book/>`_: despite its title, this is a
+ fairly beginner-friendly source of information.
+
+* `Understanding Git Conceptually
+ <http://www.eecs.harvard.edu/~cduan/technical/git/>`_: a good,
+ introductory tutorial on Git's fundamental concepts.
+
+* `Git for Computer Scientists
+ <http://eagain.net/articles/git-for-computer-scientists/>`_: if
+ you're comfortable with directed acyclic graphs, this resource
+ explains Git's functionality in graph-theoretic terms.
diff --git a/docs/source/libmaple/overview.rst b/docs/source/libmaple/overview.rst
new file mode 100644
index 0000000..9bce564
--- /dev/null
+++ b/docs/source/libmaple/overview.rst
@@ -0,0 +1,342 @@
+.. highlight:: c
+
+.. _libmaple-overview:
+
+Overview
+========
+
+This page is a general overview of the low-level aspects of libmaple
+proper. It provides a general perspective of the library's goals and
+design. Examples are given from the libmaple sources.
+
+.. contents:: Contents
+ :local:
+
+Design Goals
+------------
+
+The central goal of the libmaple project is to provide a pleasant,
+consistent set of interfaces for dealing with the various peripherals
+on the STM32 line.
+
+Let's start with the basics. If you're interested in low-level details
+on the STM32, then you're going to spend a lot of quality time wading
+through `ST RM0008
+<http://www.st.com/stonline/products/literature/rm/13902.pdf>`_.
+RM0008 is the single most important tool in your toolbox. It is the
+authoritative documentation for the capabilities and low-level
+programming interfaces of ST's line of ARM Cortex M3 microcontrollers.
+
+Perhaps you haven't read it in detail, but maybe you've at least
+thumbed through a few of the sections, trying to gain some
+understanding of what's going on. If you've done that (and if you
+haven't, just take our word for it), then you know that underneath the
+covers, *everything* is controlled by messing with bits in the
+seemingly endless collections of registers specific to every
+peripheral. The `USARTs <http://leaflabs.com/docs/usart.html>`_ have
+data registers; (some of the) the `timers
+<http://leaflabs.com/docs/timers.html>`_ have capture/compare
+registers, the `GPIOs <http://leaflabs.com/docs/gpio.html>`_ have
+output data registers, etc.
+
+For the most part, Wirish does everything it can to hide this truth
+from you. That's because when you really just want to get your robot
+to fly, your LEDs to blink, or your `FM synthesizer
+<https://github.com/Ixox/preen>`_ to, well, `synthesize
+<http://xhosxe.free.fr/IxoxFMSynth.mp3>`_, you probably couldn't care
+less about messing with registers.
+
+That's fine! In fact, it's our explicit goal for Wirish to be good
+enough that most people never need to know libmaple proper even
+exists. We want to make programming our boards as easy as possible,
+after all. But the day may come when you want to add a library for an
+as-yet unsupported peripheral, or you want to do something we didn't
+anticipate, or you'd like to squeeze a little more speed out of a
+critical section in your program. Or maybe you're just curious!
+
+If anything in the above paragraph describes you, then you'll find
+that you need a way to translate your knowledge of RM0008 into
+software. We imagine (if you're anything like us) you want to spend
+the least amount of time you possibly can doing that
+translation. Ideally, once you've finished your design, you want some
+way to start reading and writing code right away, without having to
+bushwhack your way through a thicket of clunky APIs.
+
+The central abstractions we've chosen to accomplish the above goals
+are *register maps* and *devices*. Register maps are just structs
+which encapsulate the layout of the IO-mapped memory regions
+corresponding to a peripheral's registers. Devices encapsulate a
+peripheral's register map as well as any other necessary information
+needed to operate on it. Peripheral support routines generally
+operate on devices rather than register maps.
+
+Devices
+-------
+
+At the highest level, you'll be dealing with *devices*, where a
+"device" is a general term for any particular piece of hardware you
+might encounter. So, for example, an analog to digital converter is a
+device. So is a USART. So is a GPIO port. In this section, we'll
+consider some hypothetical "xxx" device.
+
+The first thing you need to know is that the header file for dealing
+with xxx devices is, naturally enough, called ``xxx.h``. So if you
+want to interface with the :ref:`ADCs <adc>`, just ``#include
+"adc.h"``.
+
+Inside of ``xxx.h``, there will be a declaration for a ``struct
+xxx_dev`` type. This type encapsulates all of the information we keep
+track of for that xxx. So, for example, in ``adc.h``, there's a
+``struct adc_dev``::
+
+ /** ADC device type. */
+ typedef struct adc_dev {
+ adc_reg_map *regs; /**< Register map */
+ rcc_clk_id clk_id; /**< RCC clock information */
+ } adc_dev;
+
+The ADCs aren't particularly complicated. All we keep track of for an
+ADC device is a pointer to its register map (which keeps track of all
+of its registers' bits; see :ref:`below <libmaple-overview-regmaps>`
+for more details), and an identifying piece of information which tells
+the RCC (reset and clock control) interface how to turn the ADC on and
+reset its registers to their default values.
+
+The timers on the STM32 line are more involved than the ADCs, so a
+``timer_dev`` has to keep track of a bit more information::
+
+ /** Timer device type */
+ typedef struct timer_dev {
+ timer_reg_map_union regs;
+ rcc_clk_id clk_id;
+ timer_type type;
+ voidFuncPtr handlers[];
+ } timer_dev;
+
+However, as you can see, both ADC and timer devices are named
+according to a single scheme, and store similar information.
+
+``xxx.h`` will also declare pointers to the actual devices you need to
+deal with, called ``XXX1``, ``XXX2``, etc. (or just ``XXX``, if
+there's only one) [#fgpio]_. For instance, on the Maple's
+microcontroller (the STM32F103RBT6), there are two ADCs.
+Consequently, in ``adc.h``, there are declarations for dealing with
+ADC devices one and two::
+
+ extern const adc_dev *ADC1;
+ extern const adc_dev *ADC2;
+
+In general, each device needs to be initialized before it can be used.
+libmaple provides this initialization routine for each peripheral
+``xxx``; its name is ``xxx_init()``. These initialization routines
+turn on the clock to a device, and restore its register values to
+their default settings. Here are a few examples::
+
+ /* From dma.h */
+ void dma_init(dma_dev *dev);
+
+ /* From gpio.h */
+ void gpio_init(gpio_dev *dev);
+ void gpio_init_all(void);
+
+Note that, sometimes, there will be an additional initialization
+routine for all available peripherals of a certain kind.
+
+Many peripherals also need additional configuration before they can be
+used. These functions are usually called something along the lines of
+``xxx_enable()``, and often take additional arguments which specify a
+particular configuration for the peripheral. Some examples::
+
+ /* From usart.h */
+ void usart_enable(usart_dev *dev);
+
+ /* From i2c.h */
+ void i2c_master_enable(i2c_dev *dev, uint32 flags);
+
+After you've initialized, and potentially enabled, your peripheral, it
+is now time to begin using it. The file ``xxx.h`` contains other
+convenience functions for dealing with xxx devices. For instance,
+here are a few from ``adc.h``::
+
+ void adc_set_sample_rate(const adc_dev *dev, adc_smp_rate smp_rate);
+ uint32 adc_read(const adc_dev *dev, uint8 channel);
+
+We aim to enable libmaple's users to interact with peripherals through
+devices as much as possible, rather than having to break the
+abstraction and consider individual registers. However, there will
+always be a need for low-level access. To allow for that, libmaple
+provides *register maps* as a consistent set of names and abstractions
+for dealing with registers and their bits.
+
+.. _libmaple-overview-regmaps:
+
+Register Maps
+-------------
+
+A *register map* is just a C struct which names and provides access to
+a peripheral's registers. These registers are usually mapped to
+contiguous regions of memory (though at times unusable or reserved
+regions exist between a peripheral's registers). Here's an example
+register map, from ``dac.h`` (``__io`` is just libmaple's way of
+saying ``volatile`` when referring to register values)::
+
+ /** DAC register map. */
+ typedef struct dac_reg_map {
+ __io uint32 CR; /**< Control register */
+ __io uint32 SWTRIGR; /**< Software trigger register */
+ __io uint32 DHR12R1; /**< Channel 1 12-bit right-aligned data
+ holding register */
+ __io uint32 DHR12L1; /**< Channel 1 12-bit left-aligned data
+ holding register */
+ __io uint32 DHR8R1; /**< Channel 1 8-bit left-aligned data
+ holding register */
+ __io uint32 DHR12R2; /**< Channel 2 12-bit right-aligned data
+ holding register */
+ __io uint32 DHR12L2; /**< Channel 2 12-bit left-aligned data
+ holding register */
+ __io uint32 DHR8R2; /**< Channel 2 8-bit left-aligned data
+ holding register */
+ __io uint32 DHR12RD; /**< Dual DAC 12-bit right-aligned data
+ holding register */
+ __io uint32 DHR12LD; /**< Dual DAC 12-bit left-aligned data
+ holding register */
+ __io uint32 DHR8RD; /**< Dual DAC 8-bit left-aligned data holding
+ register */
+ __io uint32 DOR1; /**< Channel 1 data output register */
+ __io uint32 DOR2; /**< Channel 2 data output register */
+ } dac_reg_map;
+
+
+There are two things to notice here. First, if RM0008 names a
+register ``DAC_FOO``, then ``dac_reg_map`` has a field named ``FOO``.
+So, the Channel 1 12-bit right-aligned data register (RM0008:
+DAC_DHR12R1) is the ``DHR12R1`` field in a ``dac_reg_map``. Second,
+if RM0008 describes a register as "Foo bar register", the
+documentation for the corresponding field has the same description.
+This consistency makes it easy to search for a particular register,
+and, if you see one used in a source file, to feel sure about what's
+going on just based on its name.
+
+So let's say you've included ``xxx.h``, and you want to mess with some
+particular register. What's the name of the ``xxx_reg_map`` variable
+you want? That depends on if there's more than one xxx or not. If
+there's only one xxx, then libmaple guarantees there will be a
+``#define`` that looks like like this::
+
+ #define XXX_BASE ((xxx_reg_map*)0xDEADBEEF)
+
+That is, you're guaranteed there will be a pointer to the (only)
+``xxx_reg_map`` you want, and it will be called
+``XXX_BASE``. (``0xDEADBEEF`` is the register map's *base address*, or
+the fixed location in memory where the register map begins). Here's a
+concrete example from ``dac.h``::
+
+ #define DAC_BASE ((dac_reg_map*)0x40007400)
+
+How can you use these? This is perhaps best explained by example.
+
+* In order to write 2048 to the channel 1 12-bit left-aligned data
+ holding register (RM0008: DAC_DHR12L1), you could write::
+
+ DAC_BASE->DHR12L1 = 2048;
+
+* In order to read the DAC control register, you could write::
+
+ uint32 cr = DAC_BASE->CR;
+
+The microcontroller takes care of converting reads and writes from a
+register's IO-mapped memory regions into reads and writes to the
+corresponding hardware registers.
+
+That covers the case where there's a single xxx peripheral. If
+there's more than one (say, if there are *n*), then ``xxx.h`` provides
+the following::
+
+ #define XXX1_BASE ((xxx_reg_map*)0xDEADBEEF)
+ #define XXX2_BASE ((xxx_reg_map*)0xF00DF00D)
+ ...
+ #define XXXn_BASE ((xxx_reg_map*)0x13AF1AB5)
+
+Here's a concrete example from ``adc.h``::
+
+ /** ADC1 register map base pointer. */
+ #define ADC1_BASE ((adc_reg_map*)0x40012400)
+ /** ADC2 register map base pointer. */
+ #define ADC2_BASE ((adc_reg_map*)0x40012800)
+ /** ADC3 register map base pointer. */
+ #define ADC3_BASE ((adc_reg_map*)0x40013C00)
+
+In order to read from the ADC1's regular data register (where the
+results of ADC conversion are stored), you might write::
+
+ uint32 converted_result = ADC1->DR;
+
+Register Bit Definitions
+------------------------
+
+In ``xxx.h``, there will also be a variety of #defines for dealing
+with interesting bits in the xxx registers, called *register bit
+definitions*. These are named according to the scheme
+``XXX_REG_FIELD``, where "``REG``" refers to the register, and
+"``FIELD``" refers to the bit or bits in ``REG`` that are special.
+
+.. TODO image of the bit layout of a DMA_CCR register
+
+Again, this is probably best explained by example. Each Direct Memory
+Access (DMA) controller's register map has a certain number of channel
+configuration registers (RM0008: DMA_CCRx). In each of these channel
+configuration registers, bit 14 is called the ``MEM2MEM`` bit, and
+bits 13 and 12 are the priority level (``PL``) bits. Here are the
+register bit definitions for those fields::
+
+ /* From dma.h */
+
+ #define DMA_CCR_MEM2MEM_BIT 14
+ #define DMA_CCR_MEM2MEM BIT(DMA_CCR_MEM2MEM_BIT)
+ #define DMA_CCR_PL (0x3 << 12)
+ #define DMA_CCR_PL_LOW (0x0 << 12)
+ #define DMA_CCR_PL_MEDIUM (0x1 << 12)
+ #define DMA_CCR_PL_HIGH (0x2 << 12)
+ #define DMA_CCR_PL_VERY_HIGH (0x3 << 12)
+
+Thus, to check if the ``MEM2MEM`` bit is set in DMA controller 1's
+channel configuration register 2 (RM0008: DMA_CCR2), you can write::
+
+ if (DMA1_BASE->CCR2 & DMA_CCR_MEM2MEM) {
+ /* MEM2MEM is set */
+ }
+
+Certain register values occupy multiple bits. For example, the
+priority level (PL) of a DMA channel is determined by bits 13 and 12
+of the corresponding channel configuration register. As shown above,
+libmaple provides several register bit definitions for masking out the
+individual PL bits and determining their meaning. For example, to
+check the priority level of a DMA transfer, you can write::
+
+ switch (DMA1_BASE->CCR2 & DMA_CCR_PL) {
+ case DMA_CCR_PL_LOW:
+ /* handle low priority case */
+ case DMA_CCR_PL_MEDIUM:
+ /* handle medium priority case */
+ case DMA_CCR_PL_HIGH:
+ /* handle high priority case */
+ case DMA_CCR_PL_VERY_HIGH:
+ /* handle very high priority case */
+ }
+
+Of course, before doing that, you should check to make sure there's
+not already a device-level function for performing the same task!
+
+What Next?
+----------
+
+After you've read this page, you can proceed to the :ref:`libmaple API
+listing <libmaple-apis>`. From there, you can read documentation and
+follow links to the current source code for those files on `libmaple's
+Github page <https://github.com/leaflabs/libmaple>`_.
+
+.. rubric:: Footnotes
+
+.. [#fgpio] For consistency with RM0008, GPIO ports are given letters
+ instead of numbers (``GPIOA`` and ``GPIOB`` instead of
+ ``GPIO1`` and ``GPIO2``, etc.).
diff --git a/docs/source/libraries.rst b/docs/source/libraries.rst
index 7623963..44a72f7 100644
--- a/docs/source/libraries.rst
+++ b/docs/source/libraries.rst
@@ -10,13 +10,13 @@
.. Note: if you port an Arduino library and document it here, be sure
.. to update compatibility.rst to reflect that fact.
-This page briefly summarizes the Arduino libraries that have been
-ported to Maple. You can use a library from within a sketch by going
-to Sketch > Import Library... from within the IDE, then choosing the
-library you want.
+This page lists the extra libraries that are part of the :ref:`Maple
+IDE <ide>` (along with the rest of :ref:`libmaple <libmaple>`). You
+can use a library from within a sketch by going to Sketch > Import
+Library... from within the IDE, then choosing the library you want.
-Any incompatibilities between the Maple and Arduino versions are noted
-in the description of the library.
+Any incompatibilities between the Maple and Arduino versions of a
+library are noted in the library's documentation.
.. contents:: Contents
:local:
@@ -25,70 +25,47 @@ in the description of the library.
:hidden:
libs/servo.rst
+ libs/wire.rst
-.. _libraries-servo:
-
-Servo
------
-
-The Servo library is provided for convenient control of RC
-servomotors. For more information, see the :ref:`Servo <libs-servo>`
-reference.
+.. admonition:: **Looking for Something Else?**
-**Compatibility Note**
+ - See the :ref:`language` for information on the core functions
+ used for programming a Maple board.
-The Servo class provides a public interface identical to the Arduino
-version's documented functionality (as of Arduino 0021), so in most
-cases, this library will be a drop-in replacement.
+ - If you're looking for something from the C standard library (like
+ ``atoi()``, for instance): the :ref:`CodeSourcery GCC compiler
+ <arm-gcc>` used to compile your programs is configured to link
+ against `newlib <http://sourceware.org/newlib/>`_, and allows the
+ use of any of its header files. However, dynamic memory allocation
+ (``malloc()``, etc.) is not available.
-However, there are some differences, essentially at the level of
-implementation details.
+ - If you're looking for low-level hardware support libraries, see
+ the :ref:`libmaple Reference <libmaple>`.
-The major difference is that while the Arduino implementation drives
-the servos with "bit-banged" :ref:`PWM <pwm>`, the Maple
-implementation uses :ref:`timers <timers>` to drive the PWM directly.
-
-Consequently, **the Maple implementation only allows Servo instances
-to** :ref:`attach <libs-servo-attach>` **to pins that support PWM**.
-
-To determine if a pin supports PWM (15 Maple pins do), you can either
-check if "PWM" appears next to its number on the Maple silkscreen, or
-consult the :ref:`pwmWrite() <lang-pwmwrite>` documentation.
-
-RC Servos expect a pulse approximately every 20ms. In the Maple
-implementation, :ref:`periods <lang-hardwaretimer-setperiod>` are set
-for entire timers, rather than individual channels. Thus,
-``attach()``\ ing a Servo to a pin can interfere with other pins
-associated with the same timer\ [#fard-servo]_.
+.. _libraries-servo:
-Because of this, we recommend connecting multiple servomotors to pins
-which share a timer, in order to keep as many timers free for other
-purposes as possible. Consult the :ref:`table provided in the timers
-reference <timers-pin-channel-map>` to match up pins and timer
-channels.
+Servo
+-----
-Another difference: although it is not publicly documented to do so,
-the Arduino implementation of `attach()
-<http://arduino.cc/en/Reference/ServoAttach>`_ returns the timer
-channel associated with the newly-attached pin, or 0 on failure (as of
-Arduino 0021). The Maple implementation returns true on success, and
-false on failure (and this is its documented behavior).
+The :ref:`Servo <libs-servo>` library is provided for convenient
+control of RC servomotors.
.. _libraries-liquid-crystal:
LiquidCrystal
-------------
-.. TODO 0.0.10 make our own LiquidCrystal docs
+.. TODO [0.1.0] LiquidCrystal docs under libs/liquidcrystal.rst
The LiquidCrystal library allows Maple to control LCD screens. For
more information, see the `Arduino LiquidCrystal documentation
<http://www.arduino.cc/en/Reference/LiquidCrystal>`_.
-**Compatibility Note**
+**Arduino Compatibility**
At this time, no incompatibilities between the Maple and Arduino
-versions are known. Any observed differences should be considered
+versions are known (although the Maple version should perform
+significantly faster). Any observed differences should be considered
bugs, and reported on the forums.
.. _libraries-wire:
@@ -96,99 +73,8 @@ bugs, and reported on the forums.
Wire
----
-We provide a soft (bit-banged) implementation of the `Wire I2C library
-<http://arduino.cc/en/Reference/WireBegin>`_.
-
-**Compatibility Note**
-
-This implementation is synchronous, and thus supports only a subset of
-the full Wire interface (however, the functionality which is supported
-is fully compatible with Arduino). For now, please use the function
-reference which follows when developing projects using our
-implementation.
-
-Please note that the current implementation only supports master mode
-using a bit-banged (software) protocol. Future enhancements will use
-the hardware i2c peripheral on the stm32 as well as the DMA for
-performance. Support for slave, smBUS, and multimaster modes are also
-slated for inclusion in the enhanced Wire port.
-
-.. TODO 0.0.10 Wire docs in the cpp domain in own page under /libs/
-
-Wire Function Reference
-^^^^^^^^^^^^^^^^^^^^^^^
-
-``Wire.begin()``
- Joins the i2c bus as master, using pin 20 as SDA and pin 21 as SCL
- (this is compatible with the pin settings on the Arduino Mega).
-
-``Wire.begin(sda, scl)``
- Like ``Wire.begin()``, but with the given pins as SDA and
- SCL.
-
-``Wire.beginTransmission(slave_address)``
- Set up a transmission to a slave device with the given (7-bit)
- address. Bytes subsequently queued for transmission (using
- ``Wire.send``) will be sent to ``slave_address`` when ``void
- Wire.endTransmission()`` is called.
-
-``void Wire.send(byte)``
- Queues the given byte (``uint8`` or ``int``) to the slave address
- previously specified by a call to ``Wire.beginTransmission``. At
- most 32 bytes may be queued in a single transmission.
-
-``Wire.send(string)``
- Queues a given string (``char*``) for transmission. The characters
- of the string are individually queued for transmission as
- bytes. At most 32 bytes may be queued in a single transmission.
-
-``Wire.send(buffer, length)``
- Queues a byte buffer ``buffer`` (``uint8*`` or ``int*``), with
- ``length`` elements, for transmission. At most 32 bytes may be
- queued in a single transmission.
-
-``Wire.endTransmission()``
- Ends a transmission (begun by ``Wire.beginTransmission(uint8)``),
- and actually sends the bytes queued by calls to Wire.send.
-
- The return value is one of the following status codes:
-
- * ``SUCCESS``: All bytes were transmitted successfully.
-
- * ``EDATA``: More than 32 bytes were queued for transmission. No
- bytes are actually sent when this happens.
-
- * ``ENACKADDR``: Did not receive ACK on transmit of address. No
- bytes are actually sent when this happens.
-
- * ``ENACKTRNS``: Did not receive ACK during transmit of data. Some
- bytes may have been sent when this happens; however, the
- transmission is aborted after the first byte of data which is
- not ACKed by the slave device.
-
- * ``EOTHER``: Other error occurred.
-
-``Wire.requestFrom(address, num_bytes)``
- Requests ``num_bytes`` bytes from 7-bit slave address
- address. Returns the actual number of bytes read. These bytes may
- subsequently be read one at a time using ``Wire.receive()``.
-
- Note: if ``num_bytes`` exceeds the size of the transmit/receive
- buffer (currently 32), it will be truncated to 32.
-
-``Wire.receive()``
- Get and return the next byte read during the previous call to
- ``Wire.requestFrom(uint8, int)``. You can check how many bytes are
- left to read using ``uint8 Wire.available()``.
-
-``Wire.available()``
- Returns the number of bytes which are still available for reading
- (with ``Wire.receive()``) from the last call to
- ``Wire.requestFrom(uint8, int)``.
-
-.. rubric:: Footnotes
+.. FIXME [0.1.0] Update with hard Wire implementation info
-.. [#fard-servo] The Arduino implementation also captures timer
- channels in groups as more Servo objects are attached, but the
- details of which channels have their periods reset when are
- slightly different.
+We currently provide a soft (bit-banged) implementation of the
+:ref:`Wire <libs-wire>` I2C library. A hardware version is planned
+for Maple IDE release 0.1.0.
diff --git a/docs/source/libs/servo.rst b/docs/source/libs/servo.rst
index f92fd91..891f151 100644
--- a/docs/source/libs/servo.rst
+++ b/docs/source/libs/servo.rst
@@ -2,9 +2,10 @@
.. _libs-servo:
-=======
- Servo
-=======
+Servo
+=====
+
+.. FIXME [0.0.10] this is out of date
This documents the Servo library for controlling RC servomotors. It
is implemented as a thin layer over the built-in :ref:`timer
@@ -14,7 +15,8 @@ You can use this library in the :ref:`IDE <ide>` by choosing the Servo
item under the Sketch > Import Library... menu.
If you are using the :ref:`Unix toolchain <unix-toolchain>`, the
-library is located in ``$LIB_MAPLE_HOME/libraries/Servo/``.
+library is located in the ``/libraries/Servo/`` :ref:`libmaple`
+directory.
Servo Class Reference
---------------------
@@ -106,3 +108,54 @@ servomotor attached to pin 9, you could write ::
microseconds. This will be clamped to lie in the [``min``,
``max``\ ] pulse width range set during :ref:`attach()
<libs-servo-attach>`.
+
+Arduino Compatibility
+---------------------
+
+The Servo class provides a public interface identical to the Arduino
+version's documented functionality (as of Arduino 0021), so in most
+cases, this library will be a drop-in replacement.
+
+However, there are some differences, essentially at the level of
+implementation details.
+
+The major difference is that while the Arduino implementation drives
+the servos with "bit-banged" :ref:`PWM <pwm>`, the Maple
+implementation uses :ref:`timers <timers>` to drive the PWM directly.
+
+Consequently, **the Maple implementation only allows Servo instances
+to** :ref:`attach <libs-servo-attach>` **to pins that support PWM**.
+
+To determine if a pin supports PWM (15 Maple pins do), you can either
+check if "PWM" appears next to its number on the Maple silkscreen, or
+consult the :ref:`pwmWrite() <lang-pwmwrite>` documentation.
+
+RC Servos expect a pulse approximately every 20ms. In the Maple
+implementation, :ref:`periods <lang-hardwaretimer-setperiod>` are set
+for entire timers, rather than individual channels. Thus,
+``attach()``\ ing a Servo to a pin can interfere with other pins
+associated with the same timer\ [#fard-servo]_.
+
+Because of this, we recommend connecting multiple servomotors to pins
+which share a timer, in order to keep as many timers free for other
+purposes as possible. Consult your board's :ref:`Timer Pin Map
+<gpio-pin-maps>` to match up pins and timer channels.
+
+Another difference: although it is not publicly documented to do so,
+the Arduino implementation of `attach()
+<http://arduino.cc/en/Reference/ServoAttach>`_ returns the timer
+channel associated with the newly-attached pin, or 0 on failure (as of
+Arduino 0021). The Maple implementation returns :ref:`true
+<lang-constants-true>` on success, and :ref:`false
+<lang-constants-false>` on failure (and this is its documented
+behavior).
+
+We currently provide a soft (bit-banged) implementation of the
+:ref:`Wire <libs-wire>` I2C library.
+
+.. rubric:: Footnotes
+
+.. [#fard-servo] The Arduino implementation also captures timer
+ channels in groups as more Servo objects are attached, but the
+ details of which channels have their periods reset when are
+ slightly different.
diff --git a/docs/source/libs/wire.rst b/docs/source/libs/wire.rst
new file mode 100644
index 0000000..2c5bed9
--- /dev/null
+++ b/docs/source/libs/wire.rst
@@ -0,0 +1,104 @@
+.. highlight:: cpp
+
+.. _libs-wire:
+
+Wire
+====
+
+.. TODO [0.1.0] Format this correctly, using Breathe
+
+This page documents the Wire library for the :ref:`i2c` protocol. You
+can use this library in the :ref:`Maple IDE <ide>` by choosing the
+Wire item under the Sketch > Import Library... menu.
+
+If you are using the :ref:`Unix toolchain <unix-toolchain>`, the
+library is located in the ``/libraries/Wire/`` :ref:`libmaple`
+directory.
+
+Wire Function Reference
+-----------------------
+
+``Wire.begin()``
+ Joins the i2c bus as master, using pin 20 as SDA and pin 21 as SCL
+ (this is compatible with the pin settings on the Arduino Mega).
+
+``Wire.begin(sda, scl)``
+ Like ``Wire.begin()``, but with the given pins as SDA and
+ SCL.
+
+``Wire.beginTransmission(slave_address)``
+ Set up a transmission to a slave device with the given (7-bit)
+ address. Bytes subsequently queued for transmission (using
+ ``Wire.send``) will be sent to ``slave_address`` when ``void
+ Wire.endTransmission()`` is called.
+
+``void Wire.send(byte)``
+ Queues the given byte (``uint8`` or ``int``) to the slave address
+ previously specified by a call to ``Wire.beginTransmission``. At
+ most 32 bytes may be queued in a single transmission.
+
+``Wire.send(string)``
+ Queues a given string (``char*``) for transmission. The characters
+ of the string are individually queued for transmission as
+ bytes. At most 32 bytes may be queued in a single transmission.
+
+``Wire.send(buffer, length)``
+ Queues a byte buffer ``buffer`` (``uint8*`` or ``int*``), with
+ ``length`` elements, for transmission. At most 32 bytes may be
+ queued in a single transmission.
+
+``Wire.endTransmission()``
+ Ends a transmission (begun by ``Wire.beginTransmission(uint8)``),
+ and actually sends the bytes queued by calls to Wire.send.
+
+ The return value is one of the following status codes:
+
+ * ``SUCCESS``: All bytes were transmitted successfully.
+
+ * ``EDATA``: More than 32 bytes were queued for transmission. No
+ bytes are actually sent when this happens.
+
+ * ``ENACKADDR``: Did not receive ACK on transmit of address. No
+ bytes are actually sent when this happens.
+
+ * ``ENACKTRNS``: Did not receive ACK during transmit of data. Some
+ bytes may have been sent when this happens; however, the
+ transmission is aborted after the first byte of data which is
+ not ACKed by the slave device.
+
+ * ``EOTHER``: Other error occurred.
+
+``Wire.requestFrom(address, num_bytes)``
+ Requests ``num_bytes`` bytes from 7-bit slave address
+ address. Returns the actual number of bytes read. These bytes may
+ subsequently be read one at a time using ``Wire.receive()``.
+
+ Note: if ``num_bytes`` exceeds the size of the transmit/receive
+ buffer (currently 32), it will be truncated to 32.
+
+``Wire.receive()``
+ Get and return the next byte read during the previous call to
+ ``Wire.requestFrom(uint8, int)``. You can check how many bytes are
+ left to read using ``uint8 Wire.available()``.
+
+``Wire.available()``
+ Returns the number of bytes which are still available for reading
+ (with ``Wire.receive()``) from the last call to
+ ``Wire.requestFrom(uint8, int)``.
+
+Arduino Compatibility
+---------------------
+
+.. FIXME [0.1.0] Replace this section when i2c Wire wrapper is done
+
+This implementation is synchronous, and thus supports only a subset of
+the full Wire interface (however, the functionality which is supported
+is fully compatible with Arduino). For now, please use the function
+reference which follows when developing projects using our
+implementation.
+
+Please note that the current implementation only supports master mode
+using a bit-banged (software) protocol. For now, use of the hardware
+:ref:`i2c` peripheral is only available through :ref:`libmaple-i2c`.
+
+
diff --git a/docs/source/maple-ide-install.rst b/docs/source/maple-ide-install.rst
index 92d1a96..beba54d 100644
--- a/docs/source/maple-ide-install.rst
+++ b/docs/source/maple-ide-install.rst
@@ -17,7 +17,8 @@ us directly`_\ !
Download
--------
-Choose the correct version for your operating system:
+The current release of the Maple IDE is version 0.0.9. Choose the
+correct version for your operating system:
.. list-table::
:widths: 15 30 50
@@ -28,24 +29,28 @@ Choose the correct version for your operating system:
- IDE Package
* - Windows
- Tested on 32bit Windows XP
- - `maple-ide-LATEST-windowsxp32.zip <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-LATEST-windowsxp32.zip>`_ (about 75mb)
+ - `maple-ide-0.0.9-windowsxp32.zip <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-0.0.9-windowsxp32.zip>`_ (about 75mb)
* - Linux
- Tested on Ubuntu 9.10 (64bit) and 10.04 (32bit)
- - `maple-ide-LATEST-linux32.tgz <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-LATEST-linux32.tgz>`_ (about 30mb)
+ - `maple-ide-0.0.9-linux32.tgz <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-0.0.9-linux32.tgz>`_ (about 30mb)
- `maple-ide-LATEST-linux64.tgz <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-LATEST-linux64.tgz>`_ (about 30mb)
+ `maple-ide-0.0.9-linux64.tgz <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-0.0.9-linux64.tgz>`_ (about 30mb)
* - Mac OSX
- Tested on Snow Leopard 10.6 (64bit and 32bit)
- - `maple-ide-LATEST-macosx-10_6.dmg <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-LATEST-macosx-10_6.dmg>`_ (about 40mb)
+ - `maple-ide-0.0.9-macosx-10_6.dmg <http://static.leaflabs.com/pub/leaflabs/maple-ide/maple-ide-0.0.9-macosx-10_6.dmg>`_ (about 40mb)
The package bundles together a compiler, an upload utility, a software
library, and a simple GUI text editor. All this software is `free and
-open <http://fsf.org/>`_; we are grateful to the `Arduino
+open <http://www.fsf.org/>`_; we are grateful to the `Arduino
<http://arduino.cc/>`_, `CodeSourcery
-<http://www.codesourcery.com/>`_, `GNU <http://gnu.org/>`_, and
+<http://www.codesourcery.com/>`_, `GNU <http://www.gnu.org/>`_, and
`OpenMoko <http://openmoko.com/>`_ developers, as well as many others,
who allow us to reuse their software.
+**Looking for something older?** `Source archives and binaries
+<http://static.leaflabs.com/pub/leaflabs/maple-ide/>`_ are available
+for previously-released versions.
+
Installation
------------
@@ -65,8 +70,8 @@ some drivers. Sorry!
changes in Windows 7 mean that you won't be able to install the IDE
without disabling driver signing on your computer. We're working
on resolving this situation. For now, `users on the forum have
- reported some workarounds
- <http://forums.leaflabs.com/topic.php?id=73>`_.
+ reported a workaround
+ <http://forums.leaflabs.com/topic.php?id=73#post-788>`_.
First, install DFU drivers (for uploading code to your Maple) using
the following steps.
diff --git a/docs/source/maple-quickstart.rst b/docs/source/maple-quickstart.rst
index 899f720..c7596ce 100644
--- a/docs/source/maple-quickstart.rst
+++ b/docs/source/maple-quickstart.rst
@@ -6,7 +6,7 @@
Maple Quickstart Guide
========================
-.. TODO update the images since we changed "to FLASH" -> "to Flash"
+.. TODO [0.1.0] Update the images; we've changed "to FLASH" -> "to Flash"
You'll need a `Maple board <http://leaflabs.com/store/>`_, a `Mini-B
USB cable <http://www.google.com/products?q=mini-b+usb+cable>`_, a
@@ -73,12 +73,14 @@ window, and then a confirmation message will appear:
Upload that program!
--------------------
+.. FIXME [0.1.0 Maple-specific image; add one for Native]
+
Now it's time to plug in your Maple. Use a Mini-B cable, making sure
-that the :ref:`power source jumper <hardware-maple-powering>` is on
-the USB header first. We ship the Maple with the power source jumper
-configured that way, so you shouldn't have to do anything. For
-reference, it should look like this (don't worry if a jumper is
-hanging half off of the CHRG header):
+that the :ref:`power source jumper <maple-powering>` is on the USB
+header first. We ship Maples with the power source jumper configured
+that way, so you shouldn't have to do anything. For reference, it
+should look like this (don't worry if a jumper is hanging half off of
+the CHRG header):
.. image:: /_static/img/plugged-in-maple.png
:align: center
diff --git a/docs/source/pwm.rst b/docs/source/pwm.rst
index 1a8f4df..34ad508 100644
--- a/docs/source/pwm.rst
+++ b/docs/source/pwm.rst
@@ -19,29 +19,14 @@ filtering) generate audio waveforms.
Overview
--------
-The Maple has a large number of 16-bit PWM outputs, each connected to
-one of 4 timers. Some configuration, such as the clock rate or
-prescaling, must be common to the entire timer; see the :ref:`timer
-documentation <timers>` for more information.
-
-Note that unlike the Arduino, the Maple does not have PWM
-functionality on pin D10; all other pins are :ref:`compatible
-<compatibility>`.
-
-The following table shows which timer can generate which PWM
-outputs. See the :ref:`pin mapping table <pin-mapping-mega-table>` to
-track down exactly which timer *channel* corresponds to each pin.
-
-.. _pwm-timer-table:
-
-.. csv-table::
- :header: Timer, PWM Headers
- :delim: |
-
- Timer1 | D6,D7,D8
- Timer2 | D0,D1,D2,D3
- Timer3 | D11,D12,D27,D28
- Timer4 | D5,D9,D14,D24
+.. FIXME [0.1.0] More information about how timer channels drive PWM
+
+Each PWM output is driven by an output channel connected to one of 4
+timers. Some configuration, such as the clock rate or prescaling,
+must be common to the entire timer; see the :ref:`timer documentation
+<timers>` for more information. See your board's :ref:`pin mapping
+tables <gpio-pin-maps>` to track down the correspondence
+between timer channels and GPIO pins.
Background
----------
diff --git a/docs/source/specs.rst b/docs/source/specs.rst
deleted file mode 100644
index 4972a83..0000000
--- a/docs/source/specs.rst
+++ /dev/null
@@ -1,29 +0,0 @@
-.. _specs:
-
-.. _specs-Technical-Specifications:
-
-================================
-Maple's Technical Specifications
-================================
-
- * STM32 F103RB: a **32-bit** ARM Cortex M3 microprocessor
- * Clock Speed: **72 MHz**
- * Operating Voltage: 3.3V
- * Input Voltage (recommended): 3.0V-12V
- * 39 Digital I/O Pins (:ref:`GPIO <gpio>`)
- * 16 Analog Input Pins
- * 12-bit **ADC** resolution (:ref:`ADC <adc>`)
- * 15 **PWM** pins at 16-bit resolution (:ref:`PWM <pwm>`)
- * Dedicated **USB** port for programming and communications (:ref:`USB<usb>`)
- * External **JTAG** interface (:ref:`USB <jtag>`)
- * **128 Flash** and **20KB SRAM**
- * 64 Channel nested vector interrupt handler (including external interrupt on GPIO’s)
- * Integrated **SPI** (:ref:`SPI<spi>`)
- * Integrated **I2C** (:ref:`I2C<i2c>`)
- * 7 Channels of Direct Memory Access (DMA)
- * 3 **USART** divices (:ref:`USART <usart>`)
- * Four 4-channel Timers (:ref:`Timers <timers>`)
- * Supplies up to 800mA @ 3.3v
- * Support for low power and sleep modes (<500uA)
- * Dimensions are 2.05″x2.1″
-
diff --git a/docs/source/spi.rst b/docs/source/spi.rst
index ba43eef..dd9f1f5 100644
--- a/docs/source/spi.rst
+++ b/docs/source/spi.rst
@@ -8,23 +8,23 @@ The Serial Peripheral Interface Bus (SPI) is a serial data transfer
protocol useful for interacting with a wide variety of hardware
peripherals.
-The Maple has two SPI ports. The first has NSS on D10, MOSI on
-D11, MISO on D12, and SCK on D13. The second has NSS on D31, SCK on
-D32, MISO on D33, and MOSI on D34.
-
The public libmaple API for managing the SPI ports is the
-:ref:`HardwareSpi <lang-hardwarespi>` class.
+:ref:`HardwareSPI <lang-hardwarespi>` class.
Recommended Reading
-------------------
* `Wikipedia Article on Serial Peripheral Interface Bus (SPI)
<http://en.wikipedia.org/wiki/Serial_Peripheral_Interface_Bus>`_
+
* `Arduino reference on SPI
<http://www.arduino.cc/playground/Code/Spi>`_
+
* `Hardcore SPI on Arduino <http://klk64.com/arduino-spi/>`_ by kik64
-* STMicro documentation for STM32F103RB microcontroller:
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
+* ST Documentation:
+
+ * Reference Manual `RM0008
+ <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_
+ (PDF), Chapter 25, "Serial Peripheral Interface"
diff --git a/docs/source/timers.rst b/docs/source/timers.rst
index 56dd686..9163e69 100644
--- a/docs/source/timers.rst
+++ b/docs/source/timers.rst
@@ -5,6 +5,8 @@
Timers
======
+.. FIXME [0.0.10] links to systick.h in a few places on this page
+
There are four general purpose timers in the Maple microcontroller
that can be configured to generate periodic or delayed events with
minimal work done by the microcontroller. For example, the :ref:`PWM
@@ -43,164 +45,76 @@ event" interrupt is generated. You can configure the Maple to notify
you when this takes place, by registering an interrupt handler, which
is a function that will be called when the update event occurs.
-libmaple Reference
+By default, different compare values only change the relative offsets
+between events on a single timer ("phase"). They don't control the
+frequency with which they occur. However, a common trick is to
+increment the compare value manually in the interrupt handler so that
+the event will fire again after the increment period. There can be a
+different increment value for each channel, so this trick allows
+events to be programmed at 4 different rates on a single timer. Note
+that function call overheads mean that the smallest increment rate is
+at least a few microseconds.
+
+Function Reference
------------------
-The libmaple API for interacting with timers is documented at the
-:ref:`HardwareTimer reference <lang-hardwaretimer>`.
+* :ref:`HardwareTimer <lang-hardwaretimer>`
Caveats
-------
+Working with timers and interrupts can be tricky; they are a somewhat
+"advanced" topic. The following subsections explain some common
+problems associated with using timers and timer interrupts.
+
+In general: start simple, test with :ref:`ASSERT() <language-assert>`,
+and don't try to do too much in your interrupt handlers! Make sure
+that what you're trying to do in a handler isn't going to block other
+interrupts from firing, if those other interrupts are important for
+your program.
+
.. _timers-pwm-conflicts:
-**PWM Conflicts:** Because PWM functionality on a given pin depends on
+PWM Conflicts
+^^^^^^^^^^^^^
+
+Because PWM functionality on a given pin depends on
the configuration of the timer and channel, you must chose your
channels carefully if you want to use both timer interrupts and PWM in
-the same program. Refer to the following table to match up timer
-channels and Maple header pin numbers:
-
-.. _timers-pin-channel-map:
-
-.. csv-table::
- :header: Timer, Ch. 1 pin, Ch. 2 pin, Ch. 3 pin, Ch. 4 pin
-
- ``Timer1``, 6, 7, 8, --
- ``Timer2``, 2, 3, 1, 0
- ``Timer3``, 12, 11, 27, 28
- ``Timer4``, 5, 9, 14, 24
-
-**Overhead:** there is some overhead associated with function and
-interrupt calls (loading and unloading the stack, preparing state,
-etc.) and this overhead can fudge your timing. Imperfect code
-branching also means that, e.g., channel 1 interrupts may get called a
-couple clock cycles sooner than a channel 4 interrupt, all other
-configuration being the same.
-
-.. compound::
-
- **Jitter:** other interrupts (USB, Serial, SysTick, or other
- timers) can and will get called before or during the timer
- interrupt routines, causing pseudorandom delays and other
- frustrations.
-
- Disabling the USB port (by calling ``SerialUSB.end()``, or just
- running off a battery) helps a lot, but then you lose the
- auto-reset and communications functionality. This will require
- that you put your Maple into :ref:`perpetual bootloader mode
- <troubleshooting-perpetual-bootloader>` before uploading a new
- program to it (or somehow causing your program to re-enable serial
- over USB using :ref:`SerialUSB.begin() <lang-serialusb-begin>`).
-
- Disabling SysTick with ``systick_disable()`` helps as well.
- However, calling this function will break the ``micros()`` and
- ``millis()`` functions.
-
-**General:** working with timers and interrupts can be tricky and hard
-to debug; they are a somewhat "advanced" topic. Start simple, test
-with :ref:`ASSERT() <language-assert>`, and don't try to do too much
-in your interrupt handlers! Make sure that what you're trying to do in
-a handler isn't going to block other interrupts from firing (e.g. USB,
-Serial, SysTick) if those other interrupts are important for your
-program.
-
-SysTick Peripheral
-------------------
-
-The SysTick peripheral allows another, simple way to perform periodic
-or delayed events. This separate timer does not conflict with any
-other peripherals, but the associated 1kHz interrupt can jitter the
-general purpose timer interrupts; this is clearly seen when running
-VGA code, where the timing jitters are transformed into visual jags in
-the image. The SysTick peripheral can be disabled by calling
-``systick_disable()``, and re-enabled using ``systick_resume()``.
-
-Code Examples
--------------
-
-LED blink
-^^^^^^^^^
-
-::
-
- #define LED_RATE 500000 // in microseconds; should give 0.5Hz toggles
-
- void handler_led(void);
-
- void setup()
- {
- // Set up the LED to blink
- pinMode(BOARD_LED_PIN, OUTPUT);
-
- // Setup Timer
- Timer2.setChannel1Mode(TIMER_OUTPUTCOMPARE);
- Timer2.setPeriod(LED_RATE); // in microseconds
- Timer2.setCompare1(1); // overflow might be small
- Timer2.attachCompare1Interrupt(handler_led);
- }
-
- void loop() {
- // Nothing! It's all in the interrupts
- }
-
- void handler_led(void) {
- toggleLED();
- }
-
-Racing Counters
-^^^^^^^^^^^^^^^
-
-::
-
- void handler_count1(void);
- void handler_count2(void);
-
- int count1 = 0;
- int count2 = 0;
-
- void setup()
- {
- // Set up BUT for input
- pinMode(BOARD_BUTTON_PIN, INPUT_PULLUP);
-
- // Setup Counting Timers
- Timer3.setChannel1Mode(TIMER_OUTPUTCOMPARE);
- Timer4.setChannel1Mode(TIMER_OUTPUTCOMPARE);
- Timer3.pause();
- Timer4.pause();
- Timer3.setCount(0);
- Timer4.setCount(0);
- Timer3.setOverflow(30000);
- Timer4.setOverflow(30000);
- Timer3.setCompare1(1000); // somewhere in the middle
- Timer4.setCompare1(1000);
- Timer3.attachCompare1Interrupt(handler1);
- Timer4.attachCompare1Interrupt(handler2);
- Timer3.resume();
- Timer4.resume();
- }
-
- void loop() {
- // Display the running counts
- SerialUSB.print("Count 1: ");
- SerialUSB.print(count1);
- SerialUSB.print("\t\tCount 2: ");
- SerialUSB.println(count2);
-
- // Run... while BUT is held, pause Count2
- for(int i = 0; i<1000; i++) {
- if(digitalRead(BOARD_BUTTON_PIN)) {
- Timer4.pause();
- } else {
- Timer4.resume();
- }
- delay(1);
- }
- }
-
- void handler1(void) {
- count1++;
- }
- void handler2(void) {
- count2++;
- }
+the same program. Refer to your board's :ref:`Timer Pin Map
+<gpio-pin-maps>` to match up timer channels and pin numbers.
+
+Overhead
+^^^^^^^^
+
+There is some overhead associated with function and interrupt calls
+(loading and unloading the stack, preparing state, etc.) and this
+overhead can fudge your timing. Imperfect code branching also means
+that, e.g., channel 1 interrupts may get called a couple clock cycles
+sooner than a channel 4 interrupt, all other configuration being the
+same.
+
+Jitter
+^^^^^^
+
+Other interrupts can and will get called before or during the timer
+interrupt routines, causing pseudorandom delays and other
+frustrations.
+
+Disabling the :ref:`USB <usb>` port (by calling ``SerialUSB.end()``,
+or just running off a battery) helps a lot, but then you lose the
+auto-reset and communications functionality. This will require that
+you put your Maple into :ref:`perpetual bootloader mode
+<troubleshooting-perpetual-bootloader>` before uploading a new program
+to it (or somehow causing your program to re-enable serial over USB
+using :ref:`SerialUSB.begin() <lang-serialusb-begin>`).
+
+The SysTick peripheral another way to perform periodic or delayed
+events. Its separate timer does not conflict with any other
+peripherals, but the associated 1 kHz interrupt can jitter the general
+purpose timer interrupts. The SysTick peripheral can be disabled by
+calling :ref:`systick_disable() <libmaple-systick_disable>`, and
+re-enabled using :ref:`systick_resume() <libmaple-systick_resume>`.
+However, be aware that calling ``systick_disable()`` will stop the
+values coming from :ref:`lang-micros` and :ref:`lang-millis` from
+increasing.
diff --git a/docs/source/troubleshooting.rst b/docs/source/troubleshooting.rst
index 9146ebe..bf1b129 100644
--- a/docs/source/troubleshooting.rst
+++ b/docs/source/troubleshooting.rst
@@ -40,17 +40,17 @@ My 5v peripheral doesn't work! (I2C, SPI, USART, etc)
-----------------------------------------------------
Yup, the Maple is a 3.3v board. You may need to use a level
-converter. See the :ref:`compatibility <compatibility>`, :ref:`GPIO
-<gpio>`, or other :ref:`hardware specific documentation
-<index-hardware>` for more information.
+converter. See the :ref:`Arduino Compatibility
+<arduino-compatibility>`, :ref:`GPIO <gpio>`, or other :ref:`hardware
+specific documentation <index-hardware>` for more information.
The reset and D38/serial buttons don't seem to work reliably!
-------------------------------------------------------------
-A few rev3 boards shipped in May-June 2010 may have had unreliable
-buttons; see the :ref:`errata page <errata>` for details. `We're
-happy to replace these for you <http://leaflabs.com/contact>`_\ !
-
+A few Maple Rev3 boards shipped in May-June 2010 may have had
+unreliable buttons; see the :ref:`Maple Errata
+<maple-rev3-bad-buttons>` for details. `We're happy to replace these
+for you <http://leaflabs.com/contact>`_\ !
.. _troubleshooting-ide-install:
@@ -100,8 +100,6 @@ a board selected. The work-around is to restart the IDE. Mysterious!
A classic! Make sure you have selected a board from the pulldown menu.
-.. TODO: remove when Python version is released
-
``undefined reference to setup()/loop()``
-----------------------------------------
@@ -133,8 +131,6 @@ There is an intermittent bug with the temporary directory build system
that on occasion will lose many of the ``#include``\ d libmaple
files. If you recompile everything, it should be fine.
-.. TODO remove when the Python version is released
-
.. _troubleshooting-upload:
========================
diff --git a/docs/source/unix-toolchain.rst b/docs/source/unix-toolchain.rst
index d49b642..8b81e75 100644
--- a/docs/source/unix-toolchain.rst
+++ b/docs/source/unix-toolchain.rst
@@ -7,20 +7,23 @@
===========================
This is a tutorial for using the Maple with a standard Unix toolchain
-(make, gcc, etc.). It's not necessary to do this in order to program
-the Maple; you can always :ref:`install the Maple IDE
-<maple-ide-install>` instead.
+(``make``, ``gcc``, etc.). It's not necessary to do this in order to
+program the Maple; you can always :ref:`install the Maple IDE
+<maple-ide-install>` instead. This document is intended for users who
+are comfortable using C or C++ and would like to use :ref:`libmaple`
+directly.
You'll need a Maple board, a Mini-B USB cable, a functional computer,
-and root access to that computer. This guide assumes you've had
-success with the IDE on your machine and that you are fairly
-comfortable with the Unix command line; some previous experience with
-editing your shell startup script (.bashrc, .tcshrc, etc.) and using
-`make <http://www.gnu.org/software/make/>`_ is recommended. For
-generic installation/setup issues, the :ref:`IDE installation
-<maple-ide-install>` and :ref:`troubleshooting` pages may be
-helpful. If all else fails, try our `forum`_, or `contact us
-directly`_\ !
+and root (or Administrator) access to that computer. This guide
+assumes you've had success with the IDE on your machine and that you
+are fairly comfortable with the Unix command line. Some previous
+experience with editing your shell startup script (.bashrc, .tcshrc,
+etc.) and using `GCC <http://gcc.gnu.org/>`_ and `make
+<http://www.gnu.org/software/make/>`_ is recommended.
+
+For generic installation and setup issues, see the :ref:`IDE
+installation <maple-ide-install>` and :ref:`troubleshooting` pages. If
+all else fails, try our `forum`_, or `contact us directly`_\ !
We currently have instructions for 32- and 64-bit Linux and OS X Snow
Leopard. If you're on another Unix platform, Windows, or an earlier
@@ -54,36 +57,40 @@ First I'll give the commands to run, then explain::
$ sudo aptitude install build-essential git-core wget screen dfu-util \
openocd python python-serial
-You'll want to install a bunch of developer "basics" like
-:command:`make`, :command:`tar`, etc. A good catch-all for these
-tools is the "build-essential" meta-package on most Debian platforms:
-installing this fake package will pull in dozens of useful tools
-without bogging your system down too much. ``git-core`` is the name of
-the git package; `Git <http://git-scm.com/>`_ is a distributed code
-versioning system we use to track changes in our source
-code. :command:`wget` is a simple tool to download files over http
-from the command line, and is optional (you could pull in the required
-downloads using a browser). :command:`screen` is a really cool virtual
-terminal program; in the context of Maple, we use it to connect to
-serial port devices.
-
-:command:`dfu-util` is a tool from the `OpenMoko`_ project that we use
-to upload programs to the Maple over USB.
+You'll want to install a bunch of developer "basics" like ``make``,
+``tar``, etc. A good catch-all for these tools is the
+``build-essential`` meta-package on most Debian platforms: installing
+this fake package will pull in dozens of useful tools without bogging
+your system down too much.
+
+`Git <http://git-scm.com/>`_ is a distributed code versioning system
+we use to track changes in our source code; ``git-core`` is the
+corresponding package.
+
+``wget`` is a simple tool to download files over http from the command
+line; installing it is optional (you could pull in the required
+downloads using a browser).
+
+``screen`` is a screen manager; in the context of Maple, we use it to
+connect to serial port devices.
+
+``dfu-util`` is a tool from the `OpenMoko`_ project that we use to
+upload programs to the Maple over USB.
.. _OpenMoko: http://openmoko.com/
-:command:`openocd` is a `JTAG
+``openocd`` is a `JTAG
<http://en.wikipedia.org/wiki/Joint_Test_Action_Group>`_ control
program used in conjunction with an ARM JTAG device to do in circuit
debugging (pause/resume program execution, upload and download code,
-read out register status, etc). (optional)
+read out register status, etc). It's also optional.
Lastly, our reset script (which sends control signals over the
USB-serial connection to restart and enter the bootloader) is written
-in Python and requires the `PySerial
-<http://pyserial.sourceforge.net/>`_ library (the ``python-serial``
-package; this could also be installed with `easy_install
-<http://peak.telecommunity.com/DevCenter/EasyInstall>`_).
+in `Python <http://python.org>`_, and requires the `PySerial
+<http://pyserial.sourceforge.net/>`_ library available in the
+``python-serial`` package. This can also be installed with
+`easy_install <http://peak.telecommunity.com/DevCenter/EasyInstall>`_.
**2. Fetch libmaple and Compiler Toolchain** ::
@@ -95,15 +102,15 @@ package; this could also be installed with `easy_install
$ export PATH=$PATH:~/libmaple/arm/bin # or wherever these tools ended up
This step is fairly straightforward: do a git clone of the `libmaple
-repository <http://github.com/leaflabs/libmaple>`_ to some directory,
+repository <https://github.com/leaflabs/libmaple>`_ to some directory,
then download and extract the ARM compiler toolchain.
The :file:`arm/bin/` directory will need to be added to ``PATH``; you
can check that this worked by entering ``arm-none-`` and hitting tab
-to auto-complete (bash should show a bunch of results). Regardless of
-where you put the toolchain, make sure to preserve its internal
-directory layout, as the binaries make relative path calls and
-references.
+to auto-complete (your shell should show a bunch of results).
+Regardless of where you put the toolchain, make sure to preserve its
+internal directory layout, as the binaries make relative path calls
+and references.
After you're done, you'll probably want to update your shell startup
script so :file:`~/libmaple/arm/bin` stays in your ``PATH``.
@@ -118,12 +125,12 @@ From the libmaple directory, ::
$ sudo cp support/scripts/45-maple.rules /etc/udev/rules.d/45-maple.rules
$ sudo /etc/init.d/udev restart
-As a security precaution on linux, unknown USB devices can only be
-accessed by the superuser. This udev script identifies the Maple based
-on its vendor and product IDs, mounts it to :file:`/dev/maple`, and
-grants read/write permissions to the ``plugdev`` group. After
-restarting :command:`udev` you'll need to fully unplug or power cycle
-any Maples connected to the computer.
+As a security precaution on Linux, unknown USB devices can only be
+accessed by root. This udev script identifies the Maple based on its
+vendor and product IDs, mounts it to :file:`/dev/maple`, and grants
+read/write permissions to the ``plugdev`` group. After restarting
+``udev`` you'll need to fully unplug or power cycle any Maples
+connected to the computer.
**So far, so good?**
@@ -140,38 +147,40 @@ stated previously, this document assumes a general level of Unix
aptitude on the part of the reader; if you're uncomfortable using
Terminal (or if you don't know what that means), then you should
probably stick with using the `Maple IDE
-<http://leaflabs.com/docs/maple-ide/>`_ to develop programs.
+<http://leaflabs.com/docs/maple-ide/>`_ to write programs.
**1. Collect and Install Tools**
-You will need the following tools\ [#fmacports]_ to get started:
+You will need the following tools\ [#fpackman]_ to get started:
1. `XCode <http://developer.apple.com/technologies/xcode.html>`_: If
you're reading this, you've probably already got this. Provides
- compilers and other basic tools of the trade. It's a free download,
- but requires registration (gross, we know).
+ compilers and other basic tools of the trade. While XCode was once
+ free of charge, Apple has since begun charging for it; if you'd
+ rather not pay, you can probably get by with just a `make
+ <http://www.gnu.org/software/make/>`_ binary.
2. `Git <http://git-scm.com/>`_: All of our code is tracked by a
- distributed versioning system called git. A `Mac installer
+ distributed versioning system called Git. A `Mac installer
<http://code.google.com/p/git-osx-installer/downloads/list?can=3>`_
is available.
- 3. :command:`dfu-util`: A tool from `OpenMoko`_ that we use to upload
- programs to the Maple over USB. If you're feeling masochistic, there
- are instructions for `building dfu-util from source
+ 3. ``dfu-util``: A tool from `OpenMoko`_ that we use to upload
+ programs to the Maple over USB. If you prefer to compile from
+ source, OpenMoko provides instructions for `building dfu-util
<http://wiki.openmoko.org/wiki/Dfu-util#Mac>`_.
- However, if you've got better things to do, you can steal a dfu-util
- binary from a program called `Openmoko Flasher
- <http://www.handheld-linux.com/wiki.php?page=Openmoko%20Flasher>`_. To
- do this, first `download Openmoko Flasher
+ If you're in a hurry, you can steal a dfu-util binary from a program
+ called `OpenMoko Flasher
+ <http://www.handheld-linux.com/wiki.php?page=OpenMoko%20Flasher>`_. To
+ do this, first `download OpenMoko Flasher
<http://projects.goldelico.com/p/omflasher/downloads/>`_, then copy
- the .app into your :file:`/Applications` folder (or wherever you
- like). Let's pretend you saved the .app to the directory
+ the OpenMoko application into your :file:`/Applications` folder (or
+ wherever you like). Let's pretend you saved the .app to the directory
:file:`/Applications/OpenMoko Flasher.app`
- Then the :command:`dfu-util` binary resides in
+ Then the ``dfu-util`` binary resides in
:file:`/Applications/OpenMoko Flasher.app/Contents/Mac OS/dfu-util`
@@ -188,8 +197,9 @@ You will need the following tools\ [#fmacports]_ to get started:
.app, but you're on your own.
To make sure this worked, try plugging in your Maple, making sure
- it's in bootloader mode (you can do this by pressing RESET, then
- quickly pressing BUT and holding it for several seconds), then
+ it's in :ref:`perpetual bootloader mode
+ <troubleshooting-perpetual-bootloader>` (do this by pressing RESET,
+ then quickly pressing BUT and holding it for several seconds), then
running ::
$ dfu-util -l
@@ -212,8 +222,8 @@ You will need the following tools\ [#fmacports]_ to get started:
$ python setup.py build
$ sudo python setup.py install
- The package is also available via :command:`easy_install`, so if
- you're comfortable using that, you could also install it with ::
+ The package is also available via ``easy_install``, so if you're
+ comfortable using that, you could also install it with ::
$ easy_install pyserial
@@ -284,24 +294,24 @@ If it all works out, you should end up seeing something like this::
21824 200 552 22576 5830 build/maple.out
Flash build
-Woo! It worked. The ``dec`` field at the end gives the total program
-size in bytes. The long listing of object files above the ``Final
-Size`` helps to identify bloated code. As you write larger projects,
-you may find that they use too much space. If that happens, the
-file-by-file listing will help you track down the fatties porking up
-your program.
+The ``dec`` field at the end gives the total program size in
+bytes. The long listing of object files above the ``Final Size`` helps
+to identify bloated code. As you write larger projects, you may find
+that they use too much space. If that happens, the file-by-file
+listing will help you track down the culprits.
.. _toolchain-upload:
Upload a program
----------------
-Ok, let's blow away the little example program and upload the
-interactive test session to your Maple. This will let you interact
-textually with the Maple via USB-serial. If you're on Linux, then
-before executing :command:`make install`, you'll want to have the udev
-rules setup :ref:`as described above <toolchain-udev>`. Plug in your Maple
-using the mini-b USB cable; then run ::
+Let's blow away the little example program and upload the interactive
+test session to your Maple. This will let you interact with the Maple
+over a :ref:`USB serial port <usb>`. If you're on Linux, then before
+executing ``make install``, you'll want to have the udev rules setup
+:ref:`as described above <toolchain-udev>`.
+
+Plug in your Maple using the Mini-B USB cable; then run ::
$ cd ~/libmaple
$ cp examples/test-session.cpp main.cpp
@@ -312,91 +322,106 @@ using the mini-b USB cable; then run ::
A number of things can go wrong at this stage. Simple debugging steps
include using :ref:`perpetual bootloader mode
<troubleshooting-perpetual-bootloader>`, restarting the Maple a couple
-times, :command:`make clean`, etc. If nothing works, the `forum`_ is
-your friend.
+times, ``make clean``, etc. If nothing works, the `forum`_ is your
+friend.
.. _toolchain-serialusb:
-Communicate over USB-serial interface
+Communicate over USB-Serial interface
-------------------------------------
-Okay, now that we've flashed the interactive test session to the
-Maple, let's test it out. The device for the maple should look
-something like :file:`/dev/ttyACMXXX` on Linux or
-:file:`/dev/tty.usbmodemXXX` on OS X, but it might have a slightly
-different name on your system. To open up a session, run ::
+Now let's try out the interactive test session. The serial port
+device file should look something like :file:`/dev/ttyACMXXX` on Linux
+or :file:`/dev/tty.usbmodemXXX` on OS X, but ``XXX`` will vary
+depending on your system. Try using one of these to find out which it
+is::
+
+ # Linux
+ $ ls /dev/ttyACM*
+
+ # OS X
+ $ ls /dev/tty.usbmodem*
+
+To open up a session, run ::
$ screen /dev/ttyXXX
-If the interactive test program built and uploaded correctly, you
-should be able to connect without any errors reported by
-:command:`screen`. Type ``h`` or hit the space bar to get a response;
-there are a number of commands which demonstrate Maple peripheral
-features. As of October 2010, the HardwareSerial library is blocking,
-so using any commands which would write to the USART Serial ports will
-cause the program to hang. To exit the screen session, type :kbd:`C-a
-C-\\` (control-a, followed by control-backslash) on Mac, or :kbd:`C-a
-k` (control-a k) on Linux, and type ``y`` when prompted if you're
-sure.
+If the interactive test program built and uploaded correctly,
+``screen`` won't report any errors, and will present you an empty
+terminal. Your board is now waiting for you to send it a command.
+Type ``h`` to print a list of commands which demonstrate various
+features; type any command's letter to run it.
+
+To exit the screen session, type :kbd:`C-a C-\\` (control-a, followed
+by control-backslash) on Mac, or :kbd:`C-a k` (control-a k) on Linux,
+and type ``y`` when prompted if you're sure.
.. note::
- Using :command:`screen` in this way sometimes messes up your
- terminal session on OS X. If your shell starts acting up after you
- exit screen, you should be able to fix it with ::
+ Using ``screen`` sometimes messes up your terminal session on OS X.
+ If your shell starts acting funny after you exit ``screen``, you
+ should be able to fix it with ::
$ reset && clear
+ If that doesn't work, just close the Terminal window and open up a
+ new one.
+
.. _toolchain-projects:
Starting your own projects
--------------------------
-.. TODO fix the build-targets.mk mess, note the "library" target
-
So everything worked, and you want to start your own project? Great!
-It's easy. Just set the environment variable ``LIB_MAPLE_HOME`` in
-your shell startup script to point to the libmaple repository you
-cloned (this tutorial assumes you put it in :file:`~/libmaple`). For
-example, if you use bash as your shell, just put this line in your
-:file:`~/.bashrc` or :file:`~/.bash_profile`::
-
- export LIB_MAPLE_HOME=~/libmaple
-
-Now, in order to start your own projects, just grab a copy of the
-:file:`Makefile` and skeleton :file:`main.cpp` we provided in the
-libmaple repository, and you're good to go::
-
- $ cd
- $ mkdir my-awesome-project
- $ cp ~/libmaple/Makefile ~/libmaple/build-targets.mk my-awesome-project
- $ cp ~/libmaple/main.cpp.example my-awesome-project/main.cpp
-
-(TEMPORARY: The file :file:`build-targets.mk` is where the rule to
-build the object file for :file:`main.cpp` lives. If you have multiple
-source files, you'll probably need to look at it and edit as
-appropriate. We're sorry about that and will update the Makefile
-structure later to remove this pain point.) Then hack away! You can
-:command:`make`, :command:`make clean`, and :command:`make install`
-from your new directory :file:`my-awesome-project` just like you did
-in the libmaple repository.
-
-.. note::
-
- We update the libmaple repository fairly frequently with bugfixes
- and other improvements. In order get access to these in your local
- copy of the repository, you should periodically update it with::
-
- $ cd $LIB_MAPLE_HOME
- $ git pull
-
- The `commits page
- <http://github.com/leaflabs/libmaple/commits/master>`_ for the
- github repository is a good place to watch for bleeding-edge
- updates; our `blog <http://leaflabs.com/blog/>`_ is the place to
- watch for major releases. We keep releases of libmaple and the
- Maple IDE in lockstep, so any IDE updates will have corresponding
- library updates.
+There are two ways to go about it.
+
+If your project is small, all you have to do is replace
+:file:`~/libmaple/main.cpp` with your own code, and you're free to use
+``make`` and ``make install`` in the same way you did when you first
+:ref:`uploaded a program <toolchain-upload>`.
+
+If you have a more complicated project, with its own Makefile and
+multiple source files, or if you're using an IDE that creates its own
+Makefile, you'll probably want to load libmaple from an archive (a
+build-time library, not a DLL).
+
+To create an archive, use the ``library`` Makefile target::
+
+ $ cd ~/libmaple
+ $ make library
+
+This will produce a build-time library in the file
+:file:`~/libmaple/build/libmaple.a`. To use it, make sure that you
+link against that library, and that the libmaple sources are in your
+include path.
+
+At a minimum, your include path should contain the directories
+:file:`~/libmaple/libmaple` and :file:`~/libmaple/wirish/`. If you
+want to use one of the officially supported :ref:`libraries
+<libraries>`, those live under :file:`~/libmaple/libraries/`. The
+main include file for the Wirish library is
+:file:`~/libmaple/wirish/wirish.h`.
+
+Getting Updates
+---------------
+
+We update libmaple fairly frequently with bugfixes and other
+improvements. In order get access to these in your local copy of
+the repository, you should periodically update it with::
+
+ $ cd ~/libmaple
+ $ git pull
+
+We keep releases of libmaple and the Maple IDE in lockstep, so any
+IDE updates will have corresponding library updates. Our `blog
+<http://leaflabs.com/blog/>`_ is the place to watch for major
+releases; an `RSS feed <http://leaflabs.com/blog/feed/>`_ is
+available.
+
+You can sign up for a free `Github <https://github.com/plans>`_
+account and `watch libmaple
+<https://github.com/leaflabs/libmaple/watchers>`_ to receive
+notifications about bleeding-edge development.
.. _toolchain-openocd:
@@ -405,20 +430,25 @@ Debug with OpenOCD
TODO. For now see `this great guide
<http://fun-tech.se/stm32/OpenOCD/index.php>`_ from fun-tech.se, and
-the ``jtag`` Makefile target.
+the ``jtag`` Makefile target. There is also a `JTAG How-To
+<http://wiki.leaflabs.com/index.php?title=Maple_JTAG_How_To>`_ page on
+our `wiki <http://wiki.leaflabs.com>`_ which you may find useful.
.. _toolchain-exuberantly:
Go forth exuberantly!
---------------------
-Let us know what you come up with! Use #leaflabs on Twitter, post in
-the `forum`_, track us down in the real world, whatever. We love
-projects!
+Let us know what you come up with! Use #leaflabs on `Twitter
+<http://twitter.com/leaflabs>`_, post in the `forum`_, join the the
+#leafblowers IRC channel on `freenode
+<http://freenode.net/irc_servers.shtml>`_, whatever. We love projects!
.. rubric:: Footnotes
-.. [#fmacports] Some of these software packages might be available on
- `MacPorts <http://www.macports.org/>`_. The author had some bad
+.. [#fpackman] Some of these software packages might be available on
+ `MacPorts <http://www.macports.org/>`_ or `Homebrew
+ <http://mxcl.github.com/homebrew/>`_. The author had some bad
experiences with MacPorts a few years ago, though, and hasn't
- touched it since. Of course, your mileage may vary.
+ touched a package manager on OS X since. Of course, your mileage
+ may vary.
diff --git a/docs/source/usart.rst b/docs/source/usart.rst
index 3beb3fc..9506cc8 100644
--- a/docs/source/usart.rst
+++ b/docs/source/usart.rst
@@ -4,23 +4,34 @@
USART
=======
-.. contents::
+.. contents:: Contents
:local:
Hardware/Circuit Design
-----------------------
+.. FIXME [0.0.10] UART4 and UART5
+.. FIXME [0.1.0] Maple Native and Mini info and links
+
The Maple has 3 separate USART devices. In the most simple use case,
the RX and TX pins are used to send data at a predetermined baudrate
with the line voltage level relative to ground. Their usage is
documented in the :ref:`Serial Ports <lang-serial>` language reference
-page.
+page. Which pins correspond to the USART TX and RX pins are given on
+your board's silkscreen, and also in the board-specific USART pin maps
+available here:
+
+* :ref:`Maple <maple-usart-map>`
+* :ref:`Maple RET6 Edition <maple-ret6-usart-map>`
+
+If you use a particular serial port, you cannot also use its
+communication pins for other purposes at the same time.
Compatible Devices and Specifications
-------------------------------------
-We have successfully used the Maple USART ports with an FT232R-based
-USB-serial converter at up to 115200 baud; higher speeds should
+We have successfully used the USART ports with an FT232R-based
+USB-serial converter at up to 115200 baud. Higher speeds should
certainly be possible.
Recommended Reading
diff --git a/docs/source/usb.rst b/docs/source/usb.rst
index f502f31..a67d710 100644
--- a/docs/source/usb.rst
+++ b/docs/source/usb.rst
@@ -2,44 +2,47 @@
.. _usb:
-=====
- USB
-=====
+USB
+===
-The Maple STM32 microprocessor includes a dedicated USB peripheral
-which can be configured to act as a general USB slave device with
-transfer rates up to 12Mbps (it unfortunately can't be configured as a
-host or on-the-go device). By default, the peripheral is configured
-for two uses: first, to receive sketch/program uploads from the IDE,
-and second, to emulate a regular serial port for use as a terminal
-(text read/write).
+The STM32 microprocessors include a dedicated USB peripheral which can
+be configured to act as a general USB slave device with transfer rates
+up to 12Mbps. (It unfortunately can't be configured as a host or
+on-the-go device). By default, the peripheral is configured for two
+uses: first, to receive sketch/program uploads from the :ref:`IDE
+<ide>`, and second, to emulate a regular serial port for use as a
+terminal (text read/write).
The emulated terminal is relatively slow and inefficient; it is best
for transferring data at regular serial speeds (kilobaud). Library
support for accessing the emulated terminal is available at the
:ref:`SerialUSB <lang-serialusb>` reference.
-The SerialUSB channel is used as part of the auto-reset feature of the
-IDE to program the board on Maple Rev 3 and Rev 5: a :ref:`magic
-sequence of control line toggles and transmitted data
-<bootloader-rev3>` causes the Maple to reset itself and enter
-bootloader mode. As an unfortunate consequence, the auto-reset will
-not work if the IDE can not access the serial port, either due to a
-conflict with another program (serial monitor) or because the
-interface has been disabled from the Maple side (through
-:ref:`SerialUSB.end() <lang-serialusb-end>`). A solution to the
-second problem is the use of :ref:`perpetual bootloader mode
-<troubleshooting-perpetual-bootloader>`.
+The SerialUSB channel is used with the :ref:`Maple bootloader
+<bootloader>` to reprogram the board: a :ref:`magic sequence of
+control line toggles and transmitted data <bootloader-rev3>` causes a
+Maple to reset itself and enter bootloader mode. As an unfortunate
+consequence, the auto-reset will not work if the IDE can not access
+the serial port, either due to a conflict with another program (serial
+monitor) or because the interface has been disabled from the Maple
+side (through :ref:`SerialUSB.end() <lang-serialusb-end>`). A
+solution to the second problem is the use of :ref:`perpetual
+bootloader mode <troubleshooting-perpetual-bootloader>`.
Recommended Reading
-------------------
-* `USB in a NutShell <http://www.beyondlogic.org/usbnutshell/usb1.htm>`_ overview from Beyond Logic
+* `USB in a Nutshell <http://www.beyondlogic.org/usbnutshell/usb1.shtml>`_, an overview from Beyond Logic
+* `USB made simple <http://www.usbmadesimple.co.uk/>`_, an illustrated series of articles on USB
+* The `USB 2.0 Specification <http://www.usb.org/developers/docs/>`_ (`direct link <http://www.usb.org/developers/docs/usb_20_021411.zip>`_)
+* `Embedded USB - a brief tutorial <http://www.computer-solutions.co.uk/info/Embedded_tutorials/usb_tutorial.htm>`_
* `Wikipedia article on Universal Serial Bus (USB) <http://en.wikipedia.org/wiki/Universal_Serial_Bus>`_
* Linux Kernel documentation for `USB ACM <http://www.kernel.org/doc/Documentation/usb/acm.txt>`_ and `USB Serial <http://www.kernel.org/doc/Documentation/usb/usb-serial.txt>`_
-* STMicro documentation for STM32F103RB microcontroller:
-
- * `Datasheet <http://www.st.com/stonline/products/literature/ds/13587.pdf>`_ (pdf)
- * `Reference Manual <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_ (pdf)
- * `Programming Manual <http://www.st.com/stonline/products/literature/pm/15491.pdf>`_ (pdf; assembly
- language and register reference)
+* ST documentation:
+ * Reference Manual `RM0008
+ <http://www.st.com/stonline/products/literature/rm/13902.pdf>`_
+ (PDF), Chapter 23, "Universal serial bus full-speed device
+ interface"
+ * `Programming Manual
+ <http://www.st.com/stonline/products/literature/pm/15491.pdf>`_
+ (PDF; assembly language and register reference)