GPIO tutorial

From Miosix Wiki
Revision as of 13:16, 22 April 2014 by Fede.tft (talk | contribs)
Jump to navigation Jump to search

Include statements and namespace required to use this library

#include <miosix.h>
using namespace miosix;

This is a C++ library, it cannot be used from a C source file.

A GPIO or general purpose input-output is a software-controllable pin of a microcontroller. To be able to control multiple GPIOs at the same time, most microcontrollers group GPIOs in ports, so GPIOs are specified by a port name, and a pin number within the port. The STM32 use letters to identify ports, so the GPIO 0 of port A is called PA0. The GPIO port and number are often specified at the pin headers on development boards such as the STM32F4 Discovery, in order to make it easy to connect wires to the correct GPIO. On the contrary, NXP uses numbers also for the ports, so the GPIO 0 of port 1 is called P1.0.

A GPIO in Miosix is accessed using a C++ template class, the rationale behind this choice can be found in this article, but in short it provides both optimal performance and a high-level API.