Multiple Pin Configurations

The FSP allows a user to create multiple pin configurations in the same project, and it also allows the application firmware to switch between these pin configurations during runtime.  With this, it is possible to change the peripheral setting of a pin or enable/disable pins entirely without having to manually reconfigure each pin.  One example of using multiple pin configurations is an application that goes into sleep mode to save power consumption.  The application can be setup with two pin configurations:  one while running normally (high-power) and another when in sleep mode (low-power). 

The FSP starts with a default pin configuration when the RA project is created, so a second pin configuration will need to be created.  The Pins tab of the FSP configuration viewer will allow you to create and modify different pin configurations.   Note the text box next to the “Generate data” checkbox.  This will be the name of the data structure which contains the pin configuration for use in the application code.

In the Pins tab, click the “Manage configurations…” link.

Here you can create an entirely new pin configuration or copy an existing one as a starting point.  In this example, the second pin configuration has most of the pins disabled, with one exception being the IRQ pin used to wake the MCU.  In the image below, you can see that the SPI0 pins that were enabled in the original configuration are now disabled.  Note that this configuration is called g_bsp_pin_cfg_lp while the original configuration is called g_bsp_pin_cfg_hp.

Depending on application requirements and where needed, you can call R_IOPORT_PinsCfg() to change the active pin configuration of the MCU.