Chris,
I'm trying to follow your suggestions, but I'm getting confused. Maybe taking a step back will help (also, I am using the K22F):
The built-in gpio_pins.h contains the following:
enum _gpio_pins
{
kGpioLED1 = GPIO_MAKE_PIN(HW_GPIOA, 1), /* Red LED */
kGpioLED2 = GPIO_MAKE_PIN(HW_GPIOA, 2), /* Green LED */
kGpioLED3 = GPIO_MAKE_PIN(HW_GPIOD, 5), /* FRDM-K64F120M LED3 (Blue LED)*/
kGpioSW1 = GPIO_MAKE_PIN(HW_GPIOC, 1), /* FRDM-K22F120M SW2 */
kGpioSW2 = GPIO_MAKE_PIN(HW_GPIOB, 17), /* FRDM-K22F120M SW3 */
kGpioAccelINT1 = GPIO_MAKE_PIN(HW_GPIOD, 0), /* FRDM-K22F120M MMA8451Q/FXOS87000CB INT1 */
kGpioAccelINT2 = GPIO_MAKE_PIN(HW_GPIOD, 1), /* FRDM-K22F120M MMA8451Q/FXOS87000CB INT2 */
kGpioUsbFLGA = GPIO_MAKE_PIN(HW_GPIOC, 0), /* FRDM-K22F120M USB FLGA */
kGpioUartDemoTX = GPIO_MAKE_PIN(HW_GPIOE, 0), /* FRDM-K22F120M UART 1 TX pin (OpenSDA port) */
kGpioUartDemoRX = GPIO_MAKE_PIN(HW_GPIOE, 1), /* FRDM-K22F120M UART 1 RX pin (OpenSDA port) */
kGpioI2Caddr1 = GPIO_MAKE_PIN(HW_GPIOC, 3), /* FRDM-K22F120M I2C address pin */
kGpioI2Caddr2 = GPIO_MAKE_PIN(HW_GPIOC, 6), /* FRDM-K22F120M I2C address pin */
kGpioSpi0Cs0 = GPIO_MAKE_PIN(HW_GPIOD, 0), /* FRDM-K22F120M SPI0 CS0 pin */
kGpioSpi0Cs1 = GPIO_MAKE_PIN(HW_GPIOD, 4), /* FRDM-K22F120M SPI0 CS1 pin */
kGpioSofOut = GPIO_MAKE_PIN(HW_GPIOC, 7), /* FRDM-K22F120M USB SOF OUT pin */
kGpioRFCE = GPIO_MAKE_PIN(HW_GPIOC, 11), /* FRDM-K22F120M RF CE pin */
kGpioRFIRQ = GPIO_MAKE_PIN(HW_GPIOD, 0) /* FRDM-K22F120M RF IRQ pin */
};
extern gpio_input_pin_user_config_t switchPins[];
extern gpio_input_pin_user_config_t accelIntPins[];
extern gpio_input_pin_user_config_t i2cAddressPins[];
extern gpio_output_pin_user_config_t gpioUartDemoTxPin[];
extern gpio_input_pin_user_config_t gpioUartDemoRxPin[];
extern gpio_output_pin_user_config_t ledPins[];
extern gpio_output_pin_user_config_t spiCsPin[];
extern gpio_output_pin_user_config_t rfCEPin[];
extern gpio_input_pin_user_config_t rfIRQPin[];
and the gpio_pin.c has these (for the LEDs on-board):
/* Declare Output GPIO pins */
gpio_output_pin_user_config_t ledPins[] = {
{
.pinName = kGpioLED1,
.config.outputLogic = 1,
.config.slewRate = kPortSlowSlewRate,
.config.driveStrength = kPortLowDriveStrength,
},
{
.pinName = kGpioLED2,
.config.outputLogic = 1,
.config.slewRate = kPortSlowSlewRate,
.config.driveStrength = kPortLowDriveStrength,
},
{
.pinName = kGpioLED3,
.config.outputLogic = 1,
.config.slewRate = kPortSlowSlewRate,
.config.driveStrength = kPortLowDriveStrength,
},
{
.pinName = GPIO_PINS_OUT_OF_RANGE,
}
};
As such, my program (shown below) sequences through red, green and blue LEDs, and I can hook up external LEDs to the
corresponding header pins and see matching activity. So far, so good. However, if I change the gpio_pins.h first two enum's to
kGpioLED1 = GPIO_MAKE_PIN(HW_GPIOA, 4),
kGpioLED2 = GPIO_MAKE_PIN(HW_GPIOA, 5),
All this does (in my mind) is change the port pins from 1&2 to 4&5. But when I rebuild the project and flash it onto the board, I see no
activity on the corresponding header pins when kGpioLED1 and kGpioLED2 are switched on and off. The blue LED (kGpioLED3)
is still blinking when turned on and off, so the program is still running.
I'm missing a key part of the puzzle here, and snooping around is getting me nowhere. Why shouldn't changing port A pins from 1&2 to 4&5
transfer activity that was present on 1&2 to pins 4&5? Am I missing a configuration or initialization step for these different pins?
I feel like I'm so close to being able to use the GPIO pins at my whim, but it's getting extremely frustrating at this point.
I'd appreciate any help you can give!
Program listing follows (Processor Expert not used):
#include "fsl_device_registers.h"
#include "board.h"
static int i = 0;
static int delay = 0x08FFFF;
// LEDs are common-anode, with cathodes connected to port pins.
// Therefore, logic high (1) turns them off, and logic low
// (0) turns them on.
short OFF = 1;
short ON = 0;
int main(void)
{
hardware_init();
GPIO_DRV_SetPinDir(kGpioLED1, kGpioDigitalOutput); //Green LED
GPIO_DRV_SetPinDir(kGpioLED2, kGpioDigitalOutput); //Red LED
GPIO_DRV_SetPinDir(kGpioLED3, kGpioDigitalOutput); //Blue LED
GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED initially off
GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED initially off
GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED initially off
while (1)
{
for (i = 0; i<delay; i++)
{
}
GPIO_DRV_WritePinOutput(kGpioLED1, ON); //Green LED on
for (i = 0; i<delay; i++)
{
}
GPIO_DRV_WritePinOutput(kGpioLED1, OFF); //Green LED off
for (i = 0; i<delay; i++)
{
}
GPIO_DRV_WritePinOutput(kGpioLED2, ON); //Red LED on
for (i = 0; i<delay; i++)
{
}
GPIO_DRV_WritePinOutput(kGpioLED2, OFF); //Red LED off
for (i = 0; i<delay; i++)
{
};
GPIO_DRV_WritePinOutput(kGpioLED3, ON); //Blue LED on
for (i = 0; i<delay; i++)
{
}
GPIO_DRV_WritePinOutput(kGpioLED3, OFF); //Blue LED off
}
return 0;
}