Re: How to use KSDK fsl_gpio_irq with MQX

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Re: How to use KSDK fsl_gpio_irq with MQX

Jump to solution
959 Views
davidtietz
Contributor III

Hi David,

Where is main located? Is lwevent.c only part of the example?

1 Solution
591 Views
DavidS
NXP Employee
NXP Employee

Hi David,

For a baremetal application you are correct.

The nice aspect of the examples and demos in KSDK are they have been created for specific hardware (Tower or Freedom) boards.

As such the code "knows" about the buttons, and LED's and other resources of the processor and board combination.

Peek at the KSDK_Files folder in the lwevent_frdmk22f project.

The gpio_pins.h has the gpio settings for LEDs, switches, and sd card:

enum _gpio_pins

{

    kGpioLED1        = GPIO_MAKE_PIN(GPIOA_IDX, 2),  /* FRDM-K22F120M LED1 (Green LED) */

    kGpioLED2        = GPIO_MAKE_PIN(GPIOA_IDX, 1),  /* FRDM-K22F120M LED2 (Red LED) */

    kGpioLED3        = GPIO_MAKE_PIN(GPIOD_IDX, 5),  /* FRDM-K64F120M LED3 (Blue LED)*/

    kGpioSW2         = GPIO_MAKE_PIN(GPIOC_IDX, 1),  /* FRDM-K22F120M SW2 */

    kGpioSW3         = GPIO_MAKE_PIN(GPIOB_IDX, 17), /* FRDM-K22F120M SW3 */

    kGpioSdcardCd    = GPIO_MAKE_PIN(GPIOB_IDX, 16),

};

board.h has many #define and MACROs that are convenient for fast playing around with the code base.

So for the known capabilities on the board the RTOS is setting things up for you.

Attached is my updated lwevent.c for KSDK_1.3 and tested with the frdmk22f Freedom board.

Note the RTOS has default PORTC_IRQHandler() defined in startup_MK22F51212.S and when you declare it in your application code, you are overloading the function call so that your PORTC_IRQHandler() handler will be used.

Regards,

David

View solution in original post

3 Replies
591 Views
DavidS
NXP Employee
NXP Employee

Hi David,

Good questions and I will answer each in separate replies.

Q) Where is main() located?

A) The RTOS owns main() function and it is the starting point of the MQX RTOS.  Once the MQX RTOS initializes itself, it will ready the tasks you have defined in the application (must have at least one task defined as AUTO START).

If you use the latest KDS_3.0 and KSDK_1.3 for the frdm-k22f120m Freedom board and load the lwevent MQX application example using the Import->Project of Projects->Existing Projects Sets and point to following path:

C:\Freescale\KSDK_1.3.0\rtos\mqx\mqx\examples\lwevent\build\kds\lwevent_frdmk22f

and open the "lwevent_frdmk22f.wsd ", then you will see all the RTOS Components and the MQX Application projects open all at once.  Pretty cool!

Compile the libraries first, then the application.  Download and the default starting point if the main() of the MQX RTOS.

Regards,

David

591 Views
davidtietz
Contributor III

To be more clear with my question and to answer my question. I think your lwevent.c file needs a main function.

The function needs to declare some things:

INT_SYS_EnableIRQ(PORTC_IRQn);// Enable the Port C IRQ in NVIC
i = OSA_InstallIntHandler(PORTC_IRQn, PORTC_IRQHandler);//Install the ISR handler to MQX OS

I assume this is correct? At least this is how I got it to work.

On a side question, it looks like we are only enabling the "port" interrupt. Once in the interrupt are we responsible for checking the registers manually to see which pin triggered the interrupt? Or is there a cleaner way to do this?

0 Kudos
592 Views
DavidS
NXP Employee
NXP Employee

Hi David,

For a baremetal application you are correct.

The nice aspect of the examples and demos in KSDK are they have been created for specific hardware (Tower or Freedom) boards.

As such the code "knows" about the buttons, and LED's and other resources of the processor and board combination.

Peek at the KSDK_Files folder in the lwevent_frdmk22f project.

The gpio_pins.h has the gpio settings for LEDs, switches, and sd card:

enum _gpio_pins

{

    kGpioLED1        = GPIO_MAKE_PIN(GPIOA_IDX, 2),  /* FRDM-K22F120M LED1 (Green LED) */

    kGpioLED2        = GPIO_MAKE_PIN(GPIOA_IDX, 1),  /* FRDM-K22F120M LED2 (Red LED) */

    kGpioLED3        = GPIO_MAKE_PIN(GPIOD_IDX, 5),  /* FRDM-K64F120M LED3 (Blue LED)*/

    kGpioSW2         = GPIO_MAKE_PIN(GPIOC_IDX, 1),  /* FRDM-K22F120M SW2 */

    kGpioSW3         = GPIO_MAKE_PIN(GPIOB_IDX, 17), /* FRDM-K22F120M SW3 */

    kGpioSdcardCd    = GPIO_MAKE_PIN(GPIOB_IDX, 16),

};

board.h has many #define and MACROs that are convenient for fast playing around with the code base.

So for the known capabilities on the board the RTOS is setting things up for you.

Attached is my updated lwevent.c for KSDK_1.3 and tested with the frdmk22f Freedom board.

Note the RTOS has default PORTC_IRQHandler() defined in startup_MK22F51212.S and when you declare it in your application code, you are overloading the function call so that your PORTC_IRQHandler() handler will be used.

Regards,

David