Koduino
|
The STM32 series allows multiplexing its pins for various purposes, but the procedure for doing so requires selecting a special "alternate function" (AF) number for the pin. This number has to be looked up from the datasheet.
There are some default assignments for all the pins which are linked to below for different variants:
However, other assignments are possible, and the function pinRemap() can be called to do this. A common use case is changing the timer a pin is connected to (see example below).
This file is part of koduino https://github.com/avikde/koduino
This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along with this library; if not, see http://www.gnu.org/licenses/.
Functions | |
void | pinMode (uint8_t pin, WiringPinMode mode) |
Configure a pin before using it. More... | |
void | pinRemap (uint8_t pin, uint8_t altFunc, uint8_t timer, uint8_t channel) |
Low-level function to reassign AF number of timer assigned to a pin. The default assignments are here. More... | |
void | pinModeAlt (uint8_t pin, uint32_t oType, uint32_t pull, uint8_t altFunc) |
Low-level function to configure the pin for a specific alternate function. The user should not need to call this directly. More... | |
void pinMode | ( | uint8_t | pin, |
WiringPinMode | mode | ||
) |
Configure a pin before using it.
This function behaves like the Arduino one, but does more in some cases.
In a few situations, this MUST be called in this library when it is not necessary to in Arduino. For instance, a timer pin must be configured for PWM using pinMode(pin, PWM) before calling analogWrite() on that pin.
pin | Pin to configure |
mode | One of #WiringPinMode |
void pinModeAlt | ( | uint8_t | pin, |
uint32_t | oType, | ||
uint32_t | pull, | ||
uint8_t | altFunc | ||
) |
Low-level function to configure the pin for a specific alternate function. The user should not need to call this directly.
pin | Pin to configure |
oType | One of GPIO_OType_PP , GPIO_OType_OD |
pull | One of GPIO_PuPd_NOPULL , GPIO_PuPd_UP , GPIO_PuPd_DOWN |
altFunc | AF number between 0-15 (see datasheet) |
void pinRemap | ( | uint8_t | pin, |
uint8_t | altFunc, | ||
uint8_t | timer, | ||
uint8_t | channel | ||
) |
Low-level function to reassign AF number of timer assigned to a pin. The default assignments are here.
pin | |
altFunc | New AF number (0-15) |
timer | New timer (see variant.cpp for the variant you are using to see available timers) |
channel | Timer channel (1-4) |