Skip to content

[DOCS] Writing a new Arduino documentation about GPIO #5894

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 16 commits into from
Dec 14, 2021
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added docs/source/_static/Output.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/source/_static/PullUp.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
112 changes: 112 additions & 0 deletions docs/source/api/gpio.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,115 @@
####
GPIO
####
About
-----

GPIO (General Purpouse Input Output) is peripheral responsible to controls reception and
deliver digital signals by means of easy interface acess with world, physical pins.

A fetures of this peripheral relates with largely quantity pins available on chip, also being
this programmable and configurable. An example of interaction happen when turn on LED or pulse control a button.

.. note::
There are some GPIOs with special functions and not all the is accessible in all development board. For more information strong suggest acess datasheet.

GPIOs Configuration
*******************

The GPIOs used two different configuration :

- **Input**

- Receive external digital signals


- **Output**

- Send internal digital signals


Arduino - ESP32 API
-------------------------
Here are description of frequently used functions for GPIOs

pinMode
***********

Initial configuration for use pin with input or output.


.. code-block:: arduino

void piMode(uint8_t pin, uint8_t mode);

* ``pin`` select GPIO
* ``mode`` sets mode operation (``INPUT``, ``OUTPUT`` or ``INPUT_PULLUP``, ).

digitalWrite
*************

Write digital signal on pin.

.. code-block:: arduino

void digitalWrite(uint8_t pin, uint8_t val);

* ``pin`` select a GPIO
* ``val`` logic level write on pin (``HIGH`` or ``LOW``)

.. warning::
If pin not set to ``OUTPUT`` on pinMode(), may do not work correct.

digitalRead
***********

Read digital pin signal picked

.. code-block:: arduino

int digitalRead(uint8_t pin);

* ``pin`` select GPIO

This function will be return logical state ``HIGH`` or ``LOW``

Simulation
----------

This application helps understand concepts using dynamic simulation provide by `Wokwi`_, test the gpio code and start.

.. raw:: html

<iframe src="https://wokwi.com/arduino/projects/314835473253007936" width="100%" height="400" border="0"></iframe>


.. _gpio_example_code:

Example Code
-------------

Here is full code for example application of GPIOs

.. code-block::

#define LED 12
#define BUTTON 2

uint8_t stateLED = 0;

void setup() {
pinMode(LED, OUTPUT);
pinMode(BUTTON,INPUT_PULLUP);
}

void loop() {

if(!digitalRead(BUTTON)){
stateLED = stateLED^1;
digitalWrite(LED,stateLED);
}
}




8 changes: 3 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,18 +29,16 @@
# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx_copybutton'
]
extensions = [ ]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The suffix(es) of source filenames.
# You can specify multiple suffix as a list of string:
#
# source_suffix = ['.rst', '.md']
source_suffix = '.rst'
source_suffix = ['.rst', '.md']
#source_suffix = '.rst'

# The master toctree document.
master_doc = 'index'
Expand Down