BSPACM
20150113
Board Support Package for ARM Cortex-M Microcontrollers
|
Support for peripheral pin multiplexing configuration. More...
#include <bspacm/core.h>
Go to the source code of this file.
Data Structures | |
struct | sBSPACMdeviceTM4Cpinmux |
Typedefs | |
typedef struct sBSPACMdeviceTM4Cpinmux | sBSPACMdeviceTM4Cpinmux |
Functions | |
void | vBSPACMdeviceTM4CpinmuxConfigure (const sBSPACMdeviceTM4Cpinmux *cfgp, int enablep) |
static BSPACM_CORE_INLINE int | iBSPACMdeviceTM4CgpioPortTagFromShift (unsigned int shift) |
static BSPACM_CORE_INLINE int | iBSPACMdeviceTM4CgpioPortShift (void *gpio) |
Support for peripheral pin multiplexing configuration.
TM4C peripherals are mapped to specific GPIO pins; the specific peripheral function supported by a GPIO pin is determined by the value written to the corresponding GPIOPCTL port control register.
The mapping between pin and peripheral function is constrained by the specific device. In some cases the same function can be mapped to multiple pins; in that situation, the desired mapping may be specific to the board or even to the application.
This file declares arrays that provide pin mapping definitions for all peripherals that are used by the application. These mappings are used by the generic TM4C peripheral configuration routines. The application, board, or device should provide definitions for the structure corresponding to each required peripheral in a source file named periph_config.c
with an absolute path set in the make variable PERIPH_CONFIG_SRC
. By default the board-specific periph_config.c
is used.
This material adapted from my Stellarisiti forum post on TM4C123 10.3 Initialization and Configuration steps, repeated here as an easier-to-find reference:
Notes:
TM4C129 devices have extended drive that supports 6mA, 10mA, and 12mA drive strengths, but the DR2R DR4R and DR8R registers are documented to behave the same as the TM4C123 ones. The techniques required to select these strengths are not addressed here; see a TM4C129x datasheet for details.
typedef struct sBSPACMdeviceTM4Cpinmux sBSPACMdeviceTM4Cpinmux |
Core structure associating a GPIO port, pin, and port control function.
|
static |
Determine the bit position for a specific port within a register.
This maps, for example, GPIOK
to 9 because bit 9 of a register like @ RCGCGPIO corresponds to GPIOK
.
gpio | a reference to the port instance; generically a pointer with the bit value of the port base address. You can pass GPIOA or as appropriate. |
gpio
does not appear to be a valid port address.
|
static |
Convert a port instance index (shift) to the letter tag for the port.
This adjustment accounts for GPIOI and GPIOO being skipped in the letter identification, with the corresponding shifts being applied to the next supported port.
shift | the bit index for the port |
void vBSPACMdeviceTM4CpinmuxConfigure | ( | const sBSPACMdeviceTM4Cpinmux * | cfgp, |
int | enablep | ||
) |
Set the AFSEL bit and other bits required to configure a pin for a peripheral function according to *cfgp
, or when disabled to be treated as a GPIO input.
Where cfgp->pctl is not zero (pin provides a peripheral function): Disabling the device disables the pin entirely (clears the DEN bit).
Where cfg->pctl
is zero (pin provides GPIO): Enabling configures the pin for output; disabling configures the pin for input. This API is inadequate for full control as lacks the ability to set GPIO output initial state, or GPIO input pullup/pulldown state.
cfgp | pointer to the configuration structure. If cfgp->port is null, no configuration will be performed. |
enablep | nonzero if the pin is to be configured based on cfgp->pctl (it will be a GPIO output if cfgp->pctl is zero). If enablep is zero the pin will be disabled (or configured as a GPIO input if cfgp->pctl is zero). |