aboutsummaryrefslogtreecommitdiffstats
path: root/source/lang/api
diff options
context:
space:
mode:
Diffstat (limited to 'source/lang/api')
-rw-r--r--source/lang/api/abs.rst3
-rw-r--r--source/lang/api/analogread.rst65
-rw-r--r--source/lang/api/analogwrite.rst23
-rw-r--r--source/lang/api/attachinterrupt.rst57
-rw-r--r--source/lang/api/bit.rst12
-rw-r--r--source/lang/api/bitclear.rst13
-rw-r--r--source/lang/api/bitread.rst11
-rw-r--r--source/lang/api/bitset.rst9
-rw-r--r--source/lang/api/bitwrite.rst7
-rw-r--r--source/lang/api/board-values.rst5
-rw-r--r--source/lang/api/cc-attribution.txt9
-rw-r--r--source/lang/api/constants.rst2
-rw-r--r--source/lang/api/constrain.rst5
-rw-r--r--source/lang/api/cos.rst6
-rw-r--r--source/lang/api/delay.rst6
-rw-r--r--source/lang/api/delaymicroseconds.rst11
-rw-r--r--source/lang/api/detachinterrupt.rst8
-rw-r--r--source/lang/api/digitalread.rst39
-rw-r--r--source/lang/api/digitalwrite.rst39
-rw-r--r--source/lang/api/hardwaretimer.rst95
-rw-r--r--source/lang/api/highbyte.rst6
-rw-r--r--source/lang/api/loop.rst3
-rw-r--r--source/lang/api/lowbyte.rst2
-rw-r--r--source/lang/api/map.rst2
-rw-r--r--source/lang/api/max.rst5
-rw-r--r--source/lang/api/micros.rst2
-rw-r--r--source/lang/api/millis.rst2
-rw-r--r--source/lang/api/min.rst3
-rw-r--r--source/lang/api/pinmode.rst8
-rw-r--r--source/lang/api/pow.rst5
-rw-r--r--source/lang/api/pwmwrite.rst14
-rw-r--r--source/lang/api/random.rst6
-rw-r--r--source/lang/api/randomseed.rst2
-rw-r--r--source/lang/api/serial.rst50
-rw-r--r--source/lang/api/setup.rst2
-rw-r--r--source/lang/api/sin.rst3
-rw-r--r--source/lang/api/sq.rst3
-rw-r--r--source/lang/api/tan.rst3
-rw-r--r--source/lang/api/volatile.rst8
39 files changed, 251 insertions, 303 deletions
diff --git a/source/lang/api/abs.rst b/source/lang/api/abs.rst
index 0cc6c23..d9f1ca3 100644
--- a/source/lang/api/abs.rst
+++ b/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/source/lang/api/analogread.rst b/source/lang/api/analogread.rst
index 7099b69..6665a94 100644
--- a/source/lang/api/analogread.rst
+++ b/source/lang/api/analogread.rst
@@ -20,32 +20,33 @@ 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
--------------------
-.. FIXME generalize Maple-specific information
-
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
----
@@ -55,7 +56,6 @@ 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
-------
@@ -78,7 +78,6 @@ Example
// a serial monitor
}
-
Arduino Compatibility
---------------------
@@ -100,27 +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 Mention Native can do analogReference(), when it's time
+.. 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, `operational amplifiers
-<http://en.wikipedia.org/wiki/Operational_amplifier>`_ 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 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/source/lang/api/analogwrite.rst b/source/lang/api/analogwrite.rst
index 9147b96..e789305 100644
--- a/source/lang/api/analogwrite.rst
+++ b/source/lang/api/analogwrite.rst
@@ -65,12 +65,12 @@ 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
+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-attachinterrupt>` the timer controls) will
likely need to be modified as well.
@@ -140,9 +140,9 @@ 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). Let's say it's ``Timern``\
+ , where ``n`` is some number 1, 2, 3, or 4.
2. Call ``Timern.setPeriod(2041)``\ . This will set the timer's
period to approximately 2041 microseconds, which is a frequency of
@@ -154,7 +154,7 @@ timer. The important examples are :ref:`timer interrupts
<lang-hardwaretimer-attachinterrupt>` and :ref:`PWM
<timers-pwm-conflicts>`\ .
-See also
+See Also
--------
- :ref:`Maple PWM tutorial <pwm>`
@@ -169,5 +169,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/source/lang/api/attachinterrupt.rst b/source/lang/api/attachinterrupt.rst
index 7c5a6c7..39902ac 100644
--- a/source/lang/api/attachinterrupt.rst
+++ b/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/source/lang/api/bit.rst b/source/lang/api/bit.rst
index dd5c050..3df042c 100644
--- a/source/lang/api/bit.rst
+++ b/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/source/lang/api/bitclear.rst b/source/lang/api/bitclear.rst
index 941f912..f487059 100644
--- a/source/lang/api/bitclear.rst
+++ b/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/source/lang/api/bitread.rst b/source/lang/api/bitread.rst
index 46b4478..fd9fbbe 100644
--- a/source/lang/api/bitread.rst
+++ b/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/source/lang/api/bitset.rst b/source/lang/api/bitset.rst
index ccd76de..83ab5f8 100644
--- a/source/lang/api/bitset.rst
+++ b/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/source/lang/api/bitwrite.rst b/source/lang/api/bitwrite.rst
index b3feff2..6106545 100644
--- a/source/lang/api/bitwrite.rst
+++ b/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/source/lang/api/board-values.rst b/source/lang/api/board-values.rst
index e274163..05e3837 100644
--- a/source/lang/api/board-values.rst
+++ b/source/lang/api/board-values.rst
@@ -12,6 +12,9 @@ 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:
@@ -111,8 +114,6 @@ 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.
-.. TODO [0.1.0] links to board-specific hardware information
-
- ``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
diff --git a/source/lang/api/cc-attribution.txt b/source/lang/api/cc-attribution.txt
deleted file mode 100644
index e100140..0000000
--- a/source/lang/api/cc-attribution.txt
+++ /dev/null
@@ -1,9 +0,0 @@
-.. Included in all this directory's 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
- 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/source/lang/api/constants.rst b/source/lang/api/constants.rst
index c5a7c0c..00c1a5c 100644
--- a/source/lang/api/constants.rst
+++ b/source/lang/api/constants.rst
@@ -320,4 +320,4 @@ See Also
- :ref:`double <lang-double>`
- :ref:`Board-Specific Values <lang-board-values>`
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/source/lang/api/constrain.rst b/source/lang/api/constrain.rst
index d19b61c..28af1e3 100644
--- a/source/lang/api/constrain.rst
+++ b/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/source/lang/api/cos.rst b/source/lang/api/cos.rst
index 3fbb0af..c340f09 100644
--- a/source/lang/api/cos.rst
+++ b/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/source/lang/api/delay.rst b/source/lang/api/delay.rst
index 90ca268..9ef06a0 100644
--- a/source/lang/api/delay.rst
+++ b/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/source/lang/api/delaymicroseconds.rst b/source/lang/api/delaymicroseconds.rst
index 24a8286..7078660 100644
--- a/source/lang/api/delaymicroseconds.rst
+++ b/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/source/lang/api/detachinterrupt.rst b/source/lang/api/detachinterrupt.rst
index 41642a7..82ce974 100644
--- a/source/lang/api/detachinterrupt.rst
+++ b/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/source/lang/api/digitalread.rst b/source/lang/api/digitalread.rst
index 3502587..ccf4a4c 100644
--- a/source/lang/api/digitalread.rst
+++ b/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/source/lang/api/digitalwrite.rst b/source/lang/api/digitalwrite.rst
index 6124d5f..376cbc3 100644
--- a/source/lang/api/digitalwrite.rst
+++ b/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/source/lang/api/hardwaretimer.rst b/source/lang/api/hardwaretimer.rst
index 3f086ca..526beb6 100644
--- a/source/lang/api/hardwaretimer.rst
+++ b/source/lang/api/hardwaretimer.rst
@@ -10,8 +10,7 @@ built-in timer peripherals. More information on these peripherals
(including code examples) is available in the :ref:`timers reference
<timers>`.
-.. FIXME update HardwareTimer documentation after redoing it in terms
-.. of the new timer interface.
+.. FIXME [0.0.10] Updated HardwareTimer documentation, with deprecation
.. warning:: This class has been deprecated. It is not available in
the current build.
@@ -27,8 +26,7 @@ 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)``.
-.. TODO add code examples that people can copy and paste in case
-.. they're unfamiliar with namespace syntax
+.. TODO add tutorial-style examples
.. cpp:class:: HardwareTimer
@@ -92,9 +90,8 @@ For example, to set the prescale factor on timer 1 to 5, call
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.
+ like to set. Refer to your board's :ref:`master pin map
+ <gpio-pin-maps>` to match up timer channels and pin numbers.
.. cpp:function:: void HardwareTimer::setChannel1Mode(TimerMode mode)
@@ -377,3 +374,87 @@ different.
Other Functions
^^^^^^^^^^^^^^^
.. doxygenfunction:: getTimer
+
+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++;
+ }
diff --git a/source/lang/api/highbyte.rst b/source/lang/api/highbyte.rst
index 50a1fa6..4cb6f9b 100644
--- a/source/lang/api/highbyte.rst
+++ b/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/source/lang/api/loop.rst b/source/lang/api/loop.rst
index d8f6183..c2a5097 100644
--- a/source/lang/api/loop.rst
+++ b/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/source/lang/api/lowbyte.rst b/source/lang/api/lowbyte.rst
index 58e622f..c513711 100644
--- a/source/lang/api/lowbyte.rst
+++ b/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/source/lang/api/map.rst b/source/lang/api/map.rst
index 79122b3..69661a0 100644
--- a/source/lang/api/map.rst
+++ b/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/source/lang/api/max.rst b/source/lang/api/max.rst
index d38eebe..d356f08 100644
--- a/source/lang/api/max.rst
+++ b/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/source/lang/api/micros.rst b/source/lang/api/micros.rst
index f12976b..de85303 100644
--- a/source/lang/api/micros.rst
+++ b/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/source/lang/api/millis.rst b/source/lang/api/millis.rst
index 0288c56..db0531c 100644
--- a/source/lang/api/millis.rst
+++ b/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/source/lang/api/min.rst b/source/lang/api/min.rst
index 1245f6f..3307105 100644
--- a/source/lang/api/min.rst
+++ b/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/source/lang/api/pinmode.rst b/source/lang/api/pinmode.rst
index 03cbcfa..8cee3e5 100644
--- a/source/lang/api/pinmode.rst
+++ b/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/source/lang/api/pow.rst b/source/lang/api/pow.rst
index 4280400..219a866 100644
--- a/source/lang/api/pow.rst
+++ b/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/source/lang/api/pwmwrite.rst b/source/lang/api/pwmwrite.rst
index cea602b..5cc112e 100644
--- a/source/lang/api/pwmwrite.rst
+++ b/source/lang/api/pwmwrite.rst
@@ -11,10 +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.
-.. FIXME board-specific information
-
-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
@@ -54,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/source/lang/api/random.rst b/source/lang/api/random.rst
index dd8871d..9875ee6 100644
--- a/source/lang/api/random.rst
+++ b/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/source/lang/api/randomseed.rst b/source/lang/api/randomseed.rst
index d0a15b7..ca7b75f 100644
--- a/source/lang/api/randomseed.rst
+++ b/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/source/lang/api/serial.rst b/source/lang/api/serial.rst
index 417063d..0821f43 100644
--- a/source/lang/api/serial.rst
+++ b/source/lang/api/serial.rst
@@ -12,49 +12,20 @@ devices.
Introduction
------------
-.. FIXME [Maple-specific values]
-.. FIXME [0.0.10] Serial4, Serial5 updates for high-density devices
+.. 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:
-
-.. 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``,
@@ -209,9 +180,10 @@ 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 adapter.
+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.
.. FIXME [0.1.0] port these examples over
@@ -226,4 +198,4 @@ personal computer, you will need an additional USB-to-serial adapter.
.. - `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/source/lang/api/setup.rst b/source/lang/api/setup.rst
index 837ddd6..1e8e3b8 100644
--- a/source/lang/api/setup.rst
+++ b/source/lang/api/setup.rst
@@ -26,4 +26,4 @@ Example
// ...
}
-.. include:: cc-attribution.txt
+.. include:: /arduino-cc-attribution.txt
diff --git a/source/lang/api/sin.rst b/source/lang/api/sin.rst
index 398b8f3..3e28c0b 100644
--- a/source/lang/api/sin.rst
+++ b/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/source/lang/api/sq.rst b/source/lang/api/sq.rst
index bd32648..96724d3 100644
--- a/source/lang/api/sq.rst
+++ b/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/source/lang/api/tan.rst b/source/lang/api/tan.rst
index 4bbe0db..b1aed31 100644
--- a/source/lang/api/tan.rst
+++ b/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/source/lang/api/volatile.rst b/source/lang/api/volatile.rst
index 276bb6a..1b72897 100644
--- a/source/lang/api/volatile.rst
+++ b/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