Skip to content

Commit bbac9d4

Browse files
Add full-fledged documentation, update I2S API (#80)
Last step before 1.0. Docs for readthedocs.io. Update the I2S API to mimic others where `setXXX` is called before `begin()` to set the GPIO pins used.
1 parent 84a9273 commit bbac9d4

File tree

24 files changed

+1420
-4
lines changed

24 files changed

+1420
-4
lines changed

docs/Makefile

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Minimal makefile for Sphinx documentation
2+
#
3+
4+
# You can set these variables from the command line.
5+
SPHINXOPTS =
6+
SPHINXBUILD = sphinx-build
7+
SPHINXPROJ = Arduino-Pico
8+
SOURCEDIR = .
9+
BUILDDIR = _build
10+
11+
# Put it first so that "make" without argument is like "make help".
12+
help:
13+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
14+
15+
.PHONY: help Makefile
16+
17+
# Catch-all target: route all unknown targets to Sphinx using the new
18+
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
19+
%: Makefile
20+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

docs/analog.rst

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
Analog I/O
2+
==========
3+
4+
Analog Input
5+
------------
6+
For analog inputs, the RP2040 device has a 12-bit, 4-channel ADC +
7+
temperature sensor available on a fixed set of pins (A0...A3).
8+
The standard Arduino calls can be used to read their values (with
9+
3.3V nominally reading as 4095).
10+
11+
int analogRead(pin_size_t pin = A0..A3)
12+
---------------------------------------
13+
Returns a value from 0...4095 correspionding to the ADC reading
14+
of the specific pin.
15+
16+
float analogReadTemp()
17+
----------------------
18+
Returns the temperature, in Celsius, of the onboard thermal sensor.
19+
This reading is not exceedingly accurate and of relatively low
20+
resolution, so it is not a replacement for an external temperature
21+
sensor in many cases.
22+
23+
Analog Outputs
24+
--------------
25+
The RP2040 does not have any onboard DACs, so analog outputs are
26+
simulated using the standard method of using pulse width modulation
27+
(PWM) using the RP20400's hardware PWM units.
28+
29+
While up to 16 PWM channels can be generated, they are not independent
30+
and there are significant restrictions as to allowed pins in parallel.
31+
See the [RP2040 datasheet](https://datasheets.raspberrypi.org/rp2040/rp2040-datasheet.pdf)
32+
for full details.
33+
34+
void analogWriteFreq(uint32_t freq)
35+
-----------------------------------
36+
Sets the master PWM frequency used (i.e. how often the PWM output cycles).
37+
From 100Hz to 60KHz are supported.
38+
}
39+
40+
void analogWriteRange(uint32_t range) and analogWriteResolution(int res)
41+
------------------------------------------------------------------------
42+
These calls set the maximum PWM value (i.e. writing this value will result in
43+
a PWM duty cycle of 100%)/ either explicitly (range) or as a power-of-two
44+
(res). A range of 16 to 65535 is supported.
45+
46+
void analogWrite(pin_size_t pin, int val)
47+
-----------------------------------------
48+
Writes a PWM value to a specific pin. The PWM machine is enabled and set to
49+
the requested frequency and scale, and the output is generated. This will
50+
continue until a `digitalWrite` or other digital output is performed.

docs/conf.py

Lines changed: 168 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,168 @@
1+
# -*- coding: utf-8 -*-
2+
#
3+
# Arduino-Pico documentation build configuration file, created by
4+
# sphinx-quickstart on Sat Apr 3 15:02:21 2021.
5+
#
6+
# This file is execfile()d with the current directory set to its
7+
# containing dir.
8+
#
9+
# Note that not all possible configuration values are present in this
10+
# autogenerated file.
11+
#
12+
# All configuration values have a default; values that are commented out
13+
# serve to show the default.
14+
15+
# If extensions (or modules to document with autodoc) are in another directory,
16+
# add these directories to sys.path here. If the directory is relative to the
17+
# documentation root, use os.path.abspath to make it absolute, like shown here.
18+
#
19+
# import os
20+
# import sys
21+
# sys.path.insert(0, os.path.abspath('.'))
22+
23+
24+
# -- General configuration ------------------------------------------------
25+
26+
# If your documentation needs a minimal Sphinx version, state it here.
27+
#
28+
# needs_sphinx = '1.0'
29+
30+
# Add any Sphinx extension module names here, as strings. They can be
31+
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
32+
# ones.
33+
extensions = []
34+
35+
# Add any paths that contain templates here, relative to this directory.
36+
templates_path = ['_templates']
37+
38+
# The suffix(es) of source filenames.
39+
# You can specify multiple suffix as a list of string:
40+
#
41+
# source_suffix = ['.rst', '.md']
42+
source_suffix = '.rst'
43+
44+
# The master toctree document.
45+
master_doc = 'index'
46+
47+
# General information about the project.
48+
project = u'Arduino-Pico'
49+
copyright = u'2021, Earle F. Philhower, III'
50+
author = u'Earle F. Philhower, III'
51+
52+
# The version info for the project you're documenting, acts as replacement for
53+
# |version| and |release|, also used in various other places throughout the
54+
# built documents.
55+
#
56+
# The short X.Y version.
57+
version = u'1.0.0'
58+
# The full version, including alpha/beta/rc tags.
59+
release = u'1.0.0'
60+
61+
# The language for content autogenerated by Sphinx. Refer to documentation
62+
# for a list of supported languages.
63+
#
64+
# This is also used if you do content translation via gettext catalogs.
65+
# Usually you set "language" from the command line for these cases.
66+
language = None
67+
68+
# List of patterns, relative to source directory, that match files and
69+
# directories to ignore when looking for source files.
70+
# This patterns also effect to html_static_path and html_extra_path
71+
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']
72+
73+
# The name of the Pygments (syntax highlighting) style to use.
74+
pygments_style = 'sphinx'
75+
76+
# If true, `todo` and `todoList` produce output, else they produce nothing.
77+
todo_include_todos = False
78+
79+
80+
# -- Options for HTML output ----------------------------------------------
81+
82+
# The theme to use for HTML and HTML Help pages. See the documentation for
83+
# a list of builtin themes.
84+
#
85+
html_theme = 'alabaster'
86+
87+
# Theme options are theme-specific and customize the look and feel of a theme
88+
# further. For a list of options available for each theme, see the
89+
# documentation.
90+
#
91+
# html_theme_options = {}
92+
93+
# Add any paths that contain custom static files (such as style sheets) here,
94+
# relative to this directory. They are copied after the builtin static files,
95+
# so a file named "default.css" will overwrite the builtin "default.css".
96+
html_static_path = ['_static']
97+
98+
# Custom sidebar templates, must be a dictionary that maps document names
99+
# to template names.
100+
#
101+
# This is required for the alabaster theme
102+
# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars
103+
html_sidebars = {
104+
'**': [
105+
'relations.html', # needs 'show_related': True theme option to display
106+
'searchbox.html',
107+
]
108+
}
109+
110+
111+
# -- Options for HTMLHelp output ------------------------------------------
112+
113+
# Output file base name for HTML help builder.
114+
htmlhelp_basename = 'Arduino-Picodoc'
115+
116+
117+
# -- Options for LaTeX output ---------------------------------------------
118+
119+
latex_elements = {
120+
# The paper size ('letterpaper' or 'a4paper').
121+
#
122+
# 'papersize': 'letterpaper',
123+
124+
# The font size ('10pt', '11pt' or '12pt').
125+
#
126+
# 'pointsize': '10pt',
127+
128+
# Additional stuff for the LaTeX preamble.
129+
#
130+
# 'preamble': '',
131+
132+
# Latex figure (float) alignment
133+
#
134+
# 'figure_align': 'htbp',
135+
}
136+
137+
# Grouping the document tree into LaTeX files. List of tuples
138+
# (source start file, target name, title,
139+
# author, documentclass [howto, manual, or own class]).
140+
latex_documents = [
141+
(master_doc, 'Arduino-Pico.tex', u'Arduino-Pico Documentation',
142+
u'Earle F. Philhower, III', 'manual'),
143+
]
144+
145+
146+
# -- Options for manual page output ---------------------------------------
147+
148+
# One entry per manual page. List of tuples
149+
# (source start file, name, description, authors, manual section).
150+
man_pages = [
151+
(master_doc, 'arduino-pico', u'Arduino-Pico Documentation',
152+
[author], 1)
153+
]
154+
155+
156+
# -- Options for Texinfo output -------------------------------------------
157+
158+
# Grouping the document tree into Texinfo files. List of tuples
159+
# (source start file, target name, title, author,
160+
# dir menu entry, description, category)
161+
texinfo_documents = [
162+
(master_doc, 'Arduino-Pico', u'Arduino-Pico Documentation',
163+
author, 'Arduino-Pico', 'One line description of project.',
164+
'Miscellaneous'),
165+
]
166+
167+
168+

docs/digital.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
Digital I/O
2+
===========
3+
4+
The Raspberry Pi Pico RP2040 chip supports up to 30 digital I/O pins,
5+
however not all boards provide access to all pins.
6+

docs/eeprom.rst

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
EEPROM Library
2+
==============
3+
4+
While the Raspberry Pi Pico RP2040 does not come with an EEPROM onboard, we
5+
simulate one by using a single 4K chunk of flash at the end of flash space.
6+
7+
**Note that this is a simulated EEPROM and will only support the numeber of
8+
writes as the onboard flash chip, not the 100,000 or so of a real EEPROM.**
9+
Therefore, do not frequently update the EEPROM or you may prematurely wear
10+
out the flash.
11+
12+
EEPROM.begin(size=256...4096)
13+
-----------------------------
14+
Call before the first use of the EEPROM data for read or write. It makes a
15+
copy of the emulated EEPROM sector in RAM to allow random update and access.
16+
17+
EEPROM.read(addr), EEPROM[addr]
18+
-------------------------------
19+
Returns the data at a specific offset in the EEPROM. See `EEPROM.get` later
20+
for a more
21+
22+
EEPROM.write(addr, data), EEPROM[addr] = data
23+
---------------------------------------------
24+
Writes a byte of data at the offset specified. Not persisted to flash until
25+
`EEPROM.commit()` is called.
26+
27+
EEPROM.commit()
28+
---------------
29+
Writes the updated data to flash, so next reboot it will be readable.
30+
31+
EEPROM.end()
32+
------------
33+
`EEPROM.commit()` and frees all memory used. Need to call `EEPROM.begin()`
34+
before the EEPROM can be used again.
35+
36+
EEPROM.get(addr, val)
37+
---------------------
38+
Copies the (potentially multi-byte) data in EEPROM at the specific byte
39+
offset into the returned value. Useful for reading structures from EEPROM.
40+
41+
EEPROM.put(addr, val)
42+
---------------------
43+
Copies the (potentially multi-byte) value into EEPROM a the byte offset
44+
supplied. Useful for storing `struct` in EEPROM. Note that any pointers
45+
inside a written structure will not be valid, and that most C++ objects
46+
like `String` cannot be written to EEPROM this way because of it.
47+
48+
EEPROM.length()
49+
---------------
50+
Returns the length of the EEPROM (i.e. the value specified in
51+
`EEPROM.begin()` ).
52+
53+
EEPROM Examples
54+
---------------
55+
Three EEPROM [examples](https://github.com/earlephilhower/arduino-pico/tree/master/libraries/EEPROM) are included.

0 commit comments

Comments
 (0)