Target: FRDM-K64F
Firmware DAPLink rev0244
MCUXpresso IDE v10.1.1 [Build 606] [2018-01-02]
KSDK 2.3.0
Hello,
I'm trying to controlled a 7 Segment Led Display with a external switch (not on board switch) but this code not works.
Please, What is the correct way to create the interrupt for PTC11?
Best regards
#include <stdio.h>
#include "board.h"
#include "peripherals.h"
#include "pin_mux.h"
#include "clock_config.h"
#include "fsl_debug_console.h"
#include "fsl_port.h"
#include "fsl_gpio.h"
#include "fsl_common.h"
#define SW_FQ_GPIO GPIOC
#define SW_FQ_GPIO_PORT PTC
#define SW_FQ_GPIO_PIN 11U
#define SW_FQ_IRQ 61U
#define SW_FQ_IRQ_HANDLER PORTC_IRQHandler
#define SW_PWR_GPIO_PORT PTC
#define SW_PWR_GPIO_PIN 3U
#define LED_GPIO GPIOC
#define LED_A_GPIO_PORT PTC
#define LED_A_GPIO_PIN 7U
#define LED_A_GPIO_NAME "A"
#define LED_B_GPIO_PORT PTC
#define LED_B_GPIO_PIN 0U
#define LED_B_GPIO_NAME "B"
#define LED_C_GPIO_PORT PTC
#define LED_C_GPIO_PIN 4U
#define LED_C_GPIO_NAME "C"
#define LED_D_GPIO_PORT PTC
#define LED_D_GPIO_PIN 2U
#define LED_D_GPIO_NAME "D"
#define LED_E_GPIO_PORT PTC
#define LED_E_GPIO_PIN 1U
#define LED_E_GPIO_NAME "E"
#define LED_F_GPIO_PORT PTC
#define LED_F_GPIO_PIN 9U
#define LED_F_GPIO_NAME "F"
#define LED_G_GPIO_PORT PTC
#define LED_G_GPIO_PIN 10U
#define LED_G_GPIO_NAME "G"
#define LED_DP_GPIO_PORT PTC
#define LED_DP_GPIO_PIN 5U
#define LED_DP_GPIO_NAME "DP"
volatile bool g_ButtonPress = false;
void SW_FQ_IRQ_HANDLER(void)
{
GPIO_PortClearInterruptFlags(SW_FQ_GPIO, 1U << SW_FQ_GPIO_PIN);
g_ButtonPress = true;
#if defined __CORTEX_M && (__CORTEX_M == 4U)
__DSB();
#endif
}
int main(void) {
gpio_pin_config_t sw_fq_config = {
kGPIO_DigitalInput, 0,
};
gpio_pin_config_t sw_pwr_config = {
kGPIO_DigitalInput, 0,
};
gpio_pin_config_t led_config = {
kGPIO_DigitalOutput, 0,
};
BOARD_InitBootPins();
BOARD_InitBootClocks();
BOARD_InitBootPeripherals();
BOARD_InitDebugConsole();
PRINTF("\r\n OpenVTX Firmware\r\n");
PRINTF("\r\n Press the Frequency switch to change the channel \r\n");
PORT_SetPinInterruptConfig(SW_FQ_GPIO_PORT, SW_FQ_GPIO_PIN, kPORT_InterruptFallingEdge);
EnableIRQ(SW_FQ_IRQ);
GPIO_PinInit(SW_FQ_GPIO, SW_FQ_GPIO_PIN, &sw_fq_config);
GPIO_PinInit(LED_GPIO, LED_A_GPIO_PIN, &led_config);
while(1)
{
if(g_ButtonPress)
{
GPIO_PortToggle(LED_GPIO, 1U << LED_A_GPIO_PIN);
g_ButtonPress = false;
}
}
}
7 Segment Display datasheet