![]() ![]() More details on the code and insights on how the different modules of RIOT are used in this application can be found on the GITHUB repository.I have to admit that I am pretty ‘oldskool’ when it comes to programming my toys microcontroller based systems: I like the C programming language and for serious embedded programming, I am still waiting to be convinced that there is anything better. Here is what we should expected as output: main(): This is RIOT! (Version: 2021.04-devel-200-g67e5a) RIOT led_ext application Control an external LED using RIOT GPIO module. To compile the application, program the STM32 board and connect through the USB to receive debug information, we execute the following command: make BOARD=nucleo-f401re flash term Within the main.c file we need to use the gpio_init method to signal that pin PB5 should be initialized for output ( GPIO_OUT ) as follows: gpio_t pin_out = GPIO_PIN(PORT_B, 5) if (gpio_init(pin_out, GPIO_OUT)) Ĭompiling the code and flushing the device The GPIO interface provides capabilities to initialize a pin as output-, input- and interrupt pin. The figure below indicates that the D4 pin is connected to the PB port of the F401RE MCU at pin number 5. To access a pin, the _GPIO_PIN(port, pin) macro_ should be used.įor the case of the STM32 Nucleo board used here, the mapping of the ARDUINO® Uno V3 connectivity headers with the MCU's internal pins can be found in the user manual UM1724 of the STM32 Nucleo F401RE board. Each of these ports is then assigned a number of pins, often 8, 16, or 32. All modern micro controllers organize their GPIOs in some form of ports, often named 'PA', 'PB', 'PC'., or 'P0', 'P1', 'P2'., or similar. The GPIO interface is intentionally designed to be as simple as possible, to allow for easy implementation and maximum portability. #include #include "periph/gpio.h" #include "xtimer.h" We also include stdio.h for printing debug messages. ![]() The next step is to create the main.c file where the main code of the application is defined.įirst we include the headers of the GPIO peripheral and the XTIMER module. More details can be found on the RIOT documentation. The above are enough to setup a new application. For this reason we will use the RIOT xtimer module that provides a high-level API to multiplex the available timers. We wish to make the LED blink periodically. ![]() Within the Makefile we also define that the application will use the RIOT low-level GPIO peripheral: USEMODULE += periph_gpio # A simple name of the application APPLICATION = ledext # This has to be the absolute path to the RIOT base directory: RIOTBASE ?= $(CURDIR)/././RIOT include $(RIOTBASE)/Makefile.include
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |